//--------------------------------------------------------------------------------------------------- // Tâches de démarrages, init du hardware et création des tâches de l'applicaiton //--------------------------------------------------------------------------------------------------- static void AppTaskStart(void *p_arg) { OS_ERR aErr; // Pour le warning du compilateur (void)p_arg; // Start BSP and tick initialization BSP_Init(); // Start Tick Initialization BSP_Tick_Init(); mLeds_Setup(); #if OS_CFG_STAT_TASK_EN > 0u // Compute CPU capacity with no task running */ OSStatTaskCPUUsageInit(&aErr); #endif OSTaskCreate((OS_TCB *)&Task1_Tcb, (CPU_CHAR *)"Task1", (OS_TASK_PTR ) Task1, (void *) 0, (OS_PRIO ) kTask1Pr, (CPU_STK *)&sTask1Stk[0], (CPU_STK )(kStackSize / 10u), (CPU_STK_SIZE) kStackSize, (OS_MSG_QTY ) 0, (OS_TICK ) 0, (void *) 0, (OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), (OS_ERR *)&aErr); OSTaskCreate((OS_TCB *)&Task2_Tcb, (CPU_CHAR *)"Task2", (OS_TASK_PTR ) Task2, (void *) 0, (OS_PRIO ) kTask2Pr, (CPU_STK *)&sTask2Stk[0], (CPU_STK )(kStackSize / 10u), (CPU_STK_SIZE) kStackSize, (OS_MSG_QTY ) 0, (OS_TICK ) 0, (void *) 0, (OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), (OS_ERR *)&aErr); while (DEF_TRUE) { OSTaskDel(&sAppTaskStartTCB,&aErr); } }
void main(void) { bool ledState = false; //------------------------------------------------------------------------------- // Setup des interfaces //------------------------------------------------------------------------------- iCpu_SysInit(); iI2C_Setup(); iUart_Config(); iSpi_Setup(); iPit_Config(kPit0, 2); iPit_StartPit(kPit0); iAd_Config(); iAd_Cal(kAdc0); //------------------------------------------------------------------------------- // Open des interfaces //------------------------------------------------------------------------------- iI2C_Open(); iUart_Open(); iSpi_Open(); //------------------------------------------------------------------------------- // Setup des modules //------------------------------------------------------------------------------- mCpu_Setup(); // PLL and crossbar configuration mLeds_Setup(); // Configuration Port leds mPwm_Setup(); // FTMx configuration mDelay_Setup(); mRfInterface_Setup(); mCapteurAccelMagn_Setup(); mCapteurGyro_Setup(); mCapteurPression_Setup(); mMesureAlimentation_Setup(); mOrientationProcessing_setup(); mLeds_WriteLed(kLed2, kLedOn); //------------------------------------------------------------------------------- // Open des modules //------------------------------------------------------------------------------- mDelay_Open(); mRfInterface_Open(); mCapteurAccelMagn_Open(); mCapteurPression_Open(); mLeds_WriteLed(kLed3, kLedOn); //------------------------------------------------------------------------------- // Setup des gestionnaires //------------------------------------------------------------------------------- gInput_Setup(); gCompute_Setup(); gLabview_Setup(); gOutput_Setup(); mLeds_WriteLed(kLed4, kLedOn); mOrientationProcessing_open(); //A faire en dernier //------------------------------------------------------------------------------- // Execute des gestionnaires //------------------------------------------------------------------------------- while (1) { ledState = !ledState; mLeds_WriteLed(kLed5, ledState); gInput_Execute(); gCompute_Execute(); gLabview_Execute(); gOutput_Execute(); } }
int main(void) { //Non specific modules initialization mCpu_Setup(); mDelay_Setup(); mLeds_Setup(); mGpio_Setup(0x1<<8); mSwitches_Setup(); //Tasks initialization gAltitudeSensors_Setup(); gAttitudeSensors_Setup(); gFlightCompute_Setup(); gLight_Setup(); gMonitoring_Setup(); gReceiver_Setup(); gMotors_Setup(); gMiscSensors_Setup(); //Tasks open gAttitudeSensors_Open(); //Wait 1second after setup UInt16 aDelayBoot = mDelay_GetDelay(kPit0, 1000); while(mDelay_IsDelayDone(kPit0, aDelayBoot)==false); mDelay_DelayRelease(kPit0, aDelayBoot); //Indicate that programm is ready. mLeds_AllOn(); //Get delay for main loop UInt16 aDelayMainLoop = mDelay_GetDelay(kPit0, 5); //Main loop while(1) { while(mDelay_IsDelayDone(kPit0, aDelayMainLoop)==false); mDelay_ReStart(kPit0, aDelayMainLoop, 5); //Get inputs gAttitudeSensors_Run(); gReceiver_Run(); gAltitudeSensors_Run(); gMiscSensors_Run(); //Compute gFlightCompute_Run(); //Export outputs gMotors_Run(); gLight_Run(); //Monitoring gMonitoring_Run(); //Measure time with logic //mGpio_AllToggle(); } //Never happens (infinite loop above) return 0; }