Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Committer:
IanBenzMaxim
Date:
Fri Jun 17 15:24:37 2016 -0500
Revision:
90:c233d1c265ff
Child:
93:e496a45ce796
Moved ROM utility functions outside of the OneWireMaster class.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IanBenzMaxim 90:c233d1c265ff 1 #ifndef OneWire_RomCommands
IanBenzMaxim 90:c233d1c265ff 2 #define OneWire_RomCommands
IanBenzMaxim 90:c233d1c265ff 3
IanBenzMaxim 90:c233d1c265ff 4 #include <stdint.h>
IanBenzMaxim 90:c233d1c265ff 5 #include "RomId.h"
IanBenzMaxim 90:c233d1c265ff 6 #include "Masters/OneWireMaster.h"
IanBenzMaxim 90:c233d1c265ff 7
IanBenzMaxim 90:c233d1c265ff 8 namespace OneWire
IanBenzMaxim 90:c233d1c265ff 9 {
IanBenzMaxim 90:c233d1c265ff 10 namespace RomCommands
IanBenzMaxim 90:c233d1c265ff 11 {
IanBenzMaxim 90:c233d1c265ff 12 /// State used by all ROM ID search functions.
IanBenzMaxim 90:c233d1c265ff 13 struct SearchState
IanBenzMaxim 90:c233d1c265ff 14 {
IanBenzMaxim 90:c233d1c265ff 15 RomId romId;
IanBenzMaxim 90:c233d1c265ff 16 uint8_t last_discrepancy;
IanBenzMaxim 90:c233d1c265ff 17 uint8_t last_family_discrepancy;
IanBenzMaxim 90:c233d1c265ff 18 bool last_device_flag;
IanBenzMaxim 90:c233d1c265ff 19
IanBenzMaxim 90:c233d1c265ff 20 /// Reset to the search state to start at the beginning.
IanBenzMaxim 90:c233d1c265ff 21 void reset();
IanBenzMaxim 90:c233d1c265ff 22
IanBenzMaxim 90:c233d1c265ff 23 /// Setup the search to find the device type 'family_code'
IanBenzMaxim 90:c233d1c265ff 24 /// on the next call to OWNext() if it is present.
IanBenzMaxim 90:c233d1c265ff 25 void findFamily(uint8_t familyCode);
IanBenzMaxim 90:c233d1c265ff 26
IanBenzMaxim 90:c233d1c265ff 27 /// Setup the search to skip the current device type on the
IanBenzMaxim 90:c233d1c265ff 28 /// next call to OWNext().
IanBenzMaxim 90:c233d1c265ff 29 void skipCurrentFamily();
IanBenzMaxim 90:c233d1c265ff 30
IanBenzMaxim 90:c233d1c265ff 31 SearchState() { reset(); }
IanBenzMaxim 90:c233d1c265ff 32 };
IanBenzMaxim 90:c233d1c265ff 33
IanBenzMaxim 90:c233d1c265ff 34 /// Find the 'first' devices on the 1-Wire bus.
IanBenzMaxim 90:c233d1c265ff 35 OneWireMaster::CmdResult OWFirst(OneWireMaster & master, SearchState & searchState);
IanBenzMaxim 90:c233d1c265ff 36
IanBenzMaxim 90:c233d1c265ff 37 /// Find the 'next' devices on the 1-Wire bus.
IanBenzMaxim 90:c233d1c265ff 38 OneWireMaster::CmdResult OWNext(OneWireMaster & master, SearchState & searchState);
IanBenzMaxim 90:c233d1c265ff 39
IanBenzMaxim 90:c233d1c265ff 40 /// Verify that the device with the specified ROM ID is present.
IanBenzMaxim 90:c233d1c265ff 41 OneWireMaster::CmdResult OWVerify(OneWireMaster & master, const RomId & romId);
IanBenzMaxim 90:c233d1c265ff 42
IanBenzMaxim 90:c233d1c265ff 43 /// Use Read ROM command to read ROM ID from device on bus.
IanBenzMaxim 90:c233d1c265ff 44 /// @note Only use this command with a single drop bus, data
IanBenzMaxim 90:c233d1c265ff 45 /// collisions will occur if more than 1 device on bus.
IanBenzMaxim 90:c233d1c265ff 46 /// @param[out] romId ROM ID read from device.
IanBenzMaxim 90:c233d1c265ff 47 OneWireMaster::CmdResult OWReadRom(OneWireMaster & master, RomId & romId);
IanBenzMaxim 90:c233d1c265ff 48
IanBenzMaxim 90:c233d1c265ff 49 /// Issue Skip ROM command on bus.
IanBenzMaxim 90:c233d1c265ff 50 /// @note Only use this command with a single drop bus, data
IanBenzMaxim 90:c233d1c265ff 51 /// collisions will occur if more than 1 device on bus.
IanBenzMaxim 90:c233d1c265ff 52 OneWireMaster::CmdResult OWSkipRom(OneWireMaster & master);
IanBenzMaxim 90:c233d1c265ff 53
IanBenzMaxim 90:c233d1c265ff 54 /// Use the Match ROM command to select the device by its known ID.
IanBenzMaxim 90:c233d1c265ff 55 /// @note This command causes all devices supporting Overdrive
IanBenzMaxim 90:c233d1c265ff 56 /// mode to switch to Overdrive timing.
IanBenzMaxim 90:c233d1c265ff 57 /// @param[in] romId ROM ID of device to select.
IanBenzMaxim 90:c233d1c265ff 58 OneWireMaster::CmdResult OWMatchRom(OneWireMaster & master, const RomId & romId);
IanBenzMaxim 90:c233d1c265ff 59
IanBenzMaxim 90:c233d1c265ff 60 /// Issue Overdrive Skip ROM command on bus.
IanBenzMaxim 90:c233d1c265ff 61 /// @note This command causes all devices supporting Overdrive
IanBenzMaxim 90:c233d1c265ff 62 /// mode to switch to Overdrive timing.
IanBenzMaxim 90:c233d1c265ff 63 /// @note Only use this command with a single drop bus, data
IanBenzMaxim 90:c233d1c265ff 64 /// collisions will occur if more than 1 device on bus.
IanBenzMaxim 90:c233d1c265ff 65 OneWireMaster::CmdResult OWOverdriveSkipRom(OneWireMaster & master);
IanBenzMaxim 90:c233d1c265ff 66
IanBenzMaxim 90:c233d1c265ff 67 /// Use the Overdrive Match ROM command to select the device by its known ID.
IanBenzMaxim 90:c233d1c265ff 68 /// @param[in] romId ROM ID of device to select.
IanBenzMaxim 90:c233d1c265ff 69 OneWireMaster::CmdResult OWOverdriveMatchRom(OneWireMaster & master, const RomId & romId);
IanBenzMaxim 90:c233d1c265ff 70
IanBenzMaxim 90:c233d1c265ff 71 /// Perform a Resume ROM command on bus.
IanBenzMaxim 90:c233d1c265ff 72 /// @details Resumes communication with the last device selected
IanBenzMaxim 90:c233d1c265ff 73 /// though a Match ROM or Search ROM operation.
IanBenzMaxim 90:c233d1c265ff 74 OneWireMaster::CmdResult OWResume(OneWireMaster & master);
IanBenzMaxim 90:c233d1c265ff 75
IanBenzMaxim 90:c233d1c265ff 76 /// Find device on the 1-Wire bus.
IanBenzMaxim 90:c233d1c265ff 77 /// @details This command uses the Search ROM command to enumerate all 1-Wire devices in sequence.
IanBenzMaxim 90:c233d1c265ff 78 /// Begin with a new search state and continue using the same search state until the last
IanBenzMaxim 90:c233d1c265ff 79 /// device flag is set which indicates that all devices have been discovered.
IanBenzMaxim 90:c233d1c265ff 80 OneWireMaster::CmdResult OWSearch(OneWireMaster & master, SearchState & searchState);
IanBenzMaxim 90:c233d1c265ff 81 }
IanBenzMaxim 90:c233d1c265ff 82 }
IanBenzMaxim 90:c233d1c265ff 83
IanBenzMaxim 90:c233d1c265ff 84 #endif