/****************************************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:
2006-05-12
** Version:
V1.0.1
** Descriptions:
在DeviceARM3000上运行的第一个程序。
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"
// 定义蜂鸣器控制口
#define BEEP
(1<<10) /* GPH10口 */
#define BEEP_MASK
(~BEEP)
/*********************************************************************************************************
** Function name:
DelayNS
** Descriptions
:
长软件延时。
**
延时时间与系统时钟有关。
** Input
:
dly
延时参数,值越大,延时越久
** Output
:
无
** Created by
:
Chenxibing
** Created Date
:
2006-05-12
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void DelayNS(uint32 dly)
{
uint32 i;
for(; dly>0; dly--)
for(i=0; i<50000; i++);
}
/*********************************************************************************************************
** Function name:
main()
** Descriptions
:
在DeviceARM3000(底板为MagicARM2200)上运行的第一个程序,控制蜂鸣器周期性鸣叫。
** Input
:
无
** Output
:
系统返回值0
** Created by
:
Chenxibing
** Created Date
:
2006-05-12
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
int main(void)
{
// 初始化I/O
rGPHCON = (rGPHCON & (~(0x03<<20))) | (0x01<<20); // rGPHCON[21:20] = 01b,设置GPH10为GPIO输出模式
//对控制寄存器 数据寄存器的赋值采用移位和宏赋值
// 控制蜂鸣器周期性鸣叫
while(1)
{
rGPHDAT = rGPHDAT & BEEP_MASK; // BEEP = 0,蜂鸣器鸣叫
DelayNS(30);
rGPHDAT = rGPHDAT | BEEP;
// BEEP = 1,停止蜂鸣
DelayNS(80);
}
return(0);
}