STM32F4 UART API

group STM32F4_HAL_UART

Defines

__GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->SR & (__FLAG__)) == (__FLAG__))

Checks if flag is set on UART registers.

Functions

USART_TypeDef *uart_dev(KUARTNum uart)

Internal function to get appropriate USART_TypeDef based on UART num.

Return
USART_TypeDef
Parameters
  • uart: UART bus num

IRQn_Type uart_irqn(KUARTNum uart)

Internal function to get appropriate interrupt number based on UART num.

Return
IRQn_Type interrupt number
Parameters
  • uart: UART bus num

static void uart_clk_enable(KUARTNum uart)

Internal function to enable the correct UART clock based on UART num.

Parameters
  • uart: UART bus num

static void uart_clk_disable(KUARTNum uart)

Internal function to disable the correct UART clock based on UART num.

Parameters
  • uart: UART bus num

static uint8_t uart_alt(KUARTNum uart)

Internal function to fetch the alternate UART pin based on UART num.

Return
GPIO pin
Parameters
  • uart: UART bus num

KUARTStatus kprv_uart_dev_init(KUARTNum uart)

Setup and enable UART bus.

Return
KUARTStatus UART_OK if success, otherwise failure
Parameters
  • uart: UART bus to initialize

void kprv_uart_dev_terminate(KUARTNum uart)

UART hardware cleanup and disabling.

Parameters
  • uart: bus num to terminate

void kprv_uart_enable_tx_int(KUARTNum uart)

Enable UART tx interrupt.

Parameters
  • uart: UART bus to initialize

KUARTStatus k_uart_write_immediate(KUARTNum uart, char c)

Write a character directly to the UART interface.

The function k_uart_write queues up characters in an internal write buffer which is read by the UART interrupt. This function skips the write buffer and writes the character directly to the UART hardware.

Return
KUARTStatus UART_OK if success, otherwise failure
Parameters
  • uart: UART bus
  • c: character to write

static void uart_irq_handler(KUARTNum uart)

Internal function to process triggered interrupt.

Parameters
  • uart: UART bus num