Unit tests for USART driver.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include <conf_test.h>
Functions | |
static uint32_t | calculate_baudrate (uint32_t baud, uint32_t cpu_hz) |
int | main (void) |
Run USART unit tests. More... | |
static void | run_baudrate_test (const struct test_case *test) |
Test setting different baud rates of the USART module. More... | |
static void | run_check_registers_test (const struct test_case *test) |
Test checking different registers of the USART module. More... | |
static void | run_loopback_syncmode_test (const struct test_case *test) |
Test physical loop-back with some characters in sunc mode. More... | |
static void | run_loopback_test (const struct test_case *test) |
Test physical loop-back with some characters. More... | |
static void | run_set_functions_test (const struct test_case *test) |
Test setting different parameters of the USART module. More... | |
|
static |
References USART_U2X_bm.
Referenced by run_baudrate_test().
int main | ( | void | ) |
Run USART unit tests.
Main function.
Initializes the clock system, board and serial output, then sets up the USART unit test suite and runs it.
The SAM3X_EK, SAM3X Arduino board and SAM4C_EK use two bytes length internal address EEPROM.
References usart_rs232_options::baudrate, board_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, NULL, run_baudrate_test(), run_check_registers_test(), run_loopback_syncmode_test(), run_loopback_test(), run_set_functions_test(), stdio_serial_init(), sysclk_init(), test_suite_run(), and usart_serial_options.
|
static |
Test setting different baud rates of the USART module.
This function calls the set function and check that the correct baud-rate has been set in the register.
test | Current test case. |
References calculate_baudrate(), success, sysclk_get_cpu_hz(), test_assert_true, and usart_set_baudrate().
Referenced by main().
|
static |
Test checking different registers of the USART module.
This function calls the different check functions and make sure they set the correct values.
test | Current test case. |
References usart_rs232_options::baudrate, data, success, test_assert_true, usart_data_register_is_empty(), usart_get(), usart_init_rs232(), usart_put(), usart_rx_is_complete(), and usart_tx_is_complete().
Referenced by main().
|
static |
Test physical loop-back with some characters in sunc mode.
This function sends a character over USART on loop back to verify that init and sending/receiving works. A jumper is connected on the USART.
test | Current test case. |
References ioport_configure_port_pin(), IOPORT_CREATE_PIN, IOPORT_DIR_OUTPUT, IOPORT_INIT_HIGH, ioport_pin_to_mask(), ioport_pin_to_port(), PRUSART0_bm, sysclk_enable_module(), sysclk_get_source_clock_hz(), test_assert_true, USART_CMODE_SYNCHRONOUS_gc, usart_getchar(), usart_putchar(), usart_rx_enable(), usart_set_mode(), usart_spi_set_baudrate(), and usart_tx_enable().
Referenced by main().
|
static |
Test physical loop-back with some characters.
This function sends a character over USART on loop back to verify that init and sending/receiving works. A jumper is connected on the USART.
test | Current test case. |
References usart_rs232_options::baudrate, test_assert_true, usart_getchar(), usart_init_rs232(), and usart_putchar().
Referenced by main().
|
static |
Test setting different parameters of the USART module.
This function calls the different set functions, and verifies that the correct values are being set.
test | Current test case. |
References success, test_assert_true, USART_CHSIZE_8BIT_gc, USART_CMODE_MSPI_gc, USART_CMODE_SYNCHRONOUS_gc, usart_data_empty_interrupt_disable(), usart_data_empty_interrupt_enable(), usart_double_baud_disable(), usart_double_baud_enable(), USART_DRIE_bm, USART_FE_bm, usart_format_set(), USART_PMODE_EVEN_gc, usart_rx_complete_interrupt_disable(), usart_rx_complete_interrupt_enable(), usart_rx_disable(), usart_rx_enable(), USART_RXC_bm, USART_RXEN_bm, usart_set_mode(), usart_tx_complete_interrupt_disable(), usart_tx_complete_interrupt_enable(), usart_tx_disable(), usart_tx_enable(), USART_TXC_bm, USART_TXEN_bm, USART_U2X_bm, and USART_UMSEL01_gm.
Referenced by main().