Refactoring uart interface (#341)

* uart: Major cleanups
- Adds documentation to the uart API.
- Fixes a buffer overflow issue in `uart_receive`, where the maximum parameter was ignored.
- Splits the maximum length and bytes recieved variables in `uart_receive`.
- Downsizes the receive buffer to the minimum required, saving 16MiB of RAM at runtime.
- Refactors the POSIX and Win32 implementations of uart into separate files.
- Removes the unused `uart_{get,set}_parity` functions, which were not implemented on Win32.
This commit is contained in:
Michael Farrell 2017-07-06 04:22:02 +10:00 committed by pwpiwi
commit 067bfc8b76
7 changed files with 315 additions and 270 deletions

13
uart/README.md Normal file
View file

@ -0,0 +1,13 @@
# uart
This contains functionality for talking to UART/Serial devices on different platforms. The official client will build either `uart_posix.c` and `uart_win32.c`. Build targets for these files are contained in `client/Makefile`.
If you want to implement support for other platforms, you need to implement the methods provided in `uart.h`.
## Implementing a new driver
Each driver is called with a string, typically containing a path or other reference to a serial port on the host. The methods outlined in `uart.h` need to be implemented.
The hardware uses `common/usb_cdc.c` to implement a USB CDC endpoint exposed by the Atmel MCU.