main.c
来自「easyarm2103开发板资料」· C语言 代码 · 共 70 行
C
70 行
/***********************************************Copyright (c)*********************************************
** Guangzou ZLG-MCU Development Co.,LTD.
**
** http://www.zlgmcu.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name: main.c
** Last modified Date: 2007-09-20
** Last Version: 1.0
** Descriptions: The main() function example template
**
**--------------------------------------------------------------------------------------------------------
** Created by:
** Created date:
** Version:
** Descriptions:
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
** Version:
** Descriptions:
**
*********************************************************************************************************/
#include "config.h"
/*********************************************************************************************************
** Function name: delayNS
** Descriptions: 长软件延时
** Input parameters: dly 延时参数,值越大,延时越久
** Output parameters: NONE
** Returned value: NONE
*********************************************************************************************************/
void delayNS (uint32 dly)
{
uint32 i;
for ( ; dly>0; dly--)
for (i=0; i<50000; i++);
}
/*********************************************************************************************************
** Function name: main
** Descriptions: 用户主函数,用户写程序需要注意以下几个步骤
** 1.用户要对自己操作的管脚进行管脚功能设置,设置文件为pinConfig.h
** 2.如果用户代码需要中断,需要打开内核中断,函数为:IRQEnable(); FIQEnable();
** 3.用户有中断,需要设置VIC,设置函数请参考IRQManage.h
** 4.其他功能实现用户可参考相关驱动的头文件或使用说明文档
** Input parameters: NONE
** Output parameters: NONE
** Returned value: NONE
*********************************************************************************************************/
#define LED1 P0_17
#define KEY1 P0_16
int main (void)
{
while (1){
if ( gpioGet(KEY1) == 0x00 ){ /* 有按键按下 */
delayNS(20); /* 去抖动 */
if ( gpioGet(KEY1) == 0x00 ){ /* 有按键按下 */
while(gpioClr(LED1) == OPERATE_FAIL); /* 如果KEY1按下,LED1点亮 */
}
}
else
while(gpioSet(LED1) == OPERATE_FAIL); /* 按键松开则LED4熄灭 */
}
return 0;
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?