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.


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.


Define Documentation

#define GENDEV_SPORT   0x100

Definition at line 64 of file genchar.c.

#define GENDEV_DPORT   0x104

Definition at line 69 of file genchar.c.

#define GENDEV_SIGNAL   sig_INTERRUPT1

Definition at line 74 of file genchar.c.

Referenced by GenCharSize().


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.

Definition at line 377 of file genchar.c.

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.

Definition at line 449 of file genchar.c.

References _NUTDEVICE::dev_dcb, GENDEV_SIGNAL, _NUTFILE::nf_dev, NutIrqDisable(), and NutIrqEnable().


Variable Documentation

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.

Definition at line 466 of file genchar.c.


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