Add DWC2 Test Mode SUpport

This commit is contained in:
Rocky04
2024-01-15 12:47:13 +00:00
parent 1fdf29075d
commit 1755bba509
4 changed files with 107 additions and 6 deletions

View File

@@ -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