![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
IVSC Project
Diff: Relay.cpp
- Revision:
- 1:82f2ef52759e
- Child:
- 2:d0778c36d28d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Relay.cpp Wed Nov 14 20:01:50 2012 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" +#include "Relay.h" + +DigitalOut v13_en(p15); +DigitalOut v18_en(p16); +DigitalOut Ext_Sw(p17); +DigitalOut Hpco(p18); + +//Set all relays open (NO->Com) +int Def_Relay(void) { + Hpco = 0; + Ext_Sw = 0; + v13_en = 0; + v18_en = 0; + return 1; + } + +int Set_Relay(uint8_t *data) { + data[1] &= 0xf; //Only 4 relays + data[2] &= 0x1; //Only allow Zero or One + switch (data[1]) { + case 1: + v13_en = data[2]; + break; + case 2: + v18_en = data[2]; + break; + case 3: + Hpco = data[2]; + break; + case 4: + Ext_Sw = data[2]; + break; + default: + break; + } + return 1; + } \ No newline at end of file