Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Revision 142:85b71cfd617e, committed 2019-08-13
- Comitter:
- mfruge
- Date:
- Tue Aug 13 14:42:37 2019 +0000
- Parent:
- 141:cf38f48a2a49
- Commit message:
- Added functions to ROMCommands to add Alarm Search functionality
Changed in this revision
RomId/RomCommands.cpp | Show annotated file Show diff for this revision Revisions of this file |
RomId/RomCommands.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/RomId/RomCommands.cpp Fri Feb 17 21:54:14 2017 +0000 +++ b/RomId/RomCommands.cpp Tue Aug 13 14:42:37 2019 +0000 @@ -46,7 +46,8 @@ SkipRomCmd = 0xCC, ResumeCmd = 0xA5, OverdriveSkipRomCmd = 0x3C, - OverdriveMatchRomCmd = 0x69 + OverdriveMatchRomCmd = 0x69, + AlarmSearchCmd = 0xEC }; void SearchState::reset() @@ -239,6 +240,27 @@ OneWireMaster::CmdResult OWSearch(OneWireMaster & master, SearchState & searchState) { + return OWSearchAll(master, searchState, false); + } + + OneWireMaster::CmdResult OWAlarmSearch(OneWireMaster & master, SearchState & searchState) + { + return OWSearchAll(master, searchState, true); + } + + OneWireMaster::CmdResult OWFirstAlarm(OneWireMaster & master, SearchState & searchState) + { + searchState.reset(); + return OWAlarmSearch(master, searchState); + } + + OneWireMaster::CmdResult OWNextAlarm(OneWireMaster & master, SearchState & searchState) + { + return OWAlarmSearch(master, searchState); + } + + OneWireMaster::CmdResult OWSearchAll(OneWireMaster & master, SearchState & searchState, bool alarmSearch) + { uint8_t id_bit_number; uint8_t last_zero, rom_byte_number; uint8_t id_bit, cmp_id_bit; @@ -267,7 +289,12 @@ } // issue the search command - master.OWWriteByte(SearchRomCmd); + if(alarmSearch){ + master.OWWriteByte(AlarmSearchCmd); + } + else{ + master.OWWriteByte(SearchRomCmd); + } // loop to do the search do
--- a/RomId/RomCommands.h Fri Feb 17 21:54:14 2017 +0000 +++ b/RomId/RomCommands.h Tue Aug 13 14:42:37 2019 +0000 @@ -112,6 +112,24 @@ /// 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); + + /// Find Alarming Devices on 1-Wire bus. + /// @details This command uses the Alarm Search ROM command to enumerate all 1-Wire devices with active alarms + /// 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 OWAlarmSearch(OneWireMaster & master, SearchState & searchState); + + /// Find the first Alarming device on the 1-Wire bus. + /// @details This command resets the SearchState and uses the Alarm Search command to enumerate the first actively alarming device on the bus, in numerical order by ROM ID. + OneWireMaster::CmdResult OWFirstAlarm(OneWireMaster & master, SearchState & searchState); + + /// Find the next Alarming Device on the 1-Wire bus. + /// @details This command uses the Alarm Search command to enumerate the next actively alarming device on the bus, which is determined by the current searchState. + OneWireMaster::CmdResult OWNextAlarm(OneWireMaster & master, SearchState & searchState); + + /// Helper function for the above search functions + OneWireMaster::CmdResult OWSearchAll(OneWireMaster & master, SearchState & searchState, bool alarmSearch); + } }