diff options
author | Damien George <damien.p.george@gmail.com> | 2014-02-01 16:17:06 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-02-01 16:17:06 +0000 |
commit | d71cd86dc1b1a95ab1cbe82e4b205407a5fa1199 (patch) | |
tree | e60cbf2d586bf12853bf8ae313aa5698fce10181 | |
parent | 01156d510c728408be4fd3100bcee18e8985ac00 (diff) | |
parent | 565fdccfd21b9304a37e9602d33cf64b15781f6a (diff) | |
download | micropython-d71cd86dc1b1a95ab1cbe82e4b205407a5fa1199.tar.gz micropython-d71cd86dc1b1a95ab1cbe82e4b205407a5fa1199.zip |
Merge branch 'iabdalkader-master'
Conflicts:
stm/usb.c
stm/usb.h
-rw-r--r-- | stm/stmusbd/usbd_cdc_vcp.c | 5 | ||||
-rw-r--r-- | stm/stmusbd/usbd_pyb_core.c | 2 | ||||
-rw-r--r-- | stm/usb.c | 5 | ||||
-rw-r--r-- | stm/usb.h | 1 |
4 files changed, 11 insertions, 2 deletions
diff --git a/stm/stmusbd/usbd_cdc_vcp.c b/stm/stmusbd/usbd_cdc_vcp.c index fc2bbc4589..cb16b58f1d 100644 --- a/stm/stmusbd/usbd_cdc_vcp.c +++ b/stm/stmusbd/usbd_cdc_vcp.c @@ -48,6 +48,9 @@ LINE_CODING linecoding = /* These are external variables imported from CDC core to be used for IN
transfer management. */
+
+extern uint32_t APP_dev_is_connected; // set if CDC device is connected
+
extern uint8_t APP_Rx_Buffer []; /* Write CDC received data in this buffer.
These data will be sent over USB IN endpoint
in the CDC core functions. */
@@ -158,7 +161,7 @@ static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len) break;
case SET_CONTROL_LINE_STATE:
- /* Not needed for this driver */
+ APP_dev_is_connected = Len & 0x1; // wValue is passed in Len (bit of a hack)
break;
case SEND_BREAK:
diff --git a/stm/stmusbd/usbd_pyb_core.c b/stm/stmusbd/usbd_pyb_core.c index ac51e3ad8e..d887b89c6c 100644 --- a/stm/stmusbd/usbd_pyb_core.c +++ b/stm/stmusbd/usbd_pyb_core.c @@ -648,7 +648,7 @@ static uint8_t usbd_pyb_Setup(void *pdev, USB_SETUP_REQ *req) { // Not a Data request
// Transfer the command to the interface layer */
- return VCP_fops.pIf_Ctrl(req->bRequest, NULL, 0);
+ return VCP_fops.pIf_Ctrl(req->bRequest, NULL, req->wValue);
}
} else if (req->wIndex == 2) {
@@ -21,6 +21,7 @@ extern CDC_IF_Prop_TypeDef VCP_fops; USB_OTG_CORE_HANDLE USB_OTG_Core; static int dev_is_enabled = 0; +uint32_t APP_dev_is_connected = 0; /* used by usbd_cdc_vcp */ static char rx_buf[64]; static int rx_buf_in; static int rx_buf_out; @@ -48,6 +49,10 @@ bool usb_vcp_is_enabled(void) { return dev_is_enabled; } +bool usb_vcp_is_connected(void) { + return APP_dev_is_connected; +} + void usb_vcp_set_interrupt_char(int c) { if (dev_is_enabled) { interrupt_char = c; @@ -4,6 +4,7 @@ void pyb_usb_dev_init(void); bool usb_vcp_is_enabled(void); +bool usb_vcp_is_connected(void); void usb_vcp_set_interrupt_char(int c); int usb_vcp_rx_any(void); char usb_vcp_rx_get(void); |