📄 复件 main.c
字号:
/****************************************Copyright (c)**************************************************
** Guangzou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name: main.c
** Last modified Date: 2004-09-16
** Last Version: 1.0
** Descriptions: The main() function example template
**
**------------------------------------------------------------------------------------------------------
** Created by: Chenmingji
** Created date: 2004-09-16
** Version: 1.0
** Descriptions: The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by: Chenxibing
** Modified date: 2005-03-10
** Version:
** Descriptions: EasyARM2131 基于uCOS-II的GPIO输出实验2。
**
********************************************************************************************************/
#define TASK_STK_SIZE 64
#include "config.h"
OS_STK TaskStartStk[TASK_STK_SIZE];
OS_STK TaskStk[TASK_STK_SIZE];
/* 函数声明 */
void TaskStart(void *pdata);
void Task1(void *pdata);
void BeepMoo(void);
void BeepNoMoo(void);
uint32 GetKey(void);
#define KEY1 1 << 16 // P0.16-KEY1
#define BEEP 1 << 7 // P0.7-BEEP
/*
*********************************************************************************************************
** 函数名称 :main()
** 函数功能 :c语言的主函数,由它启动多任务环境
*********************************************************************************************************
*/
int main (void)
{
OSInit ();
OSTaskCreate(TaskStart,(void *)0, &TaskStartStk[TASK_STK_SIZE - 1], 0);
OSStart ();
return 0;
}
/*
********************************************************************************************************
** TaskStart 任务0
** 完成目标板初始化和创建TaskLED1/2任务
********************************************************************************************************
*/
void TaskStart(void *pdata)
{
pdata = pdata ;
TargetInit();
for(;;)
{
OSTimeDly(OS_TICKS_PER_SEC / 50);
if(GetKey() != KEY1)
continue ;
OSTimeDly(OS_TICKS_PER_SEC / 50);
if(GetKey() != KEY1)
continue ;
OSTaskCreate(Task1,(void *)0, &TaskStk[TASK_STK_SIZE - 1], 1);
while(GetKey() != 0)
{
OSTimeDly(OS_TICKS_PER_SEC / 50);
}
}
}
/*
********************************************************************************************************
** TaskLED1
** LED1任务
********************************************************************************************************
*/
void Task1(void *pdata)
{
pdata = pdata ;
BeepMoo();
OSTimeDly(OS_TICKS_PER_SEC / 2);
BeepNoMoo();
OSTimeDly(OS_TICKS_PER_SEC / 2);
BeepMoo();
OSTimeDly(OS_TICKS_PER_SEC / 2);
BeepNoMoo();
OSTimeDly(OS_TICKS_PER_SEC / 2);
OSTaskDel(OS_PRIO_SELF);
}
/*
********************************************************************************************************
** TaskLED2
** LED2任务
********************************************************************************************************
*/
void BeepMoo(void)
{
IO0CLR = BEEP;
}
void BeepNoMoo(void)
{
IO0SET = BEEP;
}
uint32 GetKey(void)
{
volatile uint32 key;
key = IO0PIN & KEY1;
return key;
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -