Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Revision:
115:a1ca2f3bf46d
Parent:
110:a3b5e2a4fdf2
Child:
116:8058bb54e959
diff -r 13e2865603df -r a1ca2f3bf46d Slaves/Memory/DS2431/DS2431.h
--- a/Slaves/Memory/DS2431/DS2431.h	Tue Aug 09 12:35:22 2016 -0500
+++ b/Slaves/Memory/DS2431/DS2431.h	Mon Aug 22 05:38:20 2016 +0000
@@ -30,47 +30,133 @@
 * ownership rights.
 **********************************************************************/
 
-#ifndef OneWire_Switches_DS2413
-#define OneWire_Switches_DS2413
+#ifndef OneWire_Slaves_Memory_DS2431
+#define OneWire_Slaves_Memory_DS2431
 
-#include <stdint.h>
 #include "Slaves/OneWireSlave.h"
 
 namespace OneWire
 {
+    class OneWireMaster;
+    
     /**
     * @brief DS2431 
     */
     class DS2431 : public OneWireSlave
     {
     public:
-    
-        ///Result of operations
-        enum CmdResult
-        {
-            Success,
-            CommsReadError,
-            CommsWriteError,
-            OpFailure
-        };
 
         /**********************************************************//**
         * @brief DS2431 constructor
         *
-        * @details
+        * @details Instantiate a DS2431 object that encapsulates the 
+        * 1-Wire master and ROM commands for selecting the device via 
+        * the RandomAccessRomIterator sub-class passed as an argumnent 
+        * to the constructor.  
+        *
+        * This allows the user to focus on the use of the DS2431 in
+        * their application vs. the low level details of the 1-Wire 
+        * protocol.
         *
         * On Entry:
-        *     @param[in] owm - reference to 1-wire master
+        * @param[in] selector - reference to RandomAccessRomIterator
+        * sub-class; i.e. SingledropRomIterator, MultidropRomIterator, etc.
+        * See RomId/RomIterator.h
         *
         * On Exit:
         *
         * @return
         **************************************************************/
         DS2431(RandomAccessRomIterator &selector);
-
-    private:
-
+        
+        /**********************************************************//**
+        * @brief writeScratchPad
+        *
+        * @details Writes 8 bytes to the scratchpad.
+        *
+        * On Entry:
+        * @param[in] targetAddress - EEPROM memory address that this data 
+        * will be copied to.  Must be on row boundary.
+        *
+        * @param[in] data - Pointer to memory holding data.
+        *
+        * On Exit:
+        *
+        * @return Result of operation
+        **************************************************************/
+        OneWireSlave::CmdResult writeScratchPad(uint16_t targetAddress, uint8_t *data);
+        
+        /**********************************************************//**
+        * @brief readScratchPad
+        *
+        * @details Reads contents of scratchpad.
+        *
+        * On Entry:
+        * @param[in] data - Pointer to memory for storing data, 11 bytes.
+        *
+        * On Exit:
+        *
+        * @return Result of operation
+        **************************************************************/
+        OneWireSlave::CmdResult readScratchPad(uint8_t *data);
+        
+        /**********************************************************//**
+        * @brief copyScratchPad
+        *
+        * @details Copies contents of sractshpad to EEPROM.
+        *
+        * On Entry:
+        * @param[in] targetAddress - EEPROM memory address that this data 
+        * will be copied to.  Must be on row boundary.
+        *
+        * @param[in] esByte - Returned from reading scratchpad.
+        *
+        * On Exit:
+        *
+        * @return Result of operation
+        **************************************************************/
+        OneWireSlave::CmdResult copyScratchPad(uint16_t targetAddress, uint8_t esByte);
+        
+        /**********************************************************//**
+        * @brief writeBlock
+        *
+        * @details Writes data to EEPROM.  Wraps up writeScratchPad,
+        * readScratchPad and copyScratchPad into single function.
+        * 
+        * On Entry:
+        * @param[in] targetAddress - EEPROM memory address to start 
+        * writting at.
+        *
+        * @param[in] data - Pointer to memory holding data.
+        *
+        * @param[in] numBytes - Number of bytes to write.
+        *
+        * On Exit: 
+        *
+        * @return Result of operation
+        **************************************************************/
+        OneWireSlave::CmdResult writeBlock(uint16_t targetAddress, uint8_t *data, uint8_t numBytes);
+        
+        /**********************************************************//**
+        * @brief readBlock
+        *
+        * @details Reads block of data from EEPROM memory.
+        *
+        * On Entry:
+        * @param[in] targetAddress - EEPROM memory address to start.
+        * reading from
+        *
+        * @param[in] data - Pointer to memory for storing data.
+        *
+        * @param[in] numBytes - Number of bytes to read.
+        *
+        * On Exit:
+        *
+        * @return Result of operation
+        **************************************************************/
+        OneWireSlave::CmdResult readBlock(uint16_t targetAddress, uint8_t *data, uint8_t numBytes);
+    
     };
 }
 
-#endif
+#endif /*OneWire_Slaves_Memory_DS2431*/
\ No newline at end of file