// /* mld.h Typedefs, structures, and prototypes for the XidarML daemon. Copyright (c) 1996 Eliot W. Dudley. All rights reserved. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the README file. */ /* 1-Wire, DS, DS1820, DS2405, DS2407, DS9097, and MicroLan are trademarks and/or registered trademarks of Dallas Semiconductor Coporation */ //============================================================================= //@Man: mld.h typedefs //@{ //@Man: MLNODE //@Memo: \Ref{MLNODEt} //@Man: pMLNODE //@Memo: \Ref{MLNODEt} typedef struct MLNODEt MLNODE, *pMLNODE; //@Man: MLADDR //@Memo: \Ref{MLADDRt} //@Man: pMLADDR //@Memo: \Ref{MLADDRt} typedef union MLADDRt MLADDR, *pMLADDR; //@Man: MLDRIVER //@Memo: \Ref{MLDRIVERt} //@Man: pMLDRIVER //@Memo: \Ref{MLDRIVERt} typedef struct MLDRIVERt MLDRIVER, *pMLDRIVER; //@Man: ML //@Memo: \Ref{MLt} //@Man: pML //@Memo: \Ref{MLt} typedef struct MLt ML, *pML; //@Man: MLPATH //@Memo: \Ref{MLPATHt} //@Man: pMLPATH //@Memo: \Ref{MLPATHt} typedef struct MLPATHt MLPATH, *pMLPATH; //@Man: DS1820 //@Memo: \Ref{DS1820t} //@Man: pDS1820 //@Memo: \Ref{DS1820t} typedef struct DS1820t DS1820, *pDS1820; //@Man: DS2407 //@Memo: \Ref{DS2407t} //@Man: pDS2407 //@Memo: \Ref{DS2407t} typedef struct DS2407t DS2407, *pDS2407; //@Man: DSDEV //@Memo: \Ref{DSDEVt} //@Man: pDSDEV //@Memo: \Ref{DSDEVt} typedef union DSDEVt DSDEV, *pDSDEV; //@Man: MLADDRROM //@Memo: \Ref{MLADDRROMt} //@Man: pMLADDRROM //@Memo: \Ref{MLADDRROMt} typedef struct MLADDRROMt MLADDRROM, *pMLADDRROM; //@Man: DS1820_SCRATCH //@Memo: \Ref{DS1820_SCRATCHt} //@Man: pDS1820_SCRATCH //@Memo: \Ref{DS1820_SCRATCHt} typedef struct DS1820_SCRATCHt DS1820_SCRATCH, *pDS1820_SCRATCH; //@Man: MLREAD /*@Memo: Read a 1-Wire device. */ //@{ //@Type: typedef //@Args: int (*MLREAD)(pML, pMLNODE, BYTE *buf, int count, int offset); typedef int (*MLREAD)(pML, pMLNODE, BYTE *buf, int count, int offset); //@} //@Man: MLONOFF /*@Memo: Switch a 1-Wire device on or off. */ //@{ //@Type: typedef //@Args: int (*MLONOFF)(pML, pMLNODE, int state); typedef int (*MLONOFF)(pML, pMLNODE, int state); //@} typedef struct timeval TIMEVAL, *pTIMEVAL; //@} //End: mld.h typedefs //============================================================================= //============================================================================= //@Man: mld.h structs //@{ /// //@Memo: 1-Wire ROM address components. /** 1-Wire ROM address components. */ struct MLADDRROMt { /// DS type. BYTE ds_family; /// Six bytes serial number. BYTE serial[6]; /// Eight bits CRC. BYTE crc; }; /// //@Memo: Union of 1-Wire address representations. /** Different ways to refer to different parts of a 1-Wire device address. of nodes. */ union MLADDRt { /// Eight bytes. BYTE b[8]; /// Two unsigned longs. unsigned long u[2]; /// Type, serial number, CRC. MLADDRROM rom; }; /// //@Memo: DS1820 specific status information. /** DS1820 specific status information. */ struct DS1820t { /// Fixed point Celius temperature. Decimal point between bits 16,15. long int temp; /// Temperature high trigger. BYTE t_h; /// Temperature low trigger. BYTE t_l; }; /// //@Memo: DS1820 raw status. /** DS1820 raw status. */ struct DS1820_SCRATCHt { /// Temperature LSB. BYTE t_lsb; /// Temperature MSB, sign extended. char t_msb; /// Temperature high trigger. BYTE t_h; /// Temperature low trigger. BYTE t_l; /// Reserved. BYTE reserved[2]; /// High resolution register count remain. BYTE cnt_remain; /// High resolution register count per degree C. BYTE cnt_per; /// Eight bit CRC. BYTE crc; }; /// //@Memo: DS2407 specific status information. /** DS2407 specific status information. */ struct DS2407t { /// BYTE *mem; }; /// //@Memo: 1-Wire Device status information. /** Device specific status information. */ union DSDEVt { /// \Ref{DS1820t} DS1820 ds1820; /// \Ref{DS2407t} DS2407 ds2407; }; /// //@Memo: Directory path to a node. /** The series of 1-Wire switches that have to be on to talk to a set of nodes. */ struct MLPATHt { /// Dimension of the array is the maximum depth of the LAN. pMLNODE p[8]; }; /// //@Memo: A 1-Wire node. /** The state of a node and how to get to it. */ struct MLNODEt { /// Node name. char *name; /// Different ways of referring to the eights bytes of this node's address. MLADDR mladdr; /// Arbitrate amoung tasks waiting to talk to this node. pEVENT psem; /// The current working directory of this node, its parent node. pMLNODE cwd; /// The director path to this node. MLPATH mlpath; /// Driver functions. pMLDRIVER pmldriver; /// Last time this node was timestamped. TIMEVAL tv; /// Different status information depending on the type of the device. DSDEV dev; /// The bit number MLSearch() left off with when doing a ROM search. signed int bit_highest:7; /// Number of 1-Wire switches that must be on to talk to this node. signed int mldepth:4; /// Is a switch. unsigned int is_switch:1; /// Is on? unsigned int state:1; }; /// //@Memo: Node access functions. /** Node access abstractions. */ struct MLDRIVERt { /// MLREAD mlread; /// MLONOFF mlon_off; }; //@} //End: mld.h typedefs //============================================================================= //=Prototypes.================================================================= pMLNODE GetMLNodeByName(pML pml, char *name); pMLNODE GetMLNodeByAddr(pML pml, pMLNODE pmlnode); void MLPathCheck(pML pml); //============================================================================= //