LPC1114 红外遥控解码程序(RC5 )
时间:11-11
来源:互联网
点击:
- 0; // short low, long high, ERROR
- cmd = 0;
- break;
- case 6:RC5_Shift_Bit(1); // long low, short high, shift 1,0
- RC5_Shift_Bit(0);
- half_bit = 0; // new half bit is false
- break;
- case 7:sys = 0; // long low, long high, ERROR
- cmd = 0;
- default: break; // invalid
- }
- }
- void PIOINT0_IRQHandler(void)
- {
- uint32_t regVal;
- LPC_TMR16B0->TCR = 0; //disable timer
- regVal =LPC_GPIO0->MIS & (0x1<0x01);//get interrupt status
- if ( regVal )
- {
- if( (LPC_GPIO0->DATA & RC5_INPUT_PIN) == RC5_INPUT_PIN) // check rising or falling edge
- {
- if (sys == 0) // First pulse ?
- {
- low_time= HALF_BIT_TIME; // assume short low time
- high_time = HALF_BIT_TIME; // assume short high time
- half_bit= 1; // assume half bit is true
- cmd = 0x02; // = 00000010, prepare command byte
- }
- else
- low_time = LPC_TMR16B0->TC; // rising, so capture low time
- RC5_Decode();
- }
- else
- high_time = LPC_TMR16B0->TC; // falling, so capture high time
- }
- LPC_TMR16B0->TCR = 1; //enable timer
- LPC_TMR16B0->TCR = 2; //reset timer
- LPC_GPIO0->IC |= ( 0x1 < 0x01);//clear interrupt
- LPC_TMR16B0->TCR = 1; //enable timer
- }
- void TIMER16_0_IRQHandler(void)
- {
- if ( LPC_TMR16B0->IR & 0x1 )
- {
- //timeout has occured.
- if (cmd & 0x80) // command full ?
- {
- RC5_Command = cmd & 0x7F; // OK ! Save command byte
- RC5_System = sys; // save system byte
- RC5_flag = 1; // set event to application
- }
- sys = 0;
- cmd = 0;
- }
- LPC_TMR16B0->IR = 1; // clear interrupt flag
- }
LPC1114红外遥控解码程 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)