1-Wire® library for mbed. Complete 1-Wire library that supports our silicon masters along with a bit-bang master on the MAX32600MBED platform with one common interface for mbed. Slave support has also been included and more slaves will be added as time permits.
Dependents: MAXREFDES131_Qt_Demo MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAXREFDES130_131_Demo ... more
Superseded by MaximInterface.
Diff: OneWire_Masters/DS248x/ds248x.h
- Revision:
- 2:02d228c25fd4
- Parent:
- 1:91e52f8ab8bf
- Child:
- 3:644fc630f958
diff -r 91e52f8ab8bf -r 02d228c25fd4 OneWire_Masters/DS248x/ds248x.h --- a/OneWire_Masters/DS248x/ds248x.h Sat Jan 30 23:00:57 2016 +0000 +++ b/OneWire_Masters/DS248x/ds248x.h Sun Jan 31 06:15:24 2016 +0000 @@ -65,8 +65,7 @@ DS248X_I2C_ADRS5, DS248X_I2C_ADRS6, DS248X_I2C_ADRS7, - } - ds248x_i2c_adrs_t + }ds248x_i2c_adrs_t; /**********************************************************//** * @brief Ds248x constructor @@ -128,7 +127,7 @@ * FALSE device not detected or failure to write * configuration byte **************************************************************/ - uint8_t detect(void); + bool detect(void); /**********************************************************//** @@ -142,7 +141,7 @@ * @return TRUE if device was reset * FALSE device not detected or failure to perform reset **************************************************************/ - uint8_t reset(void); + bool reset(void); /**********************************************************//** @@ -160,13 +159,29 @@ * @return TRUE: config written and response correct * FALSE: response incorrect **************************************************************/ - uint8_t write_config(uint8_t config); + bool write_config(uint8_t config); + + + /**********************************************************//** + * @brief channel_select() + * + * @details Select the 1-Wire channel on a DS2482-800. + * Min channel = 1 + * + * On Entry: + * @param[in] channel - desired channel of the DS2482 + * + * On Exit: + * @return TRUE if channel selected + * FALSE device not detected or failure to perform select + **************************************************************/ + bool channel_select(uint8_t channel); /**********************************************************//** * @brief adjust_timing() * - * @details + * @details adjustable timming available in DS2484 only * * On Entry: * @param[in] param - 1 of 8 adjustable parameters @@ -177,7 +192,7 @@ * @return TRUE: parameter successfully adjusted * FALSE: failed to adjust parameter **************************************************************/ - uint8_t adjust_timing(uint8_t param, uint8_t val); + bool adjust_timing(uint8_t param, uint8_t val); /**********************************************************//** @@ -211,7 +226,7 @@ * @return TRUE(1): presence pulse(s) detected, device(s) reset * FALSE(0): no presence pulses detected **************************************************************/ - virtual uint8_t OWReset(); + virtual bool OWReset(); /**********************************************************//** @@ -277,7 +292,7 @@ * @return TRUE: bytes written and echo was the same * FALSE: echo was not the same **************************************************************/ - virtual void OWWRiteByte(uint8_t sendbyte); + virtual bool OWWriteByte(uint8_t sendbyte); /**********************************************************//** @@ -341,7 +356,7 @@ * @return TRUE : device found, ROM number in ROM_NO buffer * FALSE : no device present **************************************************************/ - virtual void OWFirst(void); + virtual bool OWFirst(void); /**********************************************************//** @@ -355,7 +370,7 @@ * @return TRUE : device found, ROM number in ROM_NO buffer * FALSE : device not found, end of search **************************************************************/ - virtual uint8_t OWNext(void); + virtual bool OWNext(void); /**********************************************************//** @@ -370,7 +385,7 @@ * @return TRUE : device verified present * FALSE : device not present **************************************************************/ - virtual uint8_t OWVerify(void); + virtual bool OWVerify(void); /**********************************************************//** @@ -424,7 +439,7 @@ * last search was the last device or there * are no devices on the 1-Wire Net. **************************************************************/ - virtual uint8_t OWSearch(void); + virtual bool OWSearch(void); /**********************************************************//** @@ -478,7 +493,7 @@ * @return TRUE: bytes written and echo was the same, strong pullup now on * FALSE: echo was not the same **************************************************************/ - virtual uint8_t OWWriteBytePower(uint8_t sendbyte); + virtual bool OWWriteBytePower(uint8_t sendbyte); /**********************************************************//** @@ -496,9 +511,10 @@ * then start power delivery * * On Exit: - * @return + * @return TRUE: bit written and response correct, strong pullup now on + * FALSE: response incorrect **************************************************************/ - virtual uint8_t OWReadBitPower(uint8_t applyPowerResponse); + virtual bool OWReadBitPower(uint8_t applyPowerResponse); /**********************************************************//** @@ -515,12 +531,37 @@ **************************************************************/ virtual uint8_t calc_crc8(uint8_t data); + + /**********************************************************//** + * @brief get_rom_number() + * + * @details Get the ROM ID currently held in the private buffer + * + * On Entry: + * @param[in] p_rom_buff - pointer to buffer for storing + * rom number + * + * On Exit: + * @return none + **************************************************************/ + virtual void get_rom_number(uint8_t *p_rom_buff); + private: I2C *_p_i2c_bus; bool i2c_owner; uint8_t _w_adrs, _r_adrs; - + + // ds248x state + uint8_t _short_detected; + uint8_t _c1WS, _cSPU, _cPDN, _cAPU; + + // Search state + uint8_t _rom_number[8]; + uint8_t _last_discrepancy; + uint8_t _last_family_discrepancy; + uint8_t _last_device_flag; + uint8_t _crc8; }; #endif /*DS248X_H*/ \ No newline at end of file