代码拉取完成,页面将自动刷新
#include <app.h>
#include <print.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) // 空闲任务执行函数
{
// while(1);
static U32 count = 0;
while(1)
{
if(count++ % 100000 == 0)
{
static U32 j = 0;
asm volatile("cli");
SetCursorPos(0, 14);
printk("TASK Idle: %d\n", j++);
asm volatile("sti");
}
}
}
U08 taskA_stack[512]; // 任务私有栈
void TaskAFunc(void) // 任务执行函数
{
static U32 count = 0;
// U32* p = (U32*)0xB666; // 这个地址在内核范围内
// *p = 0x12345678; // 尝试改动内核数据
// printk(">>>>: %x\n", *p); // 查看是否修改成功
while(1)
{
if(count++ % 10000 == 0)
{
static U32 j = 0;
asm volatile("cli");
SetCursorPos(0, 6);
printk("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);
printk("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);
printk("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);
printk("TASK D: %d\n", j++);
asm volatile("sti");
}
}
}
void AppInit(void)
{
SetCursorPos(0, 3); // 设置光标位置: (0, 3)
SetFontColor(E_FONT_WHITE); // 设置打印字体颜色: 白色
printk("AppInit\n");
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;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。