UART
Two UART hardware channels are available for the TWELITE wireless microcontroller. Each of these UART ports has a hardware FIFO buffer of 16 bytes.
SERIAL library (serial.c and uart.c) is the standard method for processing in TWELITE NET, which handles UART interrupts and provides an API for I/O procedures using FIFO memory allocated in the microcontroller.
Initialisation
We store the initialization parameters in the tsSerialPortSetup
structure and call the SERIAL_vInit()
function. Here we need to statically allocate a memory area for the FIFO buffer to be used for serial data input and output.
We also provide a tsFILE
structure for output.
Output
Use vfPrintf()
or vPutChar()
for output. The parameter is a pointer to the tsFILE structure.
The output process may be unstable immediately after initialisation when the system starts or when it returns to sleep. If there is a problem with the operation, please wait some time before outputting.
The following is an example of outputting packet information when receiving a wireless packet.
If you want to wait for the output to complete, such as when all the output is done and then goes to sleep, you can call the SERIAL_vFlush()
function. This function will block until the output queue is empty.
Waiting for output to complete may cause instability. In this case, remove this waiting process and check the operation.
If the waiting process is omitted and the output is interrupted, an extra FIFO memory is allocated for the output.
Input
When there is an input, data is put into the FIFO memory registered at the time of initialization in the library. This data is read by SERIAL_bRxQueueEmpty()
and SEREAL_i16RxChar()
.
This process is described in the cbToCoNet_vMain()
process.。
最終更新