IRremote
IRremoteInt.h
Go to the documentation of this file.
1 //******************************************************************************
2 // IRremoteint.h
3 // IRremote
4 // Version 2.0.1 June, 2015
5 // Copyright 2009 Ken Shirriff
6 // For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
7 //
8 // Modified by Paul Stoffregen <paul@pjrc.com> to support other boards and timers
9 //
10 // Interrupt code based on NECIRrcv by Joe Knapp
11 // http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
12 // Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
13 //
14 // JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
15 // Whynter A/C ARC-110WD added by Francesco Meschia
16 //******************************************************************************
17 
18 #ifndef IRremoteint_h
19 #define IRremoteint_h
20 
21 //------------------------------------------------------------------------------
22 // Include the Arduino header
23 //
24 #include <Arduino.h>
25 
26 // All board specific stuff have been moved to its own file, included here.
27 #include "IRremoteBoardDefs.h"
28 
29 //------------------------------------------------------------------------------
30 // Information for the Interrupt Service Routine
31 //
32 #if ! defined(RAW_BUFFER_LENGTH)
33 #define RAW_BUFFER_LENGTH 101
34 #endif
35 
39 typedef struct {
40  // The fields are ordered to reduce memory over caused by struct-padding
41  uint8_t rcvstate;
42  uint8_t recvpin;
43  uint8_t blinkpin;
44  uint8_t blinkflag;
45  unsigned int rawlen;
46  unsigned int timer;
47  unsigned int rawbuf[RAW_BUFFER_LENGTH];
48  uint8_t overflow;
49 } irparams_t;
50 
51 // ISR State-Machine : Receiver States
52 #define IR_REC_STATE_IDLE 2
53 #define IR_REC_STATE_MARK 3
54 #define IR_REC_STATE_SPACE 4
55 #define IR_REC_STATE_STOP 5
56 #define IR_REC_STATE_OVERFLOW 6
57 
63 #ifdef IR_GLOBAL
64 volatile irparams_t irparams;
65 #else
66 extern volatile irparams_t irparams;
67 #endif
68 
69 //------------------------------------------------------------------------------
70 // Defines for setting and clearing register bits
71 //
72 #ifndef cbi
73 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
74 #endif
75 
76 #ifndef sbi
77 #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
78 #endif
79 
80 //------------------------------------------------------------------------------
81 // Pulse parms are ((X*50)-100) for the Mark and ((X*50)+100) for the Space.
82 // First MARK is the one after the long gap
83 // Pulse parameters in uSec
84 //
85 
92 #define MARK_EXCESS 100
93 
95 #define TOLERANCE 25
96 
98 //#define LTOL (1.0 - (TOLERANCE/100.))
99 #define LTOL (100 - TOLERANCE)
100 
101 //#define UTOL (1.0 + (TOLERANCE/100.))
102 #define UTOL (100 + TOLERANCE)
103 
105 #define _GAP 5000
106 
108 #define GAP_TICKS (_GAP/USECPERTICK)
109 
110 //#define TICKS_LOW(us) ((int)(((us)*LTOL/USECPERTICK)))
111 //#define TICKS_HIGH(us) ((int)(((us)*UTOL/USECPERTICK + 1)))
112 #if USECPERTICK == 50 && TOLERANCE == 25 // Defaults
113  #define TICKS_LOW(us) ((int) ((us)/67 )) // (us) / ((USECPERTICK:50 / LTOL:75 ) * 100)
114  #define TICKS_HIGH(us) ((int) ((us)/40 + 1)) // (us) / ((USECPERTICK:50 / UTOL:125) * 100) + 1
115 #else
116  #define TICKS_LOW(us) ((int) ((long) (us) * LTOL / (USECPERTICK * 100) ))
117  #define TICKS_HIGH(us) ((int) ((long) (us) * UTOL / (USECPERTICK * 100) + 1))
118 #endif
119 
120 //------------------------------------------------------------------------------
121 // IR detector output is active low
122 //
123 #define MARK 0
124 #define SPACE 1
125 
126 #endif
irparams_t::overflow
uint8_t overflow
Raw buffer overflow occurred.
Definition: IRremoteInt.h:48
irparams_t::timer
unsigned int timer
State timer, counts 50uS ticks.
Definition: IRremoteInt.h:46
irparams_t
This struct is used to communicate with the ISR (interrupt service routine).
Definition: IRremoteInt.h:39
irparams_t::recvpin
uint8_t recvpin
Pin connected to IR data from detector.
Definition: IRremoteInt.h:42
irparams_t::rcvstate
uint8_t rcvstate
State Machine state.
Definition: IRremoteInt.h:41
irparams
volatile irparams_t irparams
Allow all parts of the code access to the ISR data NB.
IRremoteBoardDefs.h
All board specific information should be contained in this file. It defines a number of macros,...
irparams_t::blinkpin
uint8_t blinkpin
Definition: IRremoteInt.h:43
RAW_BUFFER_LENGTH
#define RAW_BUFFER_LENGTH
Maximum length of raw duration buffer. Must be odd.
Definition: IRremoteInt.h:33
irparams_t::blinkflag
uint8_t blinkflag
true -> enable blinking of pin on IR processing
Definition: IRremoteInt.h:44
irparams_t::rawlen
unsigned int rawlen
counter of entries in rawbuf
Definition: IRremoteInt.h:45