X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/67f390fe746ccc4d1dceac23f590eb1723cb7ff2..31d8ebebc0796873f7c70db80a04acdcbb307ed8:/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c diff --git a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c index c60f08f9c..bfd337a2a 100644 --- a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c +++ b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c @@ -80,7 +80,7 @@ void SetupHardware(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and * starts the library USB task to begin the enumeration and USB management process. */ -void EVENT_USB_Connect(void) +void EVENT_USB_Device_Connect(void) { /* Indicate USB enumerating */ LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); @@ -89,7 +89,7 @@ void EVENT_USB_Connect(void) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops the USB management task. */ -void EVENT_USB_Disconnect(void) +void EVENT_USB_Device_Disconnect(void) { /* Indicate USB not ready */ LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); @@ -98,7 +98,7 @@ void EVENT_USB_Disconnect(void) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration * of the USB device after enumeration, and configures the keyboard and mouse device endpoints. */ -void EVENT_USB_ConfigurationChanged(void) +void EVENT_USB_Device_ConfigurationChanged(void) { /* Indicate USB connected and ready */ LEDs_SetAllLEDs(LEDMASK_USB_READY); @@ -132,7 +132,7 @@ void EVENT_USB_ConfigurationChanged(void) * control requests that are not handled internally by the USB library (including the HID commands, which are * all issued via the control endpoint), so that they can be handled appropriately for the application. */ -void EVENT_USB_UnhandledControlPacket(void) +void EVENT_USB_Device_UnhandledControlRequest(void) { uint8_t* ReportData; uint8_t ReportSize; @@ -174,7 +174,11 @@ void EVENT_USB_UnhandledControlPacket(void) Endpoint_ClearSETUP(); /* Wait until the LED report has been sent by the host */ - while (!(Endpoint_IsOUTReceived())); + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } /* Read in the LED report from the host */ uint8_t LEDStatus = Endpoint_Read_Byte(); @@ -195,9 +199,7 @@ void EVENT_USB_UnhandledControlPacket(void) /* Clear the endpoint data */ Endpoint_ClearOUT(); - /* Acknowledge status stage */ - while (!(Endpoint_IsINReady())); - Endpoint_ClearIN(); + Endpoint_ClearStatusStage(); } break; @@ -213,7 +215,7 @@ void Keyboard_HID_Task(void) uint8_t JoyStatus_LCL = Joystick_GetStatus(); /* Device must be connected and configured for the task to run */ - if (!(USB_IsConnected) || !(USB_ConfigurationNumber)) + if (USB_DeviceState != DEVICE_STATE_Configured) return; /* Check if board button is not pressed, if so mouse mode enabled */ @@ -284,7 +286,7 @@ void Mouse_HID_Task(void) uint8_t JoyStatus_LCL = Joystick_GetStatus(); /* Device must be connected and configured for the task to run */ - if (!(USB_IsConnected) || !(USB_ConfigurationNumber)) + if (USB_DeviceState != DEVICE_STATE_Configured) return; /* Check if board button is pressed, if so mouse mode enabled */