Unit tests for SSC driver.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdint.h>
#include <stdbool.h>
#include <board.h>
#include <sysclk.h>
#include <ssc.h>
#include <string.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include <conf_test.h>
#include <conf_board.h>
Macros | |
#define | BIT_LEN_PER_CHANNEL 8 |
SSC work bit rate. More... | |
#define | BUFFER_SIZE 10 |
Transmitter and receiver buffer size. More... | |
#define | SAMPLE_RATE 8000 |
#define | SSC_BIT_RATE (BIT_LEN_PER_CHANNEL * SAMPLE_RATE) |
#define | SSC_IRQ_PRIO 4 |
The SSC interrupt IRQ priority. More... | |
Functions | |
int | main (void) |
Run SSC driver unit tests. More... | |
static void | run_ssc_test (const struct test_case *test) |
Test Synchronous Serial Controller. More... | |
void | SSC_Handler (void) |
Synchronous Serial Controller Handler. More... | |
Variables | |
uint8_t | g_uc_rx_buff [BUFFER_SIZE] |
Receiver buffer content. More... | |
volatile uint8_t | g_uc_rx_done = 0 |
Receive done flag. More... | |
uint8_t | g_uc_rx_index = 0 |
Receive index. More... | |
uint8_t | g_uc_tx_buff [BUFFER_SIZE] |
Transmit buffer content. More... | |
uint8_t | g_uc_tx_index = 0 |
Transmit index. More... | |
#define BIT_LEN_PER_CHANNEL 8 |
SSC work bit rate.
Referenced by run_ssc_test().
#define BUFFER_SIZE 10 |
Transmitter and receiver buffer size.
Referenced by run_ssc_test(), and SSC_Handler().
#define SAMPLE_RATE 8000 |
#define SSC_BIT_RATE (BIT_LEN_PER_CHANNEL * SAMPLE_RATE) |
Referenced by run_ssc_test().
#define SSC_IRQ_PRIO 4 |
The SSC interrupt IRQ priority.
Referenced by run_ssc_test().
int main | ( | void | ) |
Run SSC driver unit tests.
References uart_rs232_options::baudrate, board_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, NULL, run_ssc_test(), stdio_serial_init(), sysclk_enable_peripheral_clock(), sysclk_init(), test_suite_run(), and usart_serial_options.
|
static |
Test Synchronous Serial Controller.
This test sets SSC module in the loop mode and check the receiver data whether it's the same as the transmit data.
test | Current test case. |
References BIT_LEN_PER_CHANNEL, BUFFER_SIZE, g_uc_rx_buff, g_uc_rx_done, g_uc_tx_buff, g_uc_tx_index, pmc_enable_periph_clk(), SSC_BIT_RATE, ssc_enable_interrupt(), ssc_enable_rx(), ssc_enable_tx(), SSC_IRQ_PRIO, ssc_reset(), ssc_set_clock_divider(), ssc_set_loop_mode(), ssc_set_receiver(), ssc_set_transmitter(), ssc_write(), sysclk_get_cpu_hz(), test_assert_true, clock_opt_t::ul_ckg, clock_opt_t::ul_cki, clock_opt_t::ul_cko, clock_opt_t::ul_cks, data_frame_opt_t::ul_datlen, data_frame_opt_t::ul_datnb, data_frame_opt_t::ul_fsedge, data_frame_opt_t::ul_fslen, data_frame_opt_t::ul_fslen_ext, data_frame_opt_t::ul_fsos, data_frame_opt_t::ul_msbf, clock_opt_t::ul_period, clock_opt_t::ul_start_sel, and clock_opt_t::ul_sttdly.
Referenced by main().
void SSC_Handler | ( | void | ) |
Synchronous Serial Controller Handler.
References BUFFER_SIZE, g_uc_rx_buff, g_uc_rx_done, g_uc_rx_index, ssc_disable_interrupt(), ssc_get_status(), and ssc_read().
uint8_t g_uc_rx_buff[BUFFER_SIZE] |
Receiver buffer content.
Referenced by run_ssc_test(), and SSC_Handler().
volatile uint8_t g_uc_rx_done = 0 |
Receive done flag.
Referenced by run_ssc_test(), and SSC_Handler().
uint8_t g_uc_rx_index = 0 |
Receive index.
Referenced by SSC_Handler().
uint8_t g_uc_tx_buff[BUFFER_SIZE] |
Transmit buffer content.
Referenced by run_ssc_test().
uint8_t g_uc_tx_index = 0 |
Transmit index.
Referenced by run_ssc_test().