/* Echo received bytes from the attached device through the USART */\r
while (CDC_Host_BytesReceived(&VirtualSerial_CDC_Interface))\r
putchar(CDC_Host_ReceiveByte(&VirtualSerial_CDC_Interface));\r
+ \r
+ CDC_Host_Flush(&VirtualSerial_CDC_Interface); \r
}\r
\r
break;\r
return ReceivedByte;\r
}\r
\r
+uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+ \r
+ uint8_t ErrorCode;\r
+\r
+ if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)\r
+ {\r
+ Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);\r
+ Pipe_SetPipeToken(PIPE_TOKEN_OUT);\r
+ }\r
+ else\r
+ {\r
+ Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber); \r
+ }\r
+ \r
+ Pipe_Unfreeze();\r
+ \r
+ if (!(Pipe_BytesInPipe()))\r
+ return PIPE_READYWAIT_NoError;\r
+\r
+ bool BankFull = !(Pipe_IsReadWriteAllowed());\r
+\r
+ Pipe_ClearOUT();\r
+\r
+ if (BankFull)\r
+ {\r
+ if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)\r
+ return ErrorCode;\r
+\r
+ Pipe_ClearOUT();\r
+ }\r
+\r
+ Pipe_Freeze();\r
+\r
+ if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)\r
+ Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
+ \r
+ return PIPE_READYWAIT_NoError;\r
+}\r
+\r
void CDC_Host_CreateStream(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, FILE* Stream)\r
{\r
*Stream = (FILE)FDEV_SETUP_STREAM(CDC_Host_putchar, CDC_Host_getchar, _FDEV_SETUP_RW);\r
*/\r
uint8_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
\r
+ /** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state\r
+ *\r
+ * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum\r
+ */\r
+ uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
/** Creates a standard characer stream for the given CDC Device instance so that it can be used with all the regular\r
* functions in the avr-libc <stdio.h> library that accept a FILE stream as a destination (e.g. fprintf). The created\r
* stream is bidirectional and can be used for both input and output functions.\r
/* Includes: */\r
#include <avr/pgmspace.h>\r
#include <stdbool.h>\r
+ #include <stddef.h>\r
\r
#include "../../../Common/Common.h"\r
#include "USBMode.h"\r
* - Added activity LED indicators to the AVRISP project to indicate when the device is busy processing a command\r
* - The USB target family and allowable USB mode tokens are now public and documented (USB_CAN_BE_*, USB_SERIES_*_AVR)\r
* - Added new XPLAIN USB to Serial Bridge project (thanks to John Steggall)\r
- * - Added new RNDISHost Host LowLevel demo\r
+ * - Added new RNDIS Ethernet Host LowLevel demo\r
* - Added new RNDIS Ethernet Host Class Driver\r
- * - Added new RNDISEthernet Host ClassDriver demo\r
+ * - Added new RNDIS Ethernet Host ClassDriver demo\r
+ * - Added CDC_Host_Flush() function to the CDC Host Class driver to flush sent data to the attached device\r
*\r
* <b>Changed:</b>\r
* - Removed code in the Keyboard demos to send zeroed reports between two reports with differing numbers of keycodes\r
* Note that this design currently has several limitations:\r
* - Minimum target clock speed of 500KHz due to hardware SPI used\r
* - No reversed/shorted target connector detection and notification\r
+ * - PDI programming is not supported for XMEGA targets\r
*\r
* On AVR models with an ADC converter, ACC should be tied to 5V (e.g. VBUS) and the VTARGET_ADC_CHANNEL token should be\r
* set to an appropriate ADC channel number in the project makefile for VTARGET detection to operate correctly. On models\r