... | ... | @@ -88,4 +88,27 @@ For the _STM32F407VG_ board, there's also another serial port, called `auxtty`: |
|
|
//#define AUX_SERIAL "auxtty" UNCOMMENT THIS TO OPEN THE SERIAL
|
|
|
const unsigned int auxSerialSpeed=9600;
|
|
|
const bool auxSerialFlowctrl=false;
|
|
|
``` |
|
|
\ No newline at end of file |
|
|
```
|
|
|
## USART driver
|
|
|
The driver for the USART peripheral permits to use all the USART/UART peripherals of any board, setting the wanted baudrate. All the pins linked to the various USART/UART peripherals are defined in the USART.h header file in the format of uNtxM or uNrxM (N = id of the peripheral; M = [absent, 1 or 2] in order to distinguish among different pins with same function; e.g. u1tx1, u1rx1, u5tx, u5rx).
|
|
|
|
|
|
### USARTInterface
|
|
|
This class is the abstract class that represents a USART peripheral. It has some abstract methods in order to expose some common features:
|
|
|
- `init`: initializes the peripheral
|
|
|
- `read`: reads in a buffer at most a specified number of bytes
|
|
|
- `write`: a blocking write method on the peripheral, to send binary data
|
|
|
- `writeString`: a blocking write method for strings, that sends also the final '\0' character
|
|
|
- `initPins`: initializes the pins with the appropriate alternate functions
|
|
|
|
|
|
### USART
|
|
|
This is a low level implementation of the USART driver. It supports all the USART/UART peripherals (from 1 to 8), there are low level parameters that can be configured (word length, parity bits, stop bits, oversampling. Also, this driver could be extended in order to implement more features of the peripheral. Some notable methods of this driver are:
|
|
|
- `IRQhandleInterrupt`: used to handle the read, fills up the queue while the `read` method empties it;
|
|
|
- Constructors: There are two constructors, one will initialize the peripheral with custom pins and the other will initialize automatically the peripheral with the default pins. Moreover, it will enable the peripheral clock, set the baudrate register and the other parameters with the default values. As parameter we can pass also the size of the queue, with the default being usart_queue_default_capacity = 256.
|
|
|
- `init`: initializes the peripheral enabling his interrupts, enabling the interrupts in the NVIC and setting the pins with the appropriate alternate functions. All the setup phase must be done before the initialization of the peripheral. The pins must be initialized before calling this function.
|
|
|
- Destructor: Disables the flags for the generation of the interrupts, disables the IRQ from the NVIC, disables the peripheral and removes his pointer from the ports list.
|
|
|
|
|
|
### STM32SerialWrapper
|
|
|
This is a wrapper of the miosix driver STM32Serial. It supports only the USART 1, 2 and 3. Some notable methods of this driver are:
|
|
|
- Constructors: There are two constructors, one will initialize the peripheral with custom pins and the other will initialize automatically the peripheral with the default pins.
|
|
|
- `init`: Creates a device that represents the serial port, adds it to the file system and opens the file that represents the device.
|
|
|
- Destructor: Removes the device from the list of the devices and closes the file of the device. |
|
|
\ No newline at end of file |