Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Revision:
26:a361e3f42ba5
Parent:
24:8942d8478d68
Child:
27:d5aaefa252f1
--- a/OneWire_Masters/OneWireMaster.h	Tue Mar 22 15:18:00 2016 -0500
+++ b/OneWire_Masters/OneWireMaster.h	Wed Mar 23 15:25:40 2016 -0500
@@ -68,6 +68,8 @@
     
     static uint16_t calculateCRC16(const uint8_t * data, size_t data_offset, size_t data_len, uint16_t crc = 0);
     
+    virtual ~OneWireMaster() { }
+    
     
     /**********************************************************//**
     * @brief OWInitMaster()
@@ -116,7 +118,7 @@
     *
     * @return CmdResult - zero on success, non-zero on failure
     **************************************************************/
-    virtual CmdResult OWTouchBit(uint8_t & sendrecvbit) = 0;
+    virtual CmdResult OWTouchBit(uint8_t & sendrecvbit, OW_LEVEL after_level) = 0;
     
     
     /**********************************************************//**
@@ -134,7 +136,7 @@
     *
     * @return CmdResult - zero on success, non-zero on failure
     **************************************************************/
-    virtual CmdResult OWWriteByte(uint8_t sendbyte) = 0;
+    virtual CmdResult OWWriteByte(uint8_t sendbyte, OW_LEVEL after_level) = 0;
     
     
     /**********************************************************//**
@@ -149,7 +151,7 @@
     *
     * @return CmdResult - zero on success, non-zero on failure
     **************************************************************/
-    virtual CmdResult OWReadByte(uint8_t & recvbyte) = 0;
+    virtual CmdResult OWReadByte(uint8_t & recvbyte, OW_LEVEL after_level) = 0;
     
     
     /**********************************************************//**
@@ -243,116 +245,17 @@
     **************************************************************/
     virtual CmdResult OWLevel(OW_LEVEL new_level) = 0;
     
-    
-    /**********************************************************//**
-    * @brief OWWriteBytePower()
-    * 
-    * @details Send 8 bits of communication to the 1-Wire Net and 
-    *          verify that the 8 bits read from the 1-Wire Net is the 
-    *          same (write operation).  The parameter 'sendbyte' least 
-    *          significant 8 bits are used.  After the 8 bits are sent 
-    *          change the level of the 1-Wire net.
-    *
-    * On Entry:
-    *     @param[in] 'sendbyte' - 8 bits to send (least significant bit)
-    *
-    * @return CmdResult - zero on success, non-zero on failure
-    **************************************************************/
-    virtual CmdResult OWWriteBytePower(uint8_t sendbyte) = 0;
-    
-    
-    /**********************************************************//**
-    * @brief OWReadBitPower()
-    * 
-    * @details Send 1 bit of communication to the 1-Wire Net and verify
-    *          that the response matches the 'applyPowerResponse' bit 
-    *          and apply power delivery to the 1-Wire net.  Note that 
-    *          some implementations may apply the power first and then 
-    *          turn it off if the response is incorrect. 
-    *
-    * On Entry:
-    *     @param[in] 'applyPowerResponse' - 1 bit response to check, 
-    *                                       if correct 
-    *                                       then start power delivery 
-    *
-    * @return CmdResult - zero on success, non-zero on failure
-    **************************************************************/
-    virtual CmdResult OWReadBitPower(uint8_t applyPowerResponse) = 0;
-    
-    
-    virtual CmdResult OWReadBytePower(uint8_t & recvbyte) = 0;
-
-    
-    //Part of OneWireInterface that should only be implemented once
-    
+    CmdResult OWWriteBit(uint8_t sendbit, OW_LEVEL after_level) { return OWTouchBit(sendbit, after_level); }
+    CmdResult OWReadBit(uint8_t & recvbit, OW_LEVEL after_level) { recvbit = 0x01; return OWTouchBit(recvbit, after_level); }
     
-    /**********************************************************//**
-    * @brief OWWriteBit()
-    * 
-    * @details Send 1 bit of communication to the 1-Wire Net.
-    *          The parameter 'sendbit' least significant bit is used.
-    *
-    * On Entry:
-    *     @param[in] 'sendbit' - 1 bit to send (least significant byte)
-    *
-    * On Exit:
-    *
-    * @return CmdResult - zero on success, non-zero on failure
-    **************************************************************/
-    CmdResult OWWriteBit(uint8_t sendbit);
-    
-    
-    /**********************************************************//**
-    * @brief OWReadBit()
-    * 
-    * @details Reads 1 bit of communication from the 1-Wire Net and 
-    *          returns the result
-    *
-    * On Entry:
-    *
-    * On Exit:
-    *
-    * @return CmdResult - zero on success, non-zero on failure
-    **************************************************************/
-    CmdResult OWReadBit(uint8_t & recvbit);
-    
-    
-    /**********************************************************//**
-    * @brief OWTouchByte()
-    * 
-    * @details Send 8 bits of communication to the 1-Wire Net and 
-    *        return the result 8 bits read from the 1-Wire Net.  The 
-    *        parameter 'sendbyte' least significant 8 bits are used 
-    *        and the least significant 8 bits of the result is the 
-    *        return byte.
-    *
-    * On Entry:
-    *     @param[in] 'sendbyte' - 8 bits to send (least significant byte)
-    *
-    * On Exit:
-    *
-    * @return CmdResult - zero on success, non-zero on failure
-    **************************************************************/
-    virtual CmdResult OWTouchByte(uint8_t & sendrecvbyte);
-    
-    
-    /**********************************************************//**
-    * @brief OWBlock()
-    * 
-    * @details The 'OWBlock' transfers a block of data to and from the
-    *        1-Wire Net. The result is returned in the same buffer.
-    *
-    * On Entry:
-    *     @param[in] 'tran_buf' - pointer to a block of unsigned
-    *                             chars of length 'tran_len' that 
-    *                             will be sent to the 1-Wire Net
-    *     @param[in] 'tran_len' - length in bytes to transfer
-    *
-    * On Exit:
-    *
-    * @return CmdResult - zero on success, non-zero on failure 
-    **************************************************************/
-    virtual CmdResult OWBlock(uint8_t *tran_buf, uint8_t tran_len);
+    CmdResult OWWriteBit(uint8_t sendbit) { return OWWriteBit(sendbit, LEVEL_NORMAL); }
+    CmdResult OWReadBit(uint8_t & recvbit) { return OWReadBit(recvbit, LEVEL_NORMAL); }
+    CmdResult OWWriteBitPower(uint8_t sendbit) { return OWWriteBit(sendbit, LEVEL_STRONG); }
+    CmdResult OWReadBitPower(uint8_t & recvbit) { return OWReadBit(recvbit, LEVEL_STRONG); }
+    CmdResult OWWriteByte(uint8_t sendbyte) { return OWWriteByte(sendbyte, LEVEL_NORMAL); }
+    CmdResult OWReadByte(uint8_t & recvbyte) { return OWReadByte(recvbyte, LEVEL_NORMAL); }
+    CmdResult OWWriteBytePower(uint8_t sendbyte) { return OWWriteByte(sendbyte, LEVEL_STRONG); }
+    CmdResult OWReadBytePower(uint8_t & recvbyte) { return OWReadByte(recvbyte, LEVEL_STRONG); }
     
     
     /**********************************************************//**