Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Revision:
74:23be10c32fa3
Parent:
73:2cecc1372acc
Child:
75:8b627804927c
--- a/Bridge/DS28E17/DS28E17.h	Thu May 12 14:38:16 2016 -0500
+++ b/Bridge/DS28E17/DS28E17.h	Fri May 13 07:48:35 2016 -0500
@@ -40,13 +40,13 @@
 namespace OneWire
 {
     namespace Masters { class OneWireMaster; }
-    
+
     namespace Bridge
     {
         class DS28E17 : public OneWireSlave
         {
         public:
-            
+
             enum DS28E17_CMDS
             {
                 CMD_I2C_WRITE_W_STOP = 0x4B,
@@ -61,7 +61,7 @@
                 CMD_ENABLE_SLEEP_MODE = 0x1E,
                 CMD_READ_DEVICE_REV = 0xC3
             };
-            
+
             enum CmdResult
             {
                 Success,
@@ -74,13 +74,13 @@
                 TimeoutError,
                 OperationFailure
             };
-            
+
             static const size_t POLL_LIMIT = 10000;
-            
+
             /**********************************************************//**
             * @brief DS28E17 constructor
-            * 
-            * @details 
+            *
+            * @details
             *
             * On Entry:
             *     @param[in] p_owm - pointer to a 1-wire master of the following
@@ -88,19 +88,19 @@
             *                        inherit the base class 'OneWireInterface'
             *
             * On Exit:
-            *    @return 
+            *    @return
             **************************************************************/
             DS28E17(Masters::OneWireMaster &owm);
-            
+
             /**********************************************************//**
-            * @brief Write to selected DS28E17's I2C with Stop.  
+            * @brief Write to selected DS28E17's I2C with Stop.
             * Poll until I2C write complete and receive status info.
-            * 
+            *
             * @details Output on I2C: S, Address + Write, Write Data [1-255], P
             *
             * On Entry:
-            * @param[in]  I2C_addr - 
-            * Writes I2C address. The least significant bit of the I2C 
+            * @param[in]  I2C_addr -
+            * Writes I2C address. The least significant bit of the I2C
             * address is automatically cleared by the command.
             *
             * @param[in] length
@@ -112,30 +112,30 @@
             *
             * On Exit:
             * @param[out] status
-            * Detects the condition of the Start (bit3), N/A (bit2), 
+            * Detects the condition of the Start (bit3), N/A (bit2),
             * Address(bit1) and CRC16(bit0) bits.
-            * b3;0=No Err|1=I2CStart prev-not issued, 
+            * b3;0=No Err|1=I2CStart prev-not issued,
             * b2;0=No Err|1=I2C N/A Err,
-            * b1;0=No Err|1=Addr Err, 
+            * b1;0=No Err|1=Addr Err,
             * b0;0=Valid CRC16|1=Invalid CRC16
             *
             * @param[out] wr_status
-            * Indicates which write byte NACK’d. A value of 00h indicates 
+            * Indicates which write byte NACK’d. A value of 00h indicates
             * all bytes were acknowledged by the slave.
             * A non-zero value indicates the byte number that NACK’d.
             *
-            * @return 
+            * @return
             * true if device selected and written @n
             * false if failed device select
             **************************************************************/
-            CmdResult I2C_WriteDataWithStop(uint8_t I2C_addr, uint8_t length, 
-                                       uint8_t *data, uint8_t &status, 
-                                       uint8_t &wr_status);
-            
+            CmdResult I2C_WriteDataWithStop(uint8_t I2C_addr, uint8_t length,
+                                            uint8_t *data, uint8_t &status,
+                                            uint8_t &wr_status);
+
             /**********************************************************//**
-            * @brief Write to selected DS28E17's I2C No Stop.  
+            * @brief Write to selected DS28E17's I2C No Stop.
             * Poll until I2C write complete and receive status info.
-            * 
+            *
             * @details Output on I2C: S, Address + Write, Write Data [1-255]
             *
             * On Entry:
@@ -152,31 +152,31 @@
             *
             * On Exit:
             * @param[out]  status
-            * Detects the condition of the Start (bit3), N/A (bit2), 
+            * Detects the condition of the Start (bit3), N/A (bit2),
             * Address(bit1) and CRC16(bit0) bits.
-            * b3;0=No Err|1=I2CStart prev-not issued, 
+            * b3;0=No Err|1=I2CStart prev-not issued,
             * b2;0=No Err|1=I2C N/A Err,
-            * b1;0=No Err|1=Addr Err, 
+            * b1;0=No Err|1=Addr Err,
             * b0;0=Valid CRC16|1=Invalid CRC16
             *
             * @param[out] wr_status
-            * Indicates which write byte NACK’d. A value of 00h indicates 
+            * Indicates which write byte NACK’d. A value of 00h indicates
             * all bytes were acknowledged by the slave.
             * A non-zero value indicates the byte number that NACK’d.
             *
-            * @return 
+            * @return
             * true if device selected and written @n
             * false if failed device select
             **************************************************************/
-            CmdResult I2C_WriteDataNoStop(uint8_t I2C_addr, uint8_t length, 
-                                     uint8_t *data, uint8_t &status, 
-                                     uint8_t &wr_status);
-            
-            
+            CmdResult I2C_WriteDataNoStop(uint8_t I2C_addr, uint8_t length,
+                                          uint8_t *data, uint8_t &status,
+                                          uint8_t &wr_status);
+
+
             /**********************************************************//**
-            * @brief Write to selected DS28E17's I2C with Data only.  
+            * @brief Write to selected DS28E17's I2C with Data only.
             * Poll until I2C write complete and receive status info.
-            * 
+            *
             * @details Output on I2C: Write Data [1-255]
             *
             * On Entry:
@@ -189,29 +189,29 @@
             *
             * On Exit:
             * @param[out]  status
-            * Detects the condition of the Start (bit3), N/A (bit2), 
+            * Detects the condition of the Start (bit3), N/A (bit2),
             * Address(bit1) and CRC16(bit0) bits.
-            * b3;0=No Err|1=I2CStart prev-not issued, 
+            * b3;0=No Err|1=I2CStart prev-not issued,
             * b2;0=No Err|1=I2C N/A Err,
-            * b1;0=No Err|1=Addr Err, 
+            * b1;0=No Err|1=Addr Err,
             * b0;0=Valid CRC16|1=Invalid CRC16
             *
             * @param[out] wr_status
             * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave.
             * A non-zero value indicates the byte number that NACK’d.
             *
-            * @return 
+            * @return
             * true if device selected and written @n
             * false if failed device select
             **************************************************************/
-            CmdResult I2C_WriteDataOnly(uint8_t length, uint8_t *data, 
-                                   uint8_t &status, uint8_t &wr_status);
-            
-            
+            CmdResult I2C_WriteDataOnly(uint8_t length, uint8_t *data,
+                                        uint8_t &status, uint8_t &wr_status);
+
+
             /**********************************************************//**
-            * @brief Write to selected DS28E17's I2C with Stop.  
+            * @brief Write to selected DS28E17's I2C with Stop.
             * Poll until I2C write complete and receive status info.
-            * 
+            *
             * @details Output on I2C: Write Data [1-255], P
             *
             * On Entry:
@@ -224,29 +224,29 @@
             *
             * On Exit:
             * @param[out]  status
-            * Detects the condition of the Start (bit3), N/A (bit2), 
+            * Detects the condition of the Start (bit3), N/A (bit2),
             * Address(bit1) and CRC16(bit0) bits.
-            * b3;0=No Err|1=I2CStart prev-not issued, 
+            * b3;0=No Err|1=I2CStart prev-not issued,
             * b2;0=No Err|1=I2C N/A Err,
-            * b1;0=No Err|1=Addr Err, 
+            * b1;0=No Err|1=Addr Err,
             * b0;0=Valid CRC16|1=Invalid CRC16
             *
             * @param[out] wr_status
             * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave.
             * A non-zero value indicates the byte number that NACK’d.
             *
-            * @return 
+            * @return
             * true if device selected and written @n
             * false if failed device select
             **************************************************************/
-            CmdResult I2C_WriteDataOnlyWithStop(uint8_t length, uint8_t *data, 
-                                           uint8_t &status, uint8_t &wr_status);
-            
-            
+            CmdResult I2C_WriteDataOnlyWithStop(uint8_t length, uint8_t *data,
+                                                uint8_t &status, uint8_t &wr_status);
+
+
             /**********************************************************//**
             * @brief Write to selected DS28E17's I2C with Stop and poll until I2C write complete
             * receive status info, and read data with a stop at the end.
-            * 
+            *
             * @details Output on I2C:
             * S, Slave Address + Write, Write Data [1-255],
             * Sr, Address + Read, Read Data [1-255], P (NACK last read byte)
@@ -268,11 +268,11 @@
             *
             * On Exit:
             * @param[out]  status
-            * Detects the condition of the Start (bit3), N/A (bit2), 
+            * Detects the condition of the Start (bit3), N/A (bit2),
             * Address(bit1) and CRC16(bit0) bits.
-            * b3;0=No Err|1=I2CStart prev-not issued, 
+            * b3;0=No Err|1=I2CStart prev-not issued,
             * b2;0=No Err|1=I2C N/A Err,
-            * b1;0=No Err|1=Addr Err, 
+            * b1;0=No Err|1=Addr Err,
             * b0;0=Valid CRC16|1=Invalid CRC16
             *
             * @param[out] wr_status
@@ -282,21 +282,21 @@
             * @param[out] *read_data
             * Array of read data received from I2C.
             *
-            * @return 
+            * @return
             * true if device selected, written and read @n
             * false if failed device select or timeout occurred or CRC16 error
             **************************************************************/
-            CmdResult I2C_WriteReadDataWithStop(uint8_t I2C_addr, uint8_t length, 
-                                           uint8_t *data, uint8_t nu_bytes_read, 
-                                           uint8_t &status, uint8_t &wr_status, 
-                                           uint8_t *read_data);
-            
-            
+            CmdResult I2C_WriteReadDataWithStop(uint8_t I2C_addr, uint8_t length,
+                                                uint8_t *data, uint8_t nu_bytes_read,
+                                                uint8_t &status, uint8_t &wr_status,
+                                                uint8_t *read_data);
+
+
             /**********************************************************//**
-            * @brief Selected DS28E17's and send I2C address and poll until 
-            * I2C read address complete, receive status info, and read data 
+            * @brief Selected DS28E17's and send I2C address and poll until
+            * I2C read address complete, receive status info, and read data
             * with a stop at the end.
-            * 
+            *
             * @details Output on I2C:
             * S, Slave Address + Read, Read Data [1-255], P (NACK last read byte)
             *
@@ -310,28 +310,28 @@
             * Number of I2C bytes to read. A value of zero will assert the Error Detected pin (ED).
             *
             * @param[out]  status
-            * Detects the condition of the Start (bit3), N/A (bit2), 
+            * Detects the condition of the Start (bit3), N/A (bit2),
             * Address(bit1) and CRC16(bit0) bits.
-            * b3;0=No Err|1=I2CStart prev-not issued, 
+            * b3;0=No Err|1=I2CStart prev-not issued,
             * b2;0=No Err|1=I2C N/A Err,
-            * b1;0=No Err|1=Addr Err, 
+            * b1;0=No Err|1=Addr Err,
             * b0;0=Valid CRC16|1=Invalid CRC16
             *
             * @param[out] *read_data
             * Array of read data received from I2C.
             *
-            * @return 
+            * @return
             * true if device selected, written and read @n
             * false if failed device select or timeout occurred or CRC16 error
             **************************************************************/
-            CmdResult I2C_ReadDataWithStop(uint8_t I2C_addr, uint8_t nu_bytes_read, 
-                                      uint8_t &status, uint8_t *read_data);
-            
-            
+            CmdResult I2C_ReadDataWithStop(uint8_t I2C_addr, uint8_t nu_bytes_read,
+                                           uint8_t &status, uint8_t *read_data);
+
+
             /**********************************************************//**
             * @brief Write to Configuration Register of DS28E17.
-            * 
-            * @details 
+            *
+            * @details
             *
             * On Entry:
             * @param[in] data
@@ -344,30 +344,30 @@
             * false if failed device select
             **************************************************************/
             CmdResult WriteConfigReg(uint8_t data);
-            
-            
+
+
             /**********************************************************//**
             * @brief Read the Configuration Register of DS28E17.
-            * 
-            * @details 
+            *
+            * @details
             *
             * On Entry:
             *
             * On Exit:
             *
-            * @return 
+            * @return
             * true if device selected and read correctly @n
             * false if failed device select
             **************************************************************/
             CmdResult ReadConfigReg(uint8_t & config);
-            
-            
+
+
             /**********************************************************//**
             * @brief Disable 1-Wire Mode DS28E17 and activates the input detection pin.
             * Immediately after the command, all 1-Wire signaling will be ignored
             * until the 1W_DET pin is high for more than 3ms.
-            * 
-            * @details 
+            *
+            * @details
             *
             * On Entry:
             *
@@ -378,15 +378,15 @@
             * false if failed device select
             **************************************************************/
             CmdResult DisableOWMode();
-            
-            
+
+
             /**********************************************************//**
             * @brief The Enable Sleep Mode command puts the device into a low current mode.
             * All 1-Wire communication is ignored until woken up. Immediately after
             * the command, the device monitors the WAKEUP input pin and
             * exits sleep mode on a rising edge.
-            * 
-            * @details 
+            *
+            * @details
             *
             * On Entry:
             *
@@ -394,17 +394,17 @@
             *
             * @return
             * true if device selected and written @n
-            * false if failed device select*    
+            * false if failed device select*
             **************************************************************/
             CmdResult EnableSleepMode();
-            
-            
+
+
             /**********************************************************//**
-            * @brief Read the Device Revision of DS28E17. The revision value 
-            *  should never be zero.  The upper nibble is the major revision 
+            * @brief Read the Device Revision of DS28E17. The revision value
+            *  should never be zero.  The upper nibble is the major revision
             *  and the lower nibble is the minor revision.
-            * 
-            * @details 
+            *
+            * @details
             *
             * On Entry:
             *
@@ -415,27 +415,27 @@
             * false if failed device select (i.e. 00h)
             **************************************************************/
             CmdResult ReadDeviceRevision(uint8_t & rev);
-            
+
         private:
-            
-            CmdResult send_packet(const uint8_t * data, uint8_t data_length, 
+
+            CmdResult send_packet(const uint8_t * data, uint8_t data_length,
                                   uint8_t & status, uint8_t & wr_status);
-            
+
             //overloaded function for I2C read only command 
-            CmdResult send_packet(const uint8_t * data, uint8_t data_length, 
+            CmdResult send_packet(const uint8_t * data, uint8_t data_length,
                                   uint8_t & status);
-            
+
             Masters::OneWireMaster &_owm;
-            
+
             uint16_t _crc16;
             uint8_t _i2c_speed;
-            
+
             static const uint16_t _oddparity[16];
-            
+
             uint16_t docrc16(uint16_t data);
         };
     }
 }
 
-#endif /*DS28E17_H*/ 
+#endif