Example #1
0
File: main.c Project: Mazetti/asf
int  main (void)
{
#if (OS_TASK_NAME_SIZE > 7) && (OS_TASK_STAT_EN > 0)
    CPU_INT08U  err;
#endif

	// Add delay to ensure EXTBT module is correctly reset.
#if UC3C
	cpu_delay_ms(AVR32_SCIF_RCOSC_FREQUENCY, 1000);
#else
        cpu_delay_ms(AVR32_PM_RCOSC_FREQUENCY, 1000);
#endif

	CPU_IntDis(); /*Disable all interrupts */

  	sysclk_init();

	OSInit();

	OSTaskCreateExt(app_task,(void *)0,
		(OS_STK *)&AppTaskStk[APP_TASK_STK_SIZE-1], APP_TASK_START_PRIO,
		APP_TASK_START_PRIO,(OS_STK *)&AppTaskStk[0], APP_TASK_STK_SIZE,
		(void *)0, OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);

#if (OS_TASK_NAME_SIZE > 7) && (OS_TASK_STAT_EN > 0)
    OSTaskNameSet(APP_TASK_START_PRIO, (CPU_CHAR *)"Startup", &err);
#endif

	OSStart();

	return (0);
}
Example #2
0
int  main (void)
{
    OS_ERR  err;


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

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

    App_OS_SetAllHooks();

    OSTaskCreate((OS_TCB     *)&AppTaskStartTCB,                /* Create the start task                                */
                 (CPU_CHAR   *)"App Task Start",
                 (OS_TASK_PTR ) AppTaskStart,
                 (void       *) 0,
                 (OS_PRIO     ) APP_TASK_START_PRIO,
                 (CPU_STK    *)&AppTaskStartStk[0],
                 (CPU_STK_SIZE) APP_TASK_START_STK_SIZE / 10u,
                 (CPU_STK_SIZE) APP_TASK_START_STK_SIZE,
                 (OS_MSG_QTY  ) 0u,
                 (OS_TICK     ) 0u,
                 (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 (1) {
        ;
    }

    return (0);
}
Example #3
0
int main(void)
{
   CPU_INT08U os_err;

   //禁止CPU中断
   CPU_IntDis();
   
   //UCOS 初始化
   OSInit();                                                   /* Initialize "uC/OS-II, The Real-Time Kernel".         */
   
   //硬件平台初始化
	SystemInit();
   BSP_Init();                                                 /* Initialize BSP functions.  */
   
   //默认LED闪烁间隔500ms
   milsec1=1000;   
   //建立主任务, 优先级最高  建立这个任务另外一个用途是为了以后使用统计任务
   os_err = OSTaskCreate((void (*) (void *)) App_TaskStart,	  		  		//指向任务代码的指针
                          (void *) 0,								  		//任务开始执行时,传递给任务的参数的指针
               (OS_STK *) &App_TaskStartStk[APP_TASK_START_STK_SIZE - 1],	//分配给任务的堆栈的栈顶指针   从顶向下递减
               (INT8U) APP_TASK_START_PRIO);								//分配给任务的优先级
   
   //ucos的节拍计数器清0    节拍计数器是0-4294967295    对于节拍频率100hz时, 每隔497天就重新计数 
   OSTimeSet(0);
   OSStart();                                                  /* Start multitasking (i.e. give control to uC/OS-II).  */
                                                 /* Start multitasking (i.e. give control to uC/OS-II).  */
 
   return (os_err);
}
Example #4
0
int  main (void)
{
#if (OS_TASK_NAME_SIZE > 7) && (OS_TASK_STAT_EN > 0)
    CPU_INT08U  err;
#endif


    CPU_IntDis();                                                       /* Disable all interrupts until we are ready to accept them */
    OSInit();  	
	BSP_Init();          
	
	init_err_printf();                                           

    OSTaskCreateExt(AppTaskStart,                                      
                    (void *)0,
                    (OS_STK *)&AppTaskStartStk[APP_TASK_START_STK_SIZE - 1],
                    APP_TASK_START_PRIO,
                    APP_TASK_START_PRIO,
                    (OS_STK *)&AppTaskStartStk[0],
                    APP_TASK_START_STK_SIZE,
                    (void *)0,
                    OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);

#if (OS_TASK_NAME_SIZE > 7) && (OS_TASK_STAT_EN > 0)
    OSTaskNameSet(APP_TASK_START_PRIO, (CPU_CHAR *)"Startup", &err);
#endif

    OSStart();     
	                                                   
	info_printf("EVK1100_Interface to cyclone-III rustlight fpga starting\n");

    return (0);                                                        
}
Example #5
0
int main(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	 CPU_INT08U os_err;
	 //BSP_Init();			
	 //BSP_IntDisAll();																						/* Disable all ints until we are ready to accept them.	*/
	 CPU_IntDis();
	 
	 OSInit();																									 /* Initialize "uC/OS-II, The Real-Time Kernel".				 */

	 BSP_Init();																								 /* Initialize BSP functions.	*/
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOC, &GPIO_InitStructure);
	GPIOC->BSRR = 1<<0;

	 os_err = OSTaskCreate((void (*) (void *)) App_TaskStart,
							 /* Create the start task.															 */
													(void *) 0,
							 (OS_STK *) &App_TaskStartStk[APP_TASK_START_STK_SIZE - 1],
							 (INT8U) APP_TASK_START_PRIO);
	 
#if (OS_TASK_NAME_SIZE >= 11)
	 OSTaskNameSet(APP_TASK_START_PRIO, (CPU_INT08U *) "Start Task", &os_err);
#endif

//	 InfoSem = OSSemCreate(0); 
//	 Disp_Box = OSMboxCreate((void *) 0);							 
	 OSTimeSet(0);
	 OSStart();																									/* Start multitasking (i.e. give control to uC/OS-II).	*/

	 return (0);
}
Example #6
0
int  main (void)
{
    OS_ERR  err;


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

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

    OSTaskCreate((OS_TCB     *)&StartUp_TCB,                /* Create the start task                                */
                 (CPU_CHAR   *)"StartUp",
                 (OS_TASK_PTR ) Task_Start,
                 (void       *) 0,
                 (OS_PRIO     ) STARTUP_TASK_PRIO,
                 (CPU_STK    *)&StartUp_Stk[0],
                 (CPU_STK_SIZE) STARTUP_TASK_STK_SIZE / 10u,
                 (CPU_STK_SIZE) STARTUP_TASK_STK_SIZE,
                 (OS_MSG_QTY  ) 0u,
                 (OS_TICK     ) 0u,
                 (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 (1) {
        ;
    }
}
Example #7
0
void main(void)
{
    OS_ERR error;

    HAL_Init();

    TP_USART1.init(0);
    Debug_Init( (struct TRANSPORT_IF*)&TP_USART1 );

    CPU_IntDis();

    OSInit(&error);

    Launcher_Exec();

    /////////////////////////////////////////////////////////////////
    RCC_ClocksTypeDef RCC_Clocks;
    RCC_GetClocksFreq(&RCC_Clocks);

    OS_CPU_SysTickInit( (RCC_Clocks.HCLK_Frequency/OSCfg_TickRate_Hz) - 1 );
    /////////////////////////////////////////////////////////////////

    OSStart(&error);

}
Example #8
0
int main(void)
{
	CPU_INT08U os_err;
	
	//禁止CPU中断
	CPU_IntDis();
	
	//UCOS 初始化
	OSInit();                                                   /* Initialize "uC/OS-II, The Real-Time Kernel".         */
	
	//硬件平台初始化
	BSP_Init();                                                 /* Initialize BSP functions.  */
	/* Configure FSMC Bank1 NOR/PSRAM */

	I2C_Ini();
    HMC5883L_Init();
	HMC5883L_Start();
	MPU6050_Init();	 

		
   //建立主任务, 优先级最高  建立这个任务另外一个用途是为了以后使用统计任务
   os_err = OSTaskCreate((void (*) (void *)) App_TaskStart,	  		  		//指向任务代码的指针
                          (void *) 0,								  		//任务开始执行时,传递给任务的参数的指针
               (OS_STK *) &App_TaskStartStk[APP_TASK_START_STK_SIZE - 1],	//分配给任务的堆栈的栈顶指针   从顶向下递减
               (INT8U) APP_TASK_START_PRIO);								//分配给任务的优先级
   os_err =os_err;
   //ucos的节拍计数器清0    节拍计数器是0-4294967295    对于节拍频率100hz时, 每隔497天就重新计数 
   OSTimeSet(0);
   OSStart();                                                  /* Start multitasking (i.e. give control to uC/OS-II).  */
                                                 /* Start multitasking (i.e. give control to uC/OS-II).  */
 
   return (0);
}
Example #9
0
void  BSP_PreInit (void)
{
    BSP_CPU_Init();                                             /* Initialize CPU Clks & PLLs                           */

    CPU_IntDis();                                               /* Disable CPU interrupts.                              */
    NVICInit();													/* Initialize hardware interrupt controller*/
    CSP_IntInit();                                              /* Initialize software interrupt controller module.              */

}
Example #10
0
void  CSP_IntVectDeref (CSP_INT_VECT  *p_vect)
{
#if (CSP_CFG_INT_ISR_ARG_EN == DEF_ENABLED)
    void          *p_int_arg;
#endif
    CPU_FNCT_PTR   int_isr_fnct;
#if (CSP_CFG_INT_ISR_EXEC_MEAS_EN == DEF_ENABLED) && \
    (CPU_CFG_TS_EN               == DEF_ENABLED)
    CPU_TS         ts;
    CPU_SR_ALLOC();
#endif


    int_isr_fnct =  p_vect->FnctPtr;
#if (CSP_CFG_INT_ISR_ARG_EN == DEF_ENABLED)
    p_int_arg    =  p_vect->ArgPtr;
#endif

   if (int_isr_fnct != (CPU_FNCT_PTR)0) {
#if (CSP_CFG_INT_ISR_EXEC_MEAS_EN == DEF_ENABLED) && \
    (CPU_CFG_TS_EN                == DEF_ENABLED)
        ts = CPU_TS_Get32();                                    /* Get current time stamp.                              */
#endif

#if (CSP_CFG_INT_NESTING_EN == DEF_ENABLED)
        CPU_IntEn();
#endif

#if (CSP_CFG_INT_ISR_ARG_EN == DEF_ENABLED)
        (*int_isr_fnct)(p_int_arg);                             /* Call interrupt handler                               */
#else
        (*int_isr_fnct)((void *)0);                             /* Call interrupt handler (default argument)            */
#endif

#if (CSP_CFG_INT_NESTING_EN == DEF_ENABLED)
        CPU_IntDis();
#endif

#if (CSP_CFG_INT_ISR_EXEC_MEAS_EN == DEF_ENABLED) && \
    (CPU_CFG_TS_EN                == DEF_ENABLED)
        ts = CPU_TS_Get32() - ts;                               /* Compute delta time between start and end.            */
                                                                /* Detect peak value                                    */
        CPU_CRITICAL_ENTER();

        if (p_vect->TimeMax < ts) {
            p_vect->TimeMax = ts;
        }

        p_vect->TimeCur = ts;

        CPU_CRITICAL_EXIT();
#endif
   }
}
Example #11
0
/*
******************************************************************************
**                        VOID  BSP_GlobalIrqIntDisable (VOID)
**
** Description  : disable global IRQ int
** Arguments    : 
                  
                  
** Returns      : 无
** Author       :                                   
** Date         : 
**
******************************************************************************
*/
VOID  BSP_GlobalIrqIntDisable (VOID)
{
     //置IRQbit禁止IRQ中断  
     
 #ifdef USE_CORTEX_M3
     CPU_IntDis();
 #else
     __asm
    {   
       MRS     R0, CPSR 
       ORR     R1, R0, #0x80
       MSR     CPSR_c, R1           
    }
#endif
}
Example #12
0
/*
*********************************************************************************************************
*                                                main()
*
* Description : This is the standard entry point for C code.  It is assumed that your code will call
*               main() once you have performed all necessary initialization.
*
* Argument(s) : none.
*
* Return(s)   : none.
*********************************************************************************************************
*/
int main(void)
{
#if (OS_TASK_NAME_EN > 0)
  CPU_INT08U  err;
#endif

  /* Disable all interrupts until we are ready to accept
   * them.                                                */
  CPU_IntDis();

  /* Chip errata */
  CHIP_Init();

  /* setup SW0 for energyAware Profiler */
  BSP_TraceSwoSetup();

  /* Initialize serial port                               */
  RETARGET_SerialInit();

  /* Map LF to CRLF                                       */
  RETARGET_SerialCrLf(1);

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

  /* Create the start task                                */
  OSTaskCreateExt((void (*)(void *)) App_TaskStart,
                  (void           *) 0,
                  (OS_STK         *)&App_TaskStartStk[APP_CFG_TASK_START_STK_SIZE - 1],
                  (INT8U           ) APP_CFG_TASK_START_PRIO,
                  (INT16U          ) APP_CFG_TASK_START_PRIO,
                  (OS_STK         *)&App_TaskStartStk[0],
                  (INT32U          ) APP_CFG_TASK_START_STK_SIZE,
                  (void           *) 0,
                  (INT16U          )(OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR));

#if (OS_TASK_NAME_EN > 0)
  OSTaskNameSet(APP_CFG_TASK_START_PRIO, (INT8U *)"Start", &err);
#endif

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

  /* OSStart() never returns, serious error had occured if
   * code execution reached this point                    */
  while(1) ;
}
Example #13
0
int  main (void)
{
//	uint32_t Temp=0;
//================================配置系统时钟==============//
	UNLOCKREG();  
	SYSCLK->PWRCON.OSC22M_EN = 1;//default is enabled 
	SYSCLK->PWRCON.XTL12M_EN = 1;
	SYSCLK->CLKSEL0.HCLK_S = 0;//using 12M as HCLK src

  //  DrvSYS_Delay(5000);    	
    Delay(5000)	 ;
    DrvSYS_Open(48000000);   
//	DSP_INIT_PIN = 0 ; 	
//  LCD_POWER = 1 ;  

//	
   
//===================================================================================//	
	BSP_INIT_UART0();                												 //init the uart0
	GR_DBG_PRINTF("System Is run\n\n"); 
	DrvUART_EnableInt(UART_PORT0,DRVUART_RDAINT | DRVUART_TOUTINT,UART_INT_HANDLE);	 //
//===================================================================================//
 //	Vir_Init() ; //初始化环境变量	
	
////===============================读取dataflash存储的系统信息=========================//	
  //读取flash中数据	  第一次运行读写写入默认值
////======================================开始任务=====================================//


	OSInit();
	CPU_IntDis() ;

 //	SysTick_Config(120000);	 
 //	InitValue();
                                     
#ifdef THREAD_TEST
    OSTaskCreateExt(Task2,  (void *)0,  (OS_STK *)&Task2_Stack[STACK2SIZE-1],  Task2_Prio,Task2_Prio,Task2_Stack,STACK2SIZE ,NULL,OS_TASK_OPT_STK_CHK);
	OSTaskCreateExt(Task1,  (void *)0,  (OS_STK *)&Task1_Stack[STACK1SIZE-1],   Task1_Prio,Task1_Prio,Task1_Stack,STACK1SIZE,NULL,OS_TASK_OPT_STK_CHK);
	OSTaskCreateExt(Task3,  (void *)0,  (OS_STK *)&Task3_Stack[STACK3SIZE-1],   Task3_Prio,Task3_Prio,Task3_Stack,STACK3SIZE,NULL,OS_TASK_OPT_STK_CHK);
//	OSTaskCreate(SYS_Task,  (void *)0,  (OS_STK *)&SYS_Task_Stack[STACKSIZE-1],SYS_Task_Prio); 
#endif
	OSStart();   
//===================================================================================//
}
Example #14
0
/*
*********************************************************************************************************
*                                                main()
*
* Description : This is the standard entry point for C code.  It is assumed that your code will call
*               main() once you have performed all necessary initialization.
*
* Argument(s) : none.
*
* Return(s)   : none.
*********************************************************************************************************
*/
int main(void)
{
  OS_ERR err = OS_ERR_NONE;


  /* Disable all interrupts until we are ready to accept
   * them.                                                */
  CPU_IntDis();

  /* Chip errata */
  CHIP_Init();

  /* setup SW0 for energyAware Profiler */
  setupSWO();

  /* Initialize "uC/OS-III, The Real-Time Kernel".        */
  OSInit(&err);

  /* Create the start task                                */
  OSTaskCreate((void           *)&AppTaskStartTCB,   /* pointer to TCB */
               (CPU_CHAR       *) "Start", /* task name, text */
               (void (*)(void *)) App_TaskStart, /* function pointer to task */
               (void           *) 0U, /* pointer to optional data */
               (CPU_INT08U      ) APP_CFG_TASK_START_PRIO, /* priority */
               (CPU_STK        *) App_TaskStartStk, /* stack base ptr */
               (CPU_STK_SIZE    )(APP_CFG_TASK_START_STK_SIZE / 10U), /* stack limit */
               (CPU_STK_SIZE    ) APP_CFG_TASK_START_STK_SIZE, /* stack size */
               (OS_MSG_QTY      ) 0U, /* q size */
               (OS_TICK         ) 0U, /* round robin time tick */
               (void           *) 0U, /* p ext */
               (OS_OPT          )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), /* options */
               (OS_ERR         *)&err);

  /* Setup the idle task */
  OS_AppIdleTaskHookPtr = (OS_APP_HOOK_VOID)App_TaskIdleHook;

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

  /* OSStart() never returns, serious error had occured if
   * code execution reached this point                    */
  while(1U) ;
}
Example #15
0
void  BSP_Init (void)
{
    CPU_IntDis();                                               /* Disable all interrupts.                              */

    Xil_ICacheEnable();                                         /* Enable the instruction cache.                        */
    Xil_DCacheEnable();                                         /* Enable the Data cache.                               */

    CSP_IntInit();                                              /* Initialize Interrupt controller module.              */
#ifdef STDOUT_IS_PS7_UART
    XUartPs         Uart_Ps_0;                                  /* Use the PS UART for Zynq devices.                    */
    XUartPs_Config *Config_0;

    Config_0 = XUartPs_LookupConfig(UART_DEVICE_ID);
    XUartPs_CfgInitialize(&Uart_Ps_0, Config_0, Config_0->BaseAddress);
    XUartPs_SetBaudRate(&Uart_Ps_0, 115200);
#elif defined(STDOUT_IS_16550)
    XUartNs550_SetBaud(STDOUT_BASEADDR, XPAR_XUARTNS550_CLOCK_HZ, UART_BAUD);
    XUartNs550_SetLineControlReg(STDOUT_BASEADDR, XUN_LCR_8_DATA_BITS);
#endif
}
Example #16
0
void  BSP_IntDisAll (void)
{
    CPU_IntDis();
}
Example #17
0
/*
*********************************************************************************************************
*                                                main()
*
* Description : This is the standard entry point for C code.  It is assumed that your code will call
*               main() once you have performed all necessary initialization.
*
* Argument(s) : none.
*
* Return(s)   : none.
*********************************************************************************************************
*/
int main(void)
{
  uint16_t osVersion1, osVersion2, osVersion3;
#if (OS_TASK_NAME_EN > 0)
  CPU_INT08U  err;
#endif


  /* Disable all interrupts until we are ready to accept
   * them.                                                */
  CPU_IntDis();

  /* Chip errata */
  CHIP_Init();

  /* setup SW0 for energyAware Profiler */
  setupSWO();

  /* Initialize BSP functions                             */
  BSPOS_Init();

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

  /* Initialize the uC/OS-II ticker                       */
   OS_CPU_SysTickInit(CMU_ClockFreqGet(cmuClock_HFPER)/OS_TICKS_PER_SEC);

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

   /* Create application tasks                             */
   App_TaskCreate();

   /* Create application mailboxes                         */
   App_MailboxCreate();

   /* Initialize LCD                                       */
   SegmentLCD_Init(true);

   /* Turn gecko symbol ON                                 */
   SegmentLCD_Symbol(LCD_SYMBOL_GECKO, 1);

   /* Turn EFM32 symbol ON                                 */
   SegmentLCD_Symbol(LCD_SYMBOL_EFM32, 1);

   /* Write welcome message on LCD                         */
   SegmentLCD_Write("uC/OS-2");

/* As USART connectors are not available on the STK by default,
 * therefore printf() functions are turned off.
 * Uncomment the macro definition in includes.h if serial
 * is connected to your STK board (USART1 or LEUART0)!    */
 #ifdef USART_CONNECTED

   /* Initialize                                          */
   RETARGET_SerialInit();
   RETARGET_SerialCrLf(1);

  osVersion3 = OSVersion();
  osVersion1 = osVersion3 / 10000;
  osVersion3 -= osVersion1 * 10000;
  osVersion2 = osVersion3 / 100;
  osVersion3 -= osVersion2 * 100;
  osVersion3 %= 100;

   /* Write welcome message on serial                     */
   printf("\n*****************************************************************************");
   printf("\n                uC/OS-II v%d.%02d.%02d on Silicon Labs EFM32TG STK             ",
         osVersion1, osVersion2, osVersion3 );
   printf("\n                               Demo Application                              \n");
   printf("\n                                   uC/OS-II                                  ");
   printf("\n                           \"The real time kernel\"                            ");
   printf("\n                               www.micrium.com                               ");
   printf("\n\n                                is running on                              ");
   printf("\n\n                             Silicon Labs EFM32                              ");
   printf("\n            \"The world's most energy friendly microcontrollers\"              ");
   printf("\n                              www.silabs.com                                 \n");
   printf("\nDescription:");
   printf("\nTask1: LED blink task");
   printf("\nTask2: Receives characters from serial and posts message to Task3");
   printf("\nTask3: Receives message from Task2 and writes it on LCD and serial ");
   printf("\n*****************************************************************************\n");
   printf("\nStart typing...\n");

 #endif /* end of #ifndef USART_CONNECTED */

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

  /* OSStart() never returns, serious error had occured if
   * code execution reached this point                    */
  while(1) ;
}