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

Device Driver API.

Input and output device functions. More...


Modules

ATmega On-Chip UART Device Driver
 Serial communication device driver.

Realtek 8019AS device driver
 Ethernet device driver.

Network Buffer
 Network buffer support.

Interrupt Management
 Interrupt registration and handling.

Formatted output functions.
 Formatted character output.

Network Stream Device Driver
 Virtual TCP socket stream device.

UART Device Status Flags
 UART status flags.

UART I/O Control Functions
 UART Ioctl commands.


Data Structures

struct  _NUTDEVICE
 Device structure. More...

struct  _NUTDEVICE
 Device structure. More...


Defines

#define IFTYP_RAM
 RAM device.

#define IFTYP_ROM
 ROM device.

#define IFTYP_STREAM
 Stream device.

#define IFTYP_NET
 Net device.


Typedefs

typedef struct _NUTDEVICE NUTDEVICE
 Device structure type.


Functions

NUTDEVICENutDeviceLookup (const char *name)
 Find device entry by name. More...

int NutRegisterDevice (NUTDEVICE *dev, u_short base, u_char irq)
 Register a device. More...

NUTDEVICENutDeviceOpen (const char *name)
 Open device by name. More...

int NutDeviceClose (NUTDEVICE *dev)
 Closes a previously opened device. More...

int NutDeviceRead (NUTDEVICE *dev, void *data, int size)
 Read up to a specified number of bytes from a device. More...

int NutDeviceGetLine (NUTDEVICE *dev, void *data, int size)
int NutDeviceWrite (NUTDEVICE *dev, const void *data, int len)
 Write a buffer to a specified device. More...

int NutDeviceWrite_P (NUTDEVICE *dev, PGM_P data, int len)
 Write a buffer in program space to a specified device. More...

int NutDeviceSend (NUTDEVICE *dev, NETBUF *nb, u_char flags)
 Send network buffer contents to network device. More...

int NutDeviceIOCtl (NUTDEVICE *dev, int req, void *conf)
 Perform device specific control functions. More...


Variables

NUTDEVICEnutDeviceList
 Linked list of all registered devices.


Detailed Description

Input and output device functions.


Function Documentation

int NutDeviceClose ( NUTDEVICE * dev )
 

Closes a previously opened device.

Waits until all buffered output data written and close device.

Parameters:
dev   Identifies the device to close. This pointer must have been retrieved by calling NutDeviceOpen().

int NutDeviceGetLine ( NUTDEVICE * dev,
void * data,
int size )
 

Reads a string from the specified device. Characters are read up to and including the first newline character, up to the end of the stream, or until the number of characters read is equal to the specified size, whichever comes first.

Parameters:
dev   Identifies the device to read from. This pointer must have been retrieved by calling NutDeviceOpen().
data   Pointer to the buffer that receives the data.
size   Size of the buffer.

Returns:
The number of bytes read or -1 in case of an error.
Examples:
portdio/portdio.c, tcps/tcps.c, and uart/nutmain.c.

int NutDeviceIOCtl ( NUTDEVICE * dev,
int req,
void * conf )
 

Perform device specific 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.
conf   Points to a buffer that contains any data required for the given control function or receives data from that function.
Examples:
httpd/nutmain.c, threads/threads.c, timers/timers.c, and uart/nutmain.c.

NUTDEVICE * NutDeviceLookup ( const char * name )
 

Find device entry by name.

Parameters:
name   Unique device name.

Returns:
Pointer to the device structure.

NUTDEVICE * NutDeviceOpen ( const char * name )
 

Open device by name.

Discards the input buffer. Any device settings are left unchanged.

Returns:
Pointer to the device structure.
Examples:
httpd/nutmain.c, threads/threads.c, timers/timers.c, and uart/nutmain.c.

int NutDeviceRead ( NUTDEVICE * dev,
void * data,
int size )
 

Read up to a specified number of bytes from a device.

The function may read fewer than the given number of bytes.

Parameters:
dev   Identifies the device to read from. This pointer must have been retrieved by calling NutDeviceOpen().
data   Pointer to the buffer that receives the data.
size   Size of the buffer.

Returns:
The number of bytes read or -1 in case of an error.
Examples:
uart/nutmain.c.

int NutDeviceSend ( NUTDEVICE * dev,
NETBUF * nb,
u_char flags )
 

Send network buffer contents to network device.

Parameters:
dev   Identifies the device that receives the data. This pointer must have been retrieved by using the NutDeviceOpen() function.
flags   Set to 1 for asynchronous output, 0 otherwise.

Deprecated:
Not yet implemented.

int NutDeviceWrite ( NUTDEVICE * dev,
const void * data,
int len )
 

Write a buffer to a specified device.

This is a raw output without any character translation like EOL (end of line).

Parameters:
dev   Identifies the device that receives the data. This pointer must have been retrieved by calling the NutDeviceOpen() function.
data   Buffer to be written.
len   Number of characters to be printed.

Returns:
If successful, the number of bytes added to the output buffer. This may be less than the specified number of bytes to print. The return value -1 indicates an error.
Examples:
uart/nutmain.c.

int NutDeviceWrite_P ( NUTDEVICE * dev,
PGM_P data,
int len )
 

Write a buffer in program space to a specified device.

This is a raw output without any character translation like EOL (end of line).

Parameters:
dev   Identifies the device that receives the data. This pointer must have been retrieved by calling the NutDeviceOpen() function.
data   Buffer to be written.
len   Number of characters to be printed.

Returns:
If successful, the number of bytes added to the output buffer. This may be less than the specified number of bytes to print. The return value -1 indicates an error.
Examples:
uart/nutmain.c.

int NutRegisterDevice ( NUTDEVICE * dev,
u_short base,
u_char irq )
 

Register a device.

Initializes the device and adds it to the system device list.

Parameters:
dev   Identifies the device to register.
base   Hardware base address of this device. Set to 0, if the device driver has a fixed hardware address.
irq   Hardware interrupt used by this device. Set to 0, if the device driver doesn't support configurable interupts.
Examples:
httpd/nutmain.c, portdio/portdio.c, tcpc/tcpc.c, tcps/tcps.c, threads/threads.c, timers/timers.c, and uart/nutmain.c.


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