/** * Funcion para obtener una variable de estado * @param indxVar. Variable de estado que quiero modificar */ int sta_get_BusStateVar(STA_BusStateVar indxVar){ portBASE_TYPE semStatus = xSemaphoreTake( statusRepositorySem, portMAX_DELAY ); int value; int param; switch(indxVar){ // Bus Hw status (connected trough the PC/104 to the OBC -PIC24-) case sta_RTC_isAlive: value = RTC_isAlive(); break; case sta_TRX_isAlive: value = trx_isAlive(NULL); break; case sta_EPS_isAlive: value = eps_isAlive(NULL); break; case sta_MemEEPROM_isAlive: value = mem_EEPROM_isAlive(); break; case sta_MemSD_isAlive: value = memSD_isAlive(); break; case sta_AntSwitch_isOpen: param = 1000; value = thk_get_AntSwitch_isOpen(¶m); break; //FPL => (C&DH subsystem) case sta_fpl_index: //printf("FPL => (C&DH subsystem, Fligth Plan)\r\n"); value = drp_fpl_get_index(NULL); break; //PPC => (C&DH subsystem) case sta_ppc_opMode: //printf("PPC => (C&DH subsystem)\r\n"); value = ppc_get_opMode(NULL); break; case sta_ppc_lastResetSource: param = 0; //verbosity level value = ppc_get_lastResetSource(¶m); break; case sta_ppc_hoursAlive: value = ppc_get_hoursAlive(NULL); break; case sta_ppc_hoursWithoutReset: value = ppc_get_hoursWithoutReset(NULL); break; case sta_ppc_resetCounter: value = ppc_get_resetCounter(NULL); break; case sta_ppc_wdt: value = ppc_get_wdt_state(NULL); break; case sta_ppc_osc: param = 0; //verbosity level value = ppc_get_osc(¶m); break; case sta_ppc_MB_nOE_USB_nINT_stat: value = ppc_get_PPC_MB_nOE_USB_nINT(NULL); break; case sta_ppc_MB_nOE_MHX_stat: value = ppc_get_PPC_MB_nOE_MHX(NULL); break; case sta_ppc_MB_nON_MHX_stat: value = ppc_get_PPC_MB_nON_MHX(NULL); break; case sta_ppc_MB_nON_SD_stat: value = ppc_get_PPC_MB_nON_SD(NULL); break; //DEP => (C&DH subsystem) case sta_dep_ant_deployed: //printf("DEP => (C&DH subsystem)\r\n"); value = thk_get_dep_ant_deployed(NULL); break; case sta_dep_ant_tries: value = thk_get_dep_ant_tries(NULL); break; case sta_dep_year: value = thk_get_dep_year(NULL); break; case sta_dep_month: value = thk_get_dep_month(NULL); break; case sta_dep_week_day: value = thk_get_dep_week_day(NULL); break; case sta_dep_day_number: value = thk_get_dep_day_number(NULL); break; case sta_dep_hours: value = thk_get_dep_hours(NULL); break; case sta_dep_minutes: value = thk_get_dep_minutes(NULL); break; case sta_dep_seconds: value = thk_get_dep_seconds(NULL); break; //RTC => (C&DH subsystem) case sta_rtc_year: //printf("RTC => (C&DH subsystem)\r\n"); value = RTC_get_year(); break; case sta_rtc_month: value = RTC_get_month(); break; case sta_rtc_week_day: value = RTC_get_week_day(); break; case sta_rtc_day_number: value = RTC_get_day_num(); break; case sta_rtc_hours: value = RTC_get_hours(); break; case sta_rtc_minutes: value = RTC_get_minutes(); break; case sta_rtc_seconds: value = RTC_get_seconds(); break; #if (SCH_EPS_ONBOARD==1) case sta_eps_batt_temp_0: param = EPS_ID_batt_temp_0; value = eps_read_vars(¶m); break; case sta_eps_batt_temp_1: param = EPS_ID_batt_temp_1; value = eps_read_vars(¶m); break; case sta_eps_battery_voltage: param = EPS_ID_battery_voltage; value = eps_read_vars(¶m); break; case sta_eps_panel_current: param = EPS_ID_panel_current; value = eps_read_vars(¶m); break; case sta_eps_panel_voltage_1: param = EPS_ID_panel_voltage_1; value = eps_read_vars(¶m); break; case sta_eps_panel_voltage_2: param = EPS_ID_panel_voltage_2; value = eps_read_vars(¶m); break; case sta_eps_panel_voltage_3: param = EPS_ID_panel_voltage_3; value = eps_read_vars(¶m); break; case sta_eps_system_current: param = EPS_ID_system_current; value = eps_read_vars(¶m); break; #endif #if (SCH_TRX_ONBOARD==1) //TRX => (Communication subsystem) case sta_trx_opmode: value = trx_get_operation_mode(NULL); break; case sta_trx_count_tm: value = trx_get_count_tm(NULL); break; case sta_trx_count_tc: value = trx_get_count_tc(NULL); break; case sta_trx_day_last_tc: value = trx_get_day_last_tc(NULL); break; case sta_trx_beacon_bat_lvl: value = trx_get_beacon_level(NULL); break; case sta_trx_beacon_period: value = trx_get_beacon_period(NULL); break; case sta_trx_rx_baud: value = trx_get_rx_baud(NULL); break; case sta_trx_tx_baud: value = trx_get_tx_baud(NULL); break; #endif default: printf("[sta_get_stateVar] Error: No function/command for STA_StateVar %d \r\n", indxVar); value = -(0x7FFF); break; } semStatus = xSemaphoreGive(statusRepositorySem); return value; }
/** * Command that writes DEP registration. It takes care of: * 1) Register success or failure of antenna deployment * 2) Reset Antenna DEP vars to a Before Fligth condition * @param param -1 = Reset, [1, MAX_TRIES] registration as succes, * [MAX_TRIES+1 = registration as failure * @return 1 = On a correct parameter, 0 incorrect parameter (no change in vars) */ int thk_deployment_registration(void *param) { int dep_tries = *( (int *)param ); int dep_state; MemEEPROM_Vars mem_eeprom_var; int value; BOOL valid_dep_tries = FALSE; //Reset antenna DEP variables (EBF routine) if(dep_tries == (-1) ) { mem_eeprom_var = mem_dep_ant_deployed; value = 0; writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_ant_tries; value = 0; writeIntEEPROM1(mem_eeprom_var, value); //RTC mem_eeprom_var = mem_dep_year; value = 0; writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_month; value = 0; writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_day_number; value = 0; writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_week_day; value = 0; writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_hours; value = 0; writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_minutes; value = 0; writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_seconds; value = 0; writeIntEEPROM1(mem_eeprom_var, value); return 1; } // Antennas were NOT deployed if(dep_tries == (THK_MAX_TRIES_ANT_DEPLOY+1) ){ dep_state = 0; dep_tries = THK_MAX_TRIES_ANT_DEPLOY+1; valid_dep_tries = TRUE; } //Antennas were deployed if( (dep_tries >= 1) && (dep_tries <= THK_MAX_TRIES_ANT_DEPLOY) ){ dep_state = 1; valid_dep_tries = TRUE; } //Register only if valid_dep_tries == TRUE; if( valid_dep_tries == TRUE ){ mem_eeprom_var = mem_dep_ant_deployed; value = dep_state; writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_ant_tries; value = dep_tries; writeIntEEPROM1(mem_eeprom_var, value); //RTC mem_eeprom_var = mem_dep_year; value = RTC_get_year(); writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_month; value = RTC_get_month(); writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_day_number; value = RTC_get_day_num(); writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_week_day; value = RTC_get_week_day(); writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_hours; value = RTC_get_hours(); writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_minutes; value = RTC_get_minutes(); writeIntEEPROM1(mem_eeprom_var, value); mem_eeprom_var = mem_dep_seconds; value = RTC_get_seconds(); writeIntEEPROM1(mem_eeprom_var, value); return 1; } else{ return 0; } }