File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 35
35
#include "nrfx_uart.h"
36
36
#include "py/ringbuf.h"
37
37
#include "py/stream.h"
38
+ #include "py/runtime.h"
38
39
39
40
#ifdef BLUETOOTH_SD
40
41
#include "nrf_sdm.h"
@@ -193,6 +194,25 @@ void usb_cdc_sd_event_handler(uint32_t soc_evt) {
193
194
}
194
195
#endif
195
196
197
+ #if MICROPY_HW_USB_CDC_1200BPS_TOUCH
198
+ static mp_sched_node_t mp_bootloader_sched_node ;
199
+ STATIC void usbd_cdc_run_bootloader_task (mp_sched_node_t * node ) {
200
+ mp_hal_delay_ms (250 );
201
+ MICROPY_BOARD_ENTER_BOOTLOADER ();
202
+ }
203
+
204
+ void tud_cdc_line_state_cb (uint8_t itf , bool dtr , bool rts ) {
205
+ if (dtr == false && rts == false) {
206
+ cdc_line_coding_t line_coding ;
207
+ tud_cdc_n_get_line_coding (itf , & line_coding );
208
+ if (line_coding .bit_rate == 1200 ) {
209
+ // Delay bootloader jump to allow the USB stack to service endpoints.
210
+ mp_sched_schedule_node (& mp_bootloader_sched_node , usbd_cdc_run_bootloader_task );
211
+ }
212
+ }
213
+ }
214
+ #endif
215
+
196
216
uintptr_t mp_hal_stdio_poll (uintptr_t poll_flags ) {
197
217
uintptr_t ret = 0 ;
198
218
if (poll_flags & MP_STREAM_POLL_RD ) {
Original file line number Diff line number Diff line change 157
157
#define MICROPY_MODULE_WEAK_LINKS (1)
158
158
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
159
159
#define MICROPY_USE_INTERNAL_ERRNO (1)
160
+ #define MICROPY_ENABLE_SCHEDULER (1)
161
+ #define MICROPY_SCHEDULER_STATIC_NODES (1)
160
162
#define MICROPY_PY_FUNCTION_ATTRS (1)
161
163
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
162
164
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
You can’t perform that action at this time.
0 commit comments