pub unsafe extern "C" fn MSS_UART_set_tx_handler(
this_uart: *mut mss_uart_instance_t,
handler: mss_uart_irq_handler_t,
)Expand description
/ /** The MSS_UART_set_tx_handler() function registers a transmit handler function that is called by the driver when a UART transmit holding register empty (THRE) interrupt occurs. You must create and register the transmit handler function to suit your application. You can then use MSS_UART_irq_tx() to trigger the interrupt and pass the data you want to transmit.
Note: If handler is NULL_HANDLER (or ((mss_uart_irq_handler_t)0)), the Tx interrupt handler is the default_tx_handler().
Note: Your alternative THRE interrupt handler must include a call to the MSS_UART_fill_tx_fifo() function to transfer the data to the UART.
@param this_uart The this_uart parameter is a pointer to an mss_uart_instance_t structure that identifies the MSS UART hardware block performing the requested function. There are ten such data structures. The data structures from g_mss_uart0_lo to g_mss_uart4_lo are associated with MSS UART0 to MSS UART4 when they are connected on the AXI switch slave 5 (main APB bus). The data structures g_mss_uart0_hi to g_mss_uart4_hi are associated with MSS UART0 to MSS UART4 when they are connected on the AXI switch slave 6 (AMP APB bus). This parameter must point to one of these ten global data structure defined within the UART driver. Note: If you are using the UART on the AMP APB bus, the hardware configuration to connect UART on AMP APB bus must already be done by the application using SYSREG registers before initializing the UART instance structure.
@param handler The handler parameter is a pointer to a transmit interrupt handler function provided by your application that is called when a UART THRE interrupt is triggered. This handler function must be of mss_uart_irq_handler_t type. If this parameter is NULL_HANDLER (or ((mss_uart_irq_handler_t)0)), the default_tx_handler() is assigned as the Tx interrupt handler.
@return This function does not return a value.
@example @code #include “mss_uart.h”
uint8_t * g_tx_buffer = “Message from Tx irq handler”; size_t g_tx_size = 27;
void uart_tx_handler(mss_uart_instance_t * this_uart) { size_t size_in_fifo; const uint8_t * sub_buffer = &this_uart->tx_buffer[this_uart->tx_idx]; uint32_t sub_buffer_size = this_uart->tx_buff_size - this_uart->tx_idx;
ASSERT(( (uint8_t*)0 ) != this_uart->tx_buffer); ASSERT(0u < this_uart->tx_buff_size);
size_in_fifo = MSS_UART_fill_tx_fifo(this_uart, sub_buffer, sub_buffer_size); this_uart->tx_idx += size_in_fifo;
// Additional user code can be added here }
int main(void) { uint8_t message[12] = “Hello world”;
MSS_UART_init(&g_mss_uart0_lo, MSS_UART_57600_BAUD, MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
g_tx_buffer = message; g_tx_size = sizeof(message);
MSS_UART_set_tx_handler(&g_mss_uart0_lo, uart_tx_handler); MSS_UART_irq_tx(&g_mss_uart0_lo, g_tx_buffer, g_tx_size);
while(1) { ; } return(0); } @endcode