Unit tests for PDCA driver.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include <board.h>
#include <sysclk.h>
#include "pdca.h"
#include "usart.h"
#include <string.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include <conf_test.h>
#include <conf_board.h>
Macros | |
#define | ALL_INTERRUPT_MASK 0xffffffff |
All interrupt mask. More... | |
#define | BUFFER_SIZE 100 |
Size of the receive buffer used by the PDC, in bytes. More... | |
#define | PDCA_PID_USART0_RX 0 |
PDCA channel peripheral setting. More... | |
#define | PDCA_PID_USART0_TX 18 |
#define | PDCA_RX_CHANNEL 0 |
#define | PDCA_TX_CHANNEL 1 |
Functions | |
static void | configure_usart (void) |
Configure USART in normal (serial rs232) mode, asynchronous, 8 bits, 1 stop bit, no parity, 115200 bauds and enable its transmitter and receiver. More... | |
int | main (void) |
Run PDCA driver unit tests. More... | |
static void | run_pdca_loopback_test (const struct test_case *test) |
Test PDCA transfer in loopback mode. More... | |
void | USART_Handler (void) |
Interrupt handler for USART. More... | |
Variables | |
static uint8_t | gs_rev_buffer [BUFFER_SIZE] |
Receive buffer. More... | |
static uint8_t | gs_tran_buffer [BUFFER_SIZE] |
Transmit buffer. More... | |
pdca_channel_config_t | pdca_rx_options |
PDC channel options. More... | |
pdca_channel_config_t | pdca_tx_options |
volatile uint8_t | rxbuff_flag = 0 |
#define ALL_INTERRUPT_MASK 0xffffffff |
All interrupt mask.
Referenced by configure_usart().
#define BUFFER_SIZE 100 |
Size of the receive buffer used by the PDC, in bytes.
Referenced by run_pdca_loopback_test().
#define PDCA_PID_USART0_RX 0 |
PDCA channel peripheral setting.
#define PDCA_PID_USART0_TX 18 |
#define PDCA_RX_CHANNEL 0 |
Referenced by run_pdca_loopback_test().
#define PDCA_TX_CHANNEL 1 |
Referenced by run_pdca_loopback_test().
|
static |
Configure USART in normal (serial rs232) mode, asynchronous, 8 bits, 1 stop bit, no parity, 115200 bauds and enable its transmitter and receiver.
References ALL_INTERRUPT_MASK, sysclk_enable_peripheral_clock(), sysclk_get_peripheral_bus_hz(), usart_disable_interrupt(), usart_enable_rx(), usart_enable_tx(), and usart_init_rs232().
Referenced by run_pdca_loopback_test().
int main | ( | void | ) |
Run PDCA driver unit tests.
References uart_rs232_options::baudrate, board_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, NULL, run_pdca_loopback_test(), stdio_serial_init(), sysclk_init(), test_suite_run(), and usart_serial_options.
|
static |
Test PDCA transfer in loopback mode.
test | Current test case. |
References BUFFER_SIZE, configure_usart(), gs_rev_buffer, gs_tran_buffer, pdca_channel_enable(), pdca_channel_set_config(), pdca_enable(), PDCA_RX_CHANNEL, PDCA_TX_CHANNEL, rxbuff_flag, test_assert_true, and usart_enable_interrupt().
Referenced by main().
void USART_Handler | ( | void | ) |
Interrupt handler for USART.
References rxbuff_flag, usart_disable_interrupt(), and usart_get_status().
|
static |
Receive buffer.
Referenced by run_pdca_loopback_test().
|
static |
Transmit buffer.
Referenced by run_pdca_loopback_test().
pdca_channel_config_t pdca_rx_options |
PDC channel options.
pdca_channel_config_t pdca_tx_options |
volatile uint8_t rxbuff_flag = 0 |
Referenced by run_pdca_loopback_test(), and USART_Handler().