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
/
GenericHID
/
GenericHID.c
diff --git
a/Demos/Device/LowLevel/GenericHID/GenericHID.c
b/Demos/Device/LowLevel/GenericHID/GenericHID.c
index
5c6d1ee
..
34c991f
100644
(file)
--- a/
Demos/Device/LowLevel/GenericHID/GenericHID.c
+++ b/
Demos/Device/LowLevel/GenericHID/GenericHID.c
@@
-148,7
+148,11
@@
void EVENT_USB_UnhandledControlPacket(void)
Endpoint_ClearSETUP();
\r
\r
/* Wait until the generic report has been sent by the host */
\r
Endpoint_ClearSETUP();
\r
\r
/* Wait until the generic 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
Endpoint_Read_Control_Stream_LE(&GenericData, sizeof(GenericData));
\r
\r
\r
Endpoint_Read_Control_Stream_LE(&GenericData, sizeof(GenericData));
\r
\r
@@
-158,7
+162,11
@@
void EVENT_USB_UnhandledControlPacket(void)
Endpoint_ClearOUT();
\r
\r
/* Wait until the host is ready to receive the request confirmation */
\r
Endpoint_ClearOUT();
\r
\r
/* Wait until the host is ready to receive the request confirmation */
\r
- while (!(Endpoint_IsINReady()));
\r
+ while (!(Endpoint_IsINReady()))
\r
+ {
\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
\r
+ return;
\r
+ }
\r
\r
/* Handshake the request by sending an empty IN packet */
\r
Endpoint_ClearIN();
\r
\r
/* Handshake the request by sending an empty IN packet */
\r
Endpoint_ClearIN();
\r
@@
-203,7
+211,7
@@
void CreateGenericHIDReport(uint8_t* DataArray)
void HID_Task(void)
\r
{
\r
/* Device must be connected and configured for the task to run */
\r
void HID_Task(void)
\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
Endpoint_SelectEndpoint(GENERIC_OUT_EPNUM);
\r
return;
\r
\r
Endpoint_SelectEndpoint(GENERIC_OUT_EPNUM);
\r