Astra MCU SDK Peripheral Driver Library
 
Loading...
Searching...
No Matches

Low level access functions. More...

Functions

uart_status_en uart_put_blocking (uart_instance_en id, char *put_buff, uint32_t num, uint32_t timeout, bool wait_for_tx_fifo_drain)
 
uart_status_en uart_put_char_blocking (uart_instance_en id, char chr, uint32_t timeout)
 
uart_status_en uart_get_blocking (uart_instance_en id, char *get_buff, uint32_t num, uint32_t timeout)
 
uart_status_en uart_get_char_blocking (uart_instance_en id, char *p_chr, uint32_t timeout)
 
void uart_enable_ints (uart_instance_en id, uint32_t mask)
 
uint32_t uart_get_enabled_ints (uart_instance_en id)
 
uart_hw_status_t uart_get_status (uart_instance_en id)
 
void uart_set_tx_fifo_trigger (uart_instance_en id, uart_tx_fifo_trigger_en thres)
 
void uart_set_rx_fifo_trigger (uart_instance_en id, uart_rx_fifo_trigger_en thres)
 
uart_tx_fifo_trigger_en uart_get_tx_fifo_trigger (uart_instance_en id)
 
uart_rx_fifo_trigger_en uart_get_rx_fifo_trigger (uart_instance_en id)
 
uint32_t uart_get_num_in_tx_fifo (uart_instance_en id)
 
uint32_t uart_get_num_in_rx_fifo (uart_instance_en id)
 
void uart_put_break (uart_instance_en id, bool send_break)
 
uart_int_id_en uart_get_interrupt_id (uart_instance_en id)
 
bool uart_room_to_transmit (uart_instance_en id)
 
bool uart_recv_char_avail (uart_instance_en id)
 
void uart_put_char (uart_instance_en id, char chr)
 
char uart_get_char (uart_instance_en id)
 

Detailed Description

Low level access functions.

Function Documentation

◆ uart_put_blocking()

uart_status_en uart_put_blocking ( uart_instance_en id,
char * put_buff,
uint32_t num,
uint32_t timeout,
bool wait_for_tx_fifo_drain )

Performs a blocking transmit operation over UART for the specified instance. Sends data from the provided buffer and blocks until all bytes are transmitted or the timeout occurs.

Parameters
idUART Instance ID.
put_buffPointer to the buffer containing data to be transmitted.
numNumber of bytes to transmit.
timeoutLoop count to wait before timing out.
wait_for_tx_fifo_drainIf true, wait until all data is fully sent. If false, return after writing to the TX FIFO.
Returns
uart_status_en Status code indicating success or the reason for failure.

◆ uart_put_char_blocking()

uart_status_en uart_put_char_blocking ( uart_instance_en id,
char chr,
uint32_t timeout )

Transmits a single character through UART in a blocking manner for the specified instance.

Waits until there is room in the transmit FIFO to write the character. Uses a loop counter as a timeout mechanism to avoid indefinite blocking if FIFO remains full.

Parameters
idUART Instance ID.
chrCharacter to transmit
timeoutLoop count to wait before timing out
Returns
uart_status_en Status code indicating success or the reason for failure.

◆ uart_get_blocking()

uart_status_en uart_get_blocking ( uart_instance_en id,
char * get_buff,
uint32_t num,
uint32_t timeout )

Performs a blocking receive operation over UART for the specified instance. Waits for the specified number of bytes to be received or until the timeout expires.

Parameters
idUART Instance ID.
get_buffPointer to the buffer where received data will be stored.
numNumber of bytes to receive.
timeoutLoop count to wait before timing out.
Returns
uart_status_en Status code indicating success or the reason for failure.

◆ uart_get_char_blocking()

uart_status_en uart_get_char_blocking ( uart_instance_en id,
char * p_chr,
uint32_t timeout )

Receives a single character from UART in a blocking manner for the specified instance.

Waits until a character is available in the receive FIFO, then reads it into the pointer. Uses a loop counter as a timeout mechanism to prevent indefinite blocking if no char arrives.

Parameters
idUART Instance ID.
p_chrPointer to variable where received character will be stored
timeoutLoop count to wait before timing out
Returns
uart_status_en Status code indicating success or the reason for failure.

◆ uart_enable_ints()

void uart_enable_ints ( uart_instance_en id,
uint32_t mask )

Enables/Disables UART interrupts by setting bits in the IER register for the specified UART instance. Performs a read-modify-write to preserve other control bits.

The interrupt mask bit values:

  • 1: Interrupt enable
  • 0: Interrupt disable
Parameters
idUART Instance ID.
maskBitmask of UART interrupts to enable/disable.

Refer to uart_int_id_en for the list of valid interrupt IDs.

Returns
None

◆ uart_get_enabled_ints()

uint32_t uart_get_enabled_ints ( uart_instance_en id)

