SAM USART Unit test.
Copyright (c) 2013-2020 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | TEST_STRING "Hello world!" |
#define | TEST_STRING_LEN 13 |
#define | TEST_USART_SPEED 115200 |
Functions | |
static void | cdc_uart_init (void) |
Initialize the USART for unit test. More... | |
int | main (void) |
Run USART unit tests. More... | |
static void | run_buffer_read_write_interrupt_test (const struct test_case *test) |
Test sending and receiving a string using interrupts. More... | |
static void | run_buffer_write_blocking_read_interrupt_test (const struct test_case *test) |
Test sending (blocking) and receiving (interrupt) a string. More... | |
static void | run_transfer_single_8bit_char_test (const struct test_case *test) |
Test single 8-bit character send and receive. More... | |
static void | run_transfer_single_9bit_char_test (const struct test_case *test) |
Test single 9-bit character send and receive. More... | |
static void | test_system_init (void) |
Initialize USARTs for unit tests. More... | |
static void | usart_callback (struct usart_module *const module) |
USART interrupt callback function. More... | |
Variables | |
struct usart_module | cdc_uart_module |
volatile bool | transfer_complete |
struct usart_config | usart_rx_config |
struct usart_module | usart_rx_module |
struct usart_config | usart_tx_config |
struct usart_module | usart_tx_module |
#define TEST_STRING "Hello world!" |
#define TEST_STRING_LEN 13 |
#define TEST_USART_SPEED 115200 |
Referenced by test_system_init().
|
static |
Initialize the USART for unit test.
Initializes the SERCOM USART 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().
int main | ( | void | ) |
Run USART unit tests.
Initializes the system and serial output, then sets up the USART unit test suite and runs it.
References cdc_uart_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, NULL, run_buffer_read_write_interrupt_test(), run_buffer_write_blocking_read_interrupt_test(), run_transfer_single_8bit_char_test(), run_transfer_single_9bit_char_test(), system_init(), test_suite_run(), and test_system_init().
|
static |
Test sending and receiving a string using interrupts.
This test sends one string from one USART to another. Both the send and receive is done using interrupts.
test | Current test case. |
References result, test_assert_false, test_assert_true, TEST_STRING, TEST_STRING_LEN, transfer_complete, USART_CALLBACK_BUFFER_RECEIVED, usart_enable_callback(), usart_read_buffer_job(), usart_register_callback(), usart_rx_module, usart_tx_module, and usart_write_buffer_job().
Referenced by main().
|
static |
Test sending (blocking) and receiving (interrupt) a string.
This test sends one string from one USART to another. It's sent using a blocking write, while it's received using interrupts.
test | Current test case. |
References result, test_assert_false, test_assert_true, TEST_STRING, TEST_STRING_LEN, transfer_complete, USART_CALLBACK_BUFFER_RECEIVED, usart_disable_callback(), usart_enable_callback(), usart_read_buffer_job(), usart_register_callback(), usart_rx_module, usart_tx_module, usart_unregister_callback(), and usart_write_buffer_wait().
Referenced by main().
|
static |
Test single 8-bit character send and receive.
This test sends on 9-bit character and checks it's received properly on the other end.
test | Current test case. |
References test_assert_true, usart_read_wait(), usart_rx_module, usart_tx_module, and usart_write_wait().
Referenced by main().
|
static |
Test single 9-bit character send and receive.
This test sends one 9-bit character and checks it's received properly on the other end.
test | Current test case. |
References usart_config::character_size, test_assert_true, USART_CHARACTER_SIZE_8BIT, USART_CHARACTER_SIZE_9BIT, usart_disable(), usart_enable(), usart_init(), usart_read_wait(), usart_rx_config, usart_rx_module, usart_tx_config, usart_tx_module, and usart_write_wait().
Referenced by main().
|
static |
Initialize USARTs for unit tests.
Initializes the two USARTs used by the unit test (one for RX and one for TX).
References usart_config::baudrate, usart_config::mux_setting, usart_config::pinmux_pad0, usart_config::pinmux_pad1, usart_config::pinmux_pad2, usart_config::pinmux_pad3, TEST_USART_SPEED, usart_enable(), usart_get_config_defaults(), usart_init(), usart_rx_config, usart_rx_module, usart_tx_config, and usart_tx_module.
Referenced by main().
|
static |
USART interrupt callback function.
Called by USART driver when receiving is complete.
module | USART module causing the interrupt (not used) |
References transfer_complete.
struct usart_module cdc_uart_module |
volatile bool transfer_complete |
struct usart_config usart_rx_config |
Referenced by run_transfer_single_9bit_char_test(), and test_system_init().
struct usart_module usart_rx_module |
struct usart_config usart_tx_config |
Referenced by run_transfer_single_9bit_char_test(), and test_system_init().
struct usart_module usart_tx_module |