diff options
| author | Jeremiah McCarthy <[email protected]> | 2021-04-22 15:02:50 -0400 |
|---|---|---|
| committer | Jeremiah McCarthy <[email protected]> | 2021-04-22 15:02:50 -0400 |
| commit | 88dea7a0a8f7cb1bc21eaa45a3abb9a912b030d6 (patch) | |
| tree | ccf3e8b2ec7d29f04dc498410fd41db8bc304317 /src/class/dfu/dfu_device.c | |
| parent | 01661b3f281c4e044a370b33bf6617b8d2481407 (diff) | |
Move debug from .h to .c
Diffstat (limited to 'src/class/dfu/dfu_device.c')
| -rw-r--r-- | src/class/dfu/dfu_device.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/class/dfu/dfu_device.c b/src/class/dfu/dfu_device.c index 98213d320..f3763adc7 100644 --- a/src/class/dfu/dfu_device.c +++ b/src/class/dfu/dfu_device.c @@ -61,6 +61,83 @@ static uint16_t dfu_req_upload(uint8_t rhport, tusb_control_request_t const * re static void dfu_req_dnload_reply(uint8_t rhport, tusb_control_request_t const * request); static bool dfu_state_machine(uint8_t rhport, tusb_control_request_t const * request); +//--------------------------------------------------------------------+ +// Debug +//--------------------------------------------------------------------+ +#if CFG_TUSB_DEBUG >= 2 + +static tu_lookup_entry_t const _dfu_request_lookup[] = +{ + { .key = DFU_REQUEST_DETACH , .data = "DETACH" }, + { .key = DFU_REQUEST_DNLOAD , .data = "DNLOAD" }, + { .key = DFU_REQUEST_UPLOAD , .data = "UPLOAD" }, + { .key = DFU_REQUEST_GETSTATUS , .data = "GETSTATUS" }, + { .key = DFU_REQUEST_CLRSTATUS , .data = "CLRSTATUS" }, + { .key = DFU_REQUEST_GETSTATE , .data = "GETSTATE" }, + { .key = DFU_REQUEST_ABORT , .data = "ABORT" }, +}; + +static tu_lookup_table_t const _dfu_request_table = +{ + .count = TU_ARRAY_SIZE(_dfu_request_lookup), + .items = _dfu_request_lookup +}; + +static tu_lookup_entry_t const _dfu_state_lookup[] = +{ + { .key = APP_IDLE , .data = "APP_IDLE" }, + { .key = APP_DETACH , .data = "APP_DETACH" }, + { .key = DFU_IDLE , .data = "DFU_IDLE" }, + { .key = DFU_DNLOAD_SYNC , .data = "DFU_DNLOAD_SYNC" }, + { .key = DFU_DNBUSY , .data = "DFU_DNBUSY" }, + { .key = DFU_DNLOAD_IDLE , .data = "DFU_DNLOAD_IDLE" }, + { .key = DFU_MANIFEST_SYNC , .data = "DFU_MANIFEST_SYNC" }, + { .key = DFU_MANIFEST , .data = "DFU_MANIFEST" }, + { .key = DFU_MANIFEST_WAIT_RESET , .data = "DFU_MANIFEST_WAIT_RESET" }, + { .key = DFU_UPLOAD_IDLE , .data = "DFU_UPLOAD_IDLE" }, + { .key = DFU_ERROR , .data = "DFU_ERROR" }, +}; + +static tu_lookup_table_t const _dfu_state_table = +{ + .count = TU_ARRAY_SIZE(_dfu_state_lookup), + .items = _dfu_state_lookup +}; + +static tu_lookup_entry_t const _dfu_status_lookup[] = +{ + { .key = DFU_STATUS_OK , .data = "OK" }, + { .key = DFU_STATUS_ERRTARGET , .data = "errTARGET" }, + { .key = DFU_STATUS_ERRFILE , .data = "errFILE" }, + { .key = DFU_STATUS_ERRWRITE , .data = "errWRITE" }, + { .key = DFU_STATUS_ERRERASE , .data = "errERASE" }, + { .key = DFU_STATUS_ERRCHECK_ERASED , .data = "errCHECK_ERASED" }, + { .key = DFU_STATUS_ERRPROG , .data = "errPROG" }, + { .key = DFU_STATUS_ERRVERIFY , .data = "errVERIFY" }, + { .key = DFU_STATUS_ERRADDRESS , .data = "errADDRESS" }, + { .key = DFU_STATUS_ERRNOTDONE , .data = "errNOTDONE" }, + { .key = DFU_STATUS_ERRFIRMWARE , .data = "errFIRMWARE" }, + { .key = DFU_STATUS_ERRVENDOR , .data = "errVENDOR" }, + { .key = DFU_STATUS_ERRUSBR , .data = "errUSBR" }, + { .key = DFU_STATUS_ERRPOR , .data = "errPOR" }, + { .key = DFU_STATUS_ERRUNKNOWN , .data = "errUNKNOWN" }, + { .key = DFU_STATUS_ERRSTALLEDPKT , .data = "errSTALLEDPKT" }, +}; + +static tu_lookup_table_t const _dfu_status_table = +{ + .count = TU_ARRAY_SIZE(_dfu_status_lookup), + .items = _dfu_status_lookup +}; + +#endif + +#define dfu_debug_print_context() \ +{ \ + TU_LOG2(" DFU at State: %s\r\n Status: %s\r\n", \ + tu_lookup_find(&_dfu_state_table, _dfu_state_ctx.state), \ + tu_lookup_find(&_dfu_status_table, _dfu_state_ctx.status) ); \ +} //--------------------------------------------------------------------+ // USBD Driver API |
