ser.h File Reference
High level serial I/O API. More...
#include <kern/kfile.h>
#include <mware/fifobuf.h>
#include <cfg/compiler.h>
#include <CPU_HEADER(ser)>
#include <appconfig.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 |
| #define | SERRF_TX (SERRF_TXTIMEOUT) |
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(h) ((h)->status) |
| #define | ser_setstatus(h, x) ((h)->status = (x)) |
Functions | |
| void | ser_resync (struct KFileSerial *fd, mtime_t delay) |
| Discard input to resynchronize with remote end. | |
| int | ser_getchar_nowait (struct KFileSerial *fd) |
| Fetch a character from the rx FIFO buffer. | |
| void | ser_purgeRx (struct KFileSerial *fd) |
| Flush RX buffer. | |
| void | ser_purgeTx (struct KFileSerial *fd) |
| Flush TX buffer. | |
| void | ser_purge (struct KFileSerial *fd) |
| Flush both the RX and TX buffers. | |
| void | ser_init (struct KFileSerial *fds, unsigned int unit) |
| Init serial driver for unit. | |
| void | spimaster_init (KFileSerial *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.
- Version:
- Id
- ser.h 1143 2008-02-19 15:35:36Z batt
Definition in file ser.h.
Function Documentation
| int ser_getchar_nowait | ( | struct KFileSerial * | fd | ) |
| void ser_resync | ( | struct KFileSerial * | fd, | |
| mtime_t | delay | |||
| ) |
| void spimaster_init | ( | KFileSerial * | fds, | |
| unsigned int | unit | |||
| ) |
Init SPI serial driver unit in master mode.
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.
