PER Firmware
Loading...
Searching...
No Matches
usart.c File Reference

Classes

struct  usart_active_transfer_t
 

Enumerations

enum  usart_dma_mode_t { USART_DMA_TX , USART_DMA_RX }
 

Functions

bool PHAL_initUSART (usart_init_t *handle, const uint32_t fck)
 Initialize a USART Peripheral with desired settings.
 
void PHAL_usartTxBl (usart_init_t *handle, uint8_t *data, uint32_t len)
 TX using no DMA (blocks until complete)
 
void PHAL_usartRxBl (usart_init_t *handle, uint8_t *data, uint32_t len)
 RX using no DMA (blocks until complete)
 
bool PHAL_usartTxDma (usart_init_t *handle, uint16_t *data, uint32_t len)
 Starts a tx using dma, use PHAL_usartTxDmaComplete to ensure the previous transmission is complete.
 
volatile bool PHAL_usartTxBusy (usart_init_t *handle)
 Returns whether USART peripheral is currently transmitting data.
 
bool PHAL_usartRxDma (usart_init_t *handle, uint16_t *data, uint32_t len, bool cont)
 Starts an rx using dma of a specific length.
 
bool PHAL_disableContinousRxDMA (usart_init_t *handle)
 Disables the Continous RX that was previously used.
 
bool PHAL_usartRxBusy (usart_init_t *handle)
 Returns whether USART peripheral is currently receiving data.
 
__WEAK void usart_recieve_complete_callback (usart_init_t *handle)
 Callback function called immediately after reception of a USART RX message Uses USART IDLE line interrupt.
 

Variables

volatile usart_active_transfer_t active_uarts [TOTAL_NUM_UART]
 

Detailed Description

Author
Aditya Anand (anand.nosp@m.89@p.nosp@m.urdue.nosp@m..edu) - Redesign of L4 UART HAL by Dawson Moore (moore.nosp@m.800@.nosp@m.purdu.nosp@m.e.ed.nosp@m.u)
Version
0.1
Date
2024-1-4

Enumeration Type Documentation

◆ usart_dma_mode_t

Enumerator
USART_DMA_TX 

USART is transmitting over DMA.

USART_DMA_RX 

USART is recieving over DMA.

Function Documentation

◆ PHAL_disableContinousRxDMA()

bool PHAL_disableContinousRxDMA ( usart_init_t * handle)

Disables the Continous RX that was previously used.

Parameters
handleThe handle for the usart configuration

◆ PHAL_initUSART()

bool PHAL_initUSART ( usart_init_t * handle,
const uint32_t fck )

Initialize a USART Peripheral with desired settings.

Parameters
handleHandle containing settings for USART peripheral
fckClock rate going to USART peripheral (APBx bus)
Returns
true Successfully initialized USART peripheral
false Failed to initialize USART peripheral

◆ PHAL_usartRxBl()

void PHAL_usartRxBl ( usart_init_t * handle,
uint8_t * data,
uint32_t len )

RX using no DMA (blocks until complete)

Parameters
handleThe handle for the usart configuration
dataThe address of the data to receive
lenNumber of u8s expected to receive. Will block if not received.

◆ PHAL_usartRxBusy()

bool PHAL_usartRxBusy ( usart_init_t * handle)

Returns whether USART peripheral is currently receiving data.

Parameters
handleHandle of USART peripheral check
Returns
true USART peripheral is currently receiving a message
false USART peripheal is not currently receiving a message

◆ PHAL_usartRxDma()

bool PHAL_usartRxDma ( usart_init_t * handle,
uint16_t * data,
uint32_t len,
bool cont )

Starts an rx using dma of a specific length.

Parameters
handleThe handle for the usart configuration
dataThe address to put the received data, ensure a cast to (uint16_t *), even if 8 bits
lenNumber of units of data, depending on the configured word length
contEnable Continous RX using the idle line interrupt (only need to call this function once, and HAL will keep recieving messages of the same length)

◆ PHAL_usartTxBl()

void PHAL_usartTxBl ( usart_init_t * handle,
uint8_t * data,
uint32_t len )

TX using no DMA (blocks until complete)

Parameters
handleThe handle for the usart configuration
dataThe address of the data to send
lenNumber of u8s

◆ PHAL_usartTxBusy()

volatile bool PHAL_usartTxBusy ( usart_init_t * handle)

Returns whether USART peripheral is currently transmitting data.

Parameters
handleHandle of USART peripheral to check
Returns
true USART peripheral is currently sending a message
false USART peripheal is not currently sending a message

◆ PHAL_usartTxDma()

bool PHAL_usartTxDma ( usart_init_t * handle,
uint16_t * data,
uint32_t len )

Starts a tx using dma, use PHAL_usartTxDmaComplete to ensure the previous transmission is complete.

Parameters
handleThe handle for the usart configuration
dataThe address of the data to send, ensure a cast to (uint16_t *), even if 8 bits
lenNumber of units of data, depending on the configured word length

◆ usart_recieve_complete_callback()

__WEAK void usart_recieve_complete_callback ( usart_init_t * handle)

Callback function called immediately after reception of a USART RX message Uses USART IDLE line interrupt.

NOTE: this is executed during an interrupt handler call, so keep code in this function light

Parameters
handleHandle of USART peripheral that just recieved a message