Classes | Macros | Functions | Variables
d_usartDMA.c File Reference
#include <asf.h>
#include <string.h>
#include <stdio.h>
#include "d_usartDMA.h"
#include "d_dma.h"
#include "usart.h"
#include "../../src/ISComm.h"
#include "board_opt.h"
#include "globals.h"
Include dependency graph for d_usartDMA.c:

Go to the source code of this file.

Classes

struct  dmaBuffer_rx_t
 
struct  dmaBuffer_tx_t
 
struct  usart_info_t
 
struct  usartDMA_t
 

Macros

#define ARG_0(A0, ...)   A0
 
#define ARG_1(A0, A1, ...)   A1
 
#define ARG_2(A0, A1, A2, ...)   A2
 
#define ARG_3(A0, A1, A2, A3, ...)   A3
 
#define ARG_4(A0, A1, A2, A3, A4, ...)   A4
 
#define ARGN(N, LIST)   CONCAT(ARG_, N) LIST
 
#define CONCAT(A, B)   A ## B
 
#define DMA_LLD_COUNT   32
 
#define DMA_LLD_MASK   (DMA_LLD_COUNT - 1)
 

Functions

 __attribute__ ((optimize("O0")))
 
 COMPILER_ALIGNED (32)
 
void d_usartDMA_callback_cdc_disable (void)
 
bool d_usartDMA_callback_cdc_enable (void)
 
void d_usartDMA_callback_cdc_tx_empty_notify (void)
 
static const uint8_t * getCurrentRxDmaAddress (dmaBuffer_rx_t *dma)
 
static const uint8_t * getCurrentTxDmaAddress (dmaBuffer_tx_t *dma)
 
static dmaBuffer_rx_tgetRxDma (uint32_t serialNum)
 
static dmaBuffer_tx_tgetTxDma (uint32_t serialNum)
 
static int serBufferInit (usartDMA_t *ser, int serialNumber)
 
static int serEnable (int serialNum)
 
int serFindCharacter (int serialNum, uint8_t ch)
 Returns number of characters in buffer before specified character. More...
 
int serGetBaudRate (int serialNum)
 Read USART baudrate. Return value is the baudrate or -1 on failure. More...
 
int serInit (int serialNum, uint32_t baudRate, sam_usart_opt_t *options, uint32_t *overrunStatus)
 Initialize serial port with specific USART/UART and DMA settings. If not NULL, the overrun status will have bits HDW_STATUS_ERR_COM_TX_LIMITED and HDW_STATUS_ERR_COM_RX_OVERRUN set during buffer limitation. More...
 
int serRead (int serialNum, unsigned char *buf, int size)
 Read data on USART. Returns number of bytes read. With use of the PDCA ring buffer, buffer overrun may occur if bytes are received is greater than bytes read plus buffer size. More...
 
int serRxClear (int serialNum, int size)
 Removes removes data from USART Rx buffer. Returns number of bytes removed. Length of -1 removes all data from USART buffer. More...
 
int serRxFree (int serialNum)
 Returns number of bytes available in Rx buffer. More...
 
static int serRxFreeDma (dmaBuffer_rx_t *dma)
 
int serRxUsed (int serialNum)
 Returns number of bytes used in Rx buffer. More...
 
static int serRxUsedDma (dmaBuffer_rx_t *dma)
 
int serSetBaudRate (int serialNum, int baudrate)
 Change USART baudrate. 0 on success, -1 on failure. More...
 
int serTxClear (int serialNum)
 Clear the entire Tx buffer. More...
 
int serTxFree (int serialNum)
 Returns number of bytes available in Tx buffer. More...
 
static int serTxFreeDma (dmaBuffer_tx_t *dma)
 
int serTxUsed (int serialNum)
 Returns number of bytes used in Tx buffer. More...
 
static int serTxUsedDma (dmaBuffer_tx_t *dma)
 
int serWrite (int serialNum, const unsigned char *buf, int size)
 Write data on USART. Returns number of bytes written. More...
 
static int setup_usart_info (usartDMA_t *ser, int serialNumber, uint32_t baudRate, sam_usart_opt_t *options)
 
void UART0_Handler (void)
 
void UART1_Handler (void)
 
void UART2_Handler (void)
 
void UART3_Handler (void)
 
void UART4_Handler (void)
 
void USART0_Handler (void)
 
void USART1_Handler (void)
 
void USART2_Handler (void)
 
int validateBaudRate (unsigned int baudRate)
 Returns -1 if the baudrate is not a standard baudrate. More...
 
void XDMAC_Handler (void)
 

Variables

port_monitor_helper_t g_portMonitorHelper [MAX_NUMBER_SERIAL_PORTS] = {0}
 
static volatile usartDMA_t g_usartDMA [MAX_NUMBER_SERIAL_PORTS]
 
static uint32_t * s_overrunStatus =NULLPTR
 
static bool usb_cdc_open = false
 

Macro Definition Documentation

◆ ARG_0

#define ARG_0 (   A0,
  ... 
)    A0

Definition at line 98 of file d_usartDMA.c.

◆ ARG_1

#define ARG_1 (   A0,
  A1,
  ... 
)    A1

Definition at line 99 of file d_usartDMA.c.

◆ ARG_2

#define ARG_2 (   A0,
  A1,
  A2,
  ... 
)    A2

Definition at line 100 of file d_usartDMA.c.

◆ ARG_3

#define ARG_3 (   A0,
  A1,
  A2,
  A3,
  ... 
)    A3

Definition at line 101 of file d_usartDMA.c.

◆ ARG_4

#define ARG_4 (   A0,
  A1,
  A2,
  A3,
  A4,
  ... 
)    A4

Definition at line 102 of file d_usartDMA.c.

◆ ARGN

#define ARGN (   N,
  LIST 
)    CONCAT(ARG_, N) LIST

Definition at line 97 of file d_usartDMA.c.

◆ CONCAT

#define CONCAT (   A,
 
)    A ## B

Definition at line 96 of file d_usartDMA.c.

◆ DMA_LLD_COUNT

#define DMA_LLD_COUNT   32

Definition at line 32 of file d_usartDMA.c.

◆ DMA_LLD_MASK

#define DMA_LLD_MASK   (DMA_LLD_COUNT - 1)

Definition at line 33 of file d_usartDMA.c.

Function Documentation

◆ __attribute__()

__attribute__ ( (optimize("O0"))  )

Definition at line 1027 of file d_usartDMA.c.

◆ COMPILER_ALIGNED()

COMPILER_ALIGNED ( 32  )

Definition at line 150 of file d_usartDMA.c.

◆ d_usartDMA_callback_cdc_disable()

void d_usartDMA_callback_cdc_disable ( void  )

Definition at line 166 of file d_usartDMA.c.

◆ d_usartDMA_callback_cdc_enable()

bool d_usartDMA_callback_cdc_enable ( void  )

Definition at line 160 of file d_usartDMA.c.

◆ d_usartDMA_callback_cdc_tx_empty_notify()

void d_usartDMA_callback_cdc_tx_empty_notify ( void  )

Definition at line 171 of file d_usartDMA.c.

◆ getCurrentRxDmaAddress()

static const uint8_t* getCurrentRxDmaAddress ( dmaBuffer_rx_t dma)
inlinestatic

Definition at line 226 of file d_usartDMA.c.

◆ getCurrentTxDmaAddress()

static const uint8_t* getCurrentTxDmaAddress ( dmaBuffer_tx_t dma)
inlinestatic

Definition at line 214 of file d_usartDMA.c.

◆ getRxDma()

static dmaBuffer_rx_t* getRxDma ( uint32_t  serialNum)
inlinestatic

Definition at line 240 of file d_usartDMA.c.

◆ getTxDma()

static dmaBuffer_tx_t* getTxDma ( uint32_t  serialNum)
inlinestatic

Definition at line 231 of file d_usartDMA.c.

◆ serBufferInit()

static int serBufferInit ( usartDMA_t ser,
int  serialNumber 
)
static

Definition at line 1341 of file d_usartDMA.c.

◆ serEnable()

static int serEnable ( int  serialNum)
static

Definition at line 928 of file d_usartDMA.c.

◆ serFindCharacter()

int serFindCharacter ( int  serialNum,
uint8_t  ch 
)

Returns number of characters in buffer before specified character.

Definition at line 884 of file d_usartDMA.c.

◆ serGetBaudRate()

int serGetBaudRate ( int  serialNum)

