Example #1
0
/**
 * Funcion a llamar luego de un Reset del PIC y luego de 
 * @sa sta_onReset_memEEPROM para inicializar a los valore correctos las
 * variables de estado que necesitan ser modificadas.
 *
 * No todas son modificadas, hay muchas que se inicializan en otros
 * llamados anteriores o posteriores (@sa default_PIC_config,
 * @sa dep_init_suchai_hw, @sa dep_init_suchai_repos).
 */
void sta_onReset_BusStateRepo(void)
{
    int param, res;

    // Set to default
    //param = STA_PPC_OPMODE_NORMAL;
    //ppc_set_opMode(&param);

    // Increment reset counter
    param = ppc_get_resetCounter(NULL);
    param++;
    ppc_set_resetCounter(&param);
    

    //print important StatusVars
    printf("    [sta_onResetStatRepo] Important STA_StateVar variables:\r\n");

    res = ppc_get_resetCounter(NULL);
    printf("        * ppc_get_resetCounter: %d\r\n", res);
    #if (SCH_DATAREPOSITORY_VERBOSE>=1)
        if(res == 0){
            printf("            * First time on, resetCounter = %d\n", res);
        }
        else{
            printf("            * NOT the First time on, resetCounter = %d\n", res);
        }
    #endif

    param = 1;  //verbose
    ppc_get_lastResetSource(&param);

    res = ppc_get_hoursAlive(NULL);
    printf("        * ppc_get_hoursAlive: %d\r\n", res);

    res = ppc_get_hoursWithoutReset(NULL);
    printf("        * ppc_get_hoursWithoutReset: %d\r\n", res);

    res = ppc_get_wdt_state(NULL);
    printf("        * ppc_get_wdt_state: %d\r\n", res);

    param = 1;  //verbose
    res = ppc_get_osc(&param);

    //Antenna
    param = 1000;
    res = thk_get_AntSwitch_isOpen(&param);
    printf("        * thk_get_AntSwitch_isOpen: %d\r\n", res);
    #if (SCH_DATAREPOSITORY_VERBOSE>=1)
        printf("            * Antenna Deployment rely on this var AND others\r\n");
    #endif

    res = thk_get_dep_ant_deployed(NULL);
    printf("        * thk_get_dep_ant_deployed: %d\r\n", res);
    #if (SCH_DATAREPOSITORY_VERBOSE>=1)
        if(res == 0){
            printf("            * Antenna Deployment is pending\r\n");
        }
        else{
            printf("            * Antenna Deployment was successfully completed\r\n");
        }
    #endif

//    /* Debug purposes      */
//    int dep = thk_get_dep_ant_deployed(NULL);
//    if(dep == 0){
//        printf("[sta_onResetStatRepo] All STA_StateVar variables:\r\n");
//        //print all SatatusVars
//        srp_print_STA_stateVar(NULL);
//    }
}
Example #2
0
/**
 * Set every memEEPROM var to its initial value (to a Before Fligth condition)
 * @param param None
 * @return 1 = Ok, 0 = Fail
 */
int srp_memEEPROM_initial_state(void * param){
    int arg;

    //PPC => (C&DH subsystem)
    arg = STA_PPC_OPMODE_NORMAL;
    ppc_set_opMode(&arg);
    arg = 0;
    ppc_set_hoursAlive(&arg);
    arg = 0;
    ppc_set_hoursWithoutReset(&arg);
    arg = -1;   //always incremented onReset => to get 0 a -1 needs to be set
    ppc_set_resetCounter(&arg);

    //DEP => (C&DH subsystem)
    arg = -1;   //Reset Antenna DEP vars to a Before Fligth condition
    thk_deployment_registration(&arg);

    //Flight Plan
    arg = 0;
    drp_fpl_set_index(&arg);

    //PAYLOAD
    #if (SCH_PAY_LANGMUIR_ONBOARD==1)
        arg = pay_xxx_state_active;
        pay_set_state_lagmuirProbe(&arg);
    #else
        sta_setstateVar(sta_pay_lagmuirarg = pay_xxx_state_inactive;
        pay_set_state_lagmuirProbe(&arg);
    #endif
    #if (SCH_PAY_SENSTEMP_ONBOARD==1)
        arg = pay_xxx_state_active;
        pay_set_state_sensTemp(&arg);
    #else
        arg = pay_xxx_state_inactive;
        pay_set_state_sensTemp(&arg);
    #endif
    #if (SCH_PAY_GPS_ONBOARD==1)
        arg = pay_xxx_state_active;
        pay_set_state_gps(&arg);
    #else
        arg = pay_xxx_state_inactive;
        pay_set_state_gps(&arg);
    #endif
    #if (SCH_PAY_FIS_ONBOARD==1)
        //arg = sta_pay_xxx_state_active;
        arg = pay_xxx_state_inactive;   //special case, not executed by FP2
        pay_set_state_expFis(&arg);
    #else
        arg = pay_xxx_state_inactive;
        pay_set_state_expFis(&arg);
    #endif
    #if (SCH_PAY_CAM_nMEMFLASH_ONBOARD==1)
        //  arg = sta_pay_xxx_state_active;
        arg = pay_xxx_state_inactive;   //special case, not executed by FP2
        pay_set_state_camera(&arg);
    #else
        arg = pay_xxx_state_inactive;
        pay_set_state_camera(&arg);
    #endif
    #if (SCH_PAY_GYRO_ONBOARD==1)
        arg = pay_xxx_state_active;
        pay_set_state_gyro(&arg);
    #else
        arg = pay_xxx_state_inactive;
        pay_set_state_gyro(&arg);
    #endif
    #if (SCH_PAY_TMESTADO_ONBOARD==1)
        arg = pay_xxx_state_active;
        pay_set_state_tmEstado(&arg);
    #else
        arg = pay_xxx_state_inactive;
        pay_set_state_tmEstado(&arg);
    #endif
    #if (SCH_PAY_BATTERY_ONBOARD==1)
        arg = pay_xxx_state_active;
        pay_set_state_battery(&arg);
    #else
        arg = pay_xxx_state_inactive;
        pay_set_state_battery(&arg);
    #endif
    #if (SCH_PAY_DEBUG_ONBOARD==1)
        arg = pay_xxx_state_active;
        pay_set_state_debug(&arg);
    #else
        arg = pay_xxx_state_inactive;
        pay_set_state_debug(&arg);
    #endif

    //TRX
    arg = 0;
    trx_set_operation_mode(&arg);
    arg = 0;
    trx_set_count_tc(&arg);
    arg = 0;
    trx_set_count_tm(&arg);
    arg = 0;
    trx_set_day_last_tc(&arg);
    arg = SCH_TRX_BEACON_PERIOD;
    trx_set_beacon_period(&arg);
    arg = SCH_TRX_BEACON_BAT_LVL;
    trx_set_beacon_level(&arg);
    arg = SCH_TRX_RX_BAUD;
    trx_set_rx_baud(&arg);
    arg = SCH_TRX_TX_BAUD;
    trx_set_tx_baud(&arg);

    /* Save configuration to TRX, to make the available to the next TRX wakeup */
    arg = 0;    //not deployed
    trx_initialize(&arg);

    return 1;
}