72 #if defined(NZ_OW2482_ENABLED)
79 #define DS2482_ADDRESS_00 0x30 //DS2482 address if AD0=0V and AD1=0V
80 #define DS2482_ADDRESS_01 0x31 //DS2482 address if AD0=Vcc and AD1=0V
81 #define DS2482_ADDRESS_10 0x32 //DS2482 address if AD0=0V and AD1=Vcc
82 #define DS2482_ADDRESS_11 0x33 //DS2482 address if AD0=Vcc and AD1=Vcc
84 #define DS2482_COMMAND_RESET 0xF0 //Device Reset command
85 #define DS2482_COMMAND_WR_CONF 0xD2 //Write Configuration command
86 #define DS2482_COMMAND_SET_RD_PTR 0xE1 //Set Read Pointer command
87 #define DS2482_COMMAND_1W_RESET 0xB4 //1-Wire Reset command
88 #define DS2482_COMMAND_1W_WR_BYTE 0xA5 //1-Wire Write Byte command
89 #define DS2482_COMMAND_1W_RD_BYTE 0x96 //1-Wire Read Byte command
90 #define DS2482_COMMAND_1W_SINGLE_BIT 0x87 //1-Wire Single Bit command
91 #define DS2482_COMMAND_1W_TRIPLET 0x78 //1-Wire Triplet command
93 #define DS2482_CONFIG_APU 0x01 //Active Pullup enabled
94 #define DS2482_CONFIG_PPM 0x02 //Presence-Pulse Masking enabled
95 #define DS2482_CONFIG_SPU 0x04 //Strong Pullup enabled
96 #define DS2482_CONFIG_1WS 0x08 //1-Wire Speed High Speed enabled
98 #define DS2482_STATUS_1WB 0x01 //1-Wire Busy
99 #define DS2482_STATUS_PPD 0x02 //Presence-Pulse Detect
100 #define DS2482_STATUS_SD 0x04 //Short Detected
101 #define DS2482_STATUS_LL 0x08 //Logic Level
102 #define DS2482_STATUS_RST 0x10 //Device Reset
103 #define DS2482_STATUS_SBR 0x20 //Single Bit Result
104 #define DS2482_STATUS_TSB 0x40 //Triplet Second Bit
105 #define DS2482_STATUS_DIR 0x80 //Branch Direction Taken
107 #define DS2482_TIMEOUT 100 //100ms
109 typedef struct DS2482_INFO_
123 BYTE lastDiscrepancy;
124 BYTE lastFamilyDiscrepancy;
135 unsigned char lastDevice : 1;
136 unsigned char searchResult : 1;
137 unsigned char idBit : 1;
138 unsigned char cmpIdBit : 1;
139 unsigned char searchDirection : 1;
148 unsigned int OWB : 1;
149 unsigned int PPD : 1;
152 unsigned int RST : 1;
153 unsigned int SBR : 1;
154 unsigned int TSB : 1;
155 unsigned int DIR : 1;
163 unsigned int APU : 1;
164 unsigned int PPM : 1;
165 unsigned int SPU : 1;
166 unsigned int OWS : 1;
167 unsigned int fill : 4;
192 BYTE ds2482_init(DS2482_INFO* pObj, BYTE i2cBus, BYTE i2cAdr);
200 void ds2482_task(DS2482_INFO* pObj);
211 #define ds2482_isBusy(pObj) ((pObj)->sm!=0)
223 #define ds2482_getStatus(pObj) ((pObj)->status)
232 BYTE ds2482_getStatusWait(DS2482_INFO* pObj);
235 #define ds2482_resetStatus(pObj) ((pObj)->status = 0)
244 #define ds2482_getStatusReg(pObj) ((pObj)->statusRegVal)
258 #define ds2482_getStatusRegPPD(pObj) ((pObj)->statusReg.PPD)
271 #define ds2482_getStatusRegSD(pObj) ((pObj)->statusReg.SD)
286 BOOL ds2482_reset(DS2482_INFO* pObj);
302 BOOL ds2482_writeConfig(DS2482_INFO* pObj, BYTE config);
324 BYTE owReset(DS2482_INFO* pObj);
342 BYTE owResetWATE(DS2482_INFO* pObj);
359 BYTE owReadWriteBit(DS2482_INFO* pObj, BOOL bVal);
366 #define owGetBit(pObj) ((pObj)->statusReg.SBR)
374 #define owGetByte(pObj) ((pObj)->readByte)
389 BYTE owReadByte(DS2482_INFO* pObj);
408 BYTE owReadByteWATE(DS2482_INFO* pObj);
425 BYTE owWriteByte(DS2482_INFO* pObj, BYTE val);
445 BYTE owWriteByteWATE(DS2482_INFO* pObj, BYTE val);
466 BYTE owWriteBytePower(DS2482_INFO* pObj, BYTE val);
486 BYTE owWriteBytePowerWATE(DS2482_INFO* pObj, BYTE val);
504 BYTE owSpeed(DS2482_INFO* pObj, BOOL speed);
526 BYTE owLevel(DS2482_INFO* pObj, BOOL level);
532 void owSearchReset(DS2482_INFO* pObj);
553 BOOL owSearch(DS2482_INFO* pObj);
575 BYTE* owSearchWATE(DS2482_INFO* pObj);
586 #define owGetAdr64(pObj) (pObj->flags.searchResult?pObj->adr64:0)
604 BYTE owSelect(DS2482_INFO* pObj, BYTE* adr64);
624 BYTE owSelectWATE(DS2482_INFO* pObj, BYTE* adr64);
626 #endif //#if defined(NZ_OW2482_ENABLED)
627 #endif //#ifndef NZ_OW2482_H