2 Star 6 Fork 4

稀风 / KOS

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
app10.c 3.55 KB
Copy Edit Raw Blame History
#include <app.h>
#include <u_syscall.h>
APP_INFO appInfo[MAX_APP_NUM] = {0};
U16 appNum = 0;
E_RET AppRegister(APP_FUNC pFunc, U08* stackAddr, U16 stackSize, U08* name, E_APP_PRI priority)
{
if(appNum >= MAX_APP_NUM)
return E_ERR;
appInfo[appNum].pfunc = pFunc;
appInfo[appNum].stackAddr = stackAddr;
appInfo[appNum].stackSize = stackSize;
appInfo[appNum].name = name;
appInfo[appNum].priority = priority;
appNum++;
return E_OK;
}
/******************************************************************************
* 函数名称: static void TaskIdleFunc(void)
* 功能说明: 空闲任务
* 输入参数: 无
* 输出参数: 无
* 函数返回: 无
* 其它说明: 无
******************************************************************************/
#define IDLE_STACK_SIZE 512
static U08 taskIdle_stack[IDLE_STACK_SIZE]; // 空闲任务私有栈
static void TaskIdleFunc(void) // 空闲任务执行函数
{
static U32 count = 0;
while(1)
{
if(count++ % 100000 == 0)
{
static U32 j = 0;
asm volatile("cli");
SetCursorPos(0, 14);
print("TASK Idle: %d\n", j++);
asm volatile("sti");
}
}
}
MUTEX* mutex = NULL;
U08 taskA_stack[512]; // 任务私有栈
void TaskAFunc(void) // 任务执行函数
{
static U32 count = 0;
mutex = MutexCreat();
print("mutex = %x\n", mutex);
MutexLock(mutex);
MutexUnLock(mutex);
MutexDestory(mutex);
while(1)
{
if(count++ % 10000 == 0)
{
static U32 j = 0;
asm volatile("cli");
SetCursorPos(0, 6);
print("TASK A: %d\n", j++);
asm volatile("sti");
}
}
}
U08 taskB_stack[512]; // 任务私有栈
void TaskBFunc(void) // 任务执行函数
{
static U32 count = 0;
while(1)
{
if(count++ % 10000 == 0)
{
static U32 j = 0;
asm volatile("cli");
SetCursorPos(0, 8);
print("TASK B: %d\n", j++);
asm volatile("sti");
}
}
}
U08 taskC_stack[512]; // 任务私有栈
void TaskCFunc(void) // 任务执行函数
{
static U32 count = 0;
while(1)
{
if(count++ % 10000 == 0)
{
static U32 j = 0;
asm volatile("cli");
SetCursorPos(0, 10);
print("TASK C: %d\n", j++);
asm volatile("sti");
}
}
}
U08 taskD_stack[512]; // 任务私有栈
void TaskDFunc(void) // 任务执行函数
{
static U32 count = 0;
while(1)
{
if(count++ % 10000 == 0)
{
static U32 j = 0;
asm volatile("cli");
SetCursorPos(0, 12);
print("TASK D: %d\n", j++);
asm volatile("sti");
}
}
}
void AppInit(void)
{
// SetCursorPos(0, 3); // 设置光标位置: (0, 3)
// SetFontColor(E_FONT_WHITE); // 设置打印字体颜色: 白色
AppRegister(TaskAFunc, taskA_stack, 512, "TASK A", E_APP_PRI5);
// AppRegister(TaskBFunc, taskB_stack, 512, "TASK B", E_APP_PRI7);
// AppRegister(TaskCFunc, taskC_stack, 512, "TASK C", E_APP_PRI9);
// AppRegister(TaskDFunc, taskD_stack, 512, "TASK D", E_APP_PRI11);
// 把应用数据放入共享内存 0xA800 处
*((volatile U32*)0xA800) = (U32)appInfo;
*((volatile U32*)0xA804) = appNum;
*((volatile U32*)0xA808) = (U32)taskIdle_stack;
*((volatile U32*)0xA80C) = IDLE_STACK_SIZE;
*((volatile U32*)0xA810) = (U32)TaskIdleFunc;
}
1
https://gitee.com/thin-wind/KOS.git
git@gitee.com:thin-wind/KOS.git
thin-wind
KOS
KOS
main

Search