10000 stm32/usbd_cdc_interface: Allow a board to hook into USBD CDC RX events. · karfas/micropython@5f2f904 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5f2f904

Browse files
committed
stm32/usbd_cdc_interface: Allow a board to hook into USBD CDC RX events.
Signed-off-by: Damien George <damien@micropython.org>
1 parent cc42b7c commit 5f2f904

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

ports/stm32/boardctrl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@
6060
#define MICROPY_BOARD_END_SOFT_RESET boardctrl_end_soft_reset
6161
#endif
6262

63+
// Called when USBD CDC data is available.
64+
// Default function defined in usbd_cdc_interface.h.
65+
#ifndef MICROPY_BOARD_USBD_CDC_RX_EVENT
66+
#define MICROPY_BOARD_USBD_CDC_RX_EVENT usbd_cdc_rx_event_callback
67+
#endif
68+
6369
// Constants to return from boardctrl_run_boot_py, boardctrl_run_main_py.
6470
enum {
6571
BOARDCTRL_CONTINUE,

ports/stm32/usbd_cdc_interface.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <stdbool.h>
3838
#include <stdint.h>
3939

40+
#include "boardctrl.h"
4041
#include "usbd_cdc_msc_hid.h"
4142
#include "usbd_cdc_interface.h"
4243
#include "pendsv.h"
@@ -308,7 +309,7 @@ int8_t usbd_cdc_receive(usbd_cdc_state_t *cdc_in, size_t len) {
308309
}
309310
}
310311

311-
usbd_cdc_rx_event_callback(cdc);
312+
MICROPY_BOARD_USBD_CDC_RX_EVENT(cdc);
312313

313314
if ((cdc->flow & USBD_CDC_FLOWCONTROL_RTS) && (usbd_cdc_rx_buffer_full(cdc))) {
314315
cdc->rx_buf_full = true;

0 commit comments

Comments
 (0)
0