USART DMAC Example for SAM.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include "asf.h"
#include "conf_example.h"
Macros | |
#define | BOARD_USART_DMAC_RX_CH 0 |
DMAC receive channel of master. More... | |
#define | BOARD_USART_DMAC_TX_CH 1 |
DMAC transmit channel of master. More... | |
#define | BUFFER_SIZE 32 |
Size of the receive buffer used by the DMAC, in bytes. More... | |
#define | STRING_EOL "\r" |
#define | STRING_HEADER |
#define | USART_RX_IDX 12 |
#define | USART_TX_IDX 11 |
DMAC Channel HW Interface Number for USART. More... | |
Functions | |
static void | configure_console (void) |
Configure UART for debug message output. More... | |
static void | configure_dmac (void) |
DMAC driver configuration. More... | |
static void | configure_dmac_rx (void) |
DMAC rx channel configuration. More... | |
static void | configure_dmac_tx (void) |
DMAC tx channel configuration. More... | |
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... | |
void | DMAC_Handler (void) |
DMAC interrupt handler. More... | |
int | main (void) |
Application entry point for usart_dmac_serial example. More... | |
Variables | |
static uint8_t | gs_puc_buffer [BUFFER_SIZE] |
Receive buffer. More... | |
#define BOARD_USART_DMAC_RX_CH 0 |
DMAC receive channel of master.
Referenced by configure_dmac(), configure_dmac_rx(), and DMAC_Handler().
#define BOARD_USART_DMAC_TX_CH 1 |
DMAC transmit channel of master.
Referenced by configure_dmac_tx().
#define BUFFER_SIZE 32 |
Size of the receive buffer used by the DMAC, in bytes.
Referenced by configure_dmac_rx(), and configure_dmac_tx().
#define STRING_EOL "\r" |
#define STRING_HEADER |
Referenced by main().
#define USART_RX_IDX 12 |
Referenced by configure_dmac_rx().
#define USART_TX_IDX 11 |
DMAC Channel HW Interface Number for USART.
Referenced by configure_dmac_tx().
|
static |
Configure UART for debug message output.
References uart_rs232_options::baudrate, stdio_serial_init(), and sysclk_enable_peripheral_clock().
Referenced by main().
|
static |
DMAC driver configuration.
References BOARD_USART_DMAC_RX_CH, dmac_enable(), dmac_enable_interrupt(), dmac_init(), DMAC_PRIORITY_ROUND_ROBIN, dmac_set_priority_mode(), and pmc_enable_periph_clk().
Referenced by main().
|
static |
DMAC rx channel configuration.
References BOARD_USART_DMAC_RX_CH, BUFFER_SIZE, dmac_channel_disable(), dmac_channel_enable(), dmac_channel_set_configuration(), dmac_channel_single_buf_transfer_init(), gs_puc_buffer, dma_transfer_descriptor_t::ul_ctrlA, dma_transfer_descriptor_t::ul_ctrlB, dma_transfer_descriptor_t::ul_descriptor_addr, dma_transfer_descriptor_t::ul_destination_addr, dma_transfer_descriptor_t::ul_source_addr, and USART_RX_IDX.
Referenced by DMAC_Handler(), and main().
|
static |
DMAC tx channel configuration.
References BOARD_USART_DMAC_TX_CH, BUFFER_SIZE, dmac_channel_disable(), dmac_channel_enable(), dmac_channel_set_configuration(), dmac_channel_single_buf_transfer_init(), gs_puc_buffer, dma_transfer_descriptor_t::ul_ctrlA, dma_transfer_descriptor_t::ul_ctrlB, dma_transfer_descriptor_t::ul_descriptor_addr, dma_transfer_descriptor_t::ul_destination_addr, dma_transfer_descriptor_t::ul_source_addr, and USART_TX_IDX.
Referenced by DMAC_Handler().
|
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 sysclk_enable_peripheral_clock(), sysclk_get_peripheral_hz(), usart_enable_rx(), usart_enable_tx(), and usart_init_rs232().
Referenced by main().
void DMAC_Handler | ( | void | ) |
DMAC interrupt handler.
References BOARD_USART_DMAC_RX_CH, configure_dmac_rx(), configure_dmac_tx(), and dmac_get_status().
int main | ( | void | ) |
Application entry point for usart_dmac_serial example.
References board_init(), configure_console(), configure_dmac(), configure_dmac_rx(), configure_usart(), STRING_HEADER, and sysclk_init().
|
static |
Receive buffer.
Referenced by configure_dmac_rx(), and configure_dmac_tx().