Nut/OS  5.0.5
API Reference
_NUTDEVICE Struct Reference

Device structure. More...

#include <device.h>

Collaboration diagram for _NUTDEVICE:
[legend]

Data Fields

NUTDEVICEdev_next
 Link to the next device structure.
char dev_name [9]
 Unique device name.
uint8_t dev_type
 Type of interface.
uintptr_t dev_base
 Hardware base address.
uint8_t dev_irq
 Interrupt registration number.
void * dev_icb
 Interface control block.
void * dev_dcb
 Driver control block.
int(* dev_init )(NUTDEVICE *)
 Driver initialization routine.
int(* dev_ioctl )(NUTDEVICE *, int, void *)
 Driver control function.
int(* dev_read )(NUTFILE *, void *, int)
 Read from device.
int(* dev_write )(NUTFILE *, const void *, int)
 Write to device.
int(* dev_write_P )(NUTFILE *, PGM_P, int)
 Write to device.
NUTFILE *(* dev_open )(NUTDEVICE *, const char *, int, int)
 Open a device or file.
int(* dev_close )(NUTFILE *)
 Close a device or file.
long(* dev_size )(NUTFILE *)
 Request file size.

Detailed Description

Device structure.

Each device driver provides a global variable of this type. Applications use NutRegisterDevice() to bind the device driver to the application code. Except this call, applications refer to device drivers by the name of the device when using standard C functions like _open() or fopen().

More than one device driver may be available for the same hardware device. Typically these drivers provide the same name for the device and applications must not refer to more than one device driver with the same name.

Examples:

pingnet/pingnet.c.


Field Documentation

Type of interface.

May be any of the following:

  • IFTYP_RAM
  • IFTYP_ROM
  • IFTYP_STREAM
  • IFTYP_NET
  • IFTYP_TCPSOCK
  • IFTYP_CHAR

Referenced by AceInit(), AhdlcAt91IOCtl(), AhdlcAvrIOCtl(), MmCardMount(), NutDeviceLookupType(), NutDhcpIfConfig(), NutIpOutput(), NutNetIfAddMcastAddr(), NutNetIfConfig2(), NutNetIfDelMcastAddr(), SpiMmcMount(), and UartAvrInit().

Interrupt registration number.

Will be set by calling NutRegisterDevice(). On some device drivers the interrupt may be fixed.

Referenced by AceInit(), NutRegisterDevice(), and UartAvrInit().

Interface control block.

With stream devices, this points to the IFSTREAM structure and with network devices this is a pointer to the IFNET structure.

Referenced by AceFlush(), AceInit(), AceInput(), AceIOCtl(), AceOutput(), AcePut(), AceRead(), AceSize(), AhdlcAt91IOCtl(), AhdlcAvrInit(), AhdlcAvrIOCtl(), AhdlcRx(), At25dfInit(), AtCanInput(), AtCanSetAccCode(), AtCanSetAccMask(), AtCanSetBaudrate(), CAN_RxAvail(), CAN_RxFrame(), CAN_SetFilter(), CAN_SetRxTimeout(), CAN_SetSpeed(), CAN_TryRxFrame(), CAN_TryTxFrame(), CAN_TxFrame(), CAN_TxFree(), cs8900Init(), CSNicInit(), CSNICrx(), DmOutput(), EmacRxThread(), Lpc17xxEmacRxThread(), MmCardIOCtl(), MmCardMount(), MmCardUnmount(), NicInit(), NicRx(), NicRxAsix(), NicRxLanc(), NutArpCacheQuery(), NutArpCacheUpdate(), NutArpInput(), NutArpOutput(), NutDhcpClient(), NutDhcpIfConfig(), NutEtherInput(), NutEtherOutput(), NutIgmpInput(), NutIpInput(), NutIpOutput(), NutNetIfAddMcastAddr(), NutNetIfConfig2(), NutNetIfDelMcastAddr(), NutNetIfSetup(), NutPppOutput(), NutRegisterSpiDevice(), NutTcpConnect(), NutUdpOutput(), PhatSectorFlush(), PhatSectorLoad(), PhatSectorWrite(), PhatVolMount(), RawFsMount(), RxThread(), SJAInit(), SJAInput(), SJASetAccCode(), SJASetAccMask(), SJASetBaudrate(), Spi7segInit(), Spi7SegPush(), Spi7segPutc(), SpiAt25PageRead(), SpiAt25PageWrite(), SpiAt45dCommand(), SpiAt45dInit(), SpiAt45dPageErase(), SpiAt45dPageRead(), SpiAt45dPageWrite(), SpiAt45dStatus(), SpiAt45dWaitReady(), SpiMmcBlockRead(), SpiMmcBlockWrite(), SpiMmcIOCtl(), SpiMmcMount(), UartAvrFlush(), UartAvrInit(), UartAvrInput(), UartAvrOutput(), UartAvrPut(), UartAvrRead(), UartAvrSize(), UFlashAttach(), UFlashDetach(), and upnp_Init().

Driver control block.

Points to a device specific information block.

Examples:
pppc/pppc.c.

