⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ostickisr.c

📁 ucosii移植到44b0的代码
💻 C
字号:
#include "..\inc\44b.h"#include "..\inc\44blib.h"#include "..\inc\option.h"#include "..\inc\def.h"#include "..\source\includes.h"#include <string.h>extern void OSSchedLock(void);#define printf Uart_Printf//**********************************************************// 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;        sys_init();         Uart_Printf("\n ### Main Starts !\n");	OSInit();	OSTaskCreate(Task1, &task_1, &TaskStk[0][TASK_STK_SIZE-1], 1);	OSTaskCreate(Task2, &task_2, &TaskStk[1][TASK_STK_SIZE-1], 2);	OSStart();	return 0;}void Task1(void * pParam){	Uart_Printf(" @@@ Task1 will star3ts time ticker !\n");	// enable Ticker, 16 ticks per second	tick_init(7);	// 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( "@@@\n");		printf( "@@@  task 1 running ... \n" );		printf( "@@@     Q__Q    \n" );		printf( "@@@    /____\\   \n" );		printf( "@@@    \\_s___/   \n" );		printf( "@@@     /\\/\\    \n" );		printf( "@@@  __(\\\\//)__ \n" );		printf( "@@@  >__/w w\\__< \n" );		printf( "@@@\n" );		printf( "@@@  go to sleep 10 time-ticks\n" );		printf( "@@@\n" );		OSSchedUnlock();		OSTimeDly(12);	}}void Task2(void * pParam){	while(1)		{		OSSchedLock();		printf( "+++ \n" );		printf( "+++  task 2 running ... \n" );		printf( "+++  ╭︿︿︿╮ \n" );		printf( "+++ {/ o o \\} \n" );		printf( "+++  ( (oo) ) \n" );		printf( "+++      ︶ \n" );		printf( "+++ \n" );		printf( "+++  go to sleep 5 time-ticks\n" );		printf( "+++ \n" );		OSSchedUnlock();		OSTimeDly(12);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -