📄 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: 2008-02-26
** Last Version: 1.0
** Descriptions: The main() function example template
**
**-------------------------------------------------------------------------------------------------------
** Created by: Chen Mingji
** Created date: 2008-02-26
** Version: 1.0
** Descriptions: The original version
**
**-------------------------------------------------------------------------------------------------------
** Modified by: Li Baihua
** Modified date: 2008-04-02
** Version: 1.1
** Descriptions: 发光二极管闪烁高速GPIO实验
**
*********************************************************************************************************/
#include "config.h"
# define LED1 1 << 17 /* P0.17控制LED1 */
# define LED2 1 << 18 /* P0.18控制LED2 */
# define LED3 1 << 19 /* P0.19控制LED3 */
# define LED4 1 << 20 /* P0.20控制LED4 */
/*********************************************************************************************************
** Function name: DelayNS
** Descriptions: 延时函数
** input parameters: uiDly 值越大,延时时间越长
** output parameters: 无
** Returned value: 无
*********************************************************************************************************/
void DelayNS (uint32 uiDly)
{
uint32 i;
for (; uiDly > 0; uiDly--){
for(i = 0; i < 50000; i++);
}
}
/*********************************************************************************************************
** Function name: main
** Descriptions: 跳线JP4短接,LED1闪烁
** input parameters: 无
** output parameters: 无
** Returned value: 无
*********************************************************************************************************/
int main (void)
{
PINSEL1 = PINSEL1 & (~(0xFF << 2)); /* 将P0.17-P0.20设置为GPIO */
SCS = 0x01; /* 设定为高速GPIO模式 */
FIO0DIR = LED1 | LED2 | LED3 | LED4; /* 设置LED控制口为输出 */
FIO0SET = LED1 | LED2 | LED3 | LED4; /* LED1熄灭 */
while (1) {
FIO0SET = LED1 | LED3; /* LED1、LED3熄灭 */
FIO0CLR = LED2 | LED4; /* LED2、LED4点亮 */
DelayNS(50); /* 延时 */
FIO0CLR = LED1 | LED3; /* LED1、LED3点亮 */
FIO0SET = LED2 | LED4; /* LED2、LED4熄灭 */
DelayNS(50); /* 延时 */
}
return 0;
}
/*********************************************************************************************************
** End Of File
**********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -