📄 yy.c
字号:
#include <includes.h>
#include <serial.h>
#include "stdio.h"
void TaskStartyya(void *yydata) reentrant;
void TaskStartyyb(void *yydata) reentrant;
void TaskStartyyc(void *yydata) reentrant;
void TaskStartyyd(void *yydata) reentrant;
void SYSCLK_Init (void) reentrant ;
void PORT_Init (void) reentrant ;
OS_STK TaskStartStkyya[MaxStkSize];//注意:我在ASM文件中设置?STACK空间为40H即64。
OS_STK TaskStartStkyyb[MaxStkSize]; //任务堆栈 ;静态堆栈
OS_STK TaskStartStkyyc[MaxStkSize];
OS_STK TaskStartStkyyd[MaxStkSize];
void main(void)
{
OSInit();
SYSCLK_Init();
PORT_Init();
InitSerial();
InitSerialBuffer();
InitTimer0();
OSTaskCreate(TaskStartyya, (void *)0, &TaskStartStkyya[0],1);
OSTaskCreate(TaskStartyyb, (void *)0, &TaskStartStkyyb[0],3);
OSTaskCreate(TaskStartyyc, (void *)0, &TaskStartStkyyc[0],4);
OSTaskCreate(TaskStartyyd, (void *)0, &TaskStartStkyyd[0],5);
OSStart();
}
void TaskStartyya(void *yydata) reentrant
{
char SFRPAGE_SAVE = SFRPAGE; // Save Current SFR page
yydata=yydata;
InitTimer0(); //用户必须在多任务系统启动以后再开启时钟节拍器
PrintStr ("\n\t\t*******************************\n");
PrintStr ("\t\t* Hello! The world. *\n");
PrintStr("\t\t*******************************\n\n\n");
for(;;){
PrintStr ("\taaaaAAAAAA111111 is active.\n");
SFRPAGE = UART1_PAGE;
printf ("%lu\n", OSTime);
SFRPAGE = SFRPAGE_SAVE; // Restore SFR page
OSTimeDly(2); // 20hz 调用?C/OS-Ⅱ的服务例程之一:任务延时函数 OSTimeDly()
}
}
void TaskStartyyb(void *yydata) reentrant
{
char SFRPAGE_SAVE = SFRPAGE; // Save Current SFR page
yydata=yydata;
for(;;){
PrintStr ("\tbbbbBBBBBB111111 is active.\n");
PrintStr ("\tbbbbBBBBBB222222 is active.\n");
PrintStr ("\tbbbbBBBBBB333333 is active.\n");
PrintStr ("\tbbbbBBBBBB444444 is active.\n");
PrintStr ("\tbbbbBBBBBB555555 is active.\n");
OSTimeDly(5); // 10hz 调用?C/OS-Ⅱ的服务例程之一:任务延时函数 OSTimeDly()
}
}
void TaskStartyyc(void *yydata) reentrant
{
char SFRPAGE_SAVE = SFRPAGE; // Save Current SFR page
yydata=yydata;
for(;;){
PrintStr ("\tcccCCCCCC6666666 is active.\n");
OSTimeDly(10); // 5hz 调用?C/OS-Ⅱ的服务例程之一:任务延时函数 OSTimeDly()
}
}
void TaskStartyyd(void *yydata) reentrant
{
char SFRPAGE_SAVE = SFRPAGE; // Save Current SFR page
yydata=yydata;
for(;;){
PrintStr ("\tddddddddd3333333 is active.\n");
OSTimeDly(25); // 2hz 调用?C/OS-Ⅱ的服务例程之一:任务延时函数 OSTimeDly()
}
}
void SYSCLK_Init (void) reentrant
{
char SFRPAGE_SAVE = SFRPAGE; // Save Current SFR page
/*
SFRPAGE = CONFIG_PAGE; // set SFR page
OSCICN = 0x83; // set internal oscillator to run
// at its maximum frequency
CLKSEL = 0x00; // Select the internal osc. as
// the SYSCLK source
*/
int i = 0;
WDTCN = 0xde; // disable watchdog timer
WDTCN = 0xad;
SFRPAGE = CONFIG_PAGE;
OSCXCN = 0x67;
for (i = 0; i < 3000; i++); // Wait 1ms for initialization
while ((OSCXCN & 0x80) == 0);
CLKSEL = 0x01;
OSCICN = 0x83;
SFRPAGE = SFRPAGE_SAVE; // Restore SFR page
}
//-----------------------------------------------------------------------------
// PORT_Init
//-----------------------------------------------------------------------------
//
// This routine configures the crossbar and GPIO ports.
//
void PORT_Init (void) reentrant
{
char SFRPAGE_SAVE = SFRPAGE; // Save Current SFR page
SFRPAGE = CONFIG_PAGE; // set SFR page
XBR0 = 0x00;
XBR1 = 0x00;
XBR2 = 0x44; // Enable crossbar and weak pull-up
// Enable UART1
P0MDOUT |= 0x01; // Set TX1 pin to push-pull
P1MDOUT |= 0x40; // Set P1.6(LED) to push-pull
SFRPAGE = SFRPAGE_SAVE; // Restore SFR page
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -