微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > LPC1114 红外遥控解码程序(RC5 )

LPC1114 红外遥控解码程序(RC5 )

时间:11-11 来源:互联网 点击:
  1. 0; // short low, long high, ERROR
  2. cmd = 0;
  3. break;
  4. case 6:RC5_Shift_Bit(1); // long low, short high, shift 1,0
  5. RC5_Shift_Bit(0);
  6. half_bit = 0; // new half bit is false
  7. break;
  8. case 7:sys = 0; // long low, long high, ERROR
  9. cmd = 0;
  10. default: break; // invalid
  11. }
  12. }
  13. void PIOINT0_IRQHandler(void)
  14. {
  15. uint32_t regVal;
  16. LPC_TMR16B0->TCR = 0; //disable timer
  17. regVal =LPC_GPIO0->MIS & (0x1<0x01);//get interrupt status
  18. if ( regVal )
  19. {
  20. if( (LPC_GPIO0->DATA & RC5_INPUT_PIN) == RC5_INPUT_PIN) // check rising or falling edge
  21. {
  22. if (sys == 0) // First pulse ?
  23. {
  24. low_time= HALF_BIT_TIME; // assume short low time
  25. high_time = HALF_BIT_TIME; // assume short high time
  26. half_bit= 1; // assume half bit is true
  27. cmd = 0x02; // = 00000010, prepare command byte
  28. }
  29. else
  30. low_time = LPC_TMR16B0->TC; // rising, so capture low time
  31. RC5_Decode();
  32. }
  33. else
  34. high_time = LPC_TMR16B0->TC; // falling, so capture high time
  35. }
  36. LPC_TMR16B0->TCR = 1; //enable timer
  37. LPC_TMR16B0->TCR = 2; //reset timer
  38. LPC_GPIO0->IC |= ( 0x1 < 0x01);//clear interrupt
  39. LPC_TMR16B0->TCR = 1; //enable timer
  40. }
  41. void TIMER16_0_IRQHandler(void)
  42. {
  43. if ( LPC_TMR16B0->IR & 0x1 )
  44. {
  45. //timeout has occured.
  46. if (cmd & 0x80) // command full ?
  47. {
  48. RC5_Command = cmd & 0x7F; // OK ! Save command byte
  49. RC5_System = sys; // save system byte
  50. RC5_flag = 1; // set event to application
  51. }
  52. sys = 0;
  53. cmd = 0;
  54. }
  55. LPC_TMR16B0->IR = 1; // clear interrupt flag
  56. }

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

网站地图

Top