Skip to content

Commit c40415c

Browse files
committed
send ASCII command prompt to host when entering command mode
1 parent 230de7d commit c40415c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

main/usb_uart_bridge_main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ volatile bool s_in_boot = false;
7171
static RingbufHandle_t s_usb_tx_ringbuf = NULL;
7272
static RingbufHandle_t s_usb_rx_ringbuf = NULL;
7373
static SemaphoreHandle_t s_trigger_bootloader = NULL;
74+
static TaskHandle_t s_usb_tx_handle = NULL;
7475

7576
static bool board_zg23_reset_gpio_init(void)
7677
{
@@ -264,6 +265,12 @@ static void tinyusb_cdc_line_coding_changed_callback(int itf, cdcacm_event_t *ev
264265
ESP_LOGW(TAG, "Enabling command mode");
265266
magic_cmdmode_trigger_stage = 0;
266267
s_cmd_mode_enabled = true;
268+
269+
// Send 'cmd> ' prompt to host, so it can detect that command mode is active
270+
const char *cmd_prompt = "cmd> ";
271+
xRingbufferSend(s_usb_tx_ringbuf, cmd_prompt, strlen(cmd_prompt), 0);
272+
xTaskNotifyGive(s_usb_tx_handle);
273+
267274
return;
268275
}
269276
}
@@ -475,7 +482,7 @@ static void bootloader_reset_task(void *arg) {
475482
void app_main(void)
476483
{
477484
// Only for debugging - do not leave uncommented in production:
478-
//esp_log_level_set("*", ESP_LOG_VERBOSE);
485+
// esp_log_level_set("*", ESP_LOG_VERBOSE);
479486

480487
uart_config_t uart_config = {
481488
.baud_rate = CFG_BAUD_RATE(s_baud_rate_active),
@@ -589,6 +596,7 @@ void app_main(void)
589596
}
590597

591598
xTaskCreate(usb_tx_task, "usb_tx", stack_size, &acm_cfg, 4, &usb_tx_handle);
599+
s_usb_tx_handle = usb_tx_handle; // Store in global variable for access in tinyusb callbacks
592600
xTaskCreate(uart_tx_task, "uart_tx", stack_size, NULL, 4, NULL);
593601
xTaskCreate(bootloader_reset_task, "bootloader_reset", 2048, NULL, 4, NULL);
594602

0 commit comments

Comments
 (0)