Main functions for USB host unit tests.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdio.h>
#include <asf.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include <conf_test.h>
#include "delay.h"
Functions | |
int | main (void) |
Run usb host core unit tests. More... | |
static void | main_display_event (void) |
void | main_usb_connection_event (uhc_device_t *dev, bool b_present) |
Notify that a USB device has been connected or disconnected. More... | |
void | main_usb_enum_event (uhc_device_t *dev, uhc_enum_status_t status) |
Notify the end of a USB device enumeration. More... | |
void | main_usb_mode_change (bool b_host_mode) |
Notify that the USB mode was automatically switched. This is possible only when ID pin is available. More... | |
void | main_usb_sof_event (void) |
Notify that a SOF has been sent (each 1 ms) More... | |
void | main_usb_vbus_change (bool b_vbus_present) |
Notify that a Vbus transition has occurred Available only in USB hardware with Vbus monitoring. More... | |
void | main_usb_vbus_error (void) |
Notify that a Vbus error has occurred Available only in USB hardware with Vbus monitoring. More... | |
void | main_usb_wakeup_event (void) |
Notify that a USB device or the host has wake up the USB line. More... | |
static void | run_test_disconnection (const struct test_case *test) |
static void | run_test_disconnection_in_suspend (const struct test_case *test) |
static void | run_test_downstream (const struct test_case *test) |
static void | run_test_downstream_disconnection (const struct test_case *test) |
static void | run_test_enum_fail (const struct test_case *test) |
static void | run_test_enum_hardwarelimit (const struct test_case *test) |
static void | run_test_enum_overcurrent (const struct test_case *test) |
static void | run_test_enum_success_fs (const struct test_case *test) |
static void | run_test_enum_success_hs (const struct test_case *test) |
static void | run_test_enum_success_ls (const struct test_case *test) |
static void | run_test_enum_unsupported (const struct test_case *test) |
static void | run_test_start_uhc (const struct test_case *test) |
static void | run_test_stop_uhc (const struct test_case *test) |
static void | run_test_upstream_fs (const struct test_case *test) |
static void | run_test_upstream_hs (const struct test_case *test) |
static void | run_test_upstream_ls (const struct test_case *test) |
Variables | |
volatile uint32_t | main_events = 0 |
#define CHECK_EVENT | ( | event, | |
msg | |||
) |
#define CHECK_EVENT_CONNECTION | ( | ) | CHECK_EVENT( MAIN_EVENT_CONNECTION ,"Event MAIN_EVENT_CONNECTION not received") |
Referenced by run_test_disconnection(), run_test_enum_fail(), run_test_enum_hardwarelimit(), run_test_enum_overcurrent(), run_test_enum_success_fs(), run_test_enum_success_hs(), run_test_enum_success_ls(), run_test_enum_unsupported(), run_test_upstream_fs(), run_test_upstream_hs(), and run_test_upstream_ls().
#define CHECK_EVENT_DEVICE_MODE | ( | ) | CHECK_EVENT( MAIN_EVENT_DEVICE_MODE ,"Event MAIN_EVENT_DEVICE_MODE not received") |
#define CHECK_EVENT_DISCONNECTION | ( | ) | CHECK_EVENT( MAIN_EVENT_DISCONNECTION ,"Event MAIN_EVENT_DISCONNECTION not received") |
#define CHECK_EVENT_ENUM_FAIL | ( | ) | CHECK_EVENT( MAIN_EVENT_ENUM_FAIL ,"Event MAIN_EVENT_ENUM_FAIL not received") |
Referenced by run_test_enum_fail().
#define CHECK_EVENT_ENUM_HARDWARE_LIMIT | ( | ) | CHECK_EVENT( MAIN_EVENT_ENUM_HARDWARE_LIMIT ,"Event MAIN_EVENT_ENUM_HARDWARE_LIMIT not received") |
Referenced by run_test_enum_hardwarelimit().
#define CHECK_EVENT_ENUM_OVERCURRENT | ( | ) | CHECK_EVENT( MAIN_EVENT_ENUM_OVERCURRENT ,"Event MAIN_EVENT_ENUM_OVERCURRENT not received") |
Referenced by run_test_enum_overcurrent().
#define CHECK_EVENT_ENUM_SUCCESS_FULL_SPEEP | ( | ) | CHECK_EVENT( MAIN_EVENT_ENUM_SUCCESS_FULL_SPEEP,"Event MAIN_EVENT_ENUM_SUCCESS_FULL_SPEEP not received") |
Referenced by run_test_enum_success_fs(), and run_test_upstream_fs().
#define CHECK_EVENT_ENUM_SUCCESS_HIGH_SPEEP | ( | ) | CHECK_EVENT( MAIN_EVENT_ENUM_SUCCESS_HIGH_SPEEP,"Event MAIN_EVENT_ENUM_SUCCESS_HIGH_SPEEP not received") |
Referenced by run_test_enum_success_hs(), and run_test_upstream_hs().
#define CHECK_EVENT_ENUM_SUCCESS_LOW_SPEEP | ( | ) | CHECK_EVENT( MAIN_EVENT_ENUM_SUCCESS_LOW_SPEEP ,"Event MAIN_EVENT_ENUM_SUCCESS_LOW_SPEEP not received") |
Referenced by run_test_enum_success_ls(), and run_test_upstream_ls().
#define CHECK_EVENT_ENUM_UNKNOW | ( | ) | CHECK_EVENT( MAIN_EVENT_ENUM_UNKNOW ,"Event MAIN_EVENT_ENUM_UNKNOW not received") |
#define CHECK_EVENT_ENUM_UNSUPPORTED | ( | ) | CHECK_EVENT( MAIN_EVENT_ENUM_UNSUPPORTED ,"Event MAIN_EVENT_ENUM_UNSUPPORTED not received") |
Referenced by run_test_enum_unsupported().
#define CHECK_EVENT_HOST_MODE | ( | ) | CHECK_EVENT( MAIN_EVENT_HOST_MODE ,"Event MAIN_EVENT_HOST_MODE not received") |
Referenced by run_test_start_uhc().
#define CHECK_EVENT_VBUS_NOT_PRESENT | ( | ) | CHECK_EVENT( MAIN_EVENT_VBUS_NOT_PRESENT ,"Event MAIN_EVENT_VBUS_NOT_PRESENT not received") |
#define CHECK_EVENT_VBUS_PRESENT | ( | ) | CHECK_EVENT( MAIN_EVENT_VBUS_PRESENT ,"Event MAIN_EVENT_VBUS_PRESENT not received") |
Referenced by run_test_start_uhc().
#define CHECK_EVENT_WAKEUP | ( | ) | CHECK_EVENT( MAIN_EVENT_WAKEUP ,"Event MAIN_EVENT_WAKEUP not received") |
Referenced by run_test_downstream(), run_test_upstream_fs(), run_test_upstream_hs(), and run_test_upstream_ls().
#define MAIN_EVENT_CONNECTION (1u<<4) |
Referenced by main_display_event(), and main_usb_connection_event().
#define MAIN_EVENT_DEVICE_MODE (1u<<1) |
Referenced by main_display_event(), and main_usb_mode_change().
#define MAIN_EVENT_DISCONNECTION (1u<<5) |
Referenced by main_display_event(), and main_usb_connection_event().
#define MAIN_EVENT_ENUM_FAIL (1u<<11) |
Referenced by main_display_event(), and main_usb_enum_event().
#define MAIN_EVENT_ENUM_HARDWARE_LIMIT (1u<<12) |
Referenced by main_display_event(), and main_usb_enum_event().
#define MAIN_EVENT_ENUM_OVERCURRENT (1u<<10) |
Referenced by main_display_event(), and main_usb_enum_event().
#define MAIN_EVENT_ENUM_SUCCESS_FULL_SPEEP (1u<<7) |
Referenced by main_display_event(), and main_usb_enum_event().
#define MAIN_EVENT_ENUM_SUCCESS_HIGH_SPEEP (1u<<8) |
Referenced by main_display_event(), and main_usb_enum_event().
#define MAIN_EVENT_ENUM_SUCCESS_LOW_SPEEP (1u<<6) |
Referenced by main_display_event(), and main_usb_enum_event().
#define MAIN_EVENT_ENUM_UNKNOW (1u<<13) |
Referenced by main_display_event(), and main_usb_enum_event().
#define MAIN_EVENT_ENUM_UNSUPPORTED (1u<<9) |
Referenced by main_display_event(), and main_usb_enum_event().
#define MAIN_EVENT_HOST_MODE (1u<<0) |
Referenced by main_display_event(), and main_usb_mode_change().
#define MAIN_EVENT_VBUS_NOT_PRESENT (1u<<3) |
Referenced by main_display_event(), and main_usb_vbus_change().
#define MAIN_EVENT_VBUS_PRESENT (1u<<2) |
Referenced by main_display_event(), and main_usb_vbus_change().
#define MAIN_EVENT_WAKEUP (1u<<14) |
Referenced by main_display_event(), and main_usb_wakeup_event().
#define record_events | ( | ) |
Referenced by run_test_start_uhc().
int main | ( | void | ) |
Run usb host core unit tests.
Initializes the clock system, board and serial output, then sets up the usb unit test suite and runs it.
References uart_rs232_options::baudrate, board_init(), cpu_irq_enable, DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, delay_init, irq_initialize_vectors, NULL, run_test_disconnection(), run_test_disconnection_in_suspend(), run_test_downstream(), run_test_downstream_disconnection(), run_test_enum_fail(), run_test_enum_hardwarelimit(), run_test_enum_overcurrent(), run_test_enum_success_fs(), run_test_enum_success_hs(), run_test_enum_success_ls(), run_test_enum_unsupported(), run_test_start_uhc(), run_test_stop_uhc(), run_test_upstream_fs(), run_test_upstream_hs(), run_test_upstream_ls(), SLEEPMGR_ACTIVE, sleepmgr_init(), sleepmgr_lock_mode(), stdio_serial_init(), sysclk_get_cpu_hz(), sysclk_init(), test_suite_run(), and usart_serial_options.
|
static |
References MAIN_EVENT_CONNECTION, MAIN_EVENT_DEVICE_MODE, MAIN_EVENT_DISCONNECTION, MAIN_EVENT_ENUM_FAIL, MAIN_EVENT_ENUM_HARDWARE_LIMIT, MAIN_EVENT_ENUM_OVERCURRENT, MAIN_EVENT_ENUM_SUCCESS_FULL_SPEEP, MAIN_EVENT_ENUM_SUCCESS_HIGH_SPEEP, MAIN_EVENT_ENUM_SUCCESS_LOW_SPEEP, MAIN_EVENT_ENUM_UNKNOW, MAIN_EVENT_ENUM_UNSUPPORTED, MAIN_EVENT_HOST_MODE, MAIN_EVENT_VBUS_NOT_PRESENT, MAIN_EVENT_VBUS_PRESENT, MAIN_EVENT_WAKEUP, and main_events.
void main_usb_connection_event | ( | uhc_device_t * | dev, |
bool | b_present | ||
) |
Notify that a USB device has been connected or disconnected.
dev | Pointer on USB device information |
b_present | true, if the device has been connected |
Notify that a USB device has been connected or disconnected.
References MAIN_EVENT_CONNECTION, MAIN_EVENT_DISCONNECTION, main_events, main_reset_states(), ui_usb_connection_event(), and UNUSED.
void main_usb_enum_event | ( | uhc_device_t * | dev, |
uhc_enum_status_t | status | ||
) |
Notify the end of a USB device enumeration.
dev | Pointer on USB device information |
status | Status of the USB enumeration |
Device is bus enumerated with at least one supported interface
All interfaces are not supported by UHIs
Device power can not be supported
A problem has been occurred during USB enumeration
USB hardware can not support it. Not enough free pipes.
References MAIN_EVENT_ENUM_FAIL, MAIN_EVENT_ENUM_HARDWARE_LIMIT, MAIN_EVENT_ENUM_OVERCURRENT, MAIN_EVENT_ENUM_SUCCESS_FULL_SPEEP, MAIN_EVENT_ENUM_SUCCESS_HIGH_SPEEP, MAIN_EVENT_ENUM_SUCCESS_LOW_SPEEP, MAIN_EVENT_ENUM_UNKNOW, MAIN_EVENT_ENUM_UNSUPPORTED, main_events, uhc_device_t::speed, UHC_ENUM_FAIL, UHC_ENUM_HARDWARE_LIMIT, UHC_ENUM_OVERCURRENT, UHC_ENUM_SUCCESS, UHC_ENUM_UNSUPPORTED, UHD_SPEED_FULL, UHD_SPEED_HIGH, and UHD_SPEED_LOW.
void main_usb_mode_change | ( | bool | b_host_mode | ) |
Notify that the USB mode was automatically switched. This is possible only when ID pin is available.
b_host_mode | true, if the host mode has been selected |
References MAIN_EVENT_DEVICE_MODE, MAIN_EVENT_HOST_MODE, and main_events.
void main_usb_sof_event | ( | void | ) |
Notify that a SOF has been sent (each 1 ms)
References main_usb_sof_counter, and ui_usb_sof_event().
void main_usb_vbus_change | ( | bool | b_vbus_present | ) |
Notify that a Vbus transition has occurred Available only in USB hardware with Vbus monitoring.
b_vbus_present | true, if Vbus is high. |
References MAIN_EVENT_VBUS_NOT_PRESENT, MAIN_EVENT_VBUS_PRESENT, and main_events.
void main_usb_vbus_error | ( | void | ) |
Notify that a Vbus error has occurred Available only in USB hardware with Vbus monitoring.
void main_usb_wakeup_event | ( | void | ) |
Notify that a USB device or the host has wake up the USB line.
References MAIN_EVENT_WAKEUP, and main_events.
|
static |
References CHECK_EVENT_CONNECTION, and CHECK_EVENT_DISCONNECTION.
Referenced by main().
|
static |
References CHECK_EVENT_DISCONNECTION, and uhc_suspend().
Referenced by main().
|
static |
References CHECK_EVENT_WAKEUP, delay_ms, uhc_resume(), and uhc_suspend().
Referenced by main().
|
static |
References CHECK_EVENT_DISCONNECTION, delay_ms, uhc_resume(), and uhc_suspend().
Referenced by main().
|
static |
References CHECK_EVENT_CONNECTION, CHECK_EVENT_DISCONNECTION, and CHECK_EVENT_ENUM_FAIL.
Referenced by main().
|
static |
References CHECK_EVENT_CONNECTION, CHECK_EVENT_DISCONNECTION, and CHECK_EVENT_ENUM_HARDWARE_LIMIT.
Referenced by main().
|
static |
References CHECK_EVENT_CONNECTION, CHECK_EVENT_DISCONNECTION, and CHECK_EVENT_ENUM_OVERCURRENT.
Referenced by main().
|
static |
References CHECK_EVENT_CONNECTION, and CHECK_EVENT_ENUM_SUCCESS_FULL_SPEEP.
Referenced by main().
|
static |
References CHECK_EVENT_CONNECTION, and CHECK_EVENT_ENUM_SUCCESS_HIGH_SPEEP.
Referenced by main().
|
static |
References CHECK_EVENT_CONNECTION, and CHECK_EVENT_ENUM_SUCCESS_LOW_SPEEP.
Referenced by main().
|
static |
References CHECK_EVENT_CONNECTION, CHECK_EVENT_DISCONNECTION, and CHECK_EVENT_ENUM_UNSUPPORTED.
Referenced by main().
|
static |
References CHECK_EVENT_HOST_MODE, CHECK_EVENT_VBUS_PRESENT, record_events, and uhc_start().
Referenced by main().
|
static |
References main_events, test_assert_true, and uhc_stop().
Referenced by main().
|
static |
References CHECK_EVENT_CONNECTION, CHECK_EVENT_ENUM_SUCCESS_FULL_SPEEP, CHECK_EVENT_WAKEUP, and uhc_suspend().
Referenced by main().
|
static |
References CHECK_EVENT_CONNECTION, CHECK_EVENT_ENUM_SUCCESS_HIGH_SPEEP, CHECK_EVENT_WAKEUP, and uhc_suspend().
Referenced by main().
|
static |
References CHECK_EVENT_CONNECTION, CHECK_EVENT_ENUM_SUCCESS_LOW_SPEEP, CHECK_EVENT_WAKEUP, and uhc_suspend().
Referenced by main().
volatile uint32_t main_events = 0 |