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:
77:529edb329ee0
Parent:
76:84e6c4994e29
Child:
78:0cbbac7f2016
--- a/Masters/OneWireMaster.h	Sat May 14 14:27:56 2016 -0500
+++ b/Masters/OneWireMaster.h	Mon May 16 10:36:30 2016 -0500
@@ -73,6 +73,28 @@
             TimeoutError,
             OperationFailure
         };
+        
+        /// State used by all ROM ID search functions.
+        struct SearchState
+        {
+            RomId romId;
+            uint8_t last_discrepancy;
+            uint8_t last_family_discrepancy;
+            bool last_device_flag;
+
+            /// Reset to the search state to start at the beginning.
+            void reset();
+            
+            /// Setup the search to find the device type 'family_code'
+            /// on the next call to OWNext() if it is present.
+            void findFamily(uint8_t familyCode);
+
+            /// Setup the search to skip the current device type on the
+            /// next call to OWNext().
+            void skipCurrentFamily();
+
+            SearchState() { reset(); }
+        };
 
         /// Perform a CRC16 calculation.
         /// @param crc16 Beginning state of the CRC generator.
@@ -166,6 +188,60 @@
         CmdResult OWReadByte(uint8_t & recvByte) { return OWReadByteSetLevel(recvByte, NormalLevel); }
         CmdResult OWWriteBytePower(uint8_t sendByte) { return OWWriteByteSetLevel(sendByte, StrongLevel); }
         CmdResult OWReadBytePower(uint8_t & recvByte) { return OWReadByteSetLevel(recvByte, StrongLevel); }
+        
+        /// Find the 'first' devices on the 1-Wire network.
+        CmdResult OWFirst(SearchState & searchState);
+
+        /// Find the 'next' devices on the 1-Wire network.
+        CmdResult OWNext(SearchState & searchState);
+
+        /// Verify that the device with the specified ROM ID is present.
+        CmdResult OWVerify(const RomId & romId);
+
+        /// Use Read ROM command to read ROM ID from device on bus.
+        /// @note Only use this command with a single drop bus, data
+        ///       collisions will occur if more than 1 device on bus.
+        /// @param[out] romId ROM ID read from device.
+        CmdResult OWReadRom(RomId & romId);
+
+        /// Issue Skip ROM command on bus.
+        /// @note Only use this command with a single drop bus, data
+        ///       collisions will occur if more than 1 device on bus.
+        CmdResult OWSkipRom();
+
+        /// Use the Match ROM command to select the device by its known ID.
+        /// @param[in] romId ROM ID of device to select.
+        CmdResult OWMatchRom(const RomId & romId);
+
+        /// Issue Overdrive Skip ROM command on bus.
+        /// @details This command causes all devices supporting Overdrive
+        ///          mode to switch to Overdrive timing.
+        /// @note Only use this command with a single drop bus, data
+        ///       collisions will occur if more than 1 device on bus.
+        CmdResult OWOverdriveSkipRom();
+
+        
+        CmdResult OWOverdriveMatchRom(const RomId & romId);
+
+        /// Perform a Resume ROM command on bus.
+        /// @details Resumes communication with the last device selected
+        ///          though a Match ROM or Search ROM operation.
+        CmdResult OWResume();
+
+        /**********************************************************//**
+        * @brief Enumerate all devices on the 1-Wire bus.
+        *
+        * @details The 'OWSearch' function does a general search.  This
+        *        function continues from the previous search state. The
+        *        search state can be reset by using the 'OWFirst'
+        *        function. This function contains one parameter
+        *        'alarm_only'. When 'alarm_only' is TRUE (1) the find
+        *        alarm command 0xEC is sent instead of the normal search
+        *        command 0xF0. Using the find alarm command 0xEC will
+        *        limit the search to only 1-Wire devices that are in an
+        *        'alarm' state.
+        **************************************************************/
+        CmdResult OWSearch(SearchState & searchState);
     };
 }