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

📄 test1.c

📁 uC/OS-II under Paradigm C/C++ 5.0
💻 C
字号:
/*
// Sample for UCOS-II running on Tern board with AMD 186ES CPU.  This application has
// two tasks, one blinks the LED on the tern board at a rate of once per second, the other
// task just wastes CPU.  If you have the book Embedded Systems Building Blocks 2nd Ed and
// a Tern board with attached LCD display, a better sample is available.  That sample
// displays the CPU statistics on Tern TD Pack (LCD) using the LCD code from the book.
// The LCD code was modified to work in 4 bit mode.
//
// This sample does not use floating point emulation.  If you do
// need fpe in your app then add the define BC_FLOATING_POINT in both the project and the UCOS-II
// project.  If you do need fpe support remember that any task that creates a task with fpe support
// must itself have been created with fpe support, ie OSTaskStkInit_FPE_x86 must have been called
// prior to OSTaskCreate.

*/
#include <ae.h>
#include <td86.h>
#include "includes.h"

#define			  TASK_STK_SIZE		512
#define          TASK_START_ID       0                /* Application tasks IDs                         */
#define          TASK_1_ID           2
#define          TASK_START_PRIO    10                /* Application tasks priorities                  */
#define          TASK_1_PRIO        11

#define			  TIMER2_REPEAT_CFG	0xe001			//config timer two to repeat
#define			  TIMER2_INTERVAL	10000					//1000 ticks per second

OS_STK				TaskStartStk[TASK_STK_SIZE];
OS_STK				Task1Stk[TASK_STK_SIZE];

void	TaskStart(void* data);
void	Task1(void* data);

void main(void)
{
	td86_init();	//initialize Tern board
	OSInit();      //initialize OS
	PARADIGM_SETVECT(uCOS, OSCtxSw); //Set tick interrupt
	OSTaskCreate(TaskStart, (void*)0, &TaskStartStk[TASK_STK_SIZE -1], TASK_START_PRIO);
	OSStart();
}

void TaskStart(void* data)
{
	data = data;
	OS_ENTER_CRITICAL();
	t2_init(TIMER2_REPEAT_CFG, TIMER2_INTERVAL, (void interrupt (*)(void))OSTickISR);
	OS_EXIT_CRITICAL();

	OSTaskCreate(Task1, (void*)0, &Task1Stk[TASK_STK_SIZE -1], TASK_1_PRIO);
	for (;;) {
		int i;
		OSTimeDly(OS_TICKS_PER_SEC*2);
		//waste come CPU
		for (i = 0; i < 10; i++) {
			int x = 10;
			x = x * 5000;
		}
	}
}

void Task1(void* data)
{
	data = data;
	for (;;) {
		led(0);
		OSTimeDly(OS_TICKS_PER_SEC);
		led(1);
		OSTimeDly(OS_TICKS_PER_SEC);
	}
}


⌨️ 快捷键说明

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