working

Dependencies:   mbed-rtos mbed

Fork of BAE_vr3honeycomb1_christmas by green rosh

Committer:
raizel_varun
Date:
Fri Dec 19 06:47:25 2014 +0000
Revision:
0:ebdf4f859dca
hhh

Who changed what in which revision?

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