Skip to content

Commit

Permalink
Reset pico to USB mass storage on connection at 1200 baud
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBell committed Feb 2, 2021
1 parent 2d5789e commit d19e441
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/rp2_common/pico_stdio_usb/stdio_usb.c
Expand Up @@ -11,6 +11,7 @@
#include "pico/stdio_usb.h"
#include "pico/stdio/driver.h"
#include "pico/binary_info.h"
#include "pico/bootrom.h"
#include "hardware/irq.h"

static_assert(PICO_STDIO_USB_LOW_PRIORITY_IRQ > RTC_IRQ, ""); // note RTC_IRQ is currently the last one
Expand All @@ -31,6 +32,14 @@ static int64_t timer_task(__unused alarm_id_t id, __unused void *user_data) {
return PICO_STDIO_USB_TASK_INTERVAL_US;
}

// Hook the TinyUSB line coding callback and reset to USB mass storage mode
// on connection at 1200 baud.
void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding) {
if (p_line_coding->bit_rate == 1200) {
reset_usb_boot(0, 0);
}
}

static void stdio_usb_out_chars(const char *buf, int length) {
static uint64_t last_avail_time;
uint32_t owner;
Expand Down

0 comments on commit d19e441

Please sign in to comment.