diff options
| author | Ha Thach <[email protected]> | 2024-07-11 21:36:00 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-11 21:36:00 +0700 |
| commit | 65b3edbb091201c1b22dca9087a802e231824874 (patch) | |
| tree | 33e243f6b2dedf1c39a37dc2e7316d325e7e343b /examples | |
| parent | cb37a17ef7ed3dad86feb89e0fe2830e62a4346e (diff) | |
| parent | e251493a161b5a383fd7f8861e3bf7ea72bf872c (diff) | |
Merge pull request #2705 from hathach/v203-use-224kb
V203 use 224kb
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/build_system/make/rules.mk | 6 | ||||
| -rw-r--r-- | examples/device/cdc_dual_ports/src/main.c | 20 |
2 files changed, 26 insertions, 0 deletions
diff --git a/examples/build_system/make/rules.mk b/examples/build_system/make/rules.mk index 102c6db0c..f322dbae6 100644 --- a/examples/build_system/make/rules.mk +++ b/examples/build_system/make/rules.mk @@ -145,6 +145,12 @@ OPENOCD_WCH_OPTION ?= flash-openocd-wch: $(BUILD)/$(PROJECT).elf $(OPENOCD_WCH) $(OPENOCD_WCH_OPTION) -c init -c halt -c "flash write_image $<" -c reset -c exit +# --------------- wlink-rs ----------------- +# flash with https://github.com/ch32-rs/wlink +WLINK_RS ?= wlink +flash-wlink-rs: $(BUILD)/$(PROJECT).elf + $(WLINK_RS) flash $< + # --------------- dfu-util ----------------- DFU_UTIL_OPTION ?= -a 0 flash-dfu-util: $(BUILD)/$(PROJECT).bin diff --git a/examples/device/cdc_dual_ports/src/main.c b/examples/device/cdc_dual_ports/src/main.c index 1167a5d50..ef12186f2 100644 --- a/examples/device/cdc_dual_ports/src/main.c +++ b/examples/device/cdc_dual_ports/src/main.c @@ -119,6 +119,26 @@ static void cdc_task(void) { } } +// Invoked when cdc when line state changed e.g connected/disconnected +// Use to reset to DFU when disconnect with 1200 bps +void tud_cdc_line_state_cb(uint8_t instance, bool dtr, bool rts) { + (void)rts; + + // DTR = false is counted as disconnected + if (!dtr) { + // touch1200 only with first CDC instance (Serial) + if (instance == 0) { + cdc_line_coding_t coding; + tud_cdc_get_line_coding(&coding); + if (coding.bit_rate == 1200) { + if (board_reset_to_bootloader) { + board_reset_to_bootloader(); + } + } + } + } +} + //--------------------------------------------------------------------+ // BLINKING TASK //--------------------------------------------------------------------+ |
