16.6.4.2.4 Function usart_read_buffer_wait()

Receive a buffer of length characters via the USART.

enum status_code usart_read_buffer_wait( struct usart_module *const module, uint8_t * rx_data, uint16_t length)

This blocking function will receive a block of length characters via the USART.

Note: Using this function in combination with the interrupt (*_job) functions is not recommended as it has no functionality to check if there is an ongoing interrupt driven operation running or not.
Table 16-13. Parameters
Data directionParameter nameDescription

[in]

module

Pointer to USART software instance struct

[out]

rx_data

Pointer to receive buffer

[in]

length

Number of characters to receive

Note: If using 9-bit data, the array that *rx_data point to should be defined as uint16_t array and should be casted to uint8_t* pointer. Because it is an address pointer, the highest byte is not discarded. For example:
#define RX_LEN 3
uint16_t rx_buf[RX_LEN] = {0x0,};
usart_read_buffer_wait(&module, (uint8_t*)rx_buf, RX_LEN);

Returns

Status of the operation.

Table 16-14. Return Values
Return valueDescription

STATUS_OK

If operation was completed

STATUS_ERR_INVALID_ARG

If operation was not completed, due to an invalid argument being supplied

STATUS_ERR_TIMEOUT

If operation was not completed, due to USART module timing out

STATUS_ERR_BAD_FORMAT

If the operation was not completed, due to a configuration mismatch between USART and the sender

STATUS_ERR_BAD_OVERFLOW

If the operation was not completed, due to the baudrate being too low or the system frequency being too high

STATUS_ERR_BAD_DATA

If the operation was not completed, due to data being corrupted

STATUS_ERR_DENIED

If the receiver is not enabled