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

📄 ex12.c

📁 基于SPCE061A的MiniOS源代码.
💻 C
字号:
//
// Example 12 This program show how to suspend task ans resume task
// Author Taiyun Wnag 
// data:2003/2/22
///////////////////////////////////////////////////////////////////////////


#include "sposvar.h"
#include "spos.h"

int err;				//Error No
int t1stack[25];		//Task 1 stack
int t2stack[25];		//Task 2 stack

volatile unsigned int *P_IOB_BUFFER =(unsigned int*)(0x7006);	//Port B data register
volatile unsigned int *P_IOB_DIR =(unsigned int*)(0x7007);		//Port B direction register
volatile unsigned int *P_IOB_ATTRIB = (unsigned int*)(0x7008);	//Port B attribute register

main()
{
	void Task1();
    void Task2();
	SpSInit();									//Initialize OS kernel
   *P_IOB_DIR = 0XFFFF;							//Set Port B direction
   *P_IOB_ATTRIB = 0XFFFF;						//Set Port B attribute
	err = SpSTaskCreate(Task1,0,t1stack+24,1);	//Create first task
	err = SpSTaskCreate(Task2,0,t2stack+24,2);	//create second task
	SpSStart();									//Start multitask kernel
}
void Task1()
{
    unsigned int i = 1;
	while(1) {
		SpSTimeDly(11);							//Delay 11 tick
		SpSTaskSuspend(2);						//Suspend task 2
		SpSTimeDly(17);							//Delay 17 tick
		SpSTaskResume(2);						//Resume task 2
	}
}
void Task2()
{
	unsigned int i = 0x80;
	while(1) {
		for(i = 0x80;i != 0;i>>=1) {
            *P_IOB_BUFFER = i;
            SpSTimeDly(1);
		}
	}
}

⌨️ 快捷键说明

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