projects
/
pub
/
USBasp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added new USB_DeviceState variable to keep track of the current Device mode USB state.
[pub/USBasp.git]
/
Demos
/
Device
/
LowLevel
/
KeyboardMouse
/
KeyboardMouse.c
diff --git
a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c
b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c
index
c60f08f
..
7d486e1
100644
(file)
--- a/
Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c
+++ b/
Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c
@@
-174,7
+174,11
@@
void EVENT_USB_UnhandledControlPacket(void)
Endpoint_ClearSETUP();
\r
\r
/* Wait until the LED report has been sent by the host */
\r
Endpoint_ClearSETUP();
\r
\r
/* Wait until the LED report has been sent by the host */
\r
- while (!(Endpoint_IsOUTReceived()));
\r
+ while (!(Endpoint_IsOUTReceived()))
\r
+ {
\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
\r
+ return;
\r
+ }
\r
\r
/* Read in the LED report from the host */
\r
uint8_t LEDStatus = Endpoint_Read_Byte();
\r
\r
/* Read in the LED report from the host */
\r
uint8_t LEDStatus = Endpoint_Read_Byte();
\r
@@
-195,9
+199,7
@@
void EVENT_USB_UnhandledControlPacket(void)
/* Clear the endpoint data */
\r
Endpoint_ClearOUT();
\r
\r
/* Clear the endpoint data */
\r
Endpoint_ClearOUT();
\r
\r
- /* Acknowledge status stage */
\r
- while (!(Endpoint_IsINReady()));
\r
- Endpoint_ClearIN();
\r
+ Endpoint_ClearStatusStage();
\r
}
\r
\r
break;
\r
}
\r
\r
break;
\r
@@
-213,7
+215,7
@@
void Keyboard_HID_Task(void)
uint8_t JoyStatus_LCL = Joystick_GetStatus();
\r
\r
/* Device must be connected and configured for the task to run */
\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();
\r
\r
/* Device must be connected and configured for the task to run */
\r
- if (
!(USB_IsConnected) || !(USB_ConfigurationNumber)
)
\r
+ if (
USB_DeviceState != DEVICE_STATE_Configured
)
\r
return;
\r
\r
/* Check if board button is not pressed, if so mouse mode enabled */
\r
return;
\r
\r
/* Check if board button is not pressed, if so mouse mode enabled */
\r
@@
-284,7
+286,7
@@
void Mouse_HID_Task(void)
uint8_t JoyStatus_LCL = Joystick_GetStatus();
\r
\r
/* Device must be connected and configured for the task to run */
\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();
\r
\r
/* Device must be connected and configured for the task to run */
\r
- if (
!(USB_IsConnected) || !(USB_ConfigurationNumber)
)
\r
+ if (
USB_DeviceState != DEVICE_STATE_Configured
)
\r
return;
\r
\r
/* Check if board button is pressed, if so mouse mode enabled */
\r
return;
\r
\r
/* Check if board button is pressed, if so mouse mode enabled */
\r