aboutsummaryrefslogtreecommitdiff
path: root/Projects/USBtoSerial/USBtoSerial.c
diff options
context:
space:
mode:
authorDean Camera <[email protected]>2010-05-26 13:26:10 +0000
committerDean Camera <[email protected]>2010-05-26 13:26:10 +0000
commit8d993afc5388c5f3d0ff568c607f7fed6bb7390e (patch)
tree6ac1c5a0ca4a7c72bd4ca2ed2e137d9c0549da30 /Projects/USBtoSerial/USBtoSerial.c
parent885170f5b456116d7c40570c36342193a30ed886 (diff)
downloadqmk_firmware-8d993afc5388c5f3d0ff568c607f7fed6bb7390e.tar.gz
qmk_firmware-8d993afc5388c5f3d0ff568c607f7fed6bb7390e.zip
Replace ring buffer library in Benito and USBtoSerial projects with the new lightweight ring buffer header to improve reliability.
Diffstat (limited to 'Projects/USBtoSerial/USBtoSerial.c')
-rw-r--r--Projects/USBtoSerial/USBtoSerial.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/Projects/USBtoSerial/USBtoSerial.c b/Projects/USBtoSerial/USBtoSerial.c
index dd9a133c3f..7a0f6866a8 100644
--- a/Projects/USBtoSerial/USBtoSerial.c
+++ b/Projects/USBtoSerial/USBtoSerial.c
@@ -73,8 +73,8 @@ int main(void)
{
SetupHardware();
- Buffer_Initialize(&USBtoUSART_Buffer);
- Buffer_Initialize(&USARTtoUSB_Buffer);
+ RingBuffer_InitBuffer(&USBtoUSART_Buffer);
+ RingBuffer_InitBuffer(&USARTtoUSB_Buffer);
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
sei();
@@ -84,19 +84,19 @@ int main(void)
/* Read bytes from the USB OUT endpoint into the USART transmit buffer */
for (uint8_t DataBytesRem = CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface); DataBytesRem != 0; DataBytesRem--)
{
- if (!(BUFF_STATICSIZE - USBtoUSART_Buffer.Elements))
+ if (!(BUFFER_SIZE - USBtoUSART_Buffer.Count))
break;
- Buffer_StoreElement(&USBtoUSART_Buffer, CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface));
+ RingBuffer_Insert(&USBtoUSART_Buffer, CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface));
}
/* Read bytes from the USART receive buffer into the USB IN endpoint */
- while (USARTtoUSB_Buffer.Elements)
- CDC_Device_SendByte(&VirtualSerial_CDC_Interface, Buffer_GetElement(&USARTtoUSB_Buffer));
+ while (USARTtoUSB_Buffer.Count)
+ CDC_Device_SendByte(&VirtualSerial_CDC_Interface, RingBuffer_Remove(&USARTtoUSB_Buffer));
/* Load bytes from the USART transmit buffer into the USART */
- while (USBtoUSART_Buffer.Elements)
- Serial_TxByte(Buffer_GetElement(&USBtoUSART_Buffer));
+ while (USBtoUSART_Buffer.Count)
+ Serial_TxByte(RingBuffer_Remove(&USBtoUSART_Buffer));
CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
USB_USBTask();
@@ -154,7 +154,7 @@ ISR(USART1_RX_vect, ISR_BLOCK)
uint8_t ReceivedByte = UDR1;
if (USB_DeviceState == DEVICE_STATE_Configured)
- Buffer_StoreElement(&USARTtoUSB_Buffer, ReceivedByte);
+ RingBuffer_Insert(&USARTtoUSB_Buffer, ReceivedByte);
}
/** Event handler for the CDC Class driver Line Encoding Changed event.