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.

Slaves/RomCommands.h

Committer:
j3
Date:
2016-06-24
Revision:
93:e496a45ce796
Parent:
90:c233d1c265ff
Child:
98:c4ac93efc036

File content as of revision 93:e496a45ce796:

#ifndef OneWire_RomCommands
#define OneWire_RomCommands

#include <stdint.h>
#include "RomId.h"
#include "Masters/OneWireMaster.h"


namespace OneWire
{
    namespace RomCommands
    {
        /// 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(); }
        };
        
        ///Find the 'first' devices on the 1-Wire bus.
        OneWireMaster::CmdResult OWFirst(OneWireMaster & master, SearchState & searchState);

        /// Find the 'next' devices on the 1-Wire bus.
        OneWireMaster::CmdResult OWNext(OneWireMaster & master, SearchState & searchState);

        /// Verify that the device with the specified ROM ID is present.
        OneWireMaster::CmdResult OWVerify(OneWireMaster & master, 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.
        OneWireMaster::CmdResult OWReadRom(OneWireMaster & master, 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.
        OneWireMaster::CmdResult OWSkipRom(OneWireMaster & master);

        /// Use the Match ROM command to select the device by its known ID.
        /// @note This command causes all devices supporting Overdrive
        ///       mode to switch to Overdrive timing.
        /// @param[in] romId ROM ID of device to select.
        OneWireMaster::CmdResult OWMatchRom(OneWireMaster & master, const RomId & romId);

        /// Issue Overdrive Skip ROM command on bus.
        /// @note 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.
        OneWireMaster::CmdResult OWOverdriveSkipRom(OneWireMaster & master);

        /// Use the Overdrive Match ROM command to select the device by its known ID.
        /// @param[in] romId ROM ID of device to select.
        OneWireMaster::CmdResult OWOverdriveMatchRom(OneWireMaster & master, 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.
        OneWireMaster::CmdResult OWResume(OneWireMaster & master);

        /// Find device on the 1-Wire bus.
        /// @details This command uses the Search ROM command to enumerate all 1-Wire devices in sequence.
        ///          Begin with a new search state and continue using the same search state until the last
        ///          device flag is set which indicates that all devices have been discovered.
        OneWireMaster::CmdResult OWSearch(OneWireMaster & master, SearchState & searchState);
    }
}

#endif