Extended MaximInterface

Dependents:   mbed_DS28EC20_GPIO

Revision:
6:a8c83a2e6fa4
Parent:
0:f77ad7f72d04
Child:
7:471901a04573
--- a/Devices/DS2482_DS2484.hpp	Fri Jan 19 10:25:02 2018 -0600
+++ b/Devices/DS2482_DS2484.hpp	Wed Jan 23 13:11:04 2019 -0600
@@ -54,48 +54,56 @@
     /// @{
     /// 1-Wire Speed
     bool get1WS() const { return (readByte_ & option1WS) == option1WS; }
-    void set1WS(bool new1WS) {
+    
+    Config & set1WS(bool new1WS) {
       if (new1WS) {
         readByte_ |= option1WS;
       } else {
         readByte_ &= ~option1WS;
       }
+      return *this;
     }
     /// @}
 
     /// @{
     /// Strong Pullup
     bool getSPU() const { return (readByte_ & optionSPU) == optionSPU; }
-    void setSPU(bool newSPU) {
+    
+    Config & setSPU(bool newSPU) {
       if (newSPU) {
         readByte_ |= optionSPU;
       } else {
         readByte_ &= ~optionSPU;
       }
+      return *this;
     }
     /// @}
 
     /// @{
     /// 1-Wire Power Down
     bool getPDN() const { return (readByte_ & optionPDN) == optionPDN; }
-    void setPDN(bool newPDN) {
+    
+    Config & setPDN(bool newPDN) {
       if (newPDN) {
         readByte_ |= optionPDN;
       } else {
         readByte_ &= ~optionPDN;
       }
+      return *this;
     }
     /// @}
 
     /// @{
     /// Active Pullup
     bool getAPU() const { return (readByte_ & optionAPU) == optionAPU; }
-    void setAPU(bool newAPU) {
+    
+    Config & setAPU(bool newAPU) {
       if (newAPU) {
         readByte_ |= optionAPU;
       } else {
         readByte_ &= ~optionAPU;
       }
+      return *this;
     }
     /// @}
 
@@ -111,11 +119,11 @@
     uint_least8_t readByte_;
   };
 
-  void setI2CMaster(I2CMaster & i2cMaster) { this->i2cMaster = &i2cMaster; }
-  uint_least8_t i2cAddress() const { return i2cAddress_; }
-  void setI2CAddress(uint_least8_t i2cAddress) {
-    this->i2cAddress_ = i2cAddress;
-  }
+  void setMaster(I2CMaster & master) { this->master = &master; }
+  
+  uint_least8_t address() const { return address_; }
+  
+  void setAddress(uint_least8_t address) { address_ = address; }
 
   /// Initialize hardware for use.
   MaximInterface_EXPORT error_code initialize(Config config = Config());
@@ -128,20 +136,25 @@
   MaximInterface_EXPORT virtual error_code triplet(TripletData & data);
 
   MaximInterface_EXPORT virtual error_code reset();
+  
   MaximInterface_EXPORT virtual error_code touchBitSetLevel(bool & sendRecvBit,
                                                             Level afterLevel);
+  
   MaximInterface_EXPORT virtual error_code
   readByteSetLevel(uint_least8_t & recvByte, Level afterLevel);
+  
   MaximInterface_EXPORT virtual error_code
   writeByteSetLevel(uint_least8_t sendByte, Level afterLevel);
+  
   MaximInterface_EXPORT virtual error_code setSpeed(Speed newSpeed);
+  
   MaximInterface_EXPORT virtual error_code setLevel(Level newLevel);
 
   MaximInterface_EXPORT static const error_category & errorCategory();
 
 protected:
-  DS2482_DS2484(I2CMaster & i2cMaster, uint_least8_t i2cAddress)
-      : i2cMaster(&i2cMaster), i2cAddress_(i2cAddress) {}
+  DS2482_DS2484(I2CMaster & master, uint_least8_t address)
+      : master(&master), address_(address) {}
 
   /// @note Allow marking const since not public.
   error_code sendCommand(uint_least8_t cmd) const;
@@ -172,8 +185,8 @@
   /// @param level Desired 1-Wire level.
   error_code configureLevel(Level level);
 
-  I2CMaster * i2cMaster;
-  uint_least8_t i2cAddress_;
+  I2CMaster * master;
+  uint_least8_t address_;
   Config curConfig;
 };