- Permission to use, copy, modify, distribute, and sell this
+ Permission to use, copy, modify, distribute, and sell this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software without specific, written prior permission.
The author disclaim all warranties with regard to this
* Main source file for the VirtualSerialHost demo. This file contains the main tasks of
* the demo and is responsible for the initial application hardware configuration.
*/
* Main source file for the VirtualSerialHost demo. This file contains the main tasks of
* the demo and is responsible for the initial application hardware configuration.
*/
#include "VirtualSerialHost.h"
/** LUFA CDC Class driver interface configuration and state information. This structure is
#include "VirtualSerialHost.h"
/** LUFA CDC Class driver interface configuration and state information. This structure is
/** Main program entry point. This routine configures the hardware required by the application, then
* enters a loop to run the application tasks in sequence.
*/
int main(void)
{
SetupHardware();
/** Main program entry point. This routine configures the hardware required by the application, then
* enters a loop to run the application tasks in sequence.
*/
int main(void)
{
SetupHardware();
puts_P(PSTR(ESC_FG_CYAN "CDC Host Demo running.\r\n" ESC_FG_WHITE));
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
puts_P(PSTR(ESC_FG_CYAN "CDC Host Demo running.\r\n" ESC_FG_WHITE));
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
{
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
{
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
puts_P(PSTR("CDC Device Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured;
puts_P(PSTR("CDC Device Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured;
if (CDC_Host_BytesReceived(&VirtualSerial_CDC_Interface))
{
/* Echo received bytes from the attached device through the USART */
if (CDC_Host_BytesReceived(&VirtualSerial_CDC_Interface))
{
/* Echo received bytes from the attached device through the USART */
- while (CDC_Host_BytesReceived(&VirtualSerial_CDC_Interface))
- putchar(CDC_Host_ReceiveByte(&VirtualSerial_CDC_Interface));
-
- CDC_Host_Flush(&VirtualSerial_CDC_Interface);
+ int16_t ReceivedByte = CDC_Host_ReceiveByte(&VirtualSerial_CDC_Interface);
+ if (!(ReceivedByte < 0))
+ putchar(ReceivedByte);
/** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */
void EVENT_USB_Host_HostError(const uint8_t ErrorCode)
{
/** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */
void EVENT_USB_Host_HostError(const uint8_t ErrorCode)
{
printf_P(PSTR(ESC_FG_RED "Host Mode Error\r\n"
" -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode);
printf_P(PSTR(ESC_FG_RED "Host Mode Error\r\n"
" -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode);
" -- Error Code %d\r\n"
" -- Sub Error Code %d\r\n"
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
" -- Error Code %d\r\n"
" -- Sub Error Code %d\r\n"
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);