PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

114 行
3.8KB

  1. //******************************************************************************
  2. // IRremote
  3. // Version 2.0.1 June, 2015
  4. // Copyright 2009 Ken Shirriff
  5. // For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
  6. //
  7. // Modified by Paul Stoffregen <paul@pjrc.com> to support other boards and timers
  8. //
  9. // Interrupt code based on NECIRrcv by Joe Knapp
  10. // http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
  11. // Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
  12. //
  13. // JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
  14. // Whynter A/C ARC-110WD added by Francesco Meschia
  15. //******************************************************************************
  16. #ifndef IRremoteint_h
  17. #define IRremoteint_h
  18. //------------------------------------------------------------------------------
  19. // Include the right Arduino header
  20. //
  21. #if defined(ARDUINO) && (ARDUINO >= 100)
  22. # include <Arduino.h>
  23. #else
  24. # if !defined(IRPRONTO)
  25. # include <WProgram.h>
  26. # endif
  27. #endif
  28. //------------------------------------------------------------------------------
  29. // This handles definition and access to global variables
  30. //
  31. #ifdef IR_GLOBAL
  32. # define EXTERN
  33. #else
  34. # define EXTERN extern
  35. #endif
  36. //------------------------------------------------------------------------------
  37. // Information for the Interrupt Service Routine
  38. //
  39. #define RAWBUF 101 // Maximum length of raw duration buffer
  40. typedef
  41. struct {
  42. // The fields are ordered to reduce memory over caused by struct-padding
  43. uint8_t rcvstate; // State Machine state
  44. uint8_t recvpin; // Pin connected to IR data from detector
  45. uint8_t blinkpin;
  46. uint8_t blinkflag; // true -> enable blinking of pin on IR processing
  47. uint8_t rawlen; // counter of entries in rawbuf
  48. unsigned int timer; // State timer, counts 50uS ticks.
  49. unsigned int rawbuf[RAWBUF]; // raw data
  50. uint8_t overflow; // Raw buffer overflow occurred
  51. }
  52. irparams_t;
  53. // ISR State-Machine : Receiver States
  54. #define STATE_IDLE 2
  55. #define STATE_MARK 3
  56. #define STATE_SPACE 4
  57. #define STATE_STOP 5
  58. #define STATE_OVERFLOW 6
  59. // Allow all parts of the code access to the ISR data
  60. // NB. The data can be changed by the ISR at any time, even mid-function
  61. // Therefore we declare it as "volatile" to stop the compiler/CPU caching it
  62. EXTERN volatile irparams_t irparams;
  63. //------------------------------------------------------------------------------
  64. // Defines for setting and clearing register bits
  65. //
  66. #ifndef cbi
  67. # define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
  68. #endif
  69. #ifndef sbi
  70. # define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
  71. #endif
  72. //------------------------------------------------------------------------------
  73. // Pulse parms are ((X*50)-100) for the Mark and ((X*50)+100) for the Space.
  74. // First MARK is the one after the long gap
  75. // Pulse parameters in uSec
  76. //
  77. // Due to sensor lag, when received, Marks tend to be 100us too long and
  78. // Spaces tend to be 100us too short
  79. #define MARK_EXCESS 100
  80. // Upper and Lower percentage tolerances in measurements
  81. #define TOLERANCE 25
  82. #define LTOL (1.0 - (TOLERANCE/100.))
  83. #define UTOL (1.0 + (TOLERANCE/100.))
  84. // Minimum gap between IR transmissions
  85. #define _GAP 5000
  86. #define GAP_TICKS (_GAP/USECPERTICK)
  87. #define TICKS_LOW(us) ((int)(((us)*LTOL/USECPERTICK)))
  88. #define TICKS_HIGH(us) ((int)(((us)*UTOL/USECPERTICK + 1)))
  89. //------------------------------------------------------------------------------
  90. // IR detector output is active low
  91. //
  92. #define MARK 0
  93. #define SPACE 1
  94. // All board specific stuff has been moved to its own file, included here.
  95. #include "boarddefs.h"
  96. #endif