Esempio n. 1
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. 2
0
void  BSP_Init (void)
{
    BSP_IntDisAll();                                            /* Disable all interrupts.                              */

  	/* M4F FPU settings --------------------------------------------------------*/
#ifdef __TARGET_FPU_VFP
    SCB->CPACR |= ((3UL << 10*2) |                 	/* set CP10 Full Access */
                   (3UL << 11*2)  );               	/* set CP11 Full Access */
    //FPU->FPCCR &= ~(3 << 30);						/* Disable automatic FP register content (bit 31) */
    //												/* Disable Lazy context switch (bit 30) */
#endif

  	/* Enable external crystal and PLL -----------------------------------------*/
	BSP_Enable_Clock(CLK_XTL_12M);								/* Enable external external 4 ~ 22M input               */

    // Enable UART0 clock
    CLK->APBCLK0 |= CLK_APBCLK0_UART0CKEN_Msk;
    
    // Select external 12 MHz as UART clock source 
    CLK->CLKSEL1 &= ~CLK_CLKSEL1_UARTSEL_Msk;
    
    /* Set GPG multi-function pins for UART0 RXD and TXD */
    SYS->GPG_MFPL = SYS_GPG_MFPL_PG1MFP_UART0_RXD | SYS_GPG_MFPL_PG2MFP_UART0_TXD ;

    UART0->LINE |= 0x07;	
    UART0->BAUD = 0x30000066;	/* 12MHz reference clock input, for 115200 */

    BSP_IntInit();

    BSP_Tick_Init();                                            /* Start Tick Initialization                            */
}
Esempio n. 3
0
//---------------------------------------------------------------------------------------------------
// 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);
		}
}
Esempio n. 4
0
static  void  App_TaskStart (void *p_arg)
{
    OS_ERR  os_err;

    (void)p_arg;                                                /* See Note #1.                                         */

    BSP_Init();                                                 /* Start BSP and tick initialization.                   */

    BSP_Tick_Init();                                            /* Start Tick Initialization.                           */
	
    BSP_UART_Init(BSP_UART_DEFAULT,                             /* Start UART Initialization                            */
	                BSP_BUSCLK,
	                9600);

    BSP_LCD_Init();                                             /* Initialize the seven-segment display panel.          */

#if OS_CFG_STAT_TASK_EN > 0u
    OSStatTaskCPUUsageInit(&os_err);                            /* Compute CPU capacity with no task running            */
#endif

#ifdef  CPU_CFG_INT_DIS_MEAS_EN
    CPU_IntDisMeasMaxCurReset();
#endif

    APP_TRACE_INFO(("Creating Application Events...\n\r"));
    App_ObjCreate();                                            /* Create Applicaton kernel objects.                    */

    APP_TRACE_INFO(("Creating Application Tasks...\n\r"));
    App_TaskCreate();                                           /* Create Application tasks.                            */

    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop.       */

        OSTimeDlyHMSM(0, 0, 2, 0,
                      OS_OPT_TIME_HMSM_STRICT, &os_err);
//		  BSP_UART_Send_String(BSP_UART_1,
//				             "Hello\n");
        uart_printf("Hello world\n");
        OSTimeDly(10, OS_OPT_TIME_HMSM_STRICT, &os_err);
        uart_printf("os_err = %d\n", os_err);
			  
//			  while (BSP_SW_Read (BSP_SW_1) != DEF_ON) {
//					  OSTimeDly(1, OS_OPT_TIME_HMSM_STRICT, &os_err);
//				}
//				BSP_LED_Toggle(BSP_LED_RED);
//				
//				BSP_UART_Send_String(BSP_UART_1,
//				                     "Hello\n");
//				
//				while (BSP_SW_Read (BSP_SW_1) == DEF_OFF) {
//			      OSTimeDly(1, OS_OPT_TIME_HMSM_STRICT, &os_err);
//				}
    }
}
Esempio n. 5
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//开始任务
void  AppTaskStart (void *p_arg)
{
	OS_ERR  err;
	CPU_Init();//初始化cpu,禁用中断,开启时间戳等
	BSP_Tick_Init();//设置滴答定时器
/*------------------------------*/		 
	OSTaskCreate((OS_TCB       *)&AppTaskTASK1TCB,              
                 (CPU_CHAR     *)"task1",
                 (OS_TASK_PTR   )task1, 
                 (void         *)0,
                 (OS_PRIO       )APP_CFG_TASK_TASK1_PRIO,
                 (CPU_STK      *)&AppTaskTASK1Stk[0],
                 (CPU_STK_SIZE  )APP_CFG_TASK_TASK1_STK_SIZE / 10,
                 (CPU_STK_SIZE  )APP_CFG_TASK_TASK1_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);
/*------------------------------*/
	OSTaskCreate((OS_TCB       *)&AppTaskTASK2TCB,              
                 (CPU_CHAR     *)"task2",
                 (OS_TASK_PTR   )task2, 
                 (void         *)0,
                 (OS_PRIO       )APP_CFG_TASK_TASK2_PRIO,
                 (CPU_STK      *)&AppTaskTASK2Stk[0],
                 (CPU_STK_SIZE  )APP_CFG_TASK_TASK2_STK_SIZE / 10,
                 (CPU_STK_SIZE  )APP_CFG_TASK_TASK2_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);  
/*-------------------------------*/
	OSTaskCreate((OS_TCB       *)&AppTaskTASK3TCB,              
                 (CPU_CHAR     *)"task3",
                 (OS_TASK_PTR   )task3, 
                 (void         *)0,
                 (OS_PRIO       )APP_CFG_TASK_TASK3_PRIO,
                 (CPU_STK      *)&AppTaskTASK3Stk[0],
                 (CPU_STK_SIZE  )APP_CFG_TASK_TASK3_STK_SIZE / 10,
                 (CPU_STK_SIZE  )APP_CFG_TASK_TASK3_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);
				 
	//创建好其他任务后就删除自己
    OSTaskDel((OS_TCB*)0,&err);
}
Esempio n. 6
0
/*
*********************************************************************************************************
*                                          STARTUP TASK
*
* Description : This is an example of a startup task.  As mentioned in the book's text, you MUST
*               initialize the ticker only once multitasking has started.
*
* Arguments   : p_arg   is the argument passed to 'AppTaskStart()' by 'OSTaskCreate()'.
*
* Returns     : none
*
* Notes       : 1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                  used.  The compiler should not generate any code for this statement.
*********************************************************************************************************
*/
static  void  AppTaskStart (void *p_arg)
{
    OS_ERR  err;

   (void)p_arg;

    BSP_Init();                                                 /* Initialize BSP functions                             */
    BSP_Tick_Init();                                            /* Initialize Tick Services.                            */
    App_OS_SetAllHooks();
    
    MEM_Init();
    DR_Init();

#if OS_CFG_STAT_TASK_EN > 0u
    OSStatTaskCPUUsageInit(&err);                               /* Compute CPU capacity with no task running            */
#endif

#ifdef CPU_CFG_INT_DIS_MEAS_EN
    CPU_IntDisMeasMaxCurReset();
#endif

    DR_LED_Off(0u);                                            /* Turn Off LEDs after initialization                   */

    APP_TRACE_DBG(("Creating Application Kernel Objects\n\r"));
    AppObjCreate();                                             /* Create Applicaiton kernel objects                    */

    APP_TRACE_DBG(("Creating Application Tasks\n\r"));
    AppDataAcqCreate();                                            /* Create Application tasks                             */


    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop.       */
        DR_LED_On(1u);
        OSTimeDlyHMSM(0u, 0u, 0u, 10u,
                      OS_OPT_TIME_HMSM_STRICT,
                      &err);
        DR_LED_Off(1u);
        OSTimeDlyHMSM(0u, 0u, 1u, 0u,
                      OS_OPT_TIME_HMSM_STRICT,
                      &err);
    }
}
Esempio n. 7
0
/*
*********************************************************************************************************
*                                            BSP_Set_System_Clock()
*
* Description : Select HCLK clock source and divider
*
* Argument(s) : clk_src  HCLK clock source. Must be type E_CLK_SRC.
*               clk_div  HCLK clock frequency = (HCLK clock source frequency) / (clk_div + 1)
*                        The valid range of clk_div is 0 <= clk_div <= 15.
*
* Return(s)   : 0        Success
*               -1       Failed
*
* Caller(s)   : Application.
*
* Note(s)     : none.
*********************************************************************************************************
*/
int  BSP_Set_System_Clock (E_CLK_SRC clk_src, int clk_div)
{
	switch (clk_src)
	{
		case CLK_XTL_12M:
			CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_HCLKSEL_Msk);
			_cpu_freq = HXT_HZ / (clk_div+1);
			break; 

		case CLK_XTL_32K:
			CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_HCLKSEL_Msk) | 0x1;
			_cpu_freq = LXT_HZ / (clk_div+1);
			break; 

		case CLK_OSC_22M:
			CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_HCLKSEL_Msk) | 0x7;
			_cpu_freq = HIRC_HZ / (clk_div+1);
			break; 

		case CLK_OSC_10K:
			CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_HCLKSEL_Msk) | 0x3;
			_cpu_freq = LIRC_HZ / (clk_div+1);
			break; 

		case CLK_PLL:
			CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_HCLKSEL_Msk) | 0x2;
			_cpu_freq = _pll_freq / (clk_div+1);
			break; 
			
		default:
			return -1;
	}

	bsp_printf("Reinit system tick with HCLK %d.\n", _cpu_freq);
	BSP_Tick_Init();
	
	return 0;
}
Esempio n. 8
0
static  void  App_TaskStart (void *p_arg)
{
     OS_ERR  os_err;

    (void)p_arg;                                                /* See Note #1.                                         */

    BSP_Init();                                                 /* Start BSP and tick initialization.                   */

    BSP_Tick_Init();                                            /* Start Tick Initialization.                           */

    BSP_LCD_Init();                                             /* Initialize the seven-segment display panel.          */

#if OS_CFG_STAT_TASK_EN > 0u
    OSStatTaskCPUUsageInit(&os_err);                            /* Compute CPU capacity with no task running            */
#endif

#ifdef  CPU_CFG_INT_DIS_MEAS_EN
    CPU_IntDisMeasMaxCurReset();
#endif

    APP_TRACE_INFO(("Creating Application Events...\n\r"));
    App_ObjCreate();                                            /* Create Applicaton kernel objects.                    */

    APP_TRACE_INFO(("Creating Application Tasks...\n\r"));
    App_TaskCreate();                                           /* Create Application tasks.                            */

    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop.       */
        BSP_LED_Toggle(BSP_LED_RED);

        OSTimeDlyHMSM(0, 0, 0, 200,
                      OS_OPT_TIME_HMSM_STRICT, &os_err);

        BSP_LED_Toggle(BSP_LED_GREEN);

        OSTimeDlyHMSM(0, 0, 0, 200,
                      OS_OPT_TIME_HMSM_STRICT, &os_err);
    }
}
Esempio n. 9
0
static  void  AppTaskStart (void *p_arg)
{
	OS_ERR      err;

   (void)p_arg;

	BSP_Tick_Init();
	
 	bsp_Init();
	CPU_Init();
	

	//Mem_Init();  //内存管理模块                           
//  Math_Init();                         

#if OS_CFG_STAT_TASK_EN > 0u
     OSStatTaskCPUUsageInit(&err);   
#endif

#ifdef CPU_CFG_INT_DIS_MEAS_EN
    CPU_IntDisMeasMaxCurReset();
#endif
	
		AppTimerCreate();
    AppObjCreate();                                            
    AppTaskCreate();                                           
    while (1)
	  {                                         
		//GPIOG->ODR ^= GPIO_Pin_10;     //添加LED指示灯,指示星务计算机工作状态 2014/10/18
		BSP_OS_TimeDlyMs(2000);
		//printf("living!\r\n");
		//bsp_LedToggle(1);
		//bsp_LedToggle(2);
		//bsp_LedToggle(3);
    }
}
Esempio n. 10
0
//开始任务
///////////////////////////////////////////////////////////////////////////////////////////////////////////
void  AppTaskStart (void *p_arg)
{
	OS_ERR  err;
	(void)p_arg;
	//信号量
	OSSemCreate((OS_SEM*		  )&SYNC_SEM,
							(CPU_CHAR*		)"SYNC_SEM",
							(OS_SEM_CTR		)0,
							(OS_ERR*		  )&err
						 );
	//消息队列
	OSQCreate((OS_Q        *)&TIME_DELAY_DATA,
						(CPU_CHAR    *)"delay time",
						(OS_MSG_QTY   )5,
						(OS_ERR      *)&err
						);
	CPU_Init();//初始化cpu,禁用中断,开启时间戳等
	BSP_Tick_Init();//设置滴答定时器
	//OSSchedRoundRobinCfg(DEF_ENABLED,1,&err);
//创建任务
    /*------------------------------*/		 
	OSTaskCreate((OS_TCB       *)&AppTaskTASK1TCB,              
                 (CPU_CHAR     *)"task1",
                 (OS_TASK_PTR   )task1, 
                 (void         *)0,
                 (OS_PRIO       )APP_CFG_TASK_TASK1_PRIO,
                 (CPU_STK      *)&AppTaskTASK1Stk[0],
                 (CPU_STK_SIZE  )APP_CFG_TASK_TASK1_STK_SIZE / 10,
                 (CPU_STK_SIZE  )APP_CFG_TASK_TASK1_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);
/*------------------------------*/
	OSTaskCreate((OS_TCB       *)&AppTaskTASK2TCB,              
                 (CPU_CHAR     *)"task2",
                 (OS_TASK_PTR   )task2, 
                 (void         *)0,
                 (OS_PRIO       )APP_CFG_TASK_TASK2_PRIO,
                 (CPU_STK      *)&AppTaskTASK2Stk[0],
                 (CPU_STK_SIZE  )APP_CFG_TASK_TASK2_STK_SIZE / 10,
                 (CPU_STK_SIZE  )APP_CFG_TASK_TASK2_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);  
/*-------------------------------*/
	OSTaskCreate((OS_TCB       *)&AppTaskTASK3TCB,              
                 (CPU_CHAR     *)"task3",
                 (OS_TASK_PTR   )task3, 
                 (void         *)0,
                 (OS_PRIO       )APP_CFG_TASK_TASK3_PRIO,
                 (CPU_STK      *)&AppTaskTASK3Stk[0],
                 (CPU_STK_SIZE  )APP_CFG_TASK_TASK3_STK_SIZE / 10,
                 (CPU_STK_SIZE  )APP_CFG_TASK_TASK3_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);
				 
	//创建好其他任务后就删除自己
    OSTaskDel((OS_TCB*)0,&err);
}