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: Masters/DS248x/DS248x.h
- Revision:
- 91:e80108bc870a
- Parent:
- 84:708b7be59fb2
- Child:
- 98:c4ac93efc036
--- a/Masters/DS248x/DS248x.h Fri Jun 17 15:24:37 2016 -0500 +++ b/Masters/DS248x/DS248x.h Mon Jun 20 19:39:21 2016 +0000 @@ -54,20 +54,6 @@ ChannelSelectReg = 0xD2 // DS2482-800 only }; - /// 1-Wire port adjustment parameters. - /// @note DS2484 only. See datasheet page 13. - enum OwAdjustParam - { - tRSTL = 0, - tRSTL_OD, - tMSP, - tMSP_OD, - tW0L, - tW0L_OD, - tREC0, // OD N/A - RWPU = 8 // OD N/A - }; - /// Represents a DS248x configuration. class Config { @@ -96,9 +82,9 @@ void setAPU(bool newAPU) { m_APU = newAPU; } /// @} - /// Byte representation that is read from the DS2465. + /// Byte representation that is read from the DS248x. uint8_t readByte() const; - /// Byte respresentation that is written to the DS2465. + /// Byte respresentation that is written to the DS248x. uint8_t writeByte() const; /// Reset to the power-on default config. @@ -108,14 +94,14 @@ private: bool m_1WS, m_SPU, m_PDN, m_APU; }; - + /// Construct to use an existing I2C interface. /// @param i2c_bus Configured I2C communication interface for DS248x. /// @param adrs I2C bus address of the DS248x in mbed format. DS248x(mbed::I2C & i2c_bus, uint8_t adrs); /// Destroys I2C interface if owner. - virtual ~DS248x(); + virtual ~DS248x(){}; /// Performs a soft reset on the DS248x. /// @note This is note a 1-Wire Reset. @@ -136,25 +122,16 @@ /// @param skipSetPointer Assume that the read pointer is already set to the correct register. OneWireMaster::CmdResult readRegister(Register reg, uint8_t & buf, bool skipSetPointer = false) const; - /// Select the 1-Wire channel on a DS2482-800. - /// @note DS2482-800 only - /// @param channel Channel number to select beginning at 1. - OneWireMaster::CmdResult selectChannel(uint8_t channel); - - /// Adjust 1-Wire port paramaters. - /// @note DS2484 only - /// @param param Parameter to adjust. - /// @param val New parameter value to set. Consult datasheet for value mappings. - OneWireMaster::CmdResult adjustOwPort(OwAdjustParam param, uint8_t val); - /// @details Performs a device reset followed by writing the configuration byte to default values: /// 1-Wire Speed Standard /// Strong Pullup Off /// 1-Wire Powerdown Off /// Active Pullup On virtual OneWireMaster::CmdResult OWInitMaster(); + /// @note Perform a 1-Wire triplet using the DS248x command. virtual OneWireMaster::CmdResult OWTriplet(SearchDirection & searchDirection, uint8_t & sbr, uint8_t & tsb); + virtual OneWireMaster::CmdResult OWReset(); virtual OneWireMaster::CmdResult OWTouchBitSetLevel(uint8_t & sendRecvBit, OWLevel afterLevel); virtual OneWireMaster::CmdResult OWReadByteSetLevel(uint8_t & recvByte, OWLevel afterLevel); @@ -162,7 +139,8 @@ virtual OneWireMaster::CmdResult OWSetSpeed(OWSpeed newSpeed); virtual OneWireMaster::CmdResult OWSetLevel(OWLevel newLevel); - private: + protected: + enum Command { DeviceResetCmd = 0xF0, @@ -176,13 +154,12 @@ OwSingleBitCmd = 0x87, OwTripletCmd = 0x78 }; - - mbed::I2C *m_p_i2c_bus; + + mbed::I2C & m_i2c_bus; uint8_t m_adrs; - bool m_i2c_owner; Config m_curConfig; - /// Polls the DS2465 status waiting for the 1-Wire Busy bit (1WB) to be cleared. + /// Polls the DS248x status waiting for the 1-Wire Busy bit (1WB) to be cleared. /// @param[out] pStatus Optionally retrive the status byte when 1WB cleared. /// @returns Success or TimeoutError if poll limit reached. OneWireMaster::CmdResult pollBusy(uint8_t * pStatus = NULL);