ME 507 Romi++
Cylindrical Differential Drive Robot created for ME 507 at Cal Poly in Spring 2025
Loading...
Searching...
No Matches
uart_dma_idle.h File Reference

UART DMA with idle line detection handler. More...

#include "stm32f4xx_hal.h"

Go to the source code of this file.

Macros

#define BUFFER_SIZE   64
 Maximum receive buffer size for UART DMA.

Functions

void UART_DMA_IDLE_Init (UART_HandleTypeDef *huart)
 Initializes UART DMA reception with idle line detection.
void UART_DMA_IDLE_IRQHandler (UART_HandleTypeDef *huart)
 UART interrupt handler for idle line detection.

Variables

uint8_t rx_buffer [BUFFER_SIZE]
 UART DMA receive buffer shared with command parser or control logic.
uint8_t buffer_index
 Current write index into the rx_buffer.
volatile uint8_t command_ready
 Flag set when a full command is received and ready to parse.

Detailed Description

UART DMA with idle line detection handler.

Provides support for non-blocking UART reception using DMA with idle line interrupt to detect end-of-packet or message termination.

Function Documentation

◆ UART_DMA_IDLE_Init()

void UART_DMA_IDLE_Init ( UART_HandleTypeDef * huart)

Initializes UART DMA reception with idle line detection.

Parameters
huartPointer to UART handle configured for DMA RX.

Initializes UART DMA reception with idle line detection.

Parameters
huartPointer to the UART handle to configure.

Starts the DMA reception and enables UART idle line detection to trigger when a message has ended. Assumes a '\r
' terminated protocol.

◆ UART_DMA_IDLE_IRQHandler()

void UART_DMA_IDLE_IRQHandler ( UART_HandleTypeDef * huart)

UART interrupt handler for idle line detection.

Parameters
huartPointer to UART handle triggering the interrupt.

Should be called from the HAL_UART_IRQHandler.

UART interrupt handler for idle line detection.

Parameters
huartPointer to the UART handle triggering the interrupt.

Stops DMA temporarily, calculates received length, and checks for a complete command (terminated by "\r\n"). If found, sets command_ready.

Variable Documentation

◆ buffer_index

uint8_t buffer_index
extern

Current write index into the rx_buffer.

Current write index into the rx_buffer.

◆ command_ready

volatile uint8_t command_ready
extern

Flag set when a full command is received and ready to parse.

Flag set when a full command is received and ready to parse.

◆ rx_buffer

uint8_t rx_buffer[BUFFER_SIZE]
extern

UART DMA receive buffer shared with command parser or control logic.

UART DMA receive buffer shared with command parser or control logic.