Main functions for USB host vendor example.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | MAIN_VENDOR_ISO_SIZE_1 (MAIN_VENDOR_LOOPBACK_SIZE/2) |
#define | MAIN_VENDOR_ISO_SIZE_2 ((MAIN_VENDOR_LOOPBACK_SIZE-MAIN_VENDOR_ISO_SIZE_1)/4) |
#define | MAIN_VENDOR_LOOPBACK_SIZE (1024) |
#define | NB_TESTS (sizeof(loop_back_tests) / sizeof(loop_back_tests[0])) |
Number of tests available. More... | |
Functions | |
int | main (void) |
Main function. Execution starts here. More... | |
static int | main_cmp_buffers (void) |
Compare output buffer with input buffer. More... | |
static bool | main_control_is_available (void) |
Check if control test is available (control EP exist) More... | |
static void | main_control_transfer_done (usb_add_t add, uhd_trans_status_t status, uint16_t payload_trans) |
End of setup callback. More... | |
static void | main_init_buffers (void) |
Initialize test buffers. More... | |
static void | main_iso_in_done (usb_add_t add, usb_ep_t ep, uhd_trans_status_t status, iram_size_t nb_transfered) |
End of ISO IN transfer callback. More... | |
static void | main_iso_out_done (usb_add_t add, usb_ep_t ep, uhd_trans_status_t status, iram_size_t nb_transfered) |
End of ISO OUT transfer callback. More... | |
static bool | main_loop_back_bulk (void) |
Perform loop back test on control endpoint. More... | |
static bool | main_loop_back_control (void) |
Perform loop back test on control endpoint. More... | |
static bool | main_loop_back_int (void) |
Perform loop back test on interrupt endpoint. More... | |
static bool | main_loop_back_iso (void) |
Perform loop back test on ISO endpoint. More... | |
static void | main_transfer_done (usb_add_t add, usb_ep_t ep, uhd_trans_status_t status, iram_size_t nb_transfered) |
End of transfer callback. More... | |
void | main_usb_sof_event (void) |
Notify that a SOF has been sent (each 1 ms) More... | |
void | main_usb_vendor_change (uhc_device_t *dev, bool b_present) |
Notify that a USB device vendor has been connected or disconnected. More... | |
Variables | |
static bool(* | loop_back_tests [])(void) |
The test function entries. More... | |
static bool(* | loop_back_tests_is_available [])(void) |
If the test is available (the endpoint is found on attached device) More... | |
static volatile bool | main_b_control_busy |
The control transfer is in progress. More... | |
static volatile bool | main_b_in_busy |
The (bulk/interrupt/iso) IN transfer is in progress. More... | |
static volatile bool | main_b_out_busy |
The (bulk/interrupt/iso) OUT transfer is in progress. More... | |
static volatile bool | main_b_usb_start_test = false |
Indicate that the test can be started. More... | |
static volatile uhd_trans_status_t | main_transfer_status |
The transfer status. More... | |
static COMPILER_WORD_ALIGNED uint8_t | main_vendor_buf_in [MAIN_VENDOR_LOOPBACK_SIZE] |
Input buffer for vendor class test. More... | |
static COMPILER_WORD_ALIGNED uint8_t | main_vendor_buf_out [MAIN_VENDOR_LOOPBACK_SIZE] |
Output buffer for vendor class test. More... | |
static volatile uint32_t | main_vendor_iso_in_index |
Index for ISO IN data transfer. More... | |
static volatile uint32_t | main_vendor_iso_out_index |
Index for ISO OUT data transfer. More... | |
#define MAIN_VENDOR_ISO_SIZE_1 (MAIN_VENDOR_LOOPBACK_SIZE/2) |
Referenced by main_loop_back_iso().
#define MAIN_VENDOR_ISO_SIZE_2 ((MAIN_VENDOR_LOOPBACK_SIZE-MAIN_VENDOR_ISO_SIZE_1)/4) |
Referenced by main_iso_out_done().
#define MAIN_VENDOR_LOOPBACK_SIZE (1024) |
#define NB_TESTS (sizeof(loop_back_tests) / sizeof(loop_back_tests[0])) |
Number of tests available.
Referenced by main().
int main | ( | void | ) |
Main function. Execution starts here.
References board_init(), cpu_irq_enable, irq_initialize_vectors, loop_back_tests, loop_back_tests_is_available, main_b_usb_start_test, main_cmp_buffers(), main_init_buffers(), NB_TESTS, sleepmgr_enter_sleep(), sleepmgr_init(), system_init(), uhc_start(), ui_init(), and ui_test_finish().
|
static |
Compare output buffer with input buffer.
References main_vendor_buf_in, main_vendor_buf_out, and MAIN_VENDOR_LOOPBACK_SIZE.
Referenced by main().
|
static |
Check if control test is available (control EP exist)
|
static |
End of setup callback.
add | USB address of the setup request |
status | Transfer status |
payload_trans | Number of data transfered during DATA phase |
References main_b_control_busy, main_transfer_status, and UNUSED.
Referenced by main_loop_back_control().
|
static |
Initialize test buffers.
References main_vendor_buf_in, main_vendor_buf_out, and MAIN_VENDOR_LOOPBACK_SIZE.
Referenced by main().
|
static |
End of ISO IN transfer callback.
add | USB address used by the transfer |
ep | Endpoint address used by the transfer |
status | Transfer status |
nb_transfered | Number of data transfered |
References main_b_in_busy, main_transfer_status, main_vendor_buf_in, main_vendor_iso_in_index, MAIN_VENDOR_LOOPBACK_SIZE, uhi_vendor_iso_in_run(), and UNUSED.
Referenced by main_loop_back_iso().
|
static |
End of ISO OUT transfer callback.
add | USB address used by the transfer |
ep | Endpoint address used by the transfer |
status | Transfer status |
nb_transfered | Number of data transfered |
References main_b_out_busy, main_transfer_status, main_vendor_buf_out, main_vendor_iso_out_index, MAIN_VENDOR_ISO_SIZE_2, MAIN_VENDOR_LOOPBACK_SIZE, uhi_vendor_iso_out_run(), and UNUSED.
Referenced by main_loop_back_iso().
|
static |
Perform loop back test on control endpoint.
References main_b_in_busy, main_b_out_busy, main_transfer_done(), main_transfer_status, main_vendor_buf_in, main_vendor_buf_out, MAIN_VENDOR_LOOPBACK_SIZE, UHD_TRANS_NOERROR, uhi_vendor_bulk_in_run(), and uhi_vendor_bulk_out_run().
|
static |
Perform loop back test on control endpoint.
1
if test passed, 0
if test failed References main_b_control_busy, main_control_transfer_done(), main_transfer_status, main_vendor_buf_in, main_vendor_buf_out, MAIN_VENDOR_LOOPBACK_SIZE, UHD_TRANS_NOERROR, uhi_vendor_control_in_run(), and uhi_vendor_control_out_run().
|
static |
Perform loop back test on interrupt endpoint.
1
if test passed, 0
if test failed References main_b_in_busy, main_b_out_busy, main_transfer_done(), main_transfer_status, main_vendor_buf_in, main_vendor_buf_out, MAIN_VENDOR_LOOPBACK_SIZE, UHD_TRANS_NOERROR, uhi_vendor_int_in_run(), and uhi_vendor_int_out_run().
|
static |
Perform loop back test on ISO endpoint.
1
if test passed, 0
if test failed References main_b_in_busy, main_b_out_busy, main_iso_in_done(), main_iso_out_done(), main_transfer_status, main_vendor_buf_in, main_vendor_buf_out, main_vendor_iso_in_index, main_vendor_iso_out_index, MAIN_VENDOR_ISO_SIZE_1, MAIN_VENDOR_LOOPBACK_SIZE, UHD_TRANS_NOERROR, uhi_vendor_iso_in_run(), and uhi_vendor_iso_out_run().
|
static |
End of transfer callback.
add | USB address used by the transfer |
ep | Endpoint address used by the transfer |
status | Transfer status |
nb_transfered | Number of data transfered |
References main_b_in_busy, main_b_out_busy, main_transfer_status, UNUSED, and USB_EP_DIR_IN.
Referenced by main_loop_back_bulk(), and main_loop_back_int().
void main_usb_sof_event | ( | void | ) |
Notify that a SOF has been sent (each 1 ms)
References ui_usb_sof_event().
void main_usb_vendor_change | ( | uhc_device_t * | dev, |
bool | b_present | ||
) |
Notify that a USB device vendor has been connected or disconnected.
dev | Pointer on USB device information |
b_present | true, if the device has been connected |
References main_b_usb_start_test, and UNUSED.
|
static |
The test function entries.
Referenced by main().
|
static |
If the test is available (the endpoint is found on attached device)
Referenced by main().
|
static |
The control transfer is in progress.
Referenced by main_control_transfer_done(), and main_loop_back_control().
|
static |
The (bulk/interrupt/iso) IN transfer is in progress.
Referenced by main_iso_in_done(), main_loop_back_bulk(), main_loop_back_int(), main_loop_back_iso(), and main_transfer_done().
|
static |
The (bulk/interrupt/iso) OUT transfer is in progress.
Referenced by main_iso_out_done(), main_loop_back_bulk(), main_loop_back_int(), main_loop_back_iso(), and main_transfer_done().
Indicate that the test can be started.
Referenced by main(), and main_usb_vendor_change().
|
static |
The transfer status.
Referenced by main_control_transfer_done(), main_iso_in_done(), main_iso_out_done(), main_loop_back_bulk(), main_loop_back_control(), main_loop_back_int(), main_loop_back_iso(), and main_transfer_done().
|
static |
Input buffer for vendor class test.
Referenced by main_cmp_buffers(), main_init_buffers(), main_iso_in_done(), main_loop_back_bulk(), main_loop_back_control(), main_loop_back_int(), and main_loop_back_iso().
|
static |
Output buffer for vendor class test.
Referenced by main_cmp_buffers(), main_init_buffers(), main_iso_out_done(), main_loop_back_bulk(), main_loop_back_control(), main_loop_back_int(), and main_loop_back_iso().
|
static |
Index for ISO IN data transfer.
Referenced by main_iso_in_done(), and main_loop_back_iso().
|
static |
Index for ISO OUT data transfer.
Referenced by main_iso_out_done(), and main_loop_back_iso().