stm32/usbd_cdc_interface: Allow a board to hook into USBD CDC RX events.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2021-10-13 18:29:00 +11:00
parent cc42b7c88b
commit 5f2f9044ff
2 changed files with 8 additions and 1 deletions

View File

@ -60,6 +60,12 @@
#define MICROPY_BOARD_END_SOFT_RESET boardctrl_end_soft_reset
#endif
// Called when USBD CDC data is available.
// Default function defined in usbd_cdc_interface.h.
#ifndef MICROPY_BOARD_USBD_CDC_RX_EVENT
#define MICROPY_BOARD_USBD_CDC_RX_EVENT usbd_cdc_rx_event_callback
#endif
// Constants to return from boardctrl_run_boot_py, boardctrl_run_main_py.
enum {
BOARDCTRL_CONTINUE,

View File

@ -37,6 +37,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "boardctrl.h"
#include "usbd_cdc_msc_hid.h"
#include "usbd_cdc_interface.h"
#include "pendsv.h"
@ -308,7 +309,7 @@ int8_t usbd_cdc_receive(usbd_cdc_state_t *cdc_in, size_t len) {
}
}
usbd_cdc_rx_event_callback(cdc);
MICROPY_BOARD_USBD_CDC_RX_EVENT(cdc);
if ((cdc->flow & USBD_CDC_FLOWCONTROL_RTS) && (usbd_cdc_rx_buffer_full(cdc))) {
cdc->rx_buf_full = true;