Microchip® Advanced Software Framework

sam/drivers/pdca/unit_tests/unit_tests.c File Reference

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 void configure_usart ( void  )
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().

static void run_pdca_loopback_test ( const struct test_case test)
static
void USART_Handler ( void  )

Interrupt handler for USART.

References rxbuff_flag, usart_disable_interrupt(), and usart_get_status().

uint8_t gs_rev_buffer[BUFFER_SIZE]
static

Receive buffer.

Referenced by run_pdca_loopback_test().

uint8_t gs_tran_buffer[BUFFER_SIZE]
static

Transmit buffer.

Referenced by run_pdca_loopback_test().

pdca_channel_config_t pdca_rx_options
Initial value:
= {
.addr = (void *)gs_rev_buffer,
.size = BUFFER_SIZE,
.r_addr = (void *)gs_rev_buffer,
.r_size = BUFFER_SIZE,
.transfer_size = PDCA_MR_SIZE_BYTE,
.etrig = false,
}
#define PDCA_PID_USART0_RX
PDCA channel peripheral setting.
Definition: sam/drivers/pdca/unit_tests/unit_tests.c:94
#define BUFFER_SIZE
Size of the receive buffer used by the PDC, in bytes.
Definition: sam/drivers/pdca/unit_tests/unit_tests.c:88
static uint8_t gs_rev_buffer[BUFFER_SIZE]
Receive buffer.
Definition: sam/drivers/pdca/unit_tests/unit_tests.c:101

PDC channel options.

pdca_channel_config_t pdca_tx_options
Initial value:
= {
.addr = (void *)gs_tran_buffer,
.size = BUFFER_SIZE,
.r_addr = (void *)gs_tran_buffer,
.r_size = BUFFER_SIZE,
.transfer_size = PDCA_MR_SIZE_BYTE,
.etrig = false,
}
#define BUFFER_SIZE
Size of the receive buffer used by the PDC, in bytes.
Definition: sam/drivers/pdca/unit_tests/unit_tests.c:88
static uint8_t gs_tran_buffer[BUFFER_SIZE]
Transmit buffer.
Definition: sam/drivers/pdca/unit_tests/unit_tests.c:104
#define PDCA_PID_USART0_TX
Definition: sam/drivers/pdca/unit_tests/unit_tests.c:95
volatile uint8_t rxbuff_flag = 0