summaryrefslogtreecommitdiff
path: root/src/class
diff options
context:
space:
mode:
authorJeremiah McCarthy <[email protected]>2021-04-22 15:02:50 -0400
committerJeremiah McCarthy <[email protected]>2021-04-22 15:02:50 -0400
commit88dea7a0a8f7cb1bc21eaa45a3abb9a912b030d6 (patch)
treeccf3e8b2ec7d29f04dc498410fd41db8bc304317 /src/class
parent01661b3f281c4e044a370b33bf6617b8d2481407 (diff)
Move debug from .h to .c
Diffstat (limited to 'src/class')
-rw-r--r--src/class/dfu/dfu.h80
-rw-r--r--src/class/dfu/dfu_device.c77
-rw-r--r--src/class/dfu/dfu_rt_device.c9
3 files changed, 84 insertions, 82 deletions
diff --git a/src/class/dfu/dfu.h b/src/class/dfu/dfu.h
index af08a29f7..18de3bf99 100644
--- a/src/class/dfu/dfu.h
+++ b/src/class/dfu/dfu.h
@@ -111,86 +111,6 @@ typedef struct TU_ATTR_PACKED
TU_VERIFY_STATIC( sizeof(dfu_status_req_payload_t) == 6, "size is not correct");
-
-//--------------------------------------------------------------------+
-// 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) ); \
-}
-
-
#ifdef __cplusplus
}
#endif
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
diff --git a/src/class/dfu/dfu_rt_device.c b/src/class/dfu/dfu_rt_device.c
index 9da2e1e4f..faeae9b68 100644
--- a/src/class/dfu/dfu_rt_device.c
+++ b/src/class/dfu/dfu_rt_device.c
@@ -93,11 +93,11 @@ bool dfu_rtd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request
// Handle class request only from here
TU_VERIFY(request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS);
- TU_LOG2(" DFU RT Request: %s\r\n", tu_lookup_find(&_dfu_request_table, request->bRequest));
switch (request->bRequest)
{
case DFU_REQUEST_DETACH:
{
+ TU_LOG2(" DFU RT Request: DETACH\r\n");
tud_control_status(rhport, request);
tud_dfu_runtime_reboot_to_dfu_cb();
}
@@ -105,6 +105,7 @@ bool dfu_rtd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request
case DFU_REQUEST_GETSTATUS:
{
+ TU_LOG2(" DFU RT Request: GETSTATUS\r\n");
dfu_status_req_payload_t resp;
// Status = OK, Poll timeout is ignored during RT, State = APP_IDLE, IString = 0
memset(&resp, 0x00, sizeof(dfu_status_req_payload_t));
@@ -112,7 +113,11 @@ bool dfu_rtd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request
}
break;
- default: return false; // stall unsupported request
+ default:
+ {
+ TU_LOG2(" DFU RT Unexpected Request: %d\r\n", request->bRequest);
+ return false; // stall unsupported request
+ }
}
return true;