From ff09cf9c73bbc2623a8c1420918747840382cc5b Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 1 Aug 2010 14:03:13 +0000 Subject: Fix XPLAINBridge project discarding characters from the USB interface due to a double read from the endpoint. Make XPLAINBridge and USBtoSerial projects more reliable by forcing a flush if the UART-to-USB buffer becomes nearly full. Reduce locking in the LightweightRingBuffer.h header files by only locking on the update of the buffer count, and require insertions and removals from each buffer to occur in only one execution thread. Fix CDC_*_ReceiveByte() returning 0 when the interface is not configured, instead of the new -1 error value. Fix CDC_Host_ReceiveByte() not re-freezing the pipe if no packet has been received. Remove redundant Pipe token set commands in the CDC and RNDIS host class drivers. --- Projects/Benito/Benito.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Projects/Benito/Benito.c') diff --git a/Projects/Benito/Benito.c b/Projects/Benito/Benito.c index ac1e064d5..88005eeb0 100644 --- a/Projects/Benito/Benito.c +++ b/Projects/Benito/Benito.c @@ -127,13 +127,14 @@ int main(void) LEDs_TurnOffLEDs(LEDMASK_RX); /* Check if the receive buffer flush period has expired */ - if (!(--FlushPeriodRemaining) || (Tx_Buffer.Count > 200)) + RingBuff_Count_t BufferCount = RingBuffer_GetCount(&Tx_Buffer); + if (!(--FlushPeriodRemaining) || (BufferCount > 200)) { /* Echo bytes from the target to the host via the virtual serial port */ - if (Tx_Buffer.Count) + if (BufferCount) { - while (Tx_Buffer.Count) - CDC_Device_SendByte(&VirtualSerial_CDC_Interface, RingBuffer_AtomicRemove(&Tx_Buffer)); + while (BufferCount--) + CDC_Device_SendByte(&VirtualSerial_CDC_Interface, RingBuffer_Remove(&Tx_Buffer)); LEDs_TurnOnLEDs(LEDMASK_RX); PulseMSRemaining.RxLEDPulse = TX_RX_LED_PULSE_MS; -- cgit v1.2.3