|
PER Firmware
|
#include "common/phal_G4/usart/usart.h"#include "common/phal_G4/usart/usart_priv.h"#include "common/phal_G4/dma/dma.h"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] |
| 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.
| periph_idx | Which USART peripheral to initialize |
| baud_rate | Desired baud rate |
| clock_rate | Frequency (Hz) of the bus clock feeding this USART (APB1/APB2) |
| 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.
| periph_idx | Which USART peripheral to receive on |
| data | Buffer to receive into |
| len | Maximum number of bytes to receive (buffer size) |
| cont | Enable continuous RX. When set, call this once and the HAL keeps receiving frames of the same maximum length, invoking PHAL_USART_rxCallback after each. |
| 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.
| periph_idx | Which USART peripheral to receive on |
| data | Buffer to receive into |
| len | Number of bytes to receive |
| 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.
| periph_idx | Which USART peripheral received the frame |
| len | Number of bytes in this frame. Bytes past this offset in the buffer are stale and must not be decoded. |
| uint16_t PHAL_USART_rxCount | ( | PHAL_USART_Idx_t | periph_idx | ) |
Number of bytes received in the last completed frame.
| periph_idx | Which USART peripheral to query |
| 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.
| periph_idx | Which USART peripheral to transmit on |
| data | Buffer to send |
| len | Number of bytes to send |
| bool PHAL_USART_txBlocking | ( | PHAL_USART_Idx_t | periph_idx, |
| uint8_t * | data, | ||
| uint16_t | len ) |
Transmit data, blocking until the transfer completes.
| periph_idx | Which USART peripheral to transmit on |
| data | Buffer to send |
| len | Number of bytes to send |
| 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.
| periph_idx | Which USART peripheral to check |
| void USART1_IRQHandler | ( | void | ) |
| void USART2_IRQHandler | ( | void | ) |
| void USART3_IRQHandler | ( | void | ) |
|
static |
|
static |
|
static |
|
static |