main.c

来自「easyarm2103开发板资料」· C语言 代码 · 共 88 行

C
88
字号
/***********************************************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"

#define     BEEP         (0x01 << 20)                                    /*  定义蜂鸣器控制引脚          */
/*********************************************************************************************************
** Function name:           delayNS
**
** Descriptions:            延时函数
**
** input parameters:        uiDly     延时参数
** Returned value:          none      无
**                          
*********************************************************************************************************/
void    delayNS (uint32  uiDly)
{
	uint32 i;
	
	for ( ; uiDly > 0; uiDly--) {
		for (i = 0; i < 0xFFFF; 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
*********************************************************************************************************/
int main (void)
{
   	         char   *pCap ="CapN=0 CapMode=1 CapInt=1";                 /*  通道1,下降沿捕获,中断       */
	         char   *pGetCap ="CapGetN=0";                              /*  返回值,通道1                */
	 static  uint32  uiGetCap;                                          /*  读取捕获值                  */
    
    IO0DIR  |= BEEP;
	IO0SET  |= BEEP;
    /*
     *  管脚配置详见PinConfig.h ,把P0.27配置为捕获输入,用杜邦线将KEY1与P0.27相连.
     */
    timeReset(2,(void*)NULL);                                           /*  功能寄存器复位,以防意外     */                                
	timerCapInit (2,pCap,(void*)NULL);                                  /*  捕获功能初始化              */
	    
	if (irqVicSet(TIMER2_VIC,0,timer2Isr) != -1) {                      /*  设置VIC中断                 */
	                                                                    /*  设置成功                    */
    	IRQEnable();                                                    /*  打开内核中断                */
    	timerStart(2,NULL);                                             /*  启动定时器                  */
	}    
	while (1) {
	    uiGetCap = timerGetCap(2,pGetCap,NULL);                         /*  获取定时器捕获值            */
	}
	
    return 0;
}


/*********************************************************************************************************
   END FILE
*********************************************************************************************************/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?