First problem I faced: there is no clean examples on USART usage, so here is my assumptions.
The easiest way to start with it - use SerialDriver. Each platform has it's own implementation for it with default settings.
E.g. os/hal/platforms/STM32/serial_lld.c
Each USART channel available as SDx object.
To use it you need to enable it in the halconf.h
Code: Select all
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
#define HAL_USE_SERIAL TRUE
#endif
After this it can be used in the main thread (this example is a simple echo):
Code: Select all
/*
* Activates the serial driver 1 using the driver default configuration.
*/
sdStart(&SD1, NULL);
u8 i = 0;
while (TRUE) {
i = chIOGet(&SD1);
if(i!=0)
chIOPut(&SD1, i);
}
This is the most basic example, but now I have some questions:
1. What pitfalls we have here?
2. How multithreading and blocking works? I mean what user must expect when working with USART over SerialDriver objects.
3. Also I propose to discuss about lowlevel USART objects, when they should be used?