ser.h File Reference
High level serial I/O API. More...
#include <io/kfile.h>#include <struct/fifobuf.h>#include <cfg/compiler.h>#include <CPU_HEADER(ser)>#include "cfg/cfg_ser.h"Go to the source code of this file.
Data Structures | |
| struct | Serial |
| Serial handle structure. More... | |
Defines | |
| #define | KFT_SERIAL MAKE_ID('S', 'E', 'R', 'L') |
| ID for serial. | |
Masks to group TX/RX errors. | |
| #define | SERRF_RX |
| All possible rx errors. | |
| #define | SERRF_TX (SERRF_TXTIMEOUT) |
| All possible tx errors. | |
LSB or MSB first data order for SPI driver. | |
| #define | SER_MSB_FIRST 0 |
| #define | SER_LSB_FIRST 1 |
Parity settings for ser_setparity(). | |
| #define | SER_PARITY_NONE 0 |
| #define | SER_PARITY_EVEN 2 |
| #define | SER_PARITY_ODD 3 |
Additional functions implemented as macros | |
| #define | ser_getstatus(serial) ((serial)->status) |
| #define | ser_setstatus(serial, new_status) ((serial)->status = (new_status)) |
Functions | |
| void | ser_setbaudrate (struct Serial *fd, unsigned long rate) |
| Set the baudrate for the serial port. | |
| void | ser_setparity (struct Serial *fd, int parity) |
| Set the parity for the fd serial port. | |
| int | ser_getchar_nowait (struct Serial *fd) |
| Fetch a character from the rx FIFO buffer. | |
| void | ser_purgeRx (struct Serial *fd) |
| Flush RX buffer. | |
| void | ser_purgeTx (struct Serial *fd) |
| Flush TX buffer. | |
| void | ser_purge (struct Serial *fd) |
| Flush both the RX and TX buffers. | |
| void | ser_init (struct Serial *fds, unsigned int unit) |
| Init serial driver for unit. | |
| void | spimaster_init (Serial *fds, unsigned int unit) |
| Init SPI serial driver unit in master mode. | |
Variables | |
| const char *const | serial_errors [8] |
| Human-readable serial error descriptions. | |
Detailed Description
High level serial I/O API.
Definition in file ser.h.
Function Documentation
| int ser_getchar_nowait | ( | struct Serial * | fd | ) |
Fetch a character from the rx FIFO buffer.
If the buffer is empty, ser_getchar_nowait() returns EOF immediatly.
- Note:
- Deprecated, use ser_getchar with rx_timeout set to 0.
| void ser_init | ( | struct Serial * | fds, | |
| unsigned int | unit | |||
| ) |
| void spimaster_init | ( | Serial * | fds, | |
| unsigned int | unit | |||
| ) |
Init SPI serial driver unit in master mode.
Use SER_SPIn for unit parameter.
This interface implements the SPI master protocol over a serial SPI driver. This is needed because normal serial driver send/receive data at the same time. SPI slaves like memories and other peripherals first receive and *then* send response back instead. To achieve this, when we are master and we are *sending*, we have to discard all incoming data. Then, when we want to receive, we must write fake data to SPI to trigger slave devices.
