X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/a9d5e129b76449c73a853af450d7d353512cd3a0..cf610c5c91c3eee02dec7ca848acc8da831ad98a:/Demos/Device/LowLevel/CDC/CDC.c diff --git a/Demos/Device/LowLevel/CDC/CDC.c b/Demos/Device/LowLevel/CDC/CDC.c index 12cd8c40f..444dc019d 100644 --- a/Demos/Device/LowLevel/CDC/CDC.c +++ b/Demos/Device/LowLevel/CDC/CDC.c @@ -36,7 +36,6 @@ #include "CDC.h" -/* Globals: */ /** Contains the current baud rate and other settings of the virtual serial port. While this demo does not use * the physical USART and thus does not use these settings, they must still be retained and returned to the host * upon request or the host will assume the device is non-functional. @@ -50,6 +49,7 @@ CDC_Line_Coding_t LineEncoding = { .BaudRateBPS = 0, .ParityType = Parity_None, .DataBits = 8 }; + #if 0 /* NOTE: Here you can set up a standard stream using the created virtual serial port, so that the standard stream functions in * can be used on the virtual serial port (e.g. fprintf(&USBSerial, "Test"); to print a string). @@ -247,14 +247,6 @@ void CDC_Task(void) char* ReportString = NULL; uint8_t JoyStatus_LCL = Joystick_GetStatus(); static bool ActionSent = false; - char* JoystickStrings[] = - { - "Joystick Up\r\n", - "Joystick Down\r\n", - "Joystick Left\r\n", - "Joystick Right\r\n", - "Joystick Pressed\r\n", - }; /* Device must be connected and configured for the task to run */ if (USB_DeviceState != DEVICE_STATE_Configured) @@ -285,22 +277,20 @@ void CDC_Task(void) /* Determine if a joystick action has occurred */ if (JoyStatus_LCL & JOY_UP) - ReportString = JoystickStrings[0]; + ReportString = "Joystick Up\r\n"; else if (JoyStatus_LCL & JOY_DOWN) - ReportString = JoystickStrings[1]; + ReportString = "Joystick Down\r\n"; else if (JoyStatus_LCL & JOY_LEFT) - ReportString = JoystickStrings[2]; + ReportString = "Joystick Left\r\n"; else if (JoyStatus_LCL & JOY_RIGHT) - ReportString = JoystickStrings[3]; + ReportString = "Joystick Right\r\n"; else if (JoyStatus_LCL & JOY_PRESS) - ReportString = JoystickStrings[4]; + ReportString = "Joystick Pressed\r\n"; + else + ActionSent = false; /* Flag management - Only allow one string to be sent per action */ - if (ReportString == NULL) - { - ActionSent = false; - } - else if ((ActionSent == false) && LineEncoding.BaudRateBPS) + if ((ReportString != NULL) && (ActionSent == false) && LineEncoding.BaudRateBPS) { ActionSent = true;