![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
IVSC Project
Relay.cpp@4:262764d24e4d, 2013-06-07 (annotated)
- Committer:
- kevinkent
- Date:
- Fri Jun 07 19:59:29 2013 +0000
- Revision:
- 4:262764d24e4d
- Parent:
- 2:d0778c36d28d
Version 1.2
; Added MSG[0] = 0x06 tow write one pot chain with a single message
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kevinkent | 1:82f2ef52759e | 1 | #include "mbed.h" |
kevinkent | 1:82f2ef52759e | 2 | #include "Relay.h" |
kevinkent | 1:82f2ef52759e | 3 | |
kevinkent | 2:d0778c36d28d | 4 | Serial dbg2(USBTX,USBRX); |
kevinkent | 1:82f2ef52759e | 5 | DigitalOut v13_en(p15); |
kevinkent | 1:82f2ef52759e | 6 | DigitalOut v18_en(p16); |
kevinkent | 1:82f2ef52759e | 7 | DigitalOut Ext_Sw(p17); |
kevinkent | 1:82f2ef52759e | 8 | DigitalOut Hpco(p18); |
kevinkent | 1:82f2ef52759e | 9 | |
kevinkent | 1:82f2ef52759e | 10 | //Set all relays open (NO->Com) |
kevinkent | 1:82f2ef52759e | 11 | int Def_Relay(void) { |
kevinkent | 1:82f2ef52759e | 12 | Hpco = 0; |
kevinkent | 1:82f2ef52759e | 13 | Ext_Sw = 0; |
kevinkent | 1:82f2ef52759e | 14 | v13_en = 0; |
kevinkent | 1:82f2ef52759e | 15 | v18_en = 0; |
kevinkent | 1:82f2ef52759e | 16 | return 1; |
kevinkent | 1:82f2ef52759e | 17 | } |
kevinkent | 1:82f2ef52759e | 18 | |
kevinkent | 1:82f2ef52759e | 19 | int Set_Relay(uint8_t *data) { |
kevinkent | 1:82f2ef52759e | 20 | data[1] &= 0xf; //Only 4 relays |
kevinkent | 1:82f2ef52759e | 21 | data[2] &= 0x1; //Only allow Zero or One |
kevinkent | 1:82f2ef52759e | 22 | switch (data[1]) { |
kevinkent | 1:82f2ef52759e | 23 | case 1: |
kevinkent | 1:82f2ef52759e | 24 | v13_en = data[2]; |
kevinkent | 2:d0778c36d28d | 25 | dbg2.printf("13.8V = %d\n",data[2]); |
kevinkent | 1:82f2ef52759e | 26 | break; |
kevinkent | 1:82f2ef52759e | 27 | case 2: |
kevinkent | 1:82f2ef52759e | 28 | v18_en = data[2]; |
kevinkent | 2:d0778c36d28d | 29 | dbg2.printf("18V = %d\n",data[2]); |
kevinkent | 1:82f2ef52759e | 30 | break; |
kevinkent | 1:82f2ef52759e | 31 | case 3: |
kevinkent | 1:82f2ef52759e | 32 | Hpco = data[2]; |
kevinkent | 2:d0778c36d28d | 33 | dbg2.printf("HPCO = %d\n",data[2]); |
kevinkent | 1:82f2ef52759e | 34 | break; |
kevinkent | 1:82f2ef52759e | 35 | case 4: |
kevinkent | 1:82f2ef52759e | 36 | Ext_Sw = data[2]; |
kevinkent | 2:d0778c36d28d | 37 | dbg2.printf("Ext SW = %d\n",data[2]); |
kevinkent | 1:82f2ef52759e | 38 | break; |
kevinkent | 1:82f2ef52759e | 39 | default: |
kevinkent | 1:82f2ef52759e | 40 | break; |
kevinkent | 1:82f2ef52759e | 41 | } |
kevinkent | 1:82f2ef52759e | 42 | return 1; |
kevinkent | 1:82f2ef52759e | 43 | } |