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 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 |
diff -r cf38f48a2a49 -r 85b71cfd617e RomId/RomCommands.cpp --- 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
diff -r cf38f48a2a49 -r 85b71cfd617e RomId/RomCommands.h --- 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); + } }