Esempio n. 1
0
int main(void)
{
    OS_ERR  err;

    BSP_IntDisAll();                                            /* Disable all interrupts.                              */
    
    CPU_Init();                                                 /* Initialize the uC/CPU Services                       */
    Mem_Init();                                                 /* Initialize Memory Management Module                  */
    Math_Init();                                                /* Initialize Mathematical Module                       */

    OSInit(&err);                                               /* Init uC/OS-III.                                      */

    OSTaskCreate((OS_TCB       *)&AppTaskStartTCB,              /* Create the start task                                */
                 (CPU_CHAR     *)"App Task Start",
                 (OS_TASK_PTR   )AppTaskStart,
                 (void         *)0u,
                 (OS_PRIO       )APP_CFG_TASK_START_PRIO,
                 (CPU_STK      *)&AppTaskStartStk[0u],
                 (CPU_STK_SIZE  )AppTaskStartStk[APP_CFG_TASK_START_STK_SIZE / 10u],
                 (CPU_STK_SIZE  )APP_CFG_TASK_START_STK_SIZE,
                 (OS_MSG_QTY    )0u,
                 (OS_TICK       )0u,
                 (void         *)0u,
                 (OS_OPT        )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
                 (OS_ERR       *)&err);

    OSStart(&err);                                              /* Start multitasking (i.e. give control to uC/OS-III). */

    (void)&err;

    return (0u);
}
Esempio n. 2
0
static  void  AppTaskStart (void *p_arg)
{
   (void)p_arg;

    BSP_Init();                                                 /* Initialize BSP functions                             */
    CPU_Init();                                                 /* Initialize the uC/CPU services                       */
    
    BSP_Tick_Init();                                            /* Start Tick Initialization                            */

    Mem_Init();                                                 /* Initialize memory managment module                   */
    Math_Init();                                                /* Initialize mathematical module                       */


#if (OS_TASK_STAT_EN > 0)
    OSStatInit();                                               /* Determine CPU capacity                               */
#endif

    BSP_LED_Off(0);
    
#if (APP_CFG_SERIAL_EN == DEF_ENABLED)    
    App_SerialInit();                                           /* Initialize Serial communication for application ...  */
#endif

    APP_TRACE_INFO(("Creating Application Events...\n\r"));
    AppEventCreate();                                          /* Create Application Events                            */

    APP_TRACE_INFO(("Creating Application Tasks...\n\r"));
    AppTaskCreate();                                           /* Create application tasks                             */
    
    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop.       */
        BSP_LED_Toggle(0);
        OSTimeDlyHMSM(0, 0, 0, 100);
    }
}
Esempio n. 3
0
File: app.c Progetto: binhfile/stm32
int main(void)
{
    OS_ERR   err;
    int i;

    HAL_Init();                                                 /* See Note 1.                                          */
    Mem_Init();                                                 /* Initialize Memory Managment Module                   */
    Math_Init();                                                /* Initialize Mathematical Module                       */
    BSP_IntDisAll();                                            /* Disable all Interrupts.                              */
    App_OS_SetAllHooks();

    OSInit(&err);                                               /* Init uC/OS-III.                                      */


    for(i = 0; i < APP_THREAD_COUNT-1; i++)
        sem_init(&g_thread_startup[i], 0, 0);
    sem_init(&g_sem_debug, 0, 1);
    g_debug_tx_buffer = mq_open(0, 512);

    pthread_attr_setstacksize(&g_thread_attr[0], 1024*2);
    pthread_create(&g_thread[0], &g_thread_attr[0], Thread_Startup, 0);
    pthread_setschedprio(&g_thread[0], 1);

    DEFINE_THREAD(Thread_DebugTX, 1024,   1);
    DEFINE_THREAD(Thread_DebugRx, 1024,   1);
    DEFINE_THREAD(Thread_RFIntr,  1024,   3);
    DEFINE_THREAD(Thread_MiwiTask,1024*5, 4);

    OSStart(&err);                                              /* Start multitasking (i.e. give control to uC/OS-III). */

    while (1) {}
}
Esempio n. 4
0
int  main (void)
{
    OS_ERR  err;

#if (CPU_CFG_NAME_EN == DEF_ENABLED)
    CPU_ERR     cpu_err;
#endif


    CPU_Init();                                                 /* Initialize the CPU abstraction layer.                */

    Mem_Init();                                                 /* Initialize the Memory Management Module.             */

    Math_Init();                                                /* Initialize the Mathematical Module.                  */

#if (CPU_CFG_NAME_EN == DEF_ENABLED)
    CPU_NameSet((CPU_CHAR *)"MKL46Z256VLL4",
                (CPU_ERR  *)&cpu_err);
#endif

    BSP_IntDisAll();                                            /* Disable all interrupts.                              */

#if (defined(TRACE_CFG_EN) && (TRACE_CFG_EN > 0u))
    TRACE_INIT();                                               /* Initialize the µC/Trace recorder.                    */
    TRACE_START();                                              /* Start recording.                                     */
#endif

    OSInit(&err);                                               /* Initialize "uC/OS-III, The Real-Time Kernel".        */
	
    OSMutexCreate((OS_MUTEX  *)&AppMutex,
                 (CPU_CHAR   *)"My App. Mutex",
                 (OS_ERR     *)&err);
  
    OSQCreate    ((OS_Q      *)&AppQ,
                 (CPU_CHAR   *)"My App Queue",
                 (OS_MSG_QTY  )10,
                 (OS_ERR     *)&err);

    OSTaskCreate((OS_TCB     *)&App_TaskStartTCB,               /* Create the startup task.                             */
                 (CPU_CHAR   *)"Startup Task",
                 (OS_TASK_PTR ) App_TaskStart,
                 (void       *) 0,
                 (OS_PRIO     ) APP_CFG_TASK_START_PRIO,
                 (CPU_STK    *)&App_TaskStartStk[0],
                 (CPU_STK     )(APP_CFG_TASK_START_STK_SIZE / 10u),
                 (CPU_STK_SIZE) APP_CFG_TASK_START_STK_SIZE,
                 (OS_MSG_QTY  ) 0,
                 (OS_TICK     ) 0,
                 (void       *) 0,
                 (OS_OPT      )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
                 (OS_ERR     *)&err);

    OSStart(&err);                                              /* Start multitasking (i.e. give control to uC/OS-III). */

    while(DEF_ON) {                                             /* Should Never Get Here                                */
    };
}
Esempio n. 5
0
//---------------------------------------------------------------------------------------------------
// Main
//---------------------------------------------------------------------------------------------------
int  main (void)
{
	OS_ERR  aErr;
    
  SCB_SHPR2=(3<<30);
    
#if (CPU_CFG_NAME_EN == DEF_ENABLED)
    CPU_ERR     aCpuErr;
#endif

	// Initialize the CPU abstraction layer
	CPU_Init();                                                 
	
	//Initialize the Memory Management Module
	Mem_Init();                                                 
	
	// Initialize the Mathematical Module
	Math_Init();                                                

#if (CPU_CFG_NAME_EN == DEF_ENABLED)
	CPU_NameSet((CPU_CHAR *)"MKL46Z256VLL4",(CPU_ERR  *)&aCpuErr);
#endif

	// Disable all interrupts
	BSP_IntDisAll();                                            

#if (defined(TRACE_CFG_EN) && (TRACE_CFG_EN > 0u))
    TRACE_INIT();		// Initialize the µC/Trace recorder
    TRACE_START();	// Start recording
#endif
   
	// Initialize "uC/OS-III, The Real-Time Kernel"
	OSInit(&aErr);                                               
	
	// Création de la tâche de démarrage
	OSTaskCreate((OS_TCB     *)&sAppTaskStartTCB,               
							 (CPU_CHAR   *)"Startup Task",
							 (OS_TASK_PTR ) AppTaskStart,
							 (void       *) 0,
							 (OS_PRIO     ) kStartTaskPr,
							 (CPU_STK    *)&sAppTaskStartStk[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);

	// Démarrage du multitâche
	OSStart(&aErr);                                              
	
	// On ne doit jamais se trouver ici...
	while(1);
}
Esempio n. 6
0
int main(void)
{
#if (OS_TASK_NAME_EN > 0)
    CPU_INT08U  err;
#endif   

	SYS_UnlockReg();

    BSP_Init();                                                 /* Initialize BSP functions                             */

    BSP_Set_PLL_Freq(CLK_XTL_12M, PLL_DEFAULT_HZ);				/* Configure PLL                                        */
    BSP_Set_System_Clock(CLK_PLL, 0);                      		/* Select HCLK source clock as PLL                      */
    
    SYS_LockReg();

    OSInit();                                                   /* Initialize "uC/OS-II, The Real-Time Kernel"          */

    CPU_Init();                                                 /* Initialize the uC/CPU services                       */
    
    Mem_Init();                                                 /* Initialize memory managment module                   */
    Math_Init();                                                /* Initialize mathematical module                       */

#if (OS_TASK_STAT_EN > 0)
    OSStatInit();                                               /* Determine CPU capacity                               */
#endif
    
    OSTaskCreateExt((void (*)(void *)) AppTask_1,            /* Create the test task                                */
                    (void           *) 0,
                    (OS_STK         *)&StackOfTask_1[TASK_STACK_SIZE - 1],
                    (INT8U           ) TASK_1_PRIO,
                    (INT16U          ) TASK_1_PRIO,
                    (OS_STK         *)&StackOfTask_1[0],
                    (INT32U          ) TASK_STACK_SIZE,
                    (void           *) 0,
                    (INT16U          )(OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR));

    OSTaskCreateExt((void (*)(void *)) AppTask_2,           /* Create the start task                                */
                    (void           *) 0,
                    (OS_STK         *)&StackOfTask_2[TASK_STACK_SIZE - 1],
                    (INT8U           ) TASK_2_PRIO,
                    (INT16U          ) TASK_2_PRIO,
                    (OS_STK         *)&StackOfTask_2[0],
                    (INT32U          ) TASK_STACK_SIZE,
                    (void           *) 0,
                    (INT16U          )(OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR));

#if (OS_TASK_NAME_EN > 0)
    OSTaskNameSet(TASK_1_PRIO, "Task 1", &err);
    OSTaskNameSet(TASK_2_PRIO, "Task 2", &err);
#endif

    OSStart();                                                  /* Start multitasking (i.e. give control to uC/OS-II)   */
    
    return (1);
}
static  void  AppTaskStart (void *p_arg)
{
    OS_ERR    os_err;

    (void)p_arg;


    CPU_Init();                                                 /* Initialize the uC/CPU Services.                      */
    Mem_Init();                                                 /* Initialize the Memory Management Module              */
    Math_Init();                                                /* Initialize the Mathematical Module                   */

    BSP_Ser_Init(115200u);

    OSTaskCreate(&TaskRedTCB,                              /* Create the red task                                */
                 "App Task Red",
                  AppTaskRed,
                  0u,
                  APP_CFG_TASK_START_PRIO,
                 &TaskRedStk[0u],
                 (APP_CFG_TASK_START_STK_SIZE / 10u),
                  APP_CFG_TASK_START_STK_SIZE,
                  0u,
                  0u,
                  0u,
                 (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR | OS_OPT_TASK_SAVE_FP),
                 &os_err);

    OSTaskCreate(&TaskGreenTCB,                              /* Create the green task                                */
                 "App Task Green",
                  AppTaskGreen,
                  0u,
                  APP_CFG_TASK_START_PRIO,
                 &TaskGreenStk[0u],
                 (APP_CFG_TASK_START_STK_SIZE / 10u),
                  APP_CFG_TASK_START_STK_SIZE,
                  0u,
                  0u,
                  0u,
                 (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR | OS_OPT_TASK_SAVE_FP),
                 &os_err);

    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop.       */
    }
}
Esempio n. 8
0
int main(void)
{
    OS_ERR   err;
#if (CPU_CFG_NAME_EN == DEF_ENABLED)
    CPU_ERR  cpu_err;
#endif

    HAL_Init();                                                 /* See Note 1.                                          */

    Mem_Init();                                                 /* Initialize Memory Managment Module                   */
    Math_Init();                                                /* Initialize Mathematical Module                       */

#if (CPU_CFG_NAME_EN == DEF_ENABLED)
    CPU_NameSet((CPU_CHAR *)"STM32F407VG",
                (CPU_ERR  *)&cpu_err);
#endif

    BSP_IntDisAll();                                            /* Disable all Interrupts.                              */

    OSInit(&err);                                               /* Init uC/OS-III.                                      */
    App_OS_SetAllHooks();

    OSTaskCreate(&AppTaskStartTCB,                              /* Create the start task                                */
                  "App Task Start",
                  AppTaskStart,
                  0u,
                  APP_CFG_TASK_START_PRIO,
                 &AppTaskStartStk[0u],
                  AppTaskStartStk[APP_CFG_TASK_START_STK_SIZE / 10u],
                  APP_CFG_TASK_START_STK_SIZE,
                  0u,
                  0u,
                  0u,
                 (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
                 &err);

    OSStart(&err);                                              /* Start multitasking (i.e. give control to uC/OS-III). */

    while (DEF_ON) {                                            /* Should Never Get Here.                               */
        ;
    }
}
static void AppTaskStart (void *p_arg)
{
  OS_ERR err;
  CPU_ERR cpu_err;
  uint32_t value;
  static uint32_t pulse_flag = 0;
  CPU_TS64 before, after;
  char tmp[80];
    
  (void)p_arg;

  CPU_Init();
  Mem_Init();
  Math_Init();

  BSP_Ser_Init(115200u);

    while (DEF_ON) {
        GPIO_DRV_TogglePinOutput( outPTB23 );
        value = GPIO_DRV_ReadPinInput( inPTB9 );
        if( value ){
            if(pulse_flag == 0)
                before = CPU_TS_Get64();    // in cpu_cfg.h must set: #define  CPU_CFG_TS_64_EN DEF_ENABLED
            pulse_flag = 1;
            GPIO_DRV_ClearPinOutput( BOARD_GPIO_LED_BLUE );
        }
        else{
            GPIO_DRV_SetPinOutput( BOARD_GPIO_LED_BLUE );
            if(pulse_flag == 1)
            {
                after = CPU_TS_Get64();     // see comment above
                sprintf( tmp, "Elapsed time in Task R = %f s\n\r", (float)((1.0*(after-before))/CPU_TS_TmrFreqGet( &cpu_err )) );
                APP_TRACE_DBG(( tmp ));
            }
            pulse_flag = 0;
        }
        OSTimeDlyHMSM(0u, 0u, 0u, 200u, OS_OPT_TIME_HMSM_STRICT, &err);
        
    }
}