Gets the currently enabled UART interrupts for the specified instance.

Parameters
idUART Instance ID.
Returns
Bitmask of currently enabled UART interrupts.

Refer to uart_int_id_en for the list of valid interrupt IDs.

◆ uart_get_status()

uart_hw_status_t uart_get_status ( uart_instance_en id)

Retrieves the current UART hardware status for the specified instance by reading and combining the USR (UART Status Register) and LSR (Line Status Register). The combined status is returned as a structured bitfield representation.

Parameters
idUART Instance ID.
Returns
uart_hw_status_t Updated UART hardware status structure.

◆ uart_set_tx_fifo_trigger()

void uart_set_tx_fifo_trigger ( uart_instance_en id,
uart_tx_fifo_trigger_en thres )

Sets the transmit FIFO trigger threshold for the specified UART instance.

This threshold defines when the UART transmit interrupt is generated based on the number of bytes remaining in the transmit FIFO.

Parameters
idUART Instance ID.
thresThreshold value to set for the transmit FIFO trigger. Refer to uart_tx_fifo_trigger_en for the list of TX FIFO trigger levels.
Returns
None

◆ uart_set_rx_fifo_trigger()

void uart_set_rx_fifo_trigger ( uart_instance_en id,
uart_rx_fifo_trigger_en thres )

Sets the receive FIFO trigger threshold for the specified UART instance.

This threshold defines when the UART receive interrupt is generated based on the number of bytes in the receive FIFO.

Parameters
idUART Instance ID.
thresThreshold value to set for the receive FIFO trigger. Refer to uart_rx_fifo_trigger_en for the list of RX FIFO trigger levels.
Returns
None

◆ uart_get_tx_fifo_trigger()

uart_tx_fifo_trigger_en uart_get_tx_fifo_trigger ( uart_instance_en id)

Gets the transmit FIFO trigger threshold for the specified UART instance.

Parameters
idUART Instance ID.
Returns
uart_tx_fifo_trigger_en The current transmit FIFO trigger threshold value.

◆ uart_get_rx_fifo_trigger()

uart_rx_fifo_trigger_en uart_get_rx_fifo_trigger ( uart_instance_en id)

Gets the receive FIFO trigger threshold for the specified UART instance.

Parameters
idUART Instance ID.
Returns
uart_rx_fifo_trigger_en The current receive FIFO trigger threshold value.

◆ uart_get_num_in_tx_fifo()

uint32_t uart_get_num_in_tx_fifo ( uart_instance_en id)

Retrieves the number of bytes currently present in the UART Transmit FIFO.

Parameters
idUART Instance ID.
Returns
Number of bytes currently stored in the TX FIFO

◆ uart_get_num_in_rx_fifo()

uint32_t uart_get_num_in_rx_fifo ( uart_instance_en id)

Retrieves the number of bytes currently present in the UART Receive FIFO.

Parameters
idUART Instance ID.
Returns
Number of bytes currently stored in the RX FIFO

◆ uart_put_break()

void uart_put_break ( uart_instance_en id,
bool send_break )

Sends or stops sending a break signal on the UART TX line.

Parameters
idUART Instance ID.
send_breakBoolean flag to start (True) or stop (False) break
Returns
None

◆ uart_get_interrupt_id()

uart_int_id_en uart_get_interrupt_id ( uart_instance_en id)

Retrieves the current UART Interrupt Identification value.

Parameters
idUART Instance ID.
Returns
uart_int_id_en Interrupt ID value indicating the current interrupt source/status

◆ uart_room_to_transmit()

bool uart_room_to_transmit ( uart_instance_en id)

Checks whether there is room available in the UART transmitter buffer to accept new data.

Parameters
idUART Instance ID.
Returns
True if there is room to transmit, False if there is no room to transmit

◆ uart_recv_char_avail()

bool uart_recv_char_avail ( uart_instance_en id)

Checks if a character has been received by the UART.

This function checks the Data Ready (DR) bit in the Line Status Register (LSR) to determine whether data is available in the UART receive FIFO.

Parameters
idUART Instance ID.
Returns
True if data is available to be read, False if no data is available.

◆ uart_put_char()

void uart_put_char ( uart_instance_en id,
char chr )

Writes a single character to the UART transmit holding register without checking if there is room.

This function writes a character directly to the UART's Transmit Holding Register (THR), initiating transmission if the UART is ready. It does not check whether there is room available before writing; calling code must ensure the transmitter is ready.

Parameters
idUART Instance ID.
chrCharacter to transmit
Returns
None

◆ uart_get_char()

char uart_get_char ( uart_instance_en id)

Reads a single character from the UART receive buffer without checking if there is data available or not.

This function reads the next available character from the UART's Receive Buffer Register (RBR). It assumes that data is already available to read.

Parameters
idUART Instance ID.
Returns
The received character from the UART