1-Wire® library for mbed. Complete 1-Wire library that supports our silicon masters along with a bit-bang master on the MAX32600MBED platform with one common interface for mbed. Slave support has also been included and more slaves will be added as time permits.

Dependents:   MAXREFDES131_Qt_Demo MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAXREFDES130_131_Demo ... more

Superseded by MaximInterface.

Revision:
116:8058bb54e959
Parent:
115:a1ca2f3bf46d
Child:
117:632abc887f95
diff -r a1ca2f3bf46d -r 8058bb54e959 Slaves/Memory/DS2431/DS2431.h
--- a/Slaves/Memory/DS2431/DS2431.h	Mon Aug 22 05:38:20 2016 +0000
+++ b/Slaves/Memory/DS2431/DS2431.h	Mon Aug 22 21:35:47 2016 +0000
@@ -51,7 +51,7 @@
         *
         * @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 
+        * the RandomAccessRomIterator sub-class passed as an argument 
         * to the constructor.  
         *
         * This allows the user to focus on the use of the DS2431 in
@@ -70,7 +70,50 @@
         DS2431(RandomAccessRomIterator &selector);
         
         /**********************************************************//**
-        * @brief writeScratchPad
+        * @brief writeMemory
+        *
+        * @details Writes data to EEPROM.  Wraps up writeScratchPad,
+        * readScratchPad and copyScratchPad into single function.
+        * 
+        * On Entry:
+        * @param[in] targetAddress - EEPROM memory address to start 
+        * writing 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 writeMemory(uint16_t targetAddress, const uint8_t *data, uint8_t numBytes);
+        
+        /**********************************************************//**
+        * @brief readMemory
+        *
+        * @details Reads block of data from EEPROM memory.
+        *
+        * On Entry:
+        * @param[in] targetAddress - EEPROM memory address to start.
+        * reading from
+        *
+        * @param[out] data - Pointer to memory for storing data.
+        *
+        * @param[in] numBytes - Number of bytes to read.
+        *
+        * On Exit:
+        *
+        * @return Result of operation
+        **************************************************************/
+        OneWireSlave::CmdResult readMemory(uint16_t targetAddress, uint8_t *data, uint8_t numBytes);
+        
+    private:
+    
+        typedef array<uint8_t, 8> Scratchpad;
+    
+        /**********************************************************//**
+        * @brief writeScratchpad
         *
         * @details Writes 8 bytes to the scratchpad.
         *
@@ -78,30 +121,30 @@
         * @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.
+        * @param[in] data - reference to bounded array type Scratchpad.
         *
         * On Exit:
         *
         * @return Result of operation
         **************************************************************/
-        OneWireSlave::CmdResult writeScratchPad(uint16_t targetAddress, uint8_t *data);
+        OneWireSlave::CmdResult writeScratchpad(uint16_t targetAddress, const Scratchpad &data);
         
         /**********************************************************//**
-        * @brief readScratchPad
+        * @brief readScratchpad
         *
         * @details Reads contents of scratchpad.
         *
         * On Entry:
-        * @param[in] data - Pointer to memory for storing data, 11 bytes.
+        * @param[out] data - reference to bounded array type Scratchpad.
         *
         * On Exit:
         *
         * @return Result of operation
         **************************************************************/
-        OneWireSlave::CmdResult readScratchPad(uint8_t *data);
+        OneWireSlave::CmdResult readScratchpad(Scratchpad &data, uint8_t &esByte);
         
         /**********************************************************//**
-        * @brief copyScratchPad
+        * @brief copyScratchpad
         *
         * @details Copies contents of sractshpad to EEPROM.
         *
@@ -115,47 +158,7 @@
         *
         * @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);
-    
+        OneWireSlave::CmdResult copyScratchpad(uint16_t targetAddress, uint8_t esByte);
     };
 }