aboutsummaryrefslogtreecommitdiff
path: root/example-cdc
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2015-09-09 17:04:59 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2015-09-09 17:04:59 +0900
commit79b13fb4a9f8c1e7d4158b19870a396b05144061 (patch)
tree364d2870c125d312388d96bd3f37614bbaef7dfb /example-cdc
parente9521648d5a4ff1238b76c3549f77e8aa4c6c417 (diff)
Cancellation fixes
Diffstat (limited to 'example-cdc')
-rw-r--r--example-cdc/usb-cdc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/example-cdc/usb-cdc.c b/example-cdc/usb-cdc.c
index 310e454..52871c2 100644
--- a/example-cdc/usb-cdc.c
+++ b/example-cdc/usb-cdc.c
@@ -173,9 +173,17 @@ usb_cb_device_reset (void)
/* Initialize Endpoint 0 */
usb_lld_setup_endpoint (ENDP0, EP_CONTROL, 0, ENDP0_RXADDR, ENDP0_TXADDR, 64);
+
+ chopstx_mutex_lock (&usb_mtx);
+ connected = 0;
+ bDeviceState = ATTACHED;
+ chopstx_cond_signal (&cnd_usb);
+ chopstx_mutex_unlock (&usb_mtx);
}
+#define CDC_CTRL_DTR 0x0001
+
void
usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no, uint16_t value)
{
@@ -186,7 +194,7 @@ usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no, uint16_t value)
{
/* Open/close the connection. */
chopstx_mutex_lock (&usb_mtx);
- connected = (value != 0)? 1 : 0;
+ connected = ((value & CDC_CTRL_DTR) != 0)? 1 : 0;
chopstx_cond_signal (&cnd_usb);
chopstx_mutex_unlock (&usb_mtx);
}