Skip to content

Commit

Permalink
Add NOPs around UART usage
Browse files Browse the repository at this point in the history
This yields some bus bandwidth to DMA operations attempting to use the
same APB DMA slave as the debugging UART peripheral.
  • Loading branch information
adamgreen committed Mar 15, 2016
1 parent 64cbe95 commit 754d17a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions devices/lpc176x/lpc176x_uart.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2015 Adam Green (http://mbed.org/users/AdamGreen/)
/* Copyright 2016 Adam Green (http://mbed.org/users/AdamGreen/)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
Expand Down Expand Up @@ -453,10 +453,12 @@ uint32_t Platform_CommHasReceiveData(void)
}


static void waitForUartToReceiveData(void);
static void yieldUartBusToDma(void);
static void waitForUartToReceiveData(void);
int Platform_CommReceiveChar(void)
{
waitForUartToReceiveData();
yieldUartBusToDma();

return (int)__mriLpc176xState.pCurrentUart->pUartRegisters->RBR;
}
Expand All @@ -465,22 +467,33 @@ static void waitForUartToReceiveData(void)
{
while (!Platform_CommHasReceiveData())
{
yieldUartBusToDma();
}
}

static void yieldUartBusToDma(void)
{
__NOP();
__NOP();
__NOP();
}


static void waitForUartToAllowTransmit(void);
static uint32_t targetUartCanTransmit(void);
void Platform_CommSendChar(int Character)
{
waitForUartToAllowTransmit();

yieldUartBusToDma();

__mriLpc176xState.pCurrentUart->pUartRegisters->THR = (uint8_t)Character;
}

static void waitForUartToAllowTransmit(void)
{
while (!targetUartCanTransmit())
{
yieldUartBusToDma();
}
}

Expand Down

0 comments on commit 754d17a

Please sign in to comment.