📄 main1.c
字号:
#include "..\inc\44b.h"#include "..\inc\44blib.h"#include "..\inc\option.h"#include "..\inc\def.h"#include "..\source\includes.h"#define printf Uart_Printfextern void OSSchedLock(void);//**********************************************************// THE MAIN FUNCTION BODY//**********************************************************#define N_TASKS 5 // Number of tasks#define TASK_STK_SIZE 1024 // Stack size, in sizeof OS_STK, or int 32bitOS_STK TaskStk[N_TASKS][TASK_STK_SIZE]; // Tasks stacksvoid Task1(void *);void Task2(void *);int Main(int argc, char **argv){ int task_1=0,task_2=1; rSYSCFG=SYSCFG_8KB;
#if (PLLON==1)
ChangePllValue(PLL_M,PLL_P,PLL_S);
#endif sys_init(); Uart_Printf("\n ### Main Starts !\n"); OSInit(); OSTaskCreate(Task1, &task_1, &TaskStk[0][TASK_STK_SIZE-1], 11); OSTaskCreate(Task2, &task_2, &TaskStk[1][TASK_STK_SIZE-1], 22); OSStart(); return 0;}void Task1(void * pParam){ Uart_Printf(" @@@ Task1 will starts time ticker !\n"); tick_init(7); // enable Ticker, 16 ticks per second // why start tick here? see uCOS-II Doc Chapter 8 : /*"You MUST enable ticker interrupts AFTER multitasking has started, i.e. after calling OSStart(). In other words, you should initialize and tick interrupts in the first task that executes following a call to OSStart(). A common mistake is to enable ticker interrupts between calling OSInit() and OSStart() ..." */while(1) { OSSchedLock(); printf( "@@@ go to sleep 1qqqqq11 time-ticks\n" ); printf( "@@@\n" ); OSSchedUnlock(); OSTimeDly(12); }}void Task2(void * pParam){ while(1) { OSSchedLock(); printf( "@@@ go to sleewwwwwwwww22time-ticks\n" ); printf( "@@@\n" ); OSSchedUnlock(); OSTimeDly(12);}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -