Receiving Data Over Uart - Bosch XDK110 Getting Started

Cross-domain development kit
Hide thumbs Also See for XDK110:
Table of Contents

Advertisement

Extension Bus Advanced Guide | XDK110

3.4 Receiving data over UART

On the opposite, data can also be read from UART. For that, it is recommended to declare a reading function in the same
manner as the writing function. A possible example is shown in Code 13.
Code 13. UART da reading function
void
UartDataRead(uint8_t
uint32_t
timeout = UINT32_MAX;
uint32_t
actualLength = 0;
UARTTransceiver_ReadData(&UartTransceiverInstance, buffer, bytesRead, &actualLength,
timeout);
}
Similar as in Code 11 the function simply takes a buffer were the data read from UART is stored, and the number of bytes
read from the internal ring buffer of the UARTTransceiver. As such, these variables are passed to the function
UARTTransceiver_ReadData(),
operation.
An example of how to use the function is shown in Code 14.
Code 14. UART read example
void appInitSystem(void
// all other initialization and preparation code here
uint8_t
buffer[20];
uint32_t
dataLength = 5;
UartDataRead(buffer,dataLength);
}
For its usage, simply a declaration of a buffer with a fixed data size is made and the number of read bytes from the internal
ring buffer of the UARTTransceiver is set. Both variables are passed to the
Please note that this is only the easiest approach to read data from the internal ring buffer of the UARTTransceiver. It does
not contain any detection if there is any stored data in the ring buffer or if a data transmission is ongoing. For that kind of
logic, the callback function declared in Code 8 can be adapted to trigger, for example, an event when a data transmission
occurs. An alternative approach could also be to build a logic with the properties of the variable
UartTransceiverInstance
* buffer,
uint32_t
along the global variable
* CmdProcessorHandle,
, which holds relative information about the internal ring buffer.
bytesRead){
UartTransceiverInstance
uint32_t
param2){
UartDataRead()
and predefined timeout for the read
function.
14 24
|

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents