Library for interfacing with the MAX4822 relay driver.
Dependents: MAXREFDES130_131_Demo MAXREFDES130_Demo
Revision 3:90f7cd976f18, committed 2016-08-02
- Comitter:
- j3
- Date:
- Tue Aug 02 23:17:48 2016 +0000
- Parent:
- 2:7b30a3361e40
- Commit message:
- Updated set_all/reset_all fxs to update private data array
Changed in this revision
MAX4822.cpp | Show annotated file Show diff for this revision Revisions of this file |
MAX4822.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7b30a3361e40 -r 90f7cd976f18 MAX4822.cpp --- a/MAX4822.cpp Tue Aug 02 19:23:49 2016 +0000 +++ b/MAX4822.cpp Tue Aug 02 23:17:48 2016 +0000 @@ -57,19 +57,40 @@ } //********************************************************************* -void MAX4822::set_all_relays(DigitalOut & set) +MAX4822::CmdResult MAX4822::set_all_relays(DigitalOut & set, uint8_t device) { - set = 0; - wait_us(1); - set = 1; + MAX4822::CmdResult result = OpFailure; + + if(device <= m_num_devices) + { + set = 0; + wait_us(1); + set = 1; + + m_relay_data[device] = 0xFF; + result = MAX4822::Success; + } + + return result; } //********************************************************************* -void MAX4822::reset_all_relays(DigitalOut & reset) +MAX4822::CmdResult MAX4822::reset_all_relays(DigitalOut & reset, uint8_t device) { - reset = 0; - wait_us(1); - reset = 1; + MAX4822::CmdResult result = OpFailure; + + if(device <= m_num_devices) + { + reset = 0; + wait_us(1); + reset = 1; + + m_relay_data[device] = 0; + result = MAX4822::Success; + } + + return result; + } //*********************************************************************
diff -r 7b30a3361e40 -r 90f7cd976f18 MAX4822.h --- a/MAX4822.h Tue Aug 02 19:23:49 2016 +0000 +++ b/MAX4822.h Tue Aug 02 23:17:48 2016 +0000 @@ -100,11 +100,15 @@ ///@brief Sets all relays of device connected to set ///@param[in] set - Pin connected to SET pin of device - void set_all_relays(DigitalOut & set); + ///@param[in] device - Device number in daisychain mode, defaults to 0 + ///@return Result of operation. + CmdResult set_all_relays(DigitalOut & set, uint8_t device = 0); ///@brief Resets all relays of device connected to reset ///@param[in] reset - Pin connected to RESET pin of device - void reset_all_relays(DigitalOut & reset); + ///@param[in] device - Device number in daisychain mode, defaults to 0 + ///@return Result of operation. + CmdResult reset_all_relays(DigitalOut & reset, uint8_t device = 0); ///@brief Sets private relay state and sends it if 'send_data' is true ///@param[in] r - Relay to set