![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
mnm gyro works -b4 implementing ctrl algo for mnm
Fork of BAE_b4hw_test by
fault.cpp
- Committer:
- raizel_varun
- Date:
- 2014-12-19
- Revision:
- 0:ebdf4f859dca
File content as of revision 0:ebdf4f859dca:
#include "fault.h" #include "HK.h" DigitalIn fault0(FAULT0,PullUp); DigitalIn fault1(FAULT1,PullUp); DigitalIn fault2(FAULT2,PullUp); DigitalIn fault3(FAULT3,PullUp); DigitalIn fault4(FAULT4,PullUp); //DigitalIn fault5(FAULT5,PullUp); //DigitalIn fault6(FAULT6,PullUp); //DigitalIn fault7(FAULT7,PullUp); //DigitalIn fault8(FAULT8,PullUp); InterruptIn fault_IR1(FAULT5); InterruptIn fault_IR2(FAULT6); InterruptIn fault_IR3(FAULT7); InterruptIn fault_IR4(FAULT8); InterruptIn fault_IR5(FAULT9); DigitalOut clear1(FAULT_CLEAR1,0); DigitalOut clear2(FAULT_CLEAR2,0); DigitalOut clear3(FAULT_CLEAR3,0); DigitalOut clear4(FAULT_CLEAR4,0); DigitalOut clear5(FAULT_CLEAR5); DigitalOut clear6(FAULT_CLEAR6); DigitalOut clear7(FAULT_CLEAR7); DigitalOut clear8(FAULT_CLEAR8); DigitalOut clear9(FAULT_CLEAR9); DigitalOut acs_active(ACS); BusIn fault_poll(FAULT0,FAULT1,FAULT2,FAULT3,FAULT4); BusIn fault_ir(FAULT5,FAULT6,FAULT7,FAULT8,FAULT9); BusOut clear_poll(FAULT_CLEAR1,FAULT_CLEAR2,FAULT_CLEAR3,FAULT_CLEAR4);//to send fault data along with hk BusOut clear_ir(FAULT_CLEAR5,FAULT_CLEAR6,FAULT_CLEAR7,FAULT_CLEAR8,FAULT_CLEAR9); extern SensorDataQuantised SensorQuantised; extern int beacon_sc; //to switch beacon between low and high power mode extern int acs_pflag; //to activate/deactivate control algo char out_poll; char out_ir; void FUNC_HK_FAULTS() { printf("Entered Fault management \n"); /*if(fault0==0)printf("CHARGER IS CHARGING THE BATTERY "); if(fault0==1)printf("CHRGER GONE OFFLINE, BATTERY DRAINING"); if(fault1==0) { clear1=1;printf("");} else { clear1=0;} if(fault2==0) { clear2=1;printf("");} else { clear2=0;} if(fault3==0) { clear3=1;printf("");} else { clear3=0;} if(fault4==0) { clear4=1;printf("");} else { clear4=0;}*/ //clear1 = !fault1; //clear2 = !fault2; //clear3 = !fault3; //clear4 = !fault4; //clear5 = !fault5; //clear6 = !fault6; //clear7 = !fault7; //clear8 = !fault8; // out_poll = clear_poll; //out_ir = clear_ir; SensorQuantised.faultpoll = fault_poll ; SensorQuantised.faultir=fault_ir ; printf(" %d , %d \n ",SensorQuantised.faultpoll, SensorQuantised.faultir ) ; } void Clear_IR1() {clear5=!clear5; } void Clear_IR2() {clear6=!clear6; } void Clear_IR3() {clear7=!clear7; } void Clear_IR4() {clear8=!clear8; } void Clear_IR5() {clear9=!clear9; } void interrupt_fault() { fault_IR1.rise(&Clear_IR1); fault_IR2.rise(&Clear_IR2); fault_IR3.rise(&Clear_IR3); fault_IR4.rise(&Clear_IR4); fault_IR5.rise(&Clear_IR5); fault_IR1.fall(&Clear_IR1); fault_IR2.fall(&Clear_IR2); fault_IR3.fall(&Clear_IR3); fault_IR4.fall(&Clear_IR4); fault_IR5.fall(&Clear_IR5); } void FUNC_HK_POWER(char flag) //flag corresponds to the power mode { printf("Entered Power Management \n"); printf("Entering mode %c \n", flag); switch (flag) { case '0': beacon_sc = 6; //least power mode acs_pflag = 0; acs_active = 0; //switching off a component of acs break; case '1': beacon_sc = 3; acs_pflag = 0; acs_active = 0; break; case '2': beacon_sc = 3; acs_pflag = 0; acs_active = 0; break; case '3': beacon_sc = 3; //normal mode acs_pflag = 1; acs_active = 1; break; } /* if (flag == '0') beacon_sc = 30; else beacon_sc = 3; if (flag == '3') acs_pflag = 1; else acs_pflag = 0; */ }