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

Generic Character Device
[Device Driver API.]

Collaboration diagram for Generic Character Device:


Detailed Description

Character Device Driver Template.

Extensively commented source code of a Nut/OS character device driver. It doesn't drive any specific device, but can be used as a template when adding new device drivers.


Data Structures

struct  DEVDCB
 Device driver's private data structure. More...

Defines

#define GENDEV_SPORT   0x100
#define GENDEV_DPORT   0x104
#define GENDEV_SIGNAL   sig_INTERRUPT1

Functions

int GenCharWrite_P (NUTFILE *fp, PGM_P buffer, int len)
 Write program data to the device.
long GenCharSize (NUTFILE *fp)
 Retrieves the number of characters in input buffer.

Variables

NUTDEVICE devGenChar
 Device information structure.


Function Documentation

int GenCharWrite_P NUTFILE fp,
PGM_P  buffer,
int  len
 

Write program data to the device.

Similar to GenCharWrite() except that the data is located in program memory.

This function is called by the low level output routines of the C runtime library, using the _NUTDEVICE::dev_write_P entry, which is available on Harvard architectures only.

The function may block the calling thread.

Parameters:
fp Pointer to a NUTFILE structure, obtained by a previous call to UsartOpen().
buffer Pointer to the data in program space to be written.
len Number of bytes to write.
Returns:
The number of bytes written. With some devices this may be less than the number of bytes specified if a timeout occured. A return value of -1 indicates an error.

long GenCharSize NUTFILE fp  ) 
 

Retrieves the number of characters in input buffer.

This function is called by the low level size routine of the C runtime library, using the _NUTDEVICE::dev_size entry.

Parameters:
fp Pointer to a _NUTFILE structure, obtained by a previous call to UsartOpen().
Returns:
The number of bytes currently stored in input buffer.


Variable Documentation

NUTDEVICE devGenChar
 

Initial value:

 {
    
    0,

    
    {'g', 'e', 'n', 'c', 'h', 'a', 'r', 0, 0},

    
    IFTYP_CHAR,

    
    0,

    
    0,

    
    0,

    
    &devdcb,

    
    GenCharInit,

    
    GenCharIOCtl,

    
    GenCharRead,

    
    GenCharWrite,


    
    GenCharWrite_P,


    
    GenCharOpen,

    
    GenCharClose,

    
    GenCharSize
}
Device information structure.


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