Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

AVR UART Device Driver
[Serial communication devices.]

Device driver for ATmega On-Chip UART. More...


Modules

ATmega On-Chip UART Devices
 UART Device Structures.


Data Structures

struct  _UARTDCB
 UART device control block structure. More...

struct  _UARTDCB
 UART device control block structure. More...


Defines

#define UART_MF_RTSSENSE
#define UART_MF_CTSCONTROL
#define UART_MF_DTRSENSE
#define UART_MF_DSRCONTROL
#define UART_MF_DCDCONTROL
#define UART_MF_RTSCONTROL
#define UART_MF_CTSSENSE
#define UART_MF_DTRCONTROL
#define UART_MF_DSRSENSE
#define UART_MF_DCDSENSE
#define UART_MF_SENSEMASK
#define UART_MF_CONTROLMASK
#define UART_MF_XONXOFF
#define UART_MF_LOCALECHO
#define UART_MF_COOKEDMODE
#define UART_MF_NOBUFFER
#define UART_MF_LINEBUFFER
#define UART_MF_BUFFERMASK
#define UART_SF_RTSOFF
#define UART_SF_CTSOFF
#define UART_SF_DTROFF
#define UART_SF_DSROFF
#define UART_SF_DCDOFF
#define HDLC_SF_FLUSH
#define HDLC_SF_ESCAPED
#define UART_SF_TXDISABLED
#define UART_SF_RXDISABLED
#define UART_HS_DCERTSCTS
#define UART_HS_DCEFULL
#define UART_HS_DTERTSCTS
#define UART_HS_DTEFULL
#define UART_HS_XONXOFF

Typedefs

typedef _UARTDCB UARTDCB

Functions

int UartAvrGetRaw (u_char *cp)
 Get raw byte from the UART receiver register.

int UartAvrPutRaw (u_char ch)
 Put raw byte to the UART transmit register.

int UartAvrInput (NUTDEVICE *dev)
 Wait for input.

int UartAvrOutput (NUTDEVICE *dev)
 Initiate output.

int UartAvrFlush (NUTDEVICE *dev)
 Wait for output buffer empty.

int UartAvrIOCtl (NUTDEVICE *dev, int req, void *conf)
 Perform on-chip UART control functions.

int UartAvrInit (NUTDEVICE *dev)
 Initialize on chip uart device.

int UartAvrRead (NUTFILE *fp, void *buffer, int size)
 Read from device.

int UartAvrPut (NUTDEVICE *dev, CONST void *buffer, int len, int pflg)
 Write to device.

NUTFILEUartAvrOpen (NUTDEVICE *dev, CONST char *name, int mode, int acc)
 Open a device or file.

int UartAvrClose (NUTFILE *fp)
 Close a device or file.


Detailed Description

Device driver for ATmega On-Chip UART.

This stream device driver writes data to and reads data from the UART on the ATmega128/103 chip. Both, input and output data is buffered and send resp. transmitted by interrupt routines.


Define Documentation

#define HDLC_SF_ESCAPED
 

Next character escaped.

#define HDLC_SF_FLUSH
 

Waiting for next HDLC flag.

#define UART_HS_DCEFULL
 

Full DCE handshake.

#define UART_HS_DCERTSCTS
 

RTS/CTS DCE handshake.

#define UART_HS_DTEFULL
 

Full DTE handshake.

#define UART_HS_DTERTSCTS
 

RTS/CTS DTE handshake.

#define UART_HS_XONXOFF
 

Software handshake.

#define UART_MF_BUFFERMASK
 

Masks buffering mode flags.

#define UART_MF_CONTROLMASK
 

Handshake control mask.

#define UART_MF_COOKEDMODE
 

Should be used in stream, not device.

#define UART_MF_CTSCONTROL
 

DCE output.

#define UART_MF_CTSSENSE
 

DTE input.

#define UART_MF_DCDCONTROL
 

DCE output.

#define UART_MF_DCDSENSE
 

DTE input.

#define UART_MF_DSRCONTROL
 

DCE output.

#define UART_MF_DSRSENSE
 

DTE input.

#define UART_MF_DTRCONTROL
 

DTE output.

#define UART_MF_DTRSENSE
 

DCE input.

#define UART_MF_LINEBUFFER
 

Line buffered.

#define UART_MF_LOCALECHO
 

Should be used in stream, not device.

#define UART_MF_NOBUFFER
 

No buffering.

#define UART_MF_RTSCONTROL
 

DTE output.

#define UART_MF_RTSSENSE
 

DCE input, low on port bit is +12V, which means ON.

#define UART_MF_SENSEMASK
 

Handshake sense mask.

#define UART_MF_XONXOFF
 

Software handshake.

#define UART_SF_CTSOFF
 

Set CTS line is off.

#define UART_SF_DCDOFF
 

Set DCD line is off.

#define UART_SF_DSROFF
 

Set DSR line is off.

#define UART_SF_DTROFF
 

Set DTR line is off.

#define UART_SF_RTSOFF
 

Set RTS line is off.

#define UART_SF_RXDISABLED
 

Receiver disabled.

#define UART_SF_TXDISABLED
 

Transmitter disabled.


Typedef Documentation

typedef struct _UARTDCB UARTDCB
 

UART device control block type.


Function Documentation

int UartAvrClose NUTFILE   fp
 

Close a device or file.

int UartAvrFlush NUTDEVICE   dev
 

Wait for output buffer empty.

If the output buffer contains any data, the calling thread is suspended until all data has been transmitted.

Parameters:
dev Indicates the UART device.
Returns:
0 on success, -1 otherwise.

int UartAvrGetRaw u_char   cp
 

Get raw byte from the UART receiver register.

Deprecated:
Will be removed in the near future.
Parameters:
cp Pointer to the character buffer.
Returns:
1 if a byte has been available, 0 otherwise.

int UartAvrInit NUTDEVICE   dev
 

Initialize on chip uart device.

Prepares the device for subsequent reading or writing. Enables UART transmitter and receiver interrupts.

Applications should not use this function, but call NutDeviceOpen().

Parameters:
dev Identifies the device to initialize.
Returns:
0 on success, -1 otherwise.

int UartAvrInput NUTDEVICE   dev
 

Wait for input.

This function checks the input buffer for any data. If the buffer is empty, the calling thread will be blocked until at least one new character is received or a timeout occurs.

Parameters:
dev Indicates the UART device.
Returns:
0 on success, -1 on timeout.

int UartAvrIOCtl NUTDEVICE   dev,
int    req,
void *    conf
 

Perform on-chip UART control functions.

Parameters:
dev Identifies the device that receives the device-control function. This pointer must have been retrieved previously by using the NutDeviceOpen() function.
req Requested control function. May be set to one of the following constants:
  • UART_SETSPEED, conf points to an u_long value containing the baudrate.
  • UART_GETSPEED, conf points to an u_long value receiving the current baudrate.
  • UART_SETDATABITS, conf points to an u_long value containing the number of data bits, 5, 6, 7 or 8.
  • UART_GETDATABITS, conf points to an u_long value receiving the number of data bits, 5, 6, 7 or 8.
  • UART_SETPARITY, conf points to an u_long value containing the parity, 0 (no), 1 (odd) or 2 (even).
  • UART_GETPARITY, conf points to an u_long value receiving the parity, 0 (no), 1 (odd) or 2 (even).
  • UART_SETSTOPBITS, conf points to an u_long value containing the number of stop bits 1 or 2.
  • UART_GETSTOPBITS, conf points to an u_long value receiving the number of stop bits 1 or 2.
  • UART_SETSTATUS
  • UART_GETSTATUS
  • UART_SETREADTIMEOUT, conf points to an u_long value containing the read timeout.
  • UART_GETREADTIMEOUT, conf points to an u_long value receiving the read timeout.
  • UART_SETWRITETIMEOUT, conf points to an u_long value containing the write timeout.
  • UART_GETWRITETIMEOUT, conf points to an u_long value receiving the write timeout.
  • UART_SETLOCALECHO, conf points to an u_long value containing 0 (off) or 1 (on).
  • UART_GETLOCALECHO, conf points to an u_long value receiving 0 (off) or 1 (on).
  • UART_SETFLOWCONTROL, conf points to an u_long value containing combined UART_FCTL_ values.
  • UART_GETFLOWCONTROL, conf points to an u_long value containing receiving UART_FCTL_ values.
  • UART_SETCOOKEDMODE, conf points to an u_long value containing 0 (off) or 1 (on).
  • UART_GETCOOKEDMODE, conf points to an u_long value receiving 0 (off) or 1 (on).
conf Points to a buffer that contains any data required for the given control function or receives data from that function.
Returns:
0 on success, -1 otherwise.
Warning:
Timeout values are given in milliseconds and are limited to the granularity of the system timer. To disable timeout, set the parameter to NUT_WAIT_INFINITE.

Bug:
For ATmega103, only 8 data bits, 1 stop bit and no parity are allowed.

NUTFILE* UartAvrOpen NUTDEVICE   dev,
CONST char *    name,
int    mode,
int    acc
 

Open a device or file.

int UartAvrOutput NUTDEVICE   dev
 

Initiate output.

This function checks the output buffer for any data. If the buffer contains at least one character, the transmitter is started, if not already running. The function returns immediately, without waiting for the character being completely transmitted. Any remaining characters in the output buffer are transmitted in the background.

Parameters:
dev Indicates the UART device.
Returns:
0 on success, -1 otherwise.

int UartAvrPut NUTDEVICE   dev,
CONST void *    buffer,
int    len,
int    pflg
 

Write to device.

int UartAvrPutRaw u_char    ch
 

Put raw byte to the UART transmit register.

Deprecated:
Will be removed in the near future.
Parameters:
ch Character to transmit.
Returns:
1 if the byte has been stored in the transmit register, 0 if the transmitter is busy.

int UartAvrRead NUTFILE   fp,
void *    buffer,
int    size
 

Read from device.


© 2000-2003 by egnite Software GmbH - visit http://www.ethernut.de/