![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
bae integrated final (may be)
Fork of BAE_FRDMTESIN2 by
fault.cpp@7:f06840d848e3, 2014-12-10 (annotated)
- Committer:
- raizel_varun
- Date:
- Wed Dec 10 06:34:17 2014 +0000
- Revision:
- 7:f06840d848e3
- Parent:
- 6:e65b1ab79f36
- Child:
- 8:667fbc82d634
f
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 | 7:f06840d848e3 | 5 | |
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 | 6:e65b1ab79f36 | 28 | DigitalOut clear5(FAULT_CLEAR5,0); |
raizel_varun | 6:e65b1ab79f36 | 29 | DigitalOut clear6(FAULT_CLEAR6,0); |
raizel_varun | 6:e65b1ab79f36 | 30 | DigitalOut clear7(FAULT_CLEAR7,0); |
raizel_varun | 6:e65b1ab79f36 | 31 | DigitalOut clear8(FAULT_CLEAR8,0); |
raizel_varun | 7:f06840d848e3 | 32 | DigitalOut clear9(FAULT_CLEAR9,0); |
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 | 7:f06840d848e3 | 38 | BusOut clear_poll(FAULT_CLEAR1,FAULT_CLEAR2,FAULT_CLEAR3,FAULT_CLEAR4);//to send fault data along with hk |
raizel_varun | 7:f06840d848e3 | 39 | BusOut clear_interrupt(FAULT_CLEAR5,FAULT_CLEAR6,FAULT_CLEAR7,FAULT_CLEAR8,FAULT_CLEAR9); |
sakthipriya | 5:255b43e8e21a | 40 | |
sakthipriya | 3:02b45de29c0f | 41 | extern SensorData Sensor; |
sakthipriya | 5:255b43e8e21a | 42 | extern int beacon_sc; //to switch beacon between low and high power mode |
sakthipriya | 5:255b43e8e21a | 43 | extern int acs_pflag; //to activate/deactivate control algo |
sakthipriya | 4:8f6c24eca109 | 44 | |
sakthipriya | 2:80b8a2e999f7 | 45 | |
sakthipriya | 2:80b8a2e999f7 | 46 | void FAULTS() |
sakthipriya | 2:80b8a2e999f7 | 47 | { |
raizel_varun | 6:e65b1ab79f36 | 48 | |
sakthipriya | 2:80b8a2e999f7 | 49 | printf("Entered Fault management \n"); |
sakthipriya | 2:80b8a2e999f7 | 50 | clear1 = !fault1; |
sakthipriya | 2:80b8a2e999f7 | 51 | clear2 = !fault2; |
sakthipriya | 2:80b8a2e999f7 | 52 | clear3 = !fault3; |
sakthipriya | 2:80b8a2e999f7 | 53 | clear4 = !fault4; |
raizel_varun | 7:f06840d848e3 | 54 | //clear5 = !fault5; |
raizel_varun | 7:f06840d848e3 | 55 | //clear6 = !fault6; |
raizel_varun | 7:f06840d848e3 | 56 | //clear7 = !fault7; |
raizel_varun | 7:f06840d848e3 | 57 | //clear8 = !fault8; |
raizel_varun | 7:f06840d848e3 | 58 | Sensor.faultpoll = clear_poll; |
raizel_varun | 7:f06840d848e3 | 59 | Sensor.faultir=clear_interrupt; |
raizel_varun | 7:f06840d848e3 | 60 | printf(" %d , %d \n",Sensor.faultpoll, Sensor.faultir ) ; |
sakthipriya | 2:80b8a2e999f7 | 61 | |
sakthipriya | 4:8f6c24eca109 | 62 | } |
sakthipriya | 4:8f6c24eca109 | 63 | |
raizel_varun | 7:f06840d848e3 | 64 | |
raizel_varun | 7:f06840d848e3 | 65 | |
raizel_varun | 7:f06840d848e3 | 66 | void Clear_IR1() |
raizel_varun | 7:f06840d848e3 | 67 | {clear5=!clear5; |
raizel_varun | 7:f06840d848e3 | 68 | } |
raizel_varun | 7:f06840d848e3 | 69 | |
raizel_varun | 7:f06840d848e3 | 70 | void Clear_IR2() |
raizel_varun | 7:f06840d848e3 | 71 | {clear6=!clear6; |
raizel_varun | 7:f06840d848e3 | 72 | } |
raizel_varun | 7:f06840d848e3 | 73 | |
raizel_varun | 7:f06840d848e3 | 74 | void Clear_IR3() |
raizel_varun | 7:f06840d848e3 | 75 | {clear7=!clear7; |
raizel_varun | 7:f06840d848e3 | 76 | } |
raizel_varun | 7:f06840d848e3 | 77 | |
raizel_varun | 7:f06840d848e3 | 78 | void Clear_IR4() |
raizel_varun | 7:f06840d848e3 | 79 | {clear8=!clear8; |
raizel_varun | 7:f06840d848e3 | 80 | } |
raizel_varun | 7:f06840d848e3 | 81 | |
raizel_varun | 7:f06840d848e3 | 82 | void Clear_IR5() |
raizel_varun | 7:f06840d848e3 | 83 | {clear9=!clear9; |
raizel_varun | 7:f06840d848e3 | 84 | } |
raizel_varun | 7:f06840d848e3 | 85 | |
raizel_varun | 7:f06840d848e3 | 86 | void interrupt_fault() |
raizel_varun | 7:f06840d848e3 | 87 | { |
raizel_varun | 7:f06840d848e3 | 88 | /*fault_IR1.rise(&Clear_IR1); |
raizel_varun | 7:f06840d848e3 | 89 | fault_IR2.rise(&Clear_IR2); |
raizel_varun | 7:f06840d848e3 | 90 | fault_IR3.rise(&Clear_IR3); |
raizel_varun | 7:f06840d848e3 | 91 | fault_IR4.rise(&Clear_IR4); |
raizel_varun | 7:f06840d848e3 | 92 | fault_IR5.rise(&Clear_IR5);*/ |
raizel_varun | 7:f06840d848e3 | 93 | fault_IR1.fall(&Clear_IR1); |
raizel_varun | 7:f06840d848e3 | 94 | fault_IR2.fall(&Clear_IR2); |
raizel_varun | 7:f06840d848e3 | 95 | fault_IR3.fall(&Clear_IR3); |
raizel_varun | 7:f06840d848e3 | 96 | fault_IR4.fall(&Clear_IR4); |
raizel_varun | 7:f06840d848e3 | 97 | fault_IR5.fall(&Clear_IR5); |
raizel_varun | 7:f06840d848e3 | 98 | } |
raizel_varun | 7:f06840d848e3 | 99 | |
raizel_varun | 7:f06840d848e3 | 100 | |
sakthipriya | 5:255b43e8e21a | 101 | void POWER(char flag) //flag corresponds to the power mode |
sakthipriya | 4:8f6c24eca109 | 102 | { |
sakthipriya | 4:8f6c24eca109 | 103 | printf("Entered Power Management \n"); |
sakthipriya | 4:8f6c24eca109 | 104 | printf("Entering mode %c \n", flag); |
sakthipriya | 4:8f6c24eca109 | 105 | switch (flag) |
sakthipriya | 4:8f6c24eca109 | 106 | { |
sakthipriya | 5:255b43e8e21a | 107 | case '0': beacon_sc = 6; //least power mode |
sakthipriya | 5:255b43e8e21a | 108 | acs_pflag = 0; |
sakthipriya | 5:255b43e8e21a | 109 | acs_active = 0; //switching off a component of acs |
sakthipriya | 4:8f6c24eca109 | 110 | break; |
sakthipriya | 5:255b43e8e21a | 111 | case '1': beacon_sc = 3; |
sakthipriya | 5:255b43e8e21a | 112 | acs_pflag = 0; |
sakthipriya | 5:255b43e8e21a | 113 | acs_active = 0; |
sakthipriya | 4:8f6c24eca109 | 114 | break; |
sakthipriya | 5:255b43e8e21a | 115 | case '2': beacon_sc = 3; |
sakthipriya | 5:255b43e8e21a | 116 | acs_pflag = 0; |
sakthipriya | 5:255b43e8e21a | 117 | acs_active = 0; |
sakthipriya | 4:8f6c24eca109 | 118 | break; |
sakthipriya | 5:255b43e8e21a | 119 | case '3': beacon_sc = 3; //normal mode |
sakthipriya | 5:255b43e8e21a | 120 | acs_pflag = 1; |
sakthipriya | 5:255b43e8e21a | 121 | acs_active = 1; |
sakthipriya | 5:255b43e8e21a | 122 | break; |
sakthipriya | 4:8f6c24eca109 | 123 | } |
sakthipriya | 5:255b43e8e21a | 124 | /* if (flag == '0') |
sakthipriya | 4:8f6c24eca109 | 125 | beacon_sc = 30; |
sakthipriya | 4:8f6c24eca109 | 126 | else |
sakthipriya | 4:8f6c24eca109 | 127 | beacon_sc = 3; |
sakthipriya | 5:255b43e8e21a | 128 | if (flag == '3') |
sakthipriya | 5:255b43e8e21a | 129 | acs_pflag = 1; |
sakthipriya | 5:255b43e8e21a | 130 | else |
sakthipriya | 5:255b43e8e21a | 131 | acs_pflag = 0; */ |
sakthipriya | 4:8f6c24eca109 | 132 | } |