#include "pico/stdlib.h" #include "tusb.h" #include "wire.h" #include "usb_cdc.h" #include "handlers.h" #include "net.h" static usb_cdc usb; int main() { tusb_init(); net_init(); static static_vector rx_buf; while (true) { tud_task(); usb.drain(); while (tud_cdc_available()) { uint8_t byte; if (tud_cdc_read(&byte, 1) != 1) break; rx_buf.push_back(byte); auto msg = try_decode(rx_buf); if (!msg) { if (rx_buf.full()) rx_buf.clear(); continue; } rx_buf.clear(); switch (msg->type_id) { case RequestPICOBOOT::ext_id: handle_picoboot(usb, msg->message_id); break; case RequestInfo::ext_id: handle_info(usb, msg->message_id); break; } } __wfi(); } }