Skip to content

Commit

Permalink
ice_usb: make sure enumeration happened during initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
josuah committed Dec 20, 2023
1 parent 91b995b commit 1e289b3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ice_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ void tud_dfu_download_cb(uint8_t alt, uint16_t block_num, const uint8_t *data, u
}
}

// Invoked when download process is complete, received DFU_DNLOAD (wLength=0) following by DFU_GETSTATUS (state=Manifest) Application can do checksum, or actual flashing if buffered entire image previously.
// Invoked when download process is complete, received DFU_DNLOAD (wLength=0)
// following by DFU_GETSTATUS (state=Manifest) Application can do checksum, or
// actual flashing if buffered entire image previously.
// Once finished flashing, application must call tud_dfu_finish_flashing()
void tud_dfu_manifest_cb(uint8_t alt) {
bool fpga_done;
Expand All @@ -388,6 +390,12 @@ void tud_dfu_detach_cb(void) {
void ice_usb_init(void) {
tusb_init();

// This is a blocking call, but expected to be done once at initialization
// rather than in the main loop.
while (!tud_ready()) {
tud_task();
}

#ifdef ICE_USB_UART0_CDC
irq_set_exclusive_handler(UART0_IRQ, ice_usb_uart0_to_cdc);
irq_set_enabled(UART0_IRQ, true);
Expand Down

0 comments on commit 1e289b3

Please sign in to comment.