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
/
DualCDC
/
DualCDC.c
diff --git
a/Demos/Device/LowLevel/DualCDC/DualCDC.c
b/Demos/Device/LowLevel/DualCDC/DualCDC.c
index
862945e
..
dd278d5
100644
(file)
--- a/
Demos/Device/LowLevel/DualCDC/DualCDC.c
+++ b/
Demos/Device/LowLevel/DualCDC/DualCDC.c
@@
-211,9
+211,7
@@
void EVENT_USB_UnhandledControlPacket(void)
/* Acknowledge the SETUP packet, ready for data transfer */
\r
Endpoint_ClearSETUP();
\r
\r
/* Acknowledge the SETUP packet, ready for data transfer */
\r
Endpoint_ClearSETUP();
\r
\r
- /* Acknowledge status stage */
\r
- while (!(Endpoint_IsINReady()));
\r
- Endpoint_ClearIN();
\r
+ Endpoint_ClearStatusStage();
\r
}
\r
\r
break;
\r
}
\r
\r
break;
\r
@@
-228,20
+226,19
@@
void CDC1_Task(void)
char* ReportString = NULL;
\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();
\r
static bool ActionSent = false;
\r
char* ReportString = NULL;
\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();
\r
static bool ActionSent = false;
\r
-
\r
+ char* JoystickStrings[] =
\r
+ {
\r
+ "Joystick Up\r\n",
\r
+ "Joystick Down\r\n",
\r
+ "Joystick Left\r\n",
\r
+ "Joystick Right\r\n",
\r
+ "Joystick Pressed\r\n",
\r
+ };
\r
+
\r
/* Device must be connected and configured for the task to run */
\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
return;
\r
\r
- char* JoystickStrings[] =
\r
- {
\r
- "Joystick Up\r\n",
\r
- "Joystick Down\r\n",
\r
- "Joystick Left\r\n",
\r
- "Joystick Right\r\n",
\r
- "Joystick Pressed\r\n",
\r
- };
\r
-
\r
/* Determine if a joystick action has occurred */
\r
if (JoyStatus_LCL & JOY_UP)
\r
ReportString = JoystickStrings[0];
\r
/* Determine if a joystick action has occurred */
\r
if (JoyStatus_LCL & JOY_UP)
\r
ReportString = JoystickStrings[0];
\r
@@
-273,7
+270,11
@@
void CDC1_Task(void)
Endpoint_ClearIN();
\r
\r
/* Wait until the endpoint is ready for another packet */
\r
Endpoint_ClearIN();
\r
\r
/* Wait until the endpoint is ready for another packet */
\r
- while (!(Endpoint_IsINReady()));
\r
+ while (!(Endpoint_IsINReady()))
\r
+ {
\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
\r
+ return;
\r
+ }
\r
\r
/* Send an empty packet to ensure that the host does not buffer data sent to it */
\r
Endpoint_ClearIN();
\r
\r
/* Send an empty packet to ensure that the host does not buffer data sent to it */
\r
Endpoint_ClearIN();
\r
@@
-293,7
+294,7
@@
void CDC1_Task(void)
void CDC2_Task(void)
\r
{
\r
/* Device must be connected and configured for the task to run */
\r
void CDC2_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
/* Select the Serial Rx Endpoint */
\r
return;
\r
\r
/* Select the Serial Rx Endpoint */
\r
@@
-324,7
+325,11
@@
void CDC2_Task(void)
Endpoint_ClearIN();
\r
\r
/* Wait until the endpoint is ready for the next packet */
\r
Endpoint_ClearIN();
\r
\r
/* Wait until the endpoint is ready for the next packet */
\r
- while (!(Endpoint_IsINReady()));
\r
+ while (!(Endpoint_IsINReady()))
\r
+ {
\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
\r
+ return;
\r
+ }
\r
\r
/* Send an empty packet to prevent host buffering */
\r
Endpoint_ClearIN();
\r
\r
/* Send an empty packet to prevent host buffering */
\r
Endpoint_ClearIN();
\r