Kernel.c[url=][/url]
1 /*------------------------------------------------------------------------- 2 3 软件主体 4 5 6 -------------------------------------------------------------------------*/ 7 8 #include "os.h" 9 #include "kernel.h" 10 #include "config.h" 11 12 extern void SysTickInit(void); 13 14 static OS_TCB taskStartTCB; 15 static CPU_STK startTaskStk[STARTUP_TASK_STK_SIZE]; //启动任务的程序空间 16 17 static OS_TCB task1TCB; 18 static CPU_STK task1_stk[TASK1_STK_SIZE]; 19 20 static OS_TCB task2TCB; 21 static CPU_STK task2_stk[TASK2_STK_SIZE]; 22 23 static OS_TCB task3TCB; 24 static CPU_STK task3_stk[TASK3_STK_SIZE]; 25 26 static volatile OS_SEM taskSem; 27 static volatile OS_ERR err; 28 29 /******************************************************************************* 30 * Function Name :void StartTask(void) 31 * Description :启动任务 32 * Input : 33 * Output : 34 * Other : 35 * Date :2012.04.18 11:48:23 36 *******************************************************************************/ 37 void StartTask(void) 38 { 39 40 led_init(); 41 SysTickInit(); 42 43 OSTaskCreate( (OS_TCB *)&task1TCB, 44 (CPU_CHAR *)"task1", 45 (OS_TASK_PTR)task1, 46 (void *)0, 47 (OS_PRIO )TASK1_PRIO, 48 (CPU_STK *)&task1_stk[0], 49 (CPU_STK_SIZE)TASK1_STK_SIZE / 10, 50 (CPU_STK_SIZE)TASK1_STK_SIZE, 51 (OS_MSG_QTY )0, 52 (OS_TICK )0, 53 (void *)0, 54 (OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), 55 (OS_ERR *)&err); 56 57 OSTaskCreate( (OS_TCB *)&task2TCB, 58 (CPU_CHAR *)"task2", 59 (OS_TASK_PTR)task2, 60 (void *)0, 61 (OS_PRIO ) TASK2_PRIO, 62 (CPU_STK *)&task2_stk[0], 63 (CPU_STK_SIZE)TASK2_STK_SIZE / 10, 64 (CPU_STK_SIZE)TASK2_STK_SIZE, 65 (OS_MSG_QTY)0, 66 (OS_TICK )0, 67 (void *)0, 68 (OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), 69 (OS_ERR *)&err); 70 71 72 OSTaskCreate( (OS_TCB *)&task3TCB, 73 (CPU_CHAR *)"task3", 74 (OS_TASK_PTR)task3, 75 (void *)0, 76 (OS_PRIO )TASK3_PRIO, 77 (CPU_STK *)&task3_stk[0], 78 (CPU_STK_SIZE)TASK3_STK_SIZE / 10, 79 (CPU_STK_SIZE)TASK3_STK_SIZE, 80 (OS_MSG_QTY)0, 81 (OS_TICK )0, 82 (void *)0, 83 (OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), 84 (OS_ERR *)&err); 85 86 OSSemCreate( (OS_SEM *)&taskSem, 87 (CPU_CHAR *)"taskSem", 88 (OS_SEM_CTR)0, 89 (OS_ERR *)err); 90 91 OSTaskDel( (OS_TCB *)&taskStartTCB, 92 (OS_ERR *)&err); 93 } 94 95 static void task1(void *p_arg) 96 { 97 98 while (1) 99 { |