ser.h File Reference

High level serial I/O API. More...

#include <kern/kfile.h>
#include <struct/fifobuf.h>
#include <cfg/compiler.h>
#include <cfg/macros.h>
#include "cfg/cfg_ser.h"

Go to the source code of this file.

Data Structures

struct  Serial
 Serial handle structure. More...

Defines

#define SERRF_RXFIFOOVERRUN   BV(0)
 Rx FIFO buffer overrun.
#define SERRF_RXTIMEOUT   BV(1)
 Receive timeout.
#define SERRF_TXTIMEOUT   BV(2)
 Transmit timeout.
#define SERRF_RXSROVERRUN   0
 Unsupported in emulated serial port.
#define SERRF_FRAMEERROR   0
 Unsupported in emulated serial port.
#define SERRF_PARITYERROR   0
 Unsupported in emulated serial port.
#define SERRF_NOISEERROR   0
 Unsupported in emulated serial port.
#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().

Note:
Values are AVR-specific for performance reasons. Other processors should either decode them or redefine these macros.


#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))

Enumerations

enum  { , SER_CNT }

Functions

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.

Version:
Id
ser.h 2883 2009-09-04 19:46:02Z batt
Author:
Bernie Innocenti <bernie@codewiz.org>

Definition in file ser.h.


Define Documentation

#define SERRF_FRAMEERROR   0

Unsupported in emulated serial port.

Definition at line 66 of file ser.h.

#define SERRF_NOISEERROR   0

Unsupported in emulated serial port.

Definition at line 68 of file ser.h.

#define SERRF_PARITYERROR   0

Unsupported in emulated serial port.

Definition at line 67 of file ser.h.

#define SERRF_RXSROVERRUN   0

Unsupported in emulated serial port.

Definition at line 65 of file ser.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
SER_CNT 

Number of serial ports.

Definition at line 70 of 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.

Definition at line 184 of file ser.c.

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.

Definition at line 505 of file ser.c.