sakthi priya amirtharaj
/
BAE_vr2_1_3
i2c working with old hk
Fork of BAE_vr2_1_1 by
fault.cpp@13:1b37d98840d3, 2014-12-17 (annotated)
- Committer:
- greenroshks
- Date:
- Wed Dec 17 05:25:04 2014 +0000
- Revision:
- 13:1b37d98840d3
- Parent:
- 8:69475d16d23d
- Child:
- 14:ef6be8ac6569
The one with the new HK
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sakthipriya | 2:80b8a2e999f7 | 1 | #include "fault.h" |
sakthipriya | 3:02b45de29c0f | 2 | #include "HK.h" |
sakthipriya | 2:80b8a2e999f7 | 3 | |
sakthipriya | 2:80b8a2e999f7 | 4 | |
raizel_varun | 8:69475d16d23d | 5 | DigitalIn fault0(FAULT0,PullUp); |
raizel_varun | 7:f06840d848e3 | 6 | DigitalIn fault1(FAULT1,PullUp); |
raizel_varun | 7:f06840d848e3 | 7 | DigitalIn fault2(FAULT2,PullUp); |
raizel_varun | 7:f06840d848e3 | 8 | DigitalIn fault3(FAULT3,PullUp); |
raizel_varun | 7:f06840d848e3 | 9 | DigitalIn fault4(FAULT4,PullUp); |
raizel_varun | 7:f06840d848e3 | 10 | //DigitalIn fault5(FAULT5,PullUp); |
raizel_varun | 7:f06840d848e3 | 11 | //DigitalIn fault6(FAULT6,PullUp); |
raizel_varun | 7:f06840d848e3 | 12 | //DigitalIn fault7(FAULT7,PullUp); |
raizel_varun | 7:f06840d848e3 | 13 | //DigitalIn fault8(FAULT8,PullUp); |
raizel_varun | 7:f06840d848e3 | 14 | |
raizel_varun | 7:f06840d848e3 | 15 | |
raizel_varun | 7:f06840d848e3 | 16 | InterruptIn fault_IR1(FAULT5); |
raizel_varun | 7:f06840d848e3 | 17 | InterruptIn fault_IR2(FAULT6); |
raizel_varun | 7:f06840d848e3 | 18 | InterruptIn fault_IR3(FAULT7); |
raizel_varun | 7:f06840d848e3 | 19 | InterruptIn fault_IR4(FAULT8); |
raizel_varun | 7:f06840d848e3 | 20 | InterruptIn fault_IR5(FAULT9); |
raizel_varun | 7:f06840d848e3 | 21 | |
sakthipriya | 2:80b8a2e999f7 | 22 | |
sakthipriya | 2:80b8a2e999f7 | 23 | |
raizel_varun | 6:e65b1ab79f36 | 24 | DigitalOut clear1(FAULT_CLEAR1,0); |
raizel_varun | 6:e65b1ab79f36 | 25 | DigitalOut clear2(FAULT_CLEAR2,0); |
raizel_varun | 6:e65b1ab79f36 | 26 | DigitalOut clear3(FAULT_CLEAR3,0); |
raizel_varun | 6:e65b1ab79f36 | 27 | DigitalOut clear4(FAULT_CLEAR4,0); |
raizel_varun | 8:69475d16d23d | 28 | DigitalOut clear5(FAULT_CLEAR5); |
raizel_varun | 8:69475d16d23d | 29 | DigitalOut clear6(FAULT_CLEAR6); |
raizel_varun | 8:69475d16d23d | 30 | DigitalOut clear7(FAULT_CLEAR7); |
raizel_varun | 8:69475d16d23d | 31 | DigitalOut clear8(FAULT_CLEAR8); |
raizel_varun | 8:69475d16d23d | 32 | DigitalOut clear9(FAULT_CLEAR9); |
raizel_varun | 7:f06840d848e3 | 33 | |
sakthipriya | 2:80b8a2e999f7 | 34 | |
sakthipriya | 5:255b43e8e21a | 35 | DigitalOut acs_active(ACS); |
sakthipriya | 2:80b8a2e999f7 | 36 | |
raizel_varun | 6:e65b1ab79f36 | 37 | |
raizel_varun | 8:69475d16d23d | 38 | BusIn fault_poll(FAULT0,FAULT1,FAULT2,FAULT3,FAULT4); |
raizel_varun | 8:69475d16d23d | 39 | BusIn fault_ir(FAULT5,FAULT6,FAULT7,FAULT8,FAULT9); |
raizel_varun | 8:69475d16d23d | 40 | |
raizel_varun | 7:f06840d848e3 | 41 | BusOut clear_poll(FAULT_CLEAR1,FAULT_CLEAR2,FAULT_CLEAR3,FAULT_CLEAR4);//to send fault data along with hk |
raizel_varun | 8:69475d16d23d | 42 | BusOut clear_ir(FAULT_CLEAR5,FAULT_CLEAR6,FAULT_CLEAR7,FAULT_CLEAR8,FAULT_CLEAR9); |
raizel_varun | 8:69475d16d23d | 43 | |
sakthipriya | 5:255b43e8e21a | 44 | |
greenroshks | 13:1b37d98840d3 | 45 | extern SensorDataQuantised SensorQuantised; |
sakthipriya | 5:255b43e8e21a | 46 | extern int beacon_sc; //to switch beacon between low and high power mode |
sakthipriya | 5:255b43e8e21a | 47 | extern int acs_pflag; //to activate/deactivate control algo |
raizel_varun | 8:69475d16d23d | 48 | char out_poll; |
raizel_varun | 8:69475d16d23d | 49 | char out_ir; |
sakthipriya | 2:80b8a2e999f7 | 50 | |
sakthipriya | 2:80b8a2e999f7 | 51 | void FAULTS() |
sakthipriya | 2:80b8a2e999f7 | 52 | { |
raizel_varun | 6:e65b1ab79f36 | 53 | |
sakthipriya | 2:80b8a2e999f7 | 54 | printf("Entered Fault management \n"); |
raizel_varun | 8:69475d16d23d | 55 | if(fault0==0)printf("CHARGER IS CHARGING THE BATTERY "); |
raizel_varun | 8:69475d16d23d | 56 | if(fault0==1)printf("CHRGER GONE OFFLINE, BATTERY DRAINING"); |
raizel_varun | 8:69475d16d23d | 57 | |
raizel_varun | 8:69475d16d23d | 58 | if(fault1==0) |
raizel_varun | 8:69475d16d23d | 59 | { clear1=1;printf("");} |
raizel_varun | 8:69475d16d23d | 60 | else |
raizel_varun | 8:69475d16d23d | 61 | { clear1=0;} |
raizel_varun | 8:69475d16d23d | 62 | |
raizel_varun | 8:69475d16d23d | 63 | if(fault2==0) |
raizel_varun | 8:69475d16d23d | 64 | { clear2=1;printf("");} |
raizel_varun | 8:69475d16d23d | 65 | else |
raizel_varun | 8:69475d16d23d | 66 | { clear2=0;} |
raizel_varun | 8:69475d16d23d | 67 | |
raizel_varun | 8:69475d16d23d | 68 | if(fault3==0) |
raizel_varun | 8:69475d16d23d | 69 | { clear3=1;printf("");} |
raizel_varun | 8:69475d16d23d | 70 | else |
raizel_varun | 8:69475d16d23d | 71 | { clear3=0;} |
raizel_varun | 8:69475d16d23d | 72 | |
raizel_varun | 8:69475d16d23d | 73 | if(fault4==0) |
raizel_varun | 8:69475d16d23d | 74 | { clear4=1;printf("");} |
raizel_varun | 8:69475d16d23d | 75 | else |
raizel_varun | 8:69475d16d23d | 76 | { clear4=0;} |
raizel_varun | 8:69475d16d23d | 77 | |
raizel_varun | 8:69475d16d23d | 78 | |
raizel_varun | 8:69475d16d23d | 79 | |
raizel_varun | 8:69475d16d23d | 80 | |
raizel_varun | 8:69475d16d23d | 81 | |
raizel_varun | 8:69475d16d23d | 82 | |
raizel_varun | 8:69475d16d23d | 83 | |
raizel_varun | 8:69475d16d23d | 84 | |
raizel_varun | 8:69475d16d23d | 85 | //clear1 = !fault1; |
raizel_varun | 8:69475d16d23d | 86 | //clear2 = !fault2; |
raizel_varun | 8:69475d16d23d | 87 | //clear3 = !fault3; |
raizel_varun | 8:69475d16d23d | 88 | //clear4 = !fault4; |
raizel_varun | 7:f06840d848e3 | 89 | //clear5 = !fault5; |
raizel_varun | 7:f06840d848e3 | 90 | //clear6 = !fault6; |
raizel_varun | 7:f06840d848e3 | 91 | //clear7 = !fault7; |
raizel_varun | 7:f06840d848e3 | 92 | //clear8 = !fault8; |
raizel_varun | 8:69475d16d23d | 93 | |
raizel_varun | 8:69475d16d23d | 94 | |
raizel_varun | 8:69475d16d23d | 95 | out_poll = clear_poll; |
raizel_varun | 8:69475d16d23d | 96 | out_ir = clear_ir; |
greenroshks | 13:1b37d98840d3 | 97 | SensorQuantised.faultpoll = fault_poll ; |
greenroshks | 13:1b37d98840d3 | 98 | SensorQuantised.faultir=fault_ir ; |
greenroshks | 13:1b37d98840d3 | 99 | printf(" %d , %d \n %d , %d\n",SensorQuantised.faultpoll, SensorQuantised.faultir , out_poll , out_ir) ; |
sakthipriya | 2:80b8a2e999f7 | 100 | |
sakthipriya | 4:8f6c24eca109 | 101 | } |
sakthipriya | 4:8f6c24eca109 | 102 | |
raizel_varun | 7:f06840d848e3 | 103 | |
raizel_varun | 7:f06840d848e3 | 104 | |
raizel_varun | 7:f06840d848e3 | 105 | void Clear_IR1() |
raizel_varun | 7:f06840d848e3 | 106 | {clear5=!clear5; |
raizel_varun | 7:f06840d848e3 | 107 | } |
raizel_varun | 7:f06840d848e3 | 108 | |
raizel_varun | 7:f06840d848e3 | 109 | void Clear_IR2() |
raizel_varun | 7:f06840d848e3 | 110 | {clear6=!clear6; |
raizel_varun | 7:f06840d848e3 | 111 | } |
raizel_varun | 7:f06840d848e3 | 112 | |
raizel_varun | 7:f06840d848e3 | 113 | void Clear_IR3() |
raizel_varun | 7:f06840d848e3 | 114 | {clear7=!clear7; |
raizel_varun | 7:f06840d848e3 | 115 | } |
raizel_varun | 7:f06840d848e3 | 116 | |
raizel_varun | 7:f06840d848e3 | 117 | void Clear_IR4() |
raizel_varun | 7:f06840d848e3 | 118 | {clear8=!clear8; |
raizel_varun | 7:f06840d848e3 | 119 | } |
raizel_varun | 7:f06840d848e3 | 120 | |
raizel_varun | 7:f06840d848e3 | 121 | void Clear_IR5() |
raizel_varun | 7:f06840d848e3 | 122 | {clear9=!clear9; |
raizel_varun | 7:f06840d848e3 | 123 | } |
raizel_varun | 7:f06840d848e3 | 124 | |
raizel_varun | 7:f06840d848e3 | 125 | void interrupt_fault() |
raizel_varun | 7:f06840d848e3 | 126 | { |
raizel_varun | 8:69475d16d23d | 127 | fault_IR1.rise(&Clear_IR1); |
raizel_varun | 7:f06840d848e3 | 128 | fault_IR2.rise(&Clear_IR2); |
raizel_varun | 7:f06840d848e3 | 129 | fault_IR3.rise(&Clear_IR3); |
raizel_varun | 7:f06840d848e3 | 130 | fault_IR4.rise(&Clear_IR4); |
raizel_varun | 8:69475d16d23d | 131 | fault_IR5.rise(&Clear_IR5); |
raizel_varun | 7:f06840d848e3 | 132 | fault_IR1.fall(&Clear_IR1); |
raizel_varun | 7:f06840d848e3 | 133 | fault_IR2.fall(&Clear_IR2); |
raizel_varun | 7:f06840d848e3 | 134 | fault_IR3.fall(&Clear_IR3); |
raizel_varun | 7:f06840d848e3 | 135 | fault_IR4.fall(&Clear_IR4); |
raizel_varun | 7:f06840d848e3 | 136 | fault_IR5.fall(&Clear_IR5); |
raizel_varun | 7:f06840d848e3 | 137 | } |
raizel_varun | 7:f06840d848e3 | 138 | |
raizel_varun | 7:f06840d848e3 | 139 | |
sakthipriya | 5:255b43e8e21a | 140 | void POWER(char flag) //flag corresponds to the power mode |
sakthipriya | 4:8f6c24eca109 | 141 | { |
sakthipriya | 4:8f6c24eca109 | 142 | printf("Entered Power Management \n"); |
sakthipriya | 4:8f6c24eca109 | 143 | printf("Entering mode %c \n", flag); |
sakthipriya | 4:8f6c24eca109 | 144 | switch (flag) |
sakthipriya | 4:8f6c24eca109 | 145 | { |
sakthipriya | 5:255b43e8e21a | 146 | case '0': beacon_sc = 6; //least power mode |
sakthipriya | 5:255b43e8e21a | 147 | acs_pflag = 0; |
sakthipriya | 5:255b43e8e21a | 148 | acs_active = 0; //switching off a component of acs |
sakthipriya | 4:8f6c24eca109 | 149 | break; |
sakthipriya | 5:255b43e8e21a | 150 | case '1': beacon_sc = 3; |
sakthipriya | 5:255b43e8e21a | 151 | acs_pflag = 0; |
sakthipriya | 5:255b43e8e21a | 152 | acs_active = 0; |
sakthipriya | 4:8f6c24eca109 | 153 | break; |
sakthipriya | 5:255b43e8e21a | 154 | case '2': beacon_sc = 3; |
sakthipriya | 5:255b43e8e21a | 155 | acs_pflag = 0; |
sakthipriya | 5:255b43e8e21a | 156 | acs_active = 0; |
sakthipriya | 4:8f6c24eca109 | 157 | break; |
sakthipriya | 5:255b43e8e21a | 158 | case '3': beacon_sc = 3; //normal mode |
sakthipriya | 5:255b43e8e21a | 159 | acs_pflag = 1; |
sakthipriya | 5:255b43e8e21a | 160 | acs_active = 1; |
sakthipriya | 5:255b43e8e21a | 161 | break; |
sakthipriya | 4:8f6c24eca109 | 162 | } |
sakthipriya | 5:255b43e8e21a | 163 | /* if (flag == '0') |
sakthipriya | 4:8f6c24eca109 | 164 | beacon_sc = 30; |
sakthipriya | 4:8f6c24eca109 | 165 | else |
sakthipriya | 4:8f6c24eca109 | 166 | beacon_sc = 3; |
sakthipriya | 5:255b43e8e21a | 167 | if (flag == '3') |
sakthipriya | 5:255b43e8e21a | 168 | acs_pflag = 1; |
sakthipriya | 5:255b43e8e21a | 169 | else |
sakthipriya | 5:255b43e8e21a | 170 | acs_pflag = 0; */ |
sakthipriya | 4:8f6c24eca109 | 171 | } |