mirror of
https://github.com/jie65535/stm32f10x-uC-OS-II.git
synced 2024-07-27 19:10:55 +08:00
upload template
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#include "task.h"
|
||||
#include "includes.h"
|
||||
#include <stdio.h>
|
||||
|
||||
// 起始任务堆栈
|
||||
OS_STK TASK_START_STK[TASK_START_STK_SIZE];
|
||||
|
||||
// 启动任务,用于初始化并启动其它任务
|
||||
void TaskStart(void *p_arg)
|
||||
{
|
||||
OS_CPU_SR cpu_sr = 0;
|
||||
|
||||
// 开始时钟
|
||||
OSTick_Init();
|
||||
|
||||
// 进入临界区创建任务
|
||||
OS_ENTER_CRITICAL();
|
||||
|
||||
// 在这里创建其它任务...
|
||||
OSTaskCreate(TaskTest, (void *)0, &TASK_TEST_STK[TASK_TEST_STK_SIZE - 1], TASK_TEST_PRIO);
|
||||
|
||||
|
||||
// 退出临界区
|
||||
OS_EXIT_CRITICAL();
|
||||
|
||||
// 启动任务完成,删除启动任务
|
||||
OSTaskDel(TASK_START_PRIO);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef START_TASK_H_
|
||||
#define START_TASK_H_
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#define TASK_START_PRIO 0u
|
||||
|
||||
#define TASK_START_STK_SIZE 512u
|
||||
|
||||
extern OS_STK TASK_START_STK[TASK_START_STK_SIZE];
|
||||
|
||||
void TaskStart(void *p_arg);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef _TASK_H_
|
||||
#define _TASK_H_
|
||||
|
||||
// 该头文件用于包含所有任务头文件
|
||||
|
||||
#include "start_task.h"
|
||||
#include "test_task.h"
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "task.h"
|
||||
#include "includes.h"
|
||||
#include <stdio.h>
|
||||
|
||||
// 测试任务堆栈
|
||||
OS_STK TASK_TEST_STK[TASK_TEST_STK_SIZE];
|
||||
|
||||
// 邮箱
|
||||
OS_EVENT *pMailBox = 0;
|
||||
|
||||
// 测试任务
|
||||
void TaskTest(void *p_arg)
|
||||
{
|
||||
OS_CPU_SR cpu_sr = 0;
|
||||
INT8U err;
|
||||
const char *pstr;
|
||||
// 创建一个空的邮箱
|
||||
pMailBox = OSMboxCreate((void*)0);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
// 无期限等待邮箱,将获取到的message通过串口进行输出
|
||||
// 在此处邮箱中的数据由stm32f10x_it.c中的串口接收中断提供
|
||||
// 数据为以字符'\0'结尾的字符串
|
||||
pstr = (const char *)OSMboxPend(pMailBox, 0, &err);
|
||||
|
||||
OS_ENTER_CRITICAL();
|
||||
puts(pstr);
|
||||
OS_EXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef TEST_TASK_H_
|
||||
#define TEST_TASK_H_
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#define TASK_TEST_PRIO 5u
|
||||
|
||||
#define TASK_TEST_STK_SIZE 512u
|
||||
|
||||
extern OS_STK TASK_TEST_STK[TASK_TEST_STK_SIZE];
|
||||
|
||||
extern OS_EVENT *pMailBox;
|
||||
|
||||
void TaskTest(void *p_arg);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user