Skip to content

Commit d71cd86

Browse files
committed
Merge branch 'iabdalkader-master'
Conflicts: stm/usb.c stm/usb.h
2 parents 01156d5 + 565fdcc commit d71cd86

4 files changed

Lines changed: 11 additions & 2 deletions

File tree

stm/stmusbd/usbd_cdc_vcp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ LINE_CODING linecoding =
4848

4949
/* These are external variables imported from CDC core to be used for IN
5050
transfer management. */
51+
52+
extern uint32_t APP_dev_is_connected; // set if CDC device is connected
53+
5154
extern uint8_t APP_Rx_Buffer []; /* Write CDC received data in this buffer.
5255
These data will be sent over USB IN endpoint
5356
in the CDC core functions. */
@@ -158,7 +161,7 @@ static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len)
158161
break;
159162

160163
case SET_CONTROL_LINE_STATE:
161-
/* Not needed for this driver */
164+
APP_dev_is_connected = Len & 0x1; // wValue is passed in Len (bit of a hack)
162165
break;
163166

164167
case SEND_BREAK:

stm/stmusbd/usbd_pyb_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ static uint8_t usbd_pyb_Setup(void *pdev, USB_SETUP_REQ *req) {
648648
// Not a Data request
649649

650650
// Transfer the command to the interface layer */
651-
return VCP_fops.pIf_Ctrl(req->bRequest, NULL, 0);
651+
return VCP_fops.pIf_Ctrl(req->bRequest, NULL, req->wValue);
652652
}
653653

654654
} else if (req->wIndex == 2) {

stm/usb.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extern CDC_IF_Prop_TypeDef VCP_fops;
2121
USB_OTG_CORE_HANDLE USB_OTG_Core;
2222

2323
static int dev_is_enabled = 0;
24+
uint32_t APP_dev_is_connected = 0; /* used by usbd_cdc_vcp */
2425
static char rx_buf[64];
2526
static int rx_buf_in;
2627
static int rx_buf_out;
@@ -48,6 +49,10 @@ bool usb_vcp_is_enabled(void) {
4849
return dev_is_enabled;
4950
}
5051

52+
bool usb_vcp_is_connected(void) {
53+
return APP_dev_is_connected;
54+
}
55+
5156
void usb_vcp_set_interrupt_char(int c) {
5257
if (dev_is_enabled) {
5358
interrupt_char = c;

stm/usb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
void pyb_usb_dev_init(void);
66
bool usb_vcp_is_enabled(void);
7+
bool usb_vcp_is_connected(void);
78
void usb_vcp_set_interrupt_char(int c);
89
int usb_vcp_rx_any(void);
910
char usb_vcp_rx_get(void);

0 commit comments

Comments
 (0)