SAM I2S Unit test.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | TEST_SIZE 4 |
Functions | |
static void | cdc_uart_init (void) |
Initialize the USART for unit test. More... | |
static void | cleanup_i2s_callback_mode_test (const struct test_case *test) |
Cleanup function for callback mode test. More... | |
static void | cleanup_i2s_polled_mode_test (const struct test_case *test) |
Cleanup function for polled mode test. More... | |
static void | i2s_callback_rx (struct i2s_module *const module_inst) |
I2S data RX callback. More... | |
static void | i2s_callback_tx (struct i2s_module *const module_inst) |
I2S data TX callback. More... | |
int | main (void) |
Run I2S unit tests. More... | |
static void | run_i2s_callback_mode_test (const struct test_case *test) |
Test for I2S TX/RX using callback. More... | |
static void | run_i2s_polled_mode_test (const struct test_case *test) |
Test for I2S TX/RX by polling. More... | |
static void | setup_i2s (void) |
Initialize the I2S module Clock Unit and Serializer. More... | |
static void | setup_i2s_callback_mode_test (const struct test_case *test) |
Setup function for callback mode test. More... | |
static void | setup_i2s_polled_mode_test (const struct test_case *test) |
Setup function for polled mode test. More... | |
Variables | |
struct usart_module | cdc_uart_module |
struct i2s_module | i2s_instance |
uint16_t | test_rx_data [TEST_SIZE] = {0, 0, 0, 0} |
volatile uint32_t | test_rx_done = false |
uint16_t | test_tx_data [TEST_SIZE] = {11, 60, 0xF860, 0x9001} |
volatile uint32_t | test_tx_done = false |
#define TEST_SIZE 4 |
Referenced by run_i2s_callback_mode_test(), and run_i2s_polled_mode_test().
|
static |
Initialize the USART for unit test.
Initializes the SERCOM USART (SERCOM4) used for sending the unit test status to the computer via the EDBG CDC gateway.
References usart_config::baudrate, cdc_uart_module, CONF_STDIO_BAUDRATE, CONF_STDIO_MUX_SETTING, CONF_STDIO_PINMUX_PAD0, CONF_STDIO_PINMUX_PAD1, CONF_STDIO_PINMUX_PAD2, CONF_STDIO_PINMUX_PAD3, usart_config::mux_setting, usart_config::pinmux_pad0, usart_config::pinmux_pad1, usart_config::pinmux_pad2, usart_config::pinmux_pad3, usart_enable(), and usart_get_config_defaults().
Referenced by main().
|
static |
Cleanup function for callback mode test.
This function disables the callback & I2S module.
test | Current test case. |
References i2s_disable(), i2s_instance, I2S_SERIALIZER_0, I2S_SERIALIZER_1, I2S_SERIALIZER_CALLBACK_BUFFER_DONE, i2s_serializer_disable_callback(), and i2s_serializer_unregister_callback().
Referenced by main().
|
static |
Cleanup function for polled mode test.
This function disables the I2S module.
test | Current test case. |
References i2s_disable(), and i2s_instance.
Referenced by main().
|
static |
|
static |
int main | ( | void | ) |
Run I2S unit tests.
Initializes the system and serial output, then sets up the I2S unit test suite and runs it.
References cdc_uart_init(), cleanup_i2s_callback_mode_test(), cleanup_i2s_polled_mode_test(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, i2s_init(), i2s_instance, run_i2s_callback_mode_test(), run_i2s_polled_mode_test(), setup_i2s_callback_mode_test(), setup_i2s_polled_mode_test(), system_init(), and test_suite_run().
|
static |
Test for I2S TX/RX using callback.
test | Current test case. |
References i, i2s_instance, I2S_SERIALIZER_0, I2S_SERIALIZER_1, i2s_serializer_read_buffer_job(), i2s_serializer_write_buffer_job(), test_assert_true, test_rx_data, test_rx_done, TEST_SIZE, test_tx_data, and test_tx_done.
Referenced by main().
|
static |
Test for I2S TX/RX by polling.
Send several words by polling and receive them.
test | Current test case. |
References i, i2s_instance, I2S_SERIALIZER_0, I2S_SERIALIZER_1, i2s_serializer_read_wait(), i2s_serializer_write_wait(), j, test_assert_true, test_rx_data, TEST_SIZE, and test_tx_data.
Referenced by main().
|
static |
Initialize the I2S module Clock Unit and Serializer.
Reset I2S module. Initialize Clock Unit 0 and Serializer 0 for TX. Initialize Serializer 1 for RX. Data format is I2S compatible 16 bit stream.
References i2s_clock_unit_config::clock, i2s_serializer_config::clock_unit, i2s_frame_config::data_delay, i2s_serializer_config::data_size, i2s_pin_config::enable, i2s_clock_unit_config::frame, i2s_frame_config::frame_sync, i2s_clock_unit_config::fs_pin, GCLK_GENERATOR_1, i2s_clock_config::gclk_src, i2s_pin_config::gpio, I2S_CLOCK_UNIT_0, I2S_CLOCK_UNIT_1, i2s_clock_unit_enable(), i2s_clock_unit_get_config_defaults(), i2s_clock_unit_set_config(), I2S_DATA_DELAY_I2S, I2S_DATA_SIZE_16BIT, i2s_enable(), I2S_FRAME_SYNC_SOURCE_FSPIN, I2S_FRAME_SYNC_SOURCE_SCKDIV, I2S_FRAME_SYNC_WIDTH_HALF_FRAME, i2s_instance, i2s_reset(), I2S_SERIAL_CLOCK_SOURCE_MCKDIV, I2S_SERIAL_CLOCK_SOURCE_SCKPIN, I2S_SERIALIZER_0, I2S_SERIALIZER_1, i2s_serializer_enable(), i2s_serializer_get_config_defaults(), I2S_SERIALIZER_RECEIVE, i2s_serializer_set_config(), I2S_SERIALIZER_TRANSMIT, I2S_SLOT_SIZE_32_BIT, i2s_serializer_config::loop_back, i2s_serializer_config::mode, i2s_pin_config::mux, i2s_frame_config::number_slots, i2s_clock_config::sck_div, i2s_clock_unit_config::sck_pin, i2s_clock_config::sck_src, i2s_frame_config::slot_size, i2s_frame_sync_config::source, and i2s_frame_sync_config::width.
Referenced by setup_i2s_callback_mode_test(), and setup_i2s_polled_mode_test().
|
static |
Setup function for callback mode test.
This function sets up the I2S & the callback function.
test | Current test case. |
References i2s_callback_rx(), i2s_callback_tx(), i2s_instance, I2S_SERIALIZER_0, I2S_SERIALIZER_1, I2S_SERIALIZER_CALLBACK_BUFFER_DONE, i2s_serializer_enable_callback(), i2s_serializer_register_callback(), and setup_i2s().
Referenced by main().
|
static |
Setup function for polled mode test.
This function sets up the I2S module.
test | Current test case. |
References setup_i2s().
Referenced by main().
struct usart_module cdc_uart_module |
struct i2s_module i2s_instance |
uint16_t test_rx_data[TEST_SIZE] = {0, 0, 0, 0} |
Referenced by run_i2s_callback_mode_test(), and run_i2s_polled_mode_test().
volatile uint32_t test_rx_done = false |
Referenced by i2s_callback_rx(), and run_i2s_callback_mode_test().
uint16_t test_tx_data[TEST_SIZE] = {11, 60, 0xF860, 0x9001} |
Referenced by run_i2s_callback_mode_test(), and run_i2s_polled_mode_test().
volatile uint32_t test_tx_done = false |
Referenced by i2s_callback_tx(), and run_i2s_callback_mode_test().