stm32/usb: Add USB_VCP.irq method, to set a callback on USB data RX.

Usage:

    usb = pyb.USB_VCP()
    usb.irq(lambda u:print(u, u.read()), usb.IRQ_RX)

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2021-05-19 23:43:21 +10:00
parent 8c02b94946
commit 71e3538a32
5 changed files with 91 additions and 1 deletions

View File

@@ -308,6 +308,8 @@ int8_t usbd_cdc_receive(usbd_cdc_state_t *cdc_in, size_t len) {
}
}
usbd_cdc_rx_event_callback(cdc);
if ((cdc->flow & USBD_CDC_FLOWCONTROL_RTS) && (usbd_cdc_rx_buffer_full(cdc))) {
cdc->rx_buf_full = true;
return USBD_BUSY;