ser.c File Reference
Buffered serial I/O driver. More...
#include "ser.h"
#include "wdt.h"
#include "timer.h"
#include "ser_p.h"
#include "cfg/cfg_ser.h"
#include "cfg/cfg_kern.h"
#include <cfg/debug.h>
#include <mware/formatwr.h>
#include <cpu/power.h>
#include <string.h>
Go to the source code of this file.
Functions | |
| static int | ser_putchar (int c, struct Serial *port) |
| Insert c in tx FIFO buffer. | |
| static int | ser_getchar (struct Serial *port) |
| Fetch a character from the rx FIFO buffer. | |
| int | ser_getchar_nowait (struct Serial *fd) |
| Fetch a character from the rx FIFO buffer. | |
| static size_t | ser_read (struct KFile *fd, void *_buf, size_t size) |
| Read at most size bytes from port and put them in buf. | |
| static size_t | ser_write (struct KFile *fd, const void *_buf, size_t size) |
| Write a buffer to serial. | |
| void | ser_resync (struct Serial *fd, mtime_t delay) |
| Discard input to resynchronize with remote end. | |
| void | ser_purge (struct Serial *fd) |
| Flush both the RX and TX buffers. | |
| void | ser_purgeRx (struct Serial *fd) |
| Flush RX buffer. | |
| void | ser_purgeTx (struct Serial *fd) |
| Flush TX buffer. | |
| static int | ser_flush (struct KFile *fd) |
| Wait until all pending output is completely transmitted to the other end. | |
| static struct Serial * | ser_open (struct Serial *fd, unsigned int unit) |
| Initialize a serial port. | |
| static int | ser_close (struct KFile *fd) |
| Clean up serial port, disabling the associated hardware. | |
| static struct KFile * | ser_reopen (struct KFile *fd) |
| Reopen serial port. | |
| void | ser_init (struct Serial *fds, unsigned int unit) |
| Init serial driver for unit. | |
| static size_t | spimaster_read (struct KFile *fd, void *_buf, size_t size) |
| Read data from SPI bus. | |
| static size_t | spimaster_write (struct KFile *fd, const void *buf, size_t size) |
| Write data to SPI bus. | |
| void | spimaster_init (Serial *fds, unsigned int unit) |
| Init SPI serial driver unit in master mode. | |
Detailed Description
Buffered serial I/O driver.The serial rx interrupt buffers incoming data in a software FIFO to decouple the higher level protocols from the line speed. Outgoing data is buffered as well for better performance. This driver is not optimized for best performance, but it has proved to be fast enough to handle transfer rates up to 38400bps on a 16MHz 80196.
MODULE CONFIGURATION
CONFIG_SER_HWHANDSHAKE- set to 1 to enable RTS/CTS handshake. Support is incomplete/untested.CONFIG_SER_TXTIMEOUT- Enable software serial transmission timeouts
- Version:
- Id
- ser.c 1726 2008-08-27 14:18:16Z batt
Definition in file ser.c.
Function Documentation
| static int ser_flush | ( | struct KFile * | fd | ) | [static] |
| static int ser_getchar | ( | struct Serial * | port | ) | [static] |
| 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.
| static int ser_putchar | ( | int | c, | |
| struct Serial * | port | |||
| ) | [static] |
| static size_t ser_read | ( | struct KFile * | fd, | |
| void * | _buf, | |||
| size_t | size | |||
| ) | [static] |
| static size_t ser_write | ( | struct KFile * | fd, | |
| const void * | _buf, | |||
| size_t | size | |||
| ) | [static] |
| void spimaster_init | ( | Serial * | 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.
| static size_t spimaster_read | ( | struct KFile * | fd, | |
| void * | _buf, | |||
| size_t | size | |||
| ) | [static] |
