基于LPC1114的学习型红外遥控器
in a specific bit position
** in GPIO portX(X is the port number.)
**
** parameters: port num, bit position, bit value
** Returned value: None
**
*****************************************************************************/
void GPIOSetValue( uint32_t portNum, uint32_t bitPosi, uint32_t bitVal )
{
/* if bitVal is 1, the bitPosi bit is set in the GPIOShadowPortx. Then
* GPIOShadowPortx is written to the I/O port register. */
switch ( portNum )
{
case PORT0:
if(bitVal)
GPIOShadowPort0 |= (1< else
GPIOShadowPort0 &= ~(1<
/* Use of shadow prevents bit operation error if the read value
* (external hardware state) of a pin differs from the I/O latch
* value. A potential side effect is that other GPIO code in this
* project that is not aware of the shadow will have its GPIO
* state overwritten.
*/
LPC_GPIO0->DATA = GPIOShadowPort0;
break;
case PORT1:
if(bitVal)
GPIOShadowPort1 |= (1< else
GPIOShadowPort1 &= ~(1<
LPC_GPIO1->DATA = GPIOShadowPort1;
break;
case PORT2:
if(bitVal)
GPIOShadowPort2 |= (1< else
GPIOShadowPort2 &= ~(1<
LPC_GPIO2->DATA = GPIOShadowPort2;
break;
case PORT3:
if(bitVal)
GPIOShadowPort3 |= (1< else
GPIOShadowPort3 &= ~(1<
LPC_GPIO3->DATA = GPIOShadowPort3;
break;
default:
break;
}
return;
}
/*****************************************************************************
** Function name: GPIOSetInterrupt
**
** Descriptions: Set interrupt sense, event, etc.
** edge or level, 0 is edge, 1 is level
** single or double edge, 0 is single, 1 is double
** active high or low, etc.
**
** parameters: port num, bit position, sense, single/doube, polarity
** Returned value: None
**
*****************************************************************************/
void GPIOSetInterrupt( uint32_t portNum, uint32_t bitPosi, uint32_t sense,
uint32_t single, uint32_t event )
{
switch ( portNum )
{
case PORT0:
if ( sense == 0 )
{
LPC_GPIO0->IS &= ~(0x1< /* single or double only applies when sense is 0(edge trigger). */
if ( single == 0 )
LPC_GPIO0->IBE &= ~(0x1< else
LPC_GPIO0->IBE |= (0x1< }
else
LPC_GPIO0->IS |= (0x1< if ( event == 0 )
LPC_GPIO0->IEV &= ~(0x1< else
LPC_GPIO0->IEV |= (0x1< break;
case PORT1:
if ( sense == 0 )
{
LPC_GPIO1->IS &= ~(0x1< /* single or double only applies when sense is 0(edge trigger). */
if ( single == 0 )
LPC_GPIO1->IBE &= ~(0x1< else
LPC_GPIO1->IBE |= (0x1< }
else
LPC_GPIO1->IS |= (0x1< if ( event == 0 )
LPC_GPIO1->IEV &= ~(0x1< else
LPC_GPIO1->IEV |= (0x1< break;
case PORT2:
if ( sense == 0 )
{
LPC_GPIO2->IS &= ~(0x1< /* single or double only applies when sense is 0(edge trigger). */
if ( single == 0 )
LPC_GPIO2->IBE &= ~(0x1< else
LPC_GPIO2->IBE |= (0x1< }
else
LPC_GPIO2->IS |= (0x1< if ( event == 0 )
LPC_GPIO2->IEV &= ~(0x1< else
LPC_GPIO2->IEV |= (0x1< break;
case PORT3:
if ( sense == 0 )
{
LPC_GPIO3->IS &= ~(0x1< /* single or double only applies when sense is 0(edge trigger). */
if ( single == 0 )
LPC_GPIO3->IBE &= ~(0x1< else
LPC_GPIO3->IBE |= (0x1< }
else
LPC_GPIO3->IS |= (0x1< if ( event == 0 )
LPC_GPIO3->IEV &= ~(0x1< else
LPC_GPIO3->IEV |= (0x1< break;
default:
break;
}
return;
}
/*****************************************************************************
** Function name: GPIOIntEnable
**
** Descriptions: Enable Interrupt Mask for a port pin.
**
** parameters: port num, bit position
** Returned value: None
**
**************************************************
- NXP_LPC1114_LED灯程序(11-29)
- LPC1114_外部中断程序_MDK编译环境(11-29)
- LPC1114_Timer16_0中断程序_MDK编译环境(11-29)
- LPC1114_时钟系统解析(11-29)
- NXP_LPC1114延时函数集合(11-29)
- LPC1114/LPC11U14和LPC1343对比学习(一)整体对比(11-27)