/********************************************************************************************************* * * File : main.c * Hardware Environment: * Build Environment : RealView MDK-ARM Version: 4.20 * Version : V1.0 * By : * * (c) Copyright 2005-2011, WaveShare * http://www.waveshare.net * All Rights Reserved * *********************************************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include /* Private variables ---------------------------------------------------------*/ static OS_STK App_TaskStartStk[APP_TASK_START_STK_SIZE]; /* Private function prototypes -----------------------------------------------*/ #if (OS_VIEW_MODULE == DEF_ENABLED) extern void App_OSViewTaskCreate (void); #endif static void App_TaskCreate (void); static void App_TaskStart (void *p_arg); extern void App_UCGUI_TaskCreate (void); static void GPIO_Configuration (void); /* ********************************************************************************************************* * 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. ********************************************************************************************************* */ INT32S main (void) { CPU_INT08U os_err; os_err = os_err; /* prevent warning... */ /* Note: 由于使用UCOS, 在OS运行之前运行,注意别使能任何中断. */ CPU_IntDis(); /* Disable all ints until we are ready to accept them. */ OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel". */ os_err = OSTaskCreateExt((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, (INT16U ) APP_TASK_START_PRIO, (OS_STK * )&App_TaskStartStk[0], (INT32U ) APP_TASK_START_STK_SIZE, (void * )0, (INT16U )(OS_TASK_OPT_STK_CLR | OS_TASK_OPT_STK_CHK)); #if OS_TASK_NAME_EN > 0 OSTaskNameSet(APP_TASK_START_PRIO, (CPU_INT08U *)"Start Task", &os_err); #endif OSStart(); /* Start multitasking (i.e. give control to uC/OS-II). */ return (0); } /* ********************************************************************************************************* * App_TaskStart() * * Description : The startup task. The uC/OS-II ticker should only be initialize once multitasking starts. * * Argument(s) : p_arg Argument passed to 'App_TaskStart()' by 'OSTaskCreate()'. * * Return(s) : none. * * Caller(s) : This is a task. * * Note(s) : none. ********************************************************************************************************* */ static void App_TaskStart (void *p_arg) { (void)p_arg; /*************** Init hardware ***************/ GPIO_Configuration(); OS_CPU_SysTickInit(); /* Initialize the SysTick. */ #if (OS_TASK_STAT_EN > 0) OSStatInit(); /* Determine CPU capacity. */ #endif App_TaskCreate(); /* Create application tasks. */ for(;;) { OSTimeDlyHMSM(0, 1, 0, 0); /* Delay One minute */ } } /* ********************************************************************************************************* * App_TaskCreate() * * Description : Create the application tasks. * * Argument(s) : none. * * Return(s) : none. * * Caller(s) : App_TaskStart(). * * Note(s) : none. ********************************************************************************************************* */ static void App_TaskCreate (void) { #if (OS_VIEW_MODULE == DEF_ENABLED) App_OSViewTaskCreate(); #endif App_UCGUI_TaskCreate(); } /******************************************************************************* * Function Name : GPIO_Configuration * Description : Configure GPIO Pin * Input : None * Output : None * Return : None * Attention : None *******************************************************************************/ void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; /* GPIOF Periph clock enable */ RCC_AHB1PeriphClockCmd(LED1_RCC_AHBPeriph | LED2_RCC_AHBPeriph | LED3_RCC_AHBPeriph | LED4_RCC_AHBPeriph, ENABLE); /* Configure PF6 PF7 PF8 PF9 in output pushpull mode */ GPIO_InitStructure.GPIO_Pin = LED1_Pin; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(LED1_Port, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = LED2_Pin; GPIO_Init(LED2_Port, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = LED3_Pin; GPIO_Init(LED3_Port, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = LED4_Pin; GPIO_Init(LED4_Port, &GPIO_InitStructure); } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } } #endif /********************************************************************************************************* END FILE *********************************************************************************************************/