Referenced by AceFlush(), AceInit(), AceInput(), AceIOCtl(), AceOpen(), AceOutput(), AcePut(), AceRead(), AhdlcAt91Init(), AhdlcAt91IOCtl(), AhdlcAt91Put(), AhdlcAt91Read(), AhdlcAvrInit(), AhdlcAvrIOCtl(), AhdlcAvrPut(), AhdlcAvrRead(), AhdlcOutput(), AhdlcRx(), AllocFirstCluster(), AsixInit(), AsixOutput(), At25dfInit(), At91DevDebugOpen(), AtCanInit(), AtCanInput(), AtCanOutput(), CAN_Tx(), cs8900Init(), cs8900Output(), CSNicInit(), CSNicOutput(), CSNICrx(), DmInit(), DmOutput(), EmacInit(), EmacOutput(), EmacRxThread(), FeederThread(), GenCharSize(), IpcpClose(), IpcpLowerDown(), IpcpLowerUp(), IpcpOpen(), IpcpRxConfAck(), IpcpRxConfReq(), IpcpRxProtRej(), IpcpRxTermAck(), IpcpRxTermReq(), IpcpTxConfReq(), IsFixedRootDir(), LancInit(), LancOutput(), LcpClose(), LcpLowerDown(), LcpLowerUp(), LcpOpen(), LcpRxProtRej(), LcpTxConfReq(), LcpTxProtRej(), Lpc17xxDevDebugOpen(), Lpc17xxEmacInit(), Lpc17xxEmacOutput(), Lpc17xxEmacRxThread(), LpcDevDebugOpen(), NicInit(), NicOutput(), NicRx(), NicRxAsix(), NicRxLanc(), NutBlockDeviceIOCtl(), NutBlockDeviceOpen(), NutBlockDeviceRead(), NutBlockDeviceWrite(), NutBlockDeviceWrite_P(), NutIpcpInput(), NutLcpInput(), NutNetIfConfig2(), NutPppInput(), NutPppOutput(), NutPppSm(), PapRxAuthAck(), PapRxAuthNak(), PapTxAuthReq(), Phat12GetClusterLink(), Phat12ReleaseChain(), Phat12SetClusterLink(), Phat16GetClusterLink(), Phat16ReleaseChain(), Phat16SetClusterLink(), Phat32FreeClusters(), Phat32GetClusterLink(), Phat32ReleaseChain(), Phat32SetClusterLink(), PhatClusterSector(), PhatDirCreate(), PhatDirEntryUpdate(), PhatDirOpen(), PhatDirReleaseChain(), PhatFilePosSet(), PhatFileRead(), PhatFileWrite(), PhatSectorBufferRelease(), PhatSectorFlush(), PhatSectorLoad(), PhatSectorWrite(), PhatVolMount(), PhatVolUnmount(), RawFsFileRead(), RawFsFileWrite(), RawFsMount(), RawFsUnmount(), RxThread(), Sc16is752UsartProcessChannelInterrupt(), SJAInit(), SJAInput(), SJAOutput(), Spi7segDot(), Spi7segInit(), Spi7SegPush(), Spi7segPutc(), SpiAt25PageRead(), SpiAt25PageWrite(), SpiAt45dInit(), SpiAt45dPageErase(), SpiAt45dPageRead(), SpiAt45dPages(), SpiAt45dPageSize(), SpiAt45dPageWrite(), SpiMmcBlockRead(), SpiMmcBlockWrite(), SpiMmcIOCtl(), SpiMmcMount(), TermInit(), TermIOCtl(), TermOpen(), UartAvrFlush(), UartAvrInit(), UartAvrInput(), UartAvrIOCtl(), UartAvrOpen(), UartAvrPut(), UartAvrRead(), UFlashFormat(), UnixDevIOCTL(), UsartClose(), UsartInit(), UsartIOCtl(), UsartOpen(), UsartRead(), UsartSize(), VsCodecBeep(), VsCodecClose(), VsCodecIOCtl(), VsCodecOpen(), VsCodecRead(), VsCodecReg(), VsCodecWaitReady(), VsCodecWrite(), VsDecoderBufferInit(), VsDecoderSetBass(), VsDecoderSetVolume(), wlandrv_IOCTL(), wlandrv_PutPacket(), and WlanInit().

Driver initialization routine.

This routine is called during device registration.

Referenced by NutInit(), and NutRegisterDevice().

int(* _NUTDEVICE::dev_read)(NUTFILE *, void *, int)

Read from device.

Referenced by _read(), and PhatSectorRead().

int(* _NUTDEVICE::dev_write)(NUTFILE *, const void *, int)

Write to device.

Referenced by _write().

int(* _NUTDEVICE::dev_write_P)(NUTFILE *, PGM_P, int)

Write to device.

Referenced by _write_P().

NUTFILE*(* _NUTDEVICE::dev_open)(NUTDEVICE *, const char *, int, int)

Open a device or file.

Referenced by _open(), and NutInit().

Close a device or file.

Referenced by _close().

Request file size.

Referenced by _filelength().


The documentation for this struct was generated from the following file: