?? 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: 李仲生
** Created date: 2007-3-26
** Version: 1.0
** Descriptions: 增強型GPIO輸出實驗,控制蜂鳴器鳴叫。
**------------------------------------------------------------------------------------------------------
** Modified by: yangshiping
** Modified date: 2007-09-03
** Version:
** Descriptions: 對程序的風(fēng)格以及注釋略作調(diào)整,并檢查代碼。
**
** Rechecked by: Litiantian
********************************************************************************************************/
#include "config.h"
#define BEEP (1 << 27) // P0.7控制蜂鳴器,低電平蜂鳴
/**********************************************************************************************************
** 函數(shù)名稱 :DelayNS
** 函數(shù)功能 :長軟件延時
** 入口參數(shù) :dly 延時參數(shù),值越大,延時越久
** 出口參數(shù) :無
**********************************************************************************************************/
void DelayNS(uint32 dly)
{
uint32 i;
for (; dly > 0; dly--)
for (i = 0; i < 50000; i++);
}
/**********************************************************************************************************
** 函數(shù)名稱 :main
** 函數(shù)功能 :用P1.27控制BEEP,讓BEEP鳴叫。
** 調(diào)試說明 :需將跳線JP21短接。
**********************************************************************************************************/
int main(void)
{
SCS = SCS | 0x01; // PORT0和PORT1端口連接到高速端口
PINSEL3 = 0x00000000; // 設(shè)置管腳連接GPIO
FIO1SET = BEEP; // P1.27輸出高電平
FIO1DIR = FIO1DIR | BEEP; // 設(shè)置增強型端口P1.27為輸出口
while (1)
{
FIO1SET = BEEP; // P1.27輸出高電平
DelayNS(50);
FIO1CLR = BEEP; // P1.27輸出低電平
DelayNS(50);
}
return (0);
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -