Hi,
Below is code in a uart driver header file for performing a non blocking read on the uart interface.
Code:
/**
* Perform a single character read from the UART interface.
* This is a blocking synchronous call.
*
* @brief UART character data read.
* @param [in] uart UART index.
* @param [out] data Data to read from UART.
* @return ti_uart_status_t Returns UART specific return code.
*/
ti_uart_status_t ti_uart_read(const ti_uart_t uart, uint8_t *data);
Below is example code that uses the above function to get the character from the uart interface. I'm trying to understand it.
Code:
int getcharacter(void) {
uint8_t c = 0;
int ret;
ret = ti_uart_read(ti_UART_0, &c);
if (ti_RC_OK == ret) {
return ((int) c);
}
return -1;
}
I would of thought that `ti_uart_read()` reads the character from the uart interface, hence why is there a need for `getcharacter()`?
Also why is it necessary to pass `&c` to the function? What is its function?
Many thanks