Character Device Driver Template. More...
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. |
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.
#define GENDEV_SIGNAL sig_INTERRUPT1 |
Definition at line 77 of file genchar.c.
Referenced by GenCharSize().
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.
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. |
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.
fp | Pointer to a _NUTFILE structure, obtained by a previous call to UsartOpen(). |
Definition at line 452 of file genchar.c.
References DEVDCB::dcb_rcnt, _NUTDEVICE::dev_dcb, GENDEV_SIGNAL, _NUTFILE::nf_dev, NutIrqDisable(), and NutIrqEnable().
{ 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.