Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of workinQM_5thJan_azad by
Diff: main.cpp
- Revision:
- 49:61c9f28332ba
- Parent:
- 48:9fd15e3e0b53
- Child:
- 50:6001287f3045
--- a/main.cpp Fri Jul 08 08:25:39 2016 +0000 +++ b/main.cpp Thu Jul 14 23:04:26 2016 +0000 @@ -1,9 +1,13 @@ + + #include "mbed.h" #include "rtos.h" #include "pin_config.h" #include "ACS.h" #include "EPS.h" #include "BCN.h" +Serial pc(USBTX,USBRX); + #include "TCTM.h" #define tm_len 134 #define tc_len 135 @@ -12,6 +16,47 @@ #define PRINT2 1 #define baby 1 #define baby2 1 +#define SBC 1 + + + +Timer timer_FCTN_ACS_GENPWM_MAIN; +Timer timer_FCTN_ACS_CNTRLALGO; +Timer timer_FCTN_BAE_INIT; +Timer timer_FLASH_INI; +Timer timer_FCTN_ACS_INIT; +Timer timer_FCTN_EPS_INIT; +Timer timer_FCTN_BCN_INIT; +Timer timer_F_ACS; +Timer timer_FCTN_ATS_DATA_ACQ; +extern Timer timer_SENSOR_INIT; +extern Timer timer_CONFIG_UPLOAD; +extern Timer timer_SENSOR_DATA_ACQ; +extern Timer timer_controlmodes; + +Timer timer_F_ESP; +Timer timer_minMaxHkData; +Timer timer_FCTN_APPEND_HKDATA; +Timer timer_FCTN_EPS_HANDLE_CDMS_FAULT; +Timer timer_FCTN_EPS_HANDLE_HW_FAULTS; +Timer timer_FCTN_HK_MAIN; +Timer timer_FCTN_BATTERYGAUGE_MAIN; +Timer timer_FCTN_BATT_TEMP_SENSOR_MAIN; +extern Timer timer_alertFlags; +extern Timer timer_soc; +extern Timer timer_FCTN_BATTERYGAUGE_INIT; + + +Timer timer_F_BCN; +Timer timer_FCTN_BCN_TX_MAIN; +extern Timer timer_Init_BEACON_HW; +extern Timer timer_Set_BCN_TX_STATUS_DISABLED; +extern Timer timer_Set_BCN_TX_STATUS_SUSPENDED; +extern Timer timer_Set_BCN_TX_STATUS_RF_SILENCE; +extern Timer timer_Set_BCN_TX_STATUS_SUCCESS; +extern Timer timer_Set_BCN_TX_STATUS_FAILURE; + + #define DISABLE_WDOG 0; @@ -28,7 +73,7 @@ kick_WDOG(); } -DigitalInOut time_wdog(PIN68);// for determining the time between code +DigitalOut time_wdog(PIN68,0);// for determining the time between code //**********************************************GLOBAL RTOS TIMER*********************************************************// RtosTimer *BAE_STANDBY_STATUS_TIMER; @@ -52,7 +97,9 @@ *min = time/60; } -extern DigitalInOut BTRY_HTR_ENABLE; +extern DigitalOut BTRY_HTR_ENABLE; +int eps_btg_read_flag; // flag to check I2C ack on reading from BTG +int eps_btg_writ_flag; // flag to check I2C ack on writing from BTG uint8_t HTR_CYCLE_COUNTS=0; //Count of heater cycles uint8_t HTR_CYCLE_START_DLY=0; //EPS_HTR_DLY_TIMER timer duration in minutes @@ -159,7 +206,7 @@ uint8_t ACS_DETUMBLING_ALGO_TYPE = 0; uint8_t ACS_ATS_ENABLE = 1; uint8_t ACS_DATA_ACQ_ENABLE = 1; -uint8_t ACS_STATE = 8; +uint8_t ACS_STATE = 3; extern uint16_t ACS_MM_X_COMSN; extern uint16_t ACS_MM_Y_COMSN; @@ -169,7 +216,7 @@ extern uint16_t ACS_MG_Z_COMSN; extern uint8_t controlmode_mms; - +extern uint8_t B_SCZ_ANGLE; //BCN extern uint8_t BCN_FEN; extern void FCTN_BCN_FEN(void const *args); @@ -197,7 +244,7 @@ extern uint8_t EPS_BAT_TEMP_HIGH; extern uint8_t EPS_BAT_TEMP_DEFAULT; float EPS_BTRY_TMP_AVG; -extern DigitalInOut BTRY_HTR_ENABLE; +extern DigitalOut BTRY_HTR_ENABLE; //extern void FCTN_BATTERYGAUGE_MAIN(float*Battery_parameters); @@ -224,7 +271,7 @@ //uint16_t BCN_TX_MAIN_COUNTER = 0; uint8_t BCN_LONG_MSG_TYPE = 1; -DigitalInOut BCN_TX_OC_FAULT(PIN80); +DigitalIn BCN_TX_OC_FAULT(PIN80); int BCN_TX_FAULT_COUNTER; //ACS @@ -237,6 +284,17 @@ DigitalIn ACS_TR_Z_FAULT(PIN89); //Driver IC fault int ACS_TR_Z_FAULT_COUNTER = 0; + +#if SBC +InterruptIn irpt_4m_mstr(PIN38); //I2c interrupt from CDMS +DigitalOut irpt_2_mstr(PIN4); //I2C interrupt to CDMS +#endif + +#if !SBC +InterruptIn irpt_4m_mstr(PIN38); //I2c interrupt from CDMS +DigitalOut irpt_2_mstr(PIN4); //I2C interrupt to CDMS +#endif + //uint8_t ACS_TR_XY_SW_STATUS; DigitalOut ACS_TR_XY_ENABLE(PIN71); DigitalIn ACS_TR_XY_OC_FAULT(PIN72); @@ -265,7 +323,7 @@ Timer t_eps; //Timer t_tc; Timer t_tm; -Serial pc(USBTX, USBRX); + int power_flag_dummy=2; float data[6]; @@ -287,7 +345,7 @@ //TCTM -extern uint8_t telemetry[135]; +extern uint8_t telemetry[tm_len]; //ACS @@ -316,8 +374,8 @@ //ASSIGNING PINS// DigitalOut ATS1_SW_ENABLE(PTC0); // enable of att sens2 switch DigitalOut ATS2_SW_ENABLE(PTC16); // enable of att sens switch -InterruptIn irpt_4m_mstr(PIN38); //I2c interrupt from CDMS -DigitalOut irpt_2_mstr(PIN4); //I2C interrupt to CDMS +////InterruptIn irpt_4m_mstr(PIN38); //I2c interrupt from CDMS +////DigitalOut irpt_2_mstr(PIN4); //I2C interrupt to CDMS I2CSlave slave (PIN1,PIN2);///pin1 pin2 //DigitalOut batt_heat(PIN96); @@ -337,7 +395,7 @@ DigitalOut TRZ_SW(PIN40,1); //TR Z Switch DigitalOut CDMS_RESET(PIN7,1); // CDMS RESET DigitalOut BCN_SW(PIN14,0); //Beacon switch -DigitalInOut DRV_XY_EN(PIN82); +DigitalOut DRV_XY_EN(PIN82); @@ -347,7 +405,7 @@ void FLASH_INI() { - uint t32_t read[8]; + uint32_t read[8]; for(int i=0;i<8;i++) { read[i] = FCTN_BAE_RD_FLASH_ENTITY(i); @@ -362,7 +420,7 @@ ACS_TR_XY_SW_STATUS = ((uint8_t)(ARR_INITIAL_VAL[0]>>22))&0x03; ACS_TR_Z_SW_STATUS = (ARR_INITIAL_VAL[0]>>20)&0x03; ACS_STATE = (ARR_INITIAL_VAL[0]>>16)&0x0F; - //pc.printf("\n\r acs state in starting is %x",ACS_STATE); + //pc.pc.printf("\n\r acs state in starting is %x",ACS_STATE); ACS_DETUMBLING_ALGO_TYPE = (ARR_INITIAL_VAL[0]>>15)&0x01; BCN_TX_SW_STATUS = ((uint8_t)(ARR_INITIAL_VAL[0]>>13))&0x03; BCN_SPND_TX = ((uint8_t)(ARR_INITIAL_VAL[0]>>12))&0x01; @@ -410,7 +468,7 @@ BCN_SPND_TX = ((uint8_t)(read[0]>>12))&0x01; BCN_FEN = ((uint8_t)(read[0]>>11))&0x01; BCN_LONG_MSG_TYPE = ((uint8_t)(read[0]>>10))&0x01; - EPS_BTRY_HTR_AUTO = ((uint8_t)(read[0]>>9))&0x03;//EPS_BATTERY_HEATER_ENABLE + EPS_BTRY_HTR_AUTO = ((uint8_t)(read[0]>>9))&0x01;//EPS_BATTERY_HEATER_ENABLE //now one spares in telemetry[5] //updating the reset counter @@ -483,7 +541,7 @@ //FLOAT TO UINT_8 CONVERSION FUNCTION extern uint8_t float_to_uint8(float min,float max,float val); -#define print 0 +//#define print 0 void F_ACS() { @@ -492,9 +550,7 @@ pc.printf("Entered ACS.\n\r"); ACS_MAIN_STATUS = 1; //set ACS_MAIN_STATUS flag - FLAG(); - - ACS_MAIN_COUNTER+=1; + //FLAG(); PWM1 = 0; //clear pwm pins PWM2 = 0; //clear pwm pins @@ -503,12 +559,12 @@ wait_ms(ACS_DEMAG_TIME_DELAY); ACS_DATA_ACQ_STATUS = (uint8_t) FCTN_ATS_DATA_ACQ(); - #if print - printing the angular speed and magnetic field values + //#if print + //printing the angular speed and magnetic field values pc.printf("gyro values\n\r"); for(int i=0; i<3; i++) { - printf("%f\n\r",actual_data.AngularSpeed_actual[i]); + pc.printf("%f\n\r",actual_data.AngularSpeed_actual[i]); } pc.printf("mag values\n\r"); @@ -516,27 +572,43 @@ { pc.printf("%f\n\r",actual_data.Bvalue_actual[i]); } - #endif + //#endif for(int i=0;i<3;i++) { mag_data[i] = actual_data.Bvalue_actual[i]/1000000; gyro_data[i] = actual_data.AngularSpeed_actual[i]*3.14159/180; } + + int b_inclination = mag_data[2]/sqrt(mag_data[0]*mag_data[0]+mag_data[1]*mag_data[1]+mag_data[2]*mag_data[2]); + + if(b_inclination <0) + { + b_inclination = (-1)*b_inclination; + } + B_SCZ_ANGLE = (uint8_t)b_inclination; + if( b_inclination >= 16) + { + B_SCZ_ANGLE = 0x0F; + } + if(b_inclination <=0) + { + B_SCZ_ANGLE = 0x00; + } if(ACS_STATE == 0) // check ACS_STATE = ACS_CONTROL_OFF? { #if print - printf("\n\r acs control off\n"); + pc.printf("\n\r acs control off\n"); #endif ACS_STATUS = 0; // set ACS_STATUS = ACS_CONTROL_OFF ACS_MAIN_STATUS = 0; return; } - else if(actual_data.power_mode<=2) + else if((actual_data.power_mode<=2)&&( (ACS_STATE&0x80) != 0x80)) { #if print - printf("\n\r Low Power \n\r"); + pc.printf("\n\r Low Power \n\r"); #endif DRV_Z_EN = 0; DRV_XY_EN = 0; @@ -562,7 +634,10 @@ moment[1] = 0; moment[2] = ACS_Z_FIXED_MOMENT; // is a dummy value + //timer_FCTN_ACS_GENPWM_MAIN.start(); FCTN_ACS_GENPWM_MAIN(moment) ; + //timer_FCTN_ACS_GENPWM_MAIN.stop(); + //pc.printf("\n\r the timer_FCTN_ACS_GENPWM_MAIN is %f",timer_FCTN_ACS_GENPWM_MAIN.read()); ACS_MAIN_STATUS = 0; return; } @@ -576,11 +651,15 @@ moment[1] = 0; moment[2] = ACS_Z_FIXED_MOMENT; // is a dummy value + //timer_FCTN_ACS_GENPWM_MAIN.start(); FCTN_ACS_GENPWM_MAIN(moment) ; + //timer_FCTN_ACS_GENPWM_MAIN.stop(); + //pc.printf("\n\r the timer_FCTN_ACS_GENPWM_MAIN is %f",timer_FCTN_ACS_GENPWM_MAIN.read()); + ACS_MAIN_STATUS = 0; return; } - else if(ACS_STATE == 5) + else if(ACS_STATE == 1) { DRV_Z_EN = 1; DRV_XY_EN = 0; @@ -604,57 +683,77 @@ FCTN_ACS_CNTRLALGO(moment,mag_data,gyro_data,0x00,0x01,ACS_DETUMBLING_ALGO_TYPE); controlmode_mms=0x00; #if print - printf("\n\r Moment values returned by control algo \n"); + pc.printf("\n\r Moment values returned by control algo \n"); #endif for(int i=0; i<3; i++) { - printf("%f\t",moment[i]); + pc.printf("%f\t",moment[i]); } FCTN_ACS_GENPWM_MAIN(moment) ; ACS_MAIN_STATUS = 0; return; } - else if(ACS_STATE == 7) // Nominal mode + else if(ACS_STATE == 2) // Nominal mode { #if print - printf("\n\r Nominal mode \n"); + pc.printf("\n\r Nominal mode \n"); #endif DRV_Z_EN = 1; - DRV_XY_EN = 1; + DRV_XY_EN = 1; + + //timer_FCTN_ACS_CNTRLALGO.start(); FCTN_ACS_CNTRLALGO(moment,mag_data,gyro_data,0x01,0x00,ACS_DETUMBLING_ALGO_TYPE); + //timer_FCTN_ACS_CNTRLALGO.stop(); + //pc.printf("\n\r the timer_FCTN_ACS_GENPWM_MAIN is %f",timer_FCTN_ACS_CNTRLALGO.read()); + controlmode_mms = 0x01; #if print - printf("\n\r Moment values returned by control algo \n"); + pc.printf("\n\r Moment values returned by control algo \n"); #endif for(int i=0; i<3; i++) { - printf("%f\t",moment[i]); + pc.printf("%f\t",moment[i]); } + + //timer_FCTN_ACS_GENPWM_MAIN.start(); FCTN_ACS_GENPWM_MAIN(moment) ; + //timer_FCTN_ACS_GENPWM_MAIN.stop(); + //pc.printf("\n\r the timer_FCTN_ACS_CNTRLALGO is %f",timer_FCTN_ACS_GENPWM_MAIN.read()); + ACS_MAIN_STATUS = 0; return; } - else if(ACS_STATE == 8) // Auto Control + else if(ACS_STATE == 3) // Auto Control { #if print - printf("\n\r Auto control mode \n"); + pc.printf("\n\r Auto control mode \n"); #endif DRV_Z_EN = 1; DRV_XY_EN = 1; + + timer_FCTN_ACS_CNTRLALGO.start(); FCTN_ACS_CNTRLALGO(moment,mag_data,gyro_data,0x00,0x00,ACS_DETUMBLING_ALGO_TYPE); + timer_FCTN_ACS_CNTRLALGO.stop(); + //pc.printf("\n\r the timer_FCTN_ACS_CNTRLALGO is %f",timer_FCTN_ACS_CNTRLALGO.read()); + controlmode_mms = 0x00; #if print - printf("\n\r Moment values returned by control algo \n"); + pc.printf("\n\r Moment values returned by control algo \n"); for(int i=0; i<3; i++) { - printf("%f\t",moment[i]); + pc.printf("%f\t",moment[i]); } #endif + + timer_FCTN_ACS_GENPWM_MAIN.start(); FCTN_ACS_GENPWM_MAIN(moment) ;// set ACS_STATUS in function + timer_FCTN_ACS_GENPWM_MAIN.stop(); + //pc.printf("\n\r the timer_FCTN_ACS_GENPWM_MAIN is %f",timer_FCTN_ACS_GENPWM_MAIN.read()); + ACS_MAIN_STATUS = 0; return; } - else if(ACS_STATE == 9) // Detumbling + else if(ACS_STATE == 4) // Detumbling { DRV_Z_EN = 1; DRV_XY_EN = 1; @@ -680,7 +779,12 @@ pc.printf("\n\rEntered EPS %f\n\r",t_start.read()); EPS_MAIN_STATUS = 1; // Set EPS main status EPS_MAIN_COUNTER++; + + timer_FCTN_BATT_TEMP_SENSOR_MAIN.reset(); + timer_FCTN_BATT_TEMP_SENSOR_MAIN.start(); FCTN_BATT_TEMP_SENSOR_MAIN(actual_data.Batt_temp_actual); + timer_FCTN_BATT_TEMP_SENSOR_MAIN.stop(); + pc.printf("Battery temperature %f %f\n\r" ,actual_data.Batt_temp_actual[0], actual_data.Batt_temp_actual[1]); EPS_BTRY_TMP_AVG = ( actual_data.Batt_temp_actual[0] + actual_data.Batt_temp_actual[1] )/2.0; if(abs(actual_data.Batt_temp_actual[0] - actual_data.Batt_temp_actual[1]) > 10) @@ -722,10 +826,14 @@ if( EPS_BATTERY_GAUGE_STATUS == 0 ) reset(); if( read(REG_STATUS) & 0x0100 == 0x0100 ) //checking if Reset Indicator bit is set { - printf("REG_STATUS = %d\r\n",read(REG_STATUS)); + pc.printf("REG_STATUS = %d\r\n",read(REG_STATUS)); FCTN_BATTERYGAUGE_INIT(); - } + } + timer_FCTN_BATTERYGAUGE_MAIN.reset(); + timer_FCTN_BATTERYGAUGE_MAIN.start(); int BTG_MAIN_FLAG = FCTN_BATTERYGAUGE_MAIN(actual_data.Batt_gauge_actual, eps_btry_temp); + timer_FCTN_BATTERYGAUGE_MAIN.stop(); + if( BTG_MAIN_FLAG == 0 ) //Data not received { actual_data.power_mode = 1; @@ -736,14 +844,34 @@ FCTN_EPS_POWERMODE(actual_data.Batt_gauge_actual[1]); //updating power level EPS_BATTERY_GAUGE_STATUS = 1; //set EPS_BATTERY_GAUGE_STATUS } - + + timer_FCTN_HK_MAIN.reset(); + timer_FCTN_HK_MAIN.start(); FCTN_HK_MAIN(); - // printf("\n\r here"); + timer_FCTN_HK_MAIN.stop(); + // pc.printf("ere"); + + timer_FCTN_EPS_HANDLE_HW_FAULTS.reset(); + timer_FCTN_EPS_HANDLE_HW_FAULTS.start(); FCTN_EPS_HANDLE_HW_FAULTS(); + timer_FCTN_EPS_HANDLE_HW_FAULTS.stop(); + + timer_FCTN_EPS_HANDLE_CDMS_FAULT.reset(); + timer_FCTN_EPS_HANDLE_CDMS_FAULT.start(); FCTN_EPS_HANDLE_CDMS_FAULT(); + timer_FCTN_EPS_HANDLE_CDMS_FAULT.stop(); + + timer_FCTN_APPEND_HKDATA.reset(); + timer_FCTN_APPEND_HKDATA.start(); FCTN_APPEND_HKDATA(); + timer_FCTN_APPEND_HKDATA.stop(); + + timer_minMaxHkData.reset(); + timer_minMaxHkData.start(); minMaxHkData(); - //printf("\n\r here"); + timer_minMaxHkData.stop(); + + //pc.printf("ere"); EPS_MAIN_STATUS = 0; // clear EPS main status } @@ -755,7 +883,11 @@ { pc.printf("\n\rEntered BCN %f\n",t_start.read()); //BCN_TX_MAIN_COUNTER=+1; + + timer_FCTN_BCN_TX_MAIN.reset(); + timer_FCTN_BCN_TX_MAIN.start(); FCTN_BCN_TX_MAIN(); + timer_FCTN_BCN_TX_MAIN.stop(); } //**************************************************TCTM THREAD*******************************************************************// @@ -767,10 +899,11 @@ { Thread::signal_wait(0x4); wait_us(300); + BAE_MNG_I2C_STATUS =1 ; I2C_last.reset(); I2C_last.start(); - pc.printf("\n\r intrpet"); + // pc.printf("\n\r intrpet"); if( slave.receive() == 0) { pdir_ss1=PTE->PDIR; /////////edited @@ -793,7 +926,8 @@ BAE_I2C_COUNTER++; //////////edited if(data_send_flag == 'h') //to be renamed as BAE_I2C_STATUS { - irpt_2_mstr =1; //wait till cdms code is changed + irpt_2_mstr =1; + //pc.printf("\n\r hk "); //wait till cdms code is changed FCTN_APPEND_HKDATA(); uint8_t i2c_count =0; //crc is already being added @@ -803,6 +937,9 @@ irpt_2_mstr = 0; if(write_ack==0)// wait till cdms code is changed { + /*checking the tc timings*/ + // time_wdog = 1; + while(((pdir_tm1 & 0x00000003)!=3)&& i2c_count<10) { wait_ms(1); @@ -812,7 +949,7 @@ if(((pdir_tm1 & 0x00000003)==3)) { pc.printf("\n\rWrite HK success"); - data_send_flag = 'h'; + // data_send_flag = 'h'; irpt_2_mstr = 0; //////////edited } else @@ -843,14 +980,15 @@ } i2c_count=0; } - else//data_send_flag = "t" //else if(telecommand[1]&0xC0 == 't') + else if (data_send_flag == 't') //else if(telecommand[1]&0xC0 == 't') { uint8_t i2c_count =0; write_ack=slave.write((char*)telemetry,134); ////////edited(size) wait_ms(1); //for correct values of register to be updated pdir_tm1=PTE->PDIR; irpt_2_mstr = 0; - data_send_flag = 'h'; + data_send_flag = 'h'; + // pc.printf("\n\r h set here"); if(write_ack==0) { while(((pdir_tm1 & 0x00000003)!=3)&& i2c_count<10) @@ -890,11 +1028,17 @@ #endif } i2c_count=0; - } + } + // else + // pc.printf("\n\r hey something wrong"); } else if( slave.receive()==3 || slave.receive()==2) // slave read { BAE_I2C_COUNTER++; + + /*checking the tc timings*/ + time_wdog = 1; + uint8_t i2c_count = 0; read_ack=slave.read((char *)telecommand,135); //read() function returns acknowledgement wait_ms(1); @@ -909,14 +1053,20 @@ } if(((pdir_tc1 & 0x00000003)==3)) { - pc.printf("\n\n\rRead TC success"); + //pc.printf("\n\n\rRead TC success"); if(telecommand[0] == 0x00) /////////////edited - FCTN_CDMS_HK_TC((uint8_t*) telecommand); /////////////edited + { + FCTN_CDMS_HK_TC((uint8_t*) telecommand); /////////////edited + data_send_flag = 'h'; + pc.printf("\n\n\rRead LBCN QM is comming"); + } else { + pc.printf("\n\r Read TC SUCESS"); FCTN_BAE_TM_TC((uint8_t*) telecommand); data_send_flag = 't'; irpt_2_mstr = 1; + } } else //either or both of SDA and SCL lines low @@ -1016,7 +1166,7 @@ void T_SC(void const *args) { #if print - printf("\n\r in scheduler"); + pc.printf("\n\r in scheduler"); #endif /*if keeping thish many cases creates a problem then make 3 seperate flagvariable i.e bae_standby_acs so on that will make it easy.!!!*/ if(schedcount == 13) //to reset the counter @@ -1026,7 +1176,18 @@ if( BAE_STANDBY!=0x02 && BAE_STANDBY!=0x03 && BAE_STANDBY!=0x06 && BAE_STANDBY!=0x07) { pc.printf("\nSTATE IS !!!!!! = %x !!\n",ACS_STATE); + timer_F_ACS.reset(); + timer_F_ACS.start(); F_ACS(); + timer_F_ACS.stop(); + /*pc.printf("\n\r timer_F_ACS is %f",timer_F_ACS.read()); + pc.printf("\n\r timer_SENSOR_INIT is %f",timer_SENSOR_INIT.read()); + pc.printf("\n\r timer_CONFIG_UPLOAD is %f",timer_CONFIG_UPLOAD.read()); + pc.printf("\n\r timer_SENSOR_DATA_ACQ is %f",timer_SENSOR_DATA_ACQ.read()); + pc.printf("\n\r timer_FCTN_ACS_GENPWM_MAIN is %f",timer_FCTN_ACS_GENPWM_MAIN.read()); + pc.printf("\n\r timer_FCTN_ACS_CNTRLALGO is %f",timer_FCTN_ACS_CNTRLALGO.read()); + pc.printf("\n\r timer_controlmodes is %f",timer_controlmodes.read()); + */ //time_wdog = 0; } @@ -1036,15 +1197,42 @@ if( BAE_STANDBY!=0x01 && BAE_STANDBY!=0x03 && BAE_STANDBY!=0x05 && BAE_STANDBY!=0x07) { //time_wdog = 1; + timer_F_ESP.reset(); + timer_F_ESP.start(); F_EPS(); + timer_F_ESP.stop(); + pc.printf("\n\r timer_F_ESP is %f",timer_F_ESP.read()); + /* pc.printf("\n\r timer_FCTN_BATTERYGAUGE_INIT is %f",timer_FCTN_BATTERYGAUGE_INIT.read()); + pc.printf("\n\r timer_alertFlags is %f",timer_alertFlags.read()); + pc.printf("\n\r timer_soc is %f",timer_soc.read()); + pc.printf("\n\r timer_FCTN_BATT_TEMP_SENSOR_MAIN is %f",timer_FCTN_BATT_TEMP_SENSOR_MAIN.read()); + pc.printf("\n\r timer_FCTN_BATTERYGAUGE_MAIN is %f",timer_FCTN_BATTERYGAUGE_MAIN.read()); + pc.printf("\n\r timer_FCTN_HK_MAIN is %f",timer_FCTN_HK_MAIN.read()); + pc.printf("\n\r timer_FCTN_EPS_HANDLE_HW_FAULTS is %f",timer_FCTN_EPS_HANDLE_HW_FAULTS.read()); + pc.printf("\n\r timer_FCTN_EPS_HANDLE_CDMS_FAULT is %f",timer_FCTN_EPS_HANDLE_CDMS_FAULT.read()); + pc.printf("\n\r timer_FCTN_APPEND_HKDATA is %f",timer_FCTN_APPEND_HKDATA.read()); + pc.printf("\n\r timer_minMaxHkData is %f",timer_minMaxHkData.read()); + */ } //time_wdog = 0; } if(schedcount%6==0) { if(BAE_STANDBY!=0x04 && BAE_STANDBY!=0x05 && BAE_STANDBY!=0x06 && BAE_STANDBY!=0x07) - // time_wdog = 0; - F_BCN(); + { // time_wdog = 0; + timer_F_BCN.reset(); + timer_F_BCN.start(); + F_BCN(); + timer_F_BCN.stop(); + /*pc.printf("\n\r timer_F_BCN is %f",timer_F_BCN.read()); + pc.printf("\n\r timer_Init_BEACON_HW is %f",timer_Init_BEACON_HW.read()); + pc.printf("\n\r timer_FCTN_BCN_TX_MAIN is %f",timer_FCTN_BCN_TX_MAIN.read()); + pc.printf("\n\r timer_Set_BCN_TX_STATUS_SUCCESS is %f",timer_Set_BCN_TX_STATUS_SUCCESS.read()); + pc.printf("\n\r timer_Set_BCN_TX_STATUS_FAILURE is %f",timer_Set_BCN_TX_STATUS_FAILURE.read()); + pc.printf("\n\r timer_Set_BCN_TX_STATUS_DISABLED is %f",timer_Set_BCN_TX_STATUS_DISABLED.read()); + pc.printf("\n\r timer_Set_BCN_TX_STATUS_SUSPENDED is %f",timer_Set_BCN_TX_STATUS_SUSPENDED.read()); + pc.printf("\n\r timer_Set_BCN_TX_STATUS_RF_SILENCE is %f",timer_Set_BCN_TX_STATUS_RF_SILENCE.read()); + */} } schedcount++; #if print @@ -1204,19 +1392,36 @@ //time_wdog = 1; + kick_WDOG(); + pc.printf("\n\r lvl1"); + //...........order mentioned in flow chart.................// + timer_FCTN_BAE_INIT.reset(); + timer_FCTN_BAE_INIT.start(); FCTN_ACS_INIT(); + timer_FCTN_BAE_INIT.stop(); + pc.printf("\n\r timer_FCTN_BAE_INIT is %f",timer_FCTN_BAE_INIT.read()); + + timer_FCTN_EPS_INIT.reset(); + timer_FCTN_EPS_INIT.start(); FCTN_EPS_INIT(); + timer_FCTN_EPS_INIT.stop(); + pc.printf("\n\r timer_FCTN_EPS_INIT is %f",timer_FCTN_EPS_INIT.read()); + + timer_FCTN_BCN_INIT.reset(); + timer_FCTN_BCN_INIT.start(); FCTN_BCN_INIT(); + timer_FCTN_BCN_INIT.stop(); + pc.printf("\n\r timer_FCTN_BCN_INIT is %f",timer_FCTN_BCN_INIT.read()); //uint32_t data_flash=FCTN_BAE_RD_FLASH_ENTITY(0);/*sending the 0 entity as in mms tc/tm bae_reset_counter is present in first 32 bits */ //uint32_t data_modify=data_flash & 0x000000FF; //data_modify +=1; //data_modify |=data_flash; //FCTN_BAE_WR_FLASH(0,data_modify); - #if print - printf("\n\rthe number of reset %d",data_modify); - #endif + //#if print + // printf("\n\rthe number of reset %d",data_modify); + //#endif BAE_INIT_STATUS=0; FLAG(); } @@ -1229,7 +1434,15 @@ //time_wdog = 1; pc.printf("\n\r BAE Activated. Testing Version 1.2 \n"); //FLASH_INI(); + + time_wdog=1; + timer_FCTN_BAE_INIT.start(); FCTN_BAE_INIT(); + timer_FCTN_BAE_INIT.stop(); + pc.printf("\n\r timer_FCTN_BAE_INIT is %f",timer_FCTN_BAE_INIT.read()); + + time_wdog=0; + //time_wdog = 0; slave.address(addr); @@ -1261,13 +1474,16 @@ RtosTimer EPS_HTR_OFF_TIMER(FCTN_EPS_HTR_OFF, osTimerOnce); HTR_OFF=&EPS_HTR_OFF_TIMER; - RtosTimer EPS_HTR_CYCLE_TIMER(FCTN_EPS_HTR_CYCLE); + RtosTimer EPS_HTR_CYCLE_TIMER(FCTN_EPS_HTR_CYCLE, osTimerPeriodic); HTR_CYCLE=&EPS_HTR_CYCLE_TIMER; RtosTimer EPS_HTR_DLY_TIMER(FCTN_EPS_HTR_DLY,osTimerOnce); HTR_DLY=&EPS_HTR_DLY_TIMER; + timer_FLASH_INI.start(); FLASH_INI(); + timer_FLASH_INI.stop(); + pc.printf("\n\r timer_FCTN_BAE_INIT is %f",timer_FCTN_BAE_INIT.read()); while(1); //required to prevent main from terminating