mirror of
https://github.com/licsber/micropython.git
synced 2024-09-20 17:10:24 +08:00
Detect VCP line state.
* Detect VCP line state, based on SET_CONTROL_LINE_STATE request
This commit is contained in:
parent
532f2c30f6
commit
b2269b610e
@ -62,6 +62,8 @@ static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len);
|
|||||||
static uint16_t VCP_DataTx (const uint8_t* Buf, uint32_t Len);
|
static uint16_t VCP_DataTx (const uint8_t* Buf, uint32_t Len);
|
||||||
static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len);
|
static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len);
|
||||||
|
|
||||||
|
extern int dev_is_connected;
|
||||||
|
|
||||||
CDC_IF_Prop_TypeDef VCP_fops =
|
CDC_IF_Prop_TypeDef VCP_fops =
|
||||||
{
|
{
|
||||||
VCP_Init,
|
VCP_Init,
|
||||||
@ -158,7 +160,7 @@ static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SET_CONTROL_LINE_STATE:
|
case SET_CONTROL_LINE_STATE:
|
||||||
/* Not needed for this driver */
|
dev_is_connected = Len & 0x1; //wValue passed in Len
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEND_BREAK:
|
case SEND_BREAK:
|
||||||
|
@ -648,7 +648,7 @@ static uint8_t usbd_pyb_Setup(void *pdev, USB_SETUP_REQ *req) {
|
|||||||
// Not a Data request
|
// Not a Data request
|
||||||
|
|
||||||
// Transfer the command to the interface layer */
|
// 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) {
|
} else if (req->wIndex == 2) {
|
||||||
|
@ -20,6 +20,7 @@ extern CDC_IF_Prop_TypeDef VCP_fops;
|
|||||||
USB_OTG_CORE_HANDLE USB_OTG_Core;
|
USB_OTG_CORE_HANDLE USB_OTG_Core;
|
||||||
|
|
||||||
static int dev_is_enabled = 0;
|
static int dev_is_enabled = 0;
|
||||||
|
int dev_is_connected=0; /* used by usbd_cdc_vcp */
|
||||||
static char rx_buf[64];
|
static char rx_buf[64];
|
||||||
static int rx_buf_in;
|
static int rx_buf_in;
|
||||||
static int rx_buf_out;
|
static int rx_buf_out;
|
||||||
@ -41,6 +42,10 @@ bool usb_vcp_is_enabled(void) {
|
|||||||
return dev_is_enabled;
|
return dev_is_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool usb_vcp_is_connected(void) {
|
||||||
|
return dev_is_connected;
|
||||||
|
}
|
||||||
|
|
||||||
void usb_vcp_receive(const char *buf, uint32_t len) {
|
void usb_vcp_receive(const char *buf, uint32_t len) {
|
||||||
if (dev_is_enabled) {
|
if (dev_is_enabled) {
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user