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
 Rx shift register overrun, unsupported in emulated serial port.
#define SERRF_FRAMEERROR   0
 Stop bit missing, unsupported in emulated serial port.
#define SERRF_PARITYERROR   0
 Parity error, unsupported in emulated serial port.
#define SERRF_NOISEERROR   0
 Noise error, 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
 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().

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(serial)   ((serial)->status)
#define ser_setstatus(serial, new_status)   ((serial)->status = (new_status))

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 3296 2010-03-29 13:55:34Z batt
Author:
Bernie Innocenti <bernie@codewiz.org>

Definition in file ser.h.


Define Documentation

#define SERRF_FRAMEERROR   0

Stop bit missing, unsupported in emulated serial port.

Definition at line 66 of file ser.h.

#define SERRF_NOISEERROR   0

Noise error, unsupported in emulated serial port.

Definition at line 68 of file ser.h.

#define SERRF_PARITYERROR   0

Parity error, unsupported in emulated serial port.

Definition at line 67 of file ser.h.

#define SERRF_RXSROVERRUN   0

Rx shift register overrun, 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 ser_init ( struct Serial fds,
unsigned int  unit 
)

Init serial driver for unit.

Use values SER_UARTn as values for unit.

Definition at line 416 of file ser.c.

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.

Definition at line 491 of file ser.c.