summaryrefslogtreecommitdiff
path: root/src/device/dcd.h
diff options
context:
space:
mode:
authorRocky04 <[email protected]>2024-01-15 12:47:13 +0000
committerRocky04 <[email protected]>2024-01-15 12:47:13 +0000
commit1755bba509edf2d5bc49cadecb6e956497732b37 (patch)
tree1205e0b008dc2ecf6672a0708b80ccdc163d5776 /src/device/dcd.h
parent1fdf29075d4e613eacfa881166015263797db0f6 (diff)
Add DWC2 Test Mode SUpport
Diffstat (limited to 'src/device/dcd.h')
-rw-r--r--src/device/dcd.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h
index 18a708347..7755ef107 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -58,6 +58,7 @@ typedef enum
DCD_EVENT_SETUP_RECEIVED,
DCD_EVENT_XFER_COMPLETE,
+ DCD_EVENT_TEST_MODE,
// Not an DCD event, just a convenient way to defer ISR function
USBD_EVENT_FUNC_CALL,
@@ -97,9 +98,23 @@ typedef struct TU_ATTR_ALIGNED(4)
void (*func) (void*);
void* param;
}func_call;
+
+ // TEST MODE
+ struct {
+ uint8_t selector;
+ }test_mode;
};
} dcd_event_t;
+typedef enum _test_mode_selector
+{
+ TEST_J = 1,
+ TEST_K,
+ TEST_SE0_NAK,
+ TEST_PACKET,
+ TEST_FORCE_ENABLE,
+} test_mode_t;
+
//TU_VERIFY_STATIC(sizeof(dcd_event_t) <= 12, "size is not correct");
//--------------------------------------------------------------------+
@@ -149,6 +164,12 @@ void dcd_disconnect(uint8_t rhport) TU_ATTR_WEAK;
// Enable/Disable Start-of-frame interrupt. Default is disabled
void dcd_sof_enable(uint8_t rhport, bool en);
+// Check if the test mode is supported
+bool dcd_test_mode_supported(test_mode_t test_selector) TU_ATTR_WEAK;
+
+// Put device into a test mode (needs power cycle to quit)
+void dcd_enter_test_mode(uint8_t rhport, test_mode_t test_selector) TU_ATTR_WEAK;
+
//--------------------------------------------------------------------+
// Endpoint API
//--------------------------------------------------------------------+
@@ -240,6 +261,13 @@ static inline void dcd_event_sof(uint8_t rhport, uint32_t frame_count, bool in_i
dcd_event_handler(&event, in_isr);
}
+TU_ATTR_ALWAYS_INLINE static inline void dcd_event_enter_test_mode(uint8_t rhport, uint8_t test_selector, bool in_isr)
+{
+ dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_TEST_MODE };
+ event.test_mode.selector = test_selector;
+ dcd_event_handler(&event, in_isr);
+}
+
#ifdef __cplusplus
}
#endif