X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/071e02c6b6b4837fa9cf0b6d4c749994e02638d7..546ab8712ee4b3dbbe238876ea2dcb2e7b9f6746:/Demos/Device/LowLevel/Joystick/Joystick.c diff --git a/Demos/Device/LowLevel/Joystick/Joystick.c b/Demos/Device/LowLevel/Joystick/Joystick.c index 6ced1ce44..5aadb599c 100644 --- a/Demos/Device/LowLevel/Joystick/Joystick.c +++ b/Demos/Device/LowLevel/Joystick/Joystick.c @@ -93,16 +93,14 @@ void EVENT_USB_Device_Disconnect(void) */ void EVENT_USB_Device_ConfigurationChanged(void) { - /* Indicate USB connected and ready */ - LEDs_SetAllLEDs(LEDMASK_USB_READY); + bool ConfigSuccess = true; - /* Setup Joystick Report Endpoint */ - if (!(Endpoint_ConfigureEndpoint(JOYSTICK_EPNUM, EP_TYPE_INTERRUPT, - ENDPOINT_DIR_IN, JOYSTICK_EPSIZE, - ENDPOINT_BANK_SINGLE))) - { - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - } + /* Setup HID Report Endpoint */ + ConfigSuccess &= Endpoint_ConfigureEndpoint(JOYSTICK_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, + JOYSTICK_EPSIZE, ENDPOINT_BANK_SINGLE); + + /* Indicate endpoint configuration success or failure */ + LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); } /** Event handler for the USB_UnhandledControlRequest event. This is used to catch standard and class specific @@ -119,15 +117,13 @@ void EVENT_USB_Device_UnhandledControlRequest(void) { USB_JoystickReport_Data_t JoystickReportData; - Endpoint_ClearSETUP(); - /* Create the next HID report to send to the host */ GetNextReport(&JoystickReportData); - + + Endpoint_ClearSETUP(); + /* Write the report data to the control endpoint */ Endpoint_Write_Control_Stream_LE(&JoystickReportData, sizeof(JoystickReportData)); - - /* Finalize the stream transfer to send the last packet or clear the host abort */ Endpoint_ClearOUT(); } @@ -141,7 +137,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) * * \return Boolean true if the new report differs from the last report, false otherwise */ -bool GetNextReport(USB_JoystickReport_Data_t* ReportData) +bool GetNextReport(USB_JoystickReport_Data_t* const ReportData) { static uint8_t PrevJoyStatus = 0; static uint8_t PrevButtonStatus = 0;