diff options
| author | Mengsk <[email protected]> | 2021-07-05 17:56:21 +0200 |
|---|---|---|
| committer | Mengsk <[email protected]> | 2021-07-05 17:56:21 +0200 |
| commit | c2d8ed3fd1fdb722d67a30a6768720c9ed578779 (patch) | |
| tree | 3cafa16736a498e689ea25f42635b18db62ae762 /examples/device/dfu/src/main.c | |
| parent | 2ae19ce40dec5aa13d9eca9b990aa704c2579581 (diff) | |
Add alt settings support in DFU class.
Diffstat (limited to 'examples/device/dfu/src/main.c')
| -rw-r--r-- | examples/device/dfu/src/main.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/examples/device/dfu/src/main.c b/examples/device/dfu/src/main.c index 1c09066a8..81532ee90 100644 --- a/examples/device/dfu/src/main.c +++ b/examples/device/dfu/src/main.c @@ -115,25 +115,20 @@ void tud_resume_cb(void) blink_interval_ms = BLINK_MOUNTED; } -// Invoked on DFU_DETACH request to reboot to the bootloader -void tud_dfu_runtime_reboot_to_dfu_cb(void) -{ - blink_interval_ms = BLINK_DFU_MODE; -} - //--------------------------------------------------------------------+ // Class callbacks //--------------------------------------------------------------------+ -bool tud_dfu_firmware_valid_check_cb(void) +bool tud_dfu_firmware_valid_check_cb(uint8_t alt) { + (void) alt; printf(" Firmware check\r\n"); return true; } -void tud_dfu_req_dnload_data_cb(uint16_t wBlockNum, uint8_t* data, uint16_t length) +void tud_dfu_req_dnload_data_cb(uint8_t alt, uint16_t wBlockNum, uint8_t* data, uint16_t length) { (void) data; - printf(" Received BlockNum %u of length %u\r\n", wBlockNum, length); + printf(" Received Alt %u BlockNum %u of length %u\r\n", alt, wBlockNum, length); #if DFU_VERBOSE for(uint16_t i=0; i<length; i++) @@ -145,8 +140,9 @@ void tud_dfu_req_dnload_data_cb(uint16_t wBlockNum, uint8_t* data, uint16_t leng tud_dfu_dnload_complete(); } -bool tud_dfu_device_data_done_check_cb(void) +bool tud_dfu_device_data_done_check_cb(uint8_t alt) { + (void) alt; printf(" Host said no more data... Returning true\r\n"); return true; } @@ -156,15 +152,16 @@ void tud_dfu_abort_cb(void) printf(" Host aborted transfer\r\n"); } -#define UPLOAD_SIZE (29) -const uint8_t upload_test[UPLOAD_SIZE] = "Hello world from TinyUSB DFU!"; +#define UPLOAD_SIZE 43 +const uint8_t upload_test[2][UPLOAD_SIZE] = {"Hello world from TinyUSB DFU! - Partition 0", + "Hello world from TinyUSB DFU! - Partition 1"}; -uint16_t tud_dfu_req_upload_data_cb(uint16_t block_num, uint8_t* data, uint16_t length) +uint16_t tud_dfu_req_upload_data_cb(uint8_t alt, uint16_t block_num, uint8_t* data, uint16_t length) { (void) block_num; (void) length; - memcpy(data, upload_test, UPLOAD_SIZE); + memcpy(data, upload_test[alt], UPLOAD_SIZE); return UPLOAD_SIZE; } |
