⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fiotest.c

📁 LPC23XX在keil下c语言的例子3:GPIO
💻 C
字号:
/*****************************************************************************
 *   fiotest.c:  GPIO test main C entry file for NXP LPC23xx/24xx Family 
 *    Microprocessors
 *
 *   Copyright(C) 2006, NXP Semiconductor
 *   All rights reserved.
 *
 *   History
 *   2006.07.14  ver 1.00    Prelimnary version, first Release
 *
******************************************************************************/
#include "LPC23xx.h"                        /* LPC2xxx definitions */
#include "type.h"
#include "irq.h"
#include "target.h"
#include "timer.h"
#include "fio.h"

extern DWORD timer_counter;


#define BEEP 	 0xff	//1 << 27	// P1.27控制蜂鸣器,低电平蜂鸣

/*
*********************************************************************************************************
** 函数名称 :DelayNS()
** 函数功能 :长软件延时
** 入口参数 :dly	延时参数,值越大,延时越久
** 出口参数 :无
*********************************************************************************************************
*/
void DelayNS ( DWORD dly)
{
	DWORD  i;
	
	for ( ; dly>0; dly--)
		for (i=0; i<50000; i++);
}



 void init_port(void)
 {
 //port initialized
 //IODIR1=0x00FF0000;
 //IODIR0=0x40600010;
 PINSEL10 = 0;
 FIO0DIR=0x000003c0;
 FIO2DIR=0x000000ff;
 FIO2MASK = 0x00000000;
 }

/*****************************************************************************
**   Main Function  main()
******************************************************************************/
int main (void)
{

	init_port();
	PINSEL4 = 0x00000000;		// 设置管脚连接GPIO
	//IO1DIR   = BEEP;			// 设置BEEP控制口为输出	
	FIO2DIR0 = BEEP;
	
	while (1)
	{
		//IO1SET = BEEP;			// BEEP停止蜂鸣
		FIO2SET0 = BEEP;
		DelayNS(50);
		//IO1CLR = BEEP;			// BEEP	蜂鸣
		FIO2CLR0 = BEEP;
		DelayNS(50);
	}
	
    return 0;
   // DWORD counter;
		    		
    /********* The main Function is an endless loop ***********/
    //init_timer( TIME_INTERVAL );

    /* GPIOInit() need to be carefully called if you want to run some
	other peripherals, it will set the PINSEL to default value and change
	the direction of IOs. */

    /* Initialize port for LED display, the LEDs on Keil MCB2300 is Port 2.0~2.7 */
    //GPIOInit( 2, FAST_PORT, DIR_OUT );

	init_port();

    /* Initialize timer for GPIO toggling timing */
/*	enable_timer( 0 );

	counter = 0;
	FIO2SET = 1 << counter;
    while ( 1 )
	{
		if ( timer_counter >= (0x20 * counter) )
		{
			FIO2SET = 1 << counter;
			counter++;
			if ( counter > 8 )
			{
		    	counter = 0;	
		    	timer_counter = 0;
		    	FIO2CLR = 0x000000FF;
			}
	    }
	}
	return 0;	
*/
}

/*****************************************************************************
**                            End Of File
*****************************************************************************/

⌨️ 快捷键说明

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