PER Firmware
Loading...
Searching...
No Matches
usart.c File Reference
Include dependency graph for usart.c:

Classes

struct  PHAL_USART_state_t
 

Functions

static void usart_tx_dma_callback (void *ctx)
 
bool PHAL_USART_init (PHAL_USART_Idx_t periph_idx, uint32_t baud_rate, const uint32_t clock_rate)
 Initialize a USART peripheral for DMA-driven communication.
 
bool PHAL_USART_tx (PHAL_USART_Idx_t periph_idx, uint8_t *data, uint16_t len)
 Start a DMA-based transmission.
 
void PHAL_USART_rx (PHAL_USART_Idx_t periph_idx, uint8_t *data, uint16_t len, bool cont)
 Start a DMA-based reception, completed on the IDLE line.
 
bool PHAL_USART_txBusy (PHAL_USART_Idx_t periph_idx)
 Check whether a transmission is still in progress.
 
uint16_t PHAL_USART_rxCount (PHAL_USART_Idx_t periph_idx)
 Number of bytes received in the last completed frame.
 
bool PHAL_USART_txBlocking (PHAL_USART_Idx_t periph_idx, uint8_t *data, uint16_t len)
 Transmit data, blocking until the transfer completes.
 
void PHAL_USART_rxBlocking (PHAL_USART_Idx_t periph_idx, uint8_t *data, uint16_t len)
 Receive data, blocking until a one-shot reception completes.
 
static void usart_handle_irq (PHAL_USART_Idx_t periph_idx)
 
static void usart_handle_dma (PHAL_USART_Idx_t periph_idx)
 
void PHAL_USART_rxCallback (PHAL_USART_Idx_t periph_idx, uint16_t len)
 Weak callback invoked when a full RX frame is received. Override in application code. Runs in ISR context, so keep it light.
 
void USART1_IRQHandler (void)
 
void USART2_IRQHandler (void)
 
void USART3_IRQHandler (void)
 

Variables

static PHAL_USART_state_t usart_state [NUM_USART]
 

Function Documentation

◆ PHAL_USART_init()

bool PHAL_USART_init ( PHAL_USART_Idx_t periph_idx,
uint32_t baud_rate,
const uint32_t clock_rate )

Initialize a USART peripheral for DMA-driven communication.

Parameters
periph_idxWhich USART peripheral to initialize
baud_rateDesired baud rate
clock_rateFrequency (Hz) of the bus clock feeding this USART (APB1/APB2)
Returns
true on success, false if DMA init failed
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PHAL_USART_rx()

void PHAL_USART_rx ( PHAL_USART_Idx_t periph_idx,
uint8_t * data,
uint16_t len,
bool cont )

Start a DMA-based reception, completed on the IDLE line.

Start a reception using DMA of a specific length.

Parameters
periph_idxWhich USART peripheral to receive on
dataBuffer to receive into
lenMaximum number of bytes to receive (buffer size)
contEnable continuous RX. When set, call this once and the HAL keeps receiving frames of the same maximum length, invoking PHAL_USART_rxCallback after each.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PHAL_USART_rxBlocking()

void PHAL_USART_rxBlocking ( PHAL_USART_Idx_t periph_idx,
uint8_t * data,
uint16_t len )

Receive data, blocking until a one-shot reception completes.

Parameters
periph_idxWhich USART peripheral to receive on
dataBuffer to receive into
lenNumber of bytes to receive
Here is the call graph for this function:

◆ PHAL_USART_rxCallback()

void PHAL_USART_rxCallback ( PHAL_USART_Idx_t periph_idx,
uint16_t len )

Weak callback invoked when a full RX frame is received. Override in application code. Runs in ISR context, so keep it light.

Parameters
periph_idxWhich USART peripheral received the frame
lenNumber of bytes in this frame. Bytes past this offset in the buffer are stale and must not be decoded.
Here is the caller graph for this function:

◆ PHAL_USART_rxCount()

uint16_t PHAL_USART_rxCount ( PHAL_USART_Idx_t periph_idx)

Number of bytes received in the last completed frame.

Parameters
periph_idxWhich USART peripheral to query
Returns
byte count, valid once PHAL_USART_rxCallback has fired

◆ PHAL_USART_tx()

bool PHAL_USART_tx ( PHAL_USART_Idx_t periph_idx,
uint8_t * data,
uint16_t len )

Start a DMA-based transmission.

Start a transmission using DMA.

Parameters
periph_idxWhich USART peripheral to transmit on
dataBuffer to send
lenNumber of bytes to send
Returns
true if every DMA reconfiguration step succeeded, false if a transmission is already in flight or a step failed
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PHAL_USART_txBlocking()

bool PHAL_USART_txBlocking ( PHAL_USART_Idx_t periph_idx,
uint8_t * data,
uint16_t len )

Transmit data, blocking until the transfer completes.

Parameters
periph_idxWhich USART peripheral to transmit on
dataBuffer to send
lenNumber of bytes to send
Returns
true if the transfer completed, false if it failed to start
Here is the call graph for this function:

◆ PHAL_USART_txBusy()

bool PHAL_USART_txBusy ( PHAL_USART_Idx_t periph_idx)

Check whether a transmission is still in progress.

Returns whether the USART peripheral is currently transmitting data.

Parameters
periph_idxWhich USART peripheral to check
Returns
true if a transmission is in flight, false otherwise
Here is the caller graph for this function:

◆ USART1_IRQHandler()

void USART1_IRQHandler ( void )
Here is the call graph for this function:

◆ USART2_IRQHandler()

void USART2_IRQHandler ( void )
Here is the call graph for this function:

◆ USART3_IRQHandler()

void USART3_IRQHandler ( void )
Here is the call graph for this function:

◆ usart_handle_dma()

static void usart_handle_dma ( PHAL_USART_Idx_t periph_idx)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ usart_handle_irq()

static void usart_handle_irq ( PHAL_USART_Idx_t periph_idx)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ usart_tx_dma_callback()

static void usart_tx_dma_callback ( void * ctx)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ usart_state

PHAL_USART_state_t usart_state[NUM_USART]
static