微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 基于LPC1114的学习型红外遥控器

基于LPC1114的学习型红外遥控器

时间:08-10 来源:互联网 点击:

** Returned value: None

**

*****************************************************************************/

void PIOINT1_IRQHandler(void)

{

uint32_t regVal;

gpio1_counter++;

regVal = GPIOIntStatus( PORT1, 1 );

if ( regVal )

{

p1_1_counter++;

GPIOIntClear( PORT1, 1 );

}

return;

}

/*****************************************************************************

** Function name: PIOINT2_IRQHandler

**

** Descriptions: Use one GPIO pin(port2 pin1) as interrupt source

**

** parameters: None

** Returned value: None

**

*****************************************************************************/

void PIOINT2_IRQHandler(void)

{

uint32_t regVal;

gpio2_counter++;

regVal = GPIOIntStatus( PORT2, 1 );

if ( regVal )

{

p2_1_counter++;

GPIOIntClear( PORT2, 1 );

}

return;

}

/*****************************************************************************

** Function name: PIOINT3_IRQHandler

**

** Descriptions: Use one GPIO pin(port3 pin1) as interrupt source

**

** parameters: None

** Returned value: None

**

*****************************************************************************/

void PIOINT3_IRQHandler(void)

{

uint32_t regVal;

gpio3_counter++;

regVal = GPIOIntStatus( PORT3, 1 );

if ( regVal )

{

p3_1_counter++;

GPIOIntClear( PORT3, 1 );

}

return;

}

/*****************************************************************************

** Function name: GPIOInit

**

** Descriptions: Initialize GPIO, install the

** GPIO interrupt handler

**

** parameters: None

** Returned value: true or false, return false if the VIC table

** is full and GPIO interrupt handler can be

** installed.

**

*****************************************************************************/

void GPIOInit( void )

{

/* Enable AHB clock to the GPIO domain. */

LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);

#ifdef __JTAG_DISABLED

LPC_IOCON->JTAG_TDO_PIO1_1 &= ~0x07;

LPC_IOCON->JTAG_TDO_PIO1_1 |= 0x01;

#endif

/* Set up NVIC when I/O pins are configured as external interrupts. */

NVIC_EnableIRQ(EINT0_IRQn);

NVIC_EnableIRQ(EINT1_IRQn);

NVIC_EnableIRQ(EINT2_IRQn);

NVIC_EnableIRQ(EINT3_IRQn);

return;

}

/*****************************************************************************

** Function name: GPIOSetDir

**

** Descriptions: Set the direction in GPIO port

**

** parameters: port num, bit position, direction (1 out, 0 input)

** Returned value: None

**

*****************************************************************************/

void GPIOSetDir( uint32_t portNum, uint32_t bitPosi, uint32_t dir )

{

/* if DIR is OUT(1), but GPIOx_DIR is not set, set DIR

to OUT(1); if DIR is IN(0), but GPIOx_DIR is set, clr

DIR to IN(0). All the other cases are ignored.

On port3(bit 0 through 3 only), no error protection if

bit value is out of range. */

switch ( portNum )

{

case PORT0:

if ( !(LPC_GPIO0->DIR & (0x1< LPC_GPIO0->DIR |= (0x1< else if ( (LPC_GPIO0->DIR & (0x1< LPC_GPIO0->DIR &= ~(0x1< break;

case PORT1:

if ( !(LPC_GPIO1->DIR & (0x1< LPC_GPIO1->DIR |= (0x1< else if ( (LPC_GPIO1->DIR & (0x1< LPC_GPIO1->DIR &= ~(0x1< break;

case PORT2:

if ( !(LPC_GPIO2->DIR & (0x1< LPC_GPIO2->DIR |= (0x1< else if ( (LPC_GPIO2->DIR & (0x1< LPC_GPIO2->DIR &= ~(0x1< break;

case PORT3:

if ( !(LPC_GPIO3->DIR & (0x1< LPC_GPIO3->DIR |= (0x1< else if ( (LPC_GPIO3->DIR & (0x1< LPC_GPIO3->DIR &= ~(0x1< break;

default:

break;

}

return;

}

/*****************************************************************************

** Function name: GPIOSetValue

**

** Descriptions: Set/clear a bitvalue

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top