Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Diff: OneWire_Masters/DS248x/ds248x.cpp
- Revision:
- 71:562f5c702094
- Parent:
- 69:f915c4c59a69
- Child:
- 72:6892702709ee
diff -r 7db8ff74bcbe -r 562f5c702094 OneWire_Masters/DS248x/ds248x.cpp --- a/OneWire_Masters/DS248x/ds248x.cpp Mon May 09 08:31:53 2016 -0500 +++ b/OneWire_Masters/DS248x/ds248x.cpp Mon May 09 15:04:23 2016 -0500 @@ -54,13 +54,13 @@ std::uint8_t Ds248x::Config::readByte() const { std::uint8_t config = 0; - if (c1WS()) + if (get1WS()) config |= 0x08; - if (cSPU()) + if (getSPU()) config |= 0x04; - if (cPDN()) + if (getPDN()) config |= 0x02; - if (cAPU()) + if (getAPU()) config |= 0x01; return config; } @@ -73,10 +73,10 @@ void Ds248x::Config::reset() { - setC1WS(false); - setCSPU(false); - setCPDN(false); - setCAPU(true); + set1WS(false); + setSPU(false); + setPDN(false); + setAPU(true); } @@ -364,52 +364,15 @@ //********************************************************************* -OneWireMaster::CmdResult Ds248x::OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len) -{ - OneWireMaster::CmdResult result; - - for(uint8_t idx = 0; idx < tran_len; idx++) - { - result = OneWireMaster::OWWriteByte(tran_buf[idx]); - if(result != OneWireMaster::Success) - { - break; - } - } - - return result; -} - - -//********************************************************************* -OneWireMaster::CmdResult Ds248x::OWReadBlock(uint8_t *rx_buf, uint8_t rx_len) -{ - OneWireMaster::CmdResult result; - - for(uint8_t idx = 0; idx < rx_len; idx++) - { - //OwReadByte() uses pass by reference - result = OneWireMaster::OWReadByte(rx_buf[idx]); - if(result != OneWireMaster::Success) - { - break; - } - } - - return result; -} - - -//********************************************************************* OneWireMaster::CmdResult Ds248x::OWSetSpeed(OWSpeed new_speed) { // Requested speed is already set - if (m_curConfig.c1WS() == (new_speed == SPEED_OVERDRIVE)) + if (m_curConfig.get1WS() == (new_speed == SPEED_OVERDRIVE)) return OneWireMaster::Success; // set the speed Config newConfig = m_curConfig; - newConfig.setC1WS(new_speed == SPEED_OVERDRIVE); + newConfig.set1WS(new_speed == SPEED_OVERDRIVE); // write the new config return writeConfig(newConfig, true); @@ -499,10 +462,10 @@ OneWireMaster::CmdResult Ds248x::configureLevel(OWLevel level) { OneWireMaster::CmdResult result; - if (m_curConfig.cSPU() != (level == LEVEL_STRONG)) + if (m_curConfig.getSPU() != (level == LEVEL_STRONG)) { Config newConfig = m_curConfig; - newConfig.setCSPU(level == LEVEL_STRONG); + newConfig.setSPU(level == LEVEL_STRONG); result = writeConfig(newConfig, true); } else