Read USART baudrate. Return value is the baudrate or -1 on failure.

Definition at line 1016 of file d_usartDMA.c.

◆ serInit()

int serInit ( int  serialNum,
uint32_t  baudRate,
sam_usart_opt_t options,
uint32_t *  overrunStatus 
)

Initialize serial port with specific USART/UART and DMA settings. If not NULL, the overrun status will have bits HDW_STATUS_ERR_COM_TX_LIMITED and HDW_STATUS_ERR_COM_RX_OVERRUN set during buffer limitation.

Definition at line 1560 of file d_usartDMA.c.

◆ serRead()

int serRead ( int  serialNum,
unsigned char *  buf,
int  size 
)

Read data on USART. Returns number of bytes read. With use of the PDCA ring buffer, buffer overrun may occur if bytes are received is greater than bytes read plus buffer size.

Definition at line 782 of file d_usartDMA.c.

◆ serRxClear()

int serRxClear ( int  serialNum,
int  size 
)

Removes removes data from USART Rx buffer. Returns number of bytes removed. Length of -1 removes all data from USART buffer.

Definition at line 398 of file d_usartDMA.c.

◆ serRxFree()

int serRxFree ( int  serialNum)

Returns number of bytes available in Rx buffer.

Definition at line 332 of file d_usartDMA.c.

◆ serRxFreeDma()

static int serRxFreeDma ( dmaBuffer_rx_t dma)
inlinestatic

Definition at line 280 of file d_usartDMA.c.

◆ serRxUsed()

int serRxUsed ( int  serialNum)

Returns number of bytes used in Rx buffer.

Definition at line 301 of file d_usartDMA.c.

◆ serRxUsedDma()

static int serRxUsedDma ( dmaBuffer_rx_t dma)
inlinestatic

Definition at line 262 of file d_usartDMA.c.

◆ serSetBaudRate()

int serSetBaudRate ( int  serialNum,
int  baudrate 
)

Change USART baudrate. 0 on success, -1 on failure.

Definition at line 995 of file d_usartDMA.c.

◆ serTxClear()

int serTxClear ( int  serialNum)

Clear the entire Tx buffer.

Clear the entire Tx buffer, returns how much was cleared.

Definition at line 344 of file d_usartDMA.c.

◆ serTxFree()

int serTxFree ( int  serialNum)

Returns number of bytes available in Tx buffer.

Definition at line 313 of file d_usartDMA.c.

◆ serTxFreeDma()

static int serTxFreeDma ( dmaBuffer_tx_t dma)
inlinestatic

Definition at line 275 of file d_usartDMA.c.

◆ serTxUsed()

int serTxUsed ( int  serialNum)

Returns number of bytes used in Tx buffer.

Definition at line 289 of file d_usartDMA.c.

◆ serTxUsedDma()

static int serTxUsedDma ( dmaBuffer_tx_t dma)
inlinestatic

Definition at line 249 of file d_usartDMA.c.

◆ serWrite()

int serWrite ( int  serialNum,
const unsigned char *  buf,
int  size 
)

Write data on USART. Returns number of bytes written.

Definition at line 443 of file d_usartDMA.c.

◆ setup_usart_info()

static int setup_usart_info ( usartDMA_t ser,
int  serialNumber,
uint32_t  baudRate,
sam_usart_opt_t options 
)
static

Definition at line 1301 of file d_usartDMA.c.

◆ validateBaudRate()

int validateBaudRate ( unsigned int  baudRate)

Returns -1 if the baudrate is not a standard baudrate.

Definition at line 980 of file d_usartDMA.c.

Variable Documentation

◆ g_portMonitorHelper

port_monitor_helper_t g_portMonitorHelper[MAX_NUMBER_SERIAL_PORTS] = {0}

Definition at line 153 of file d_usartDMA.c.

◆ g_usartDMA

volatile usartDMA_t g_usartDMA[MAX_NUMBER_SERIAL_PORTS]
static

Definition at line 150 of file d_usartDMA.c.

◆ s_overrunStatus

uint32_t* s_overrunStatus =NULLPTR
static

Definition at line 152 of file d_usartDMA.c.

◆ usb_cdc_open

bool usb_cdc_open = false
static

Definition at line 158 of file d_usartDMA.c.



inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:59