Library for interfacing with the MAX4822 relay driver.

Dependents:   MAXREFDES130_131_Demo MAXREFDES130_Demo

Revision:
3:90f7cd976f18
Parent:
2:7b30a3361e40
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;
+    
 }
 
 //*********************************************************************