diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-07-13 13:30:38 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-07-13 13:30:38 +0000 |
commit | edeffa28c526825510f7ff35024ea242f82252e5 (patch) | |
tree | 6e73fb2151408160fea483c4c143ef6cf95c00ed /nuttx/drivers/serial/serial.c | |
parent | 286a4141b552e05aa782b1fafa192426af2f42a2 (diff) | |
download | px4-nuttx-edeffa28c526825510f7ff35024ea242f82252e5.tar.gz px4-nuttx-edeffa28c526825510f7ff35024ea242f82252e5.tar.bz2 px4-nuttx-edeffa28c526825510f7ff35024ea242f82252e5.zip |
Re-architect FAT data structures to support long file names
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3780 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/serial/serial.c')
-rw-r--r-- | nuttx/drivers/serial/serial.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/nuttx/drivers/serial/serial.c b/nuttx/drivers/serial/serial.c index 983d4ae16..cff810743 100644 --- a/nuttx/drivers/serial/serial.c +++ b/nuttx/drivers/serial/serial.c @@ -163,12 +163,21 @@ static void uart_pollnotify(FAR uart_dev_t *dev, pollevent_t eventset) static void uart_putxmitchar(FAR uart_dev_t *dev, int ch) { - int nexthead = dev->xmit.head + 1; + irqstate_t flags; + int nexthead; + + /* Increment to see what the next head pointer will be. We need to use the "next" + * head pointer to determine when the circular buffer would overrun + */ + + nexthead = dev->xmit.head + 1; if (nexthead >= dev->xmit.size) { nexthead = 0; } + /* Loop until we are able to add the character to the TX buffer */ + for (;;) { if (nexthead != dev->xmit.tail) @@ -179,8 +188,11 @@ static void uart_putxmitchar(FAR uart_dev_t *dev, int ch) } else { - /* Inform the interrupt level logic that we are waiting */ + /* Inform the interrupt level logic that we are waiting. + * This and the following steps must be atomic. + */ + flags = irqsave(); dev->xmitwaiting = true; /* Wait for some characters to be sent from the buffer @@ -192,6 +204,7 @@ static void uart_putxmitchar(FAR uart_dev_t *dev, int ch) uart_enabletxint(dev); uart_takesem(&dev->xmitsem); uart_disabletxint(dev); + irqrestore(flags); } } } |