Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define IRremoteint_h
- #include <Arduino.h>
- #define CLKFUDGE 5 // fudge factor for clock interrupt overhead
- #define CLK 256 // max value for clock (timer 2)
- #define PRESCALE 8 // timer2 clock prescale
- #define SYSCLOCK 8000000 // main Arduino clock
- #define CLKSPERUSEC (SYSCLOCK/PRESCALE/1000000) // timer clocks per microsecond
- #define ERR 0
- #define DECODED 1
- // defines for setting and clearing register bits
- #ifndef cbi
- #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
- #endif
- #ifndef sbi
- #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
- #endif
- // clock timer reset value
- #define INIT_TIMER_COUNT2 (CLK - USECPERTICK*CLKSPERUSEC + CLKFUDGE)
- #define RESET_TIMER2 TCNT0 = INIT_TIMER_COUNT2
- #define TOLERANCE 25 // percent tolerance in measurements
- #define LTOL (1.0 - TOLERANCE/100.)
- #define UTOL (1.0 + TOLERANCE/100.)
- #define _GAP 5000 // Minimum map between transmissions
- #define GAP_TICKS (_GAP/USECPERTICK)
- #define TICKS_LOW(us) (int) (((us)*LTOL/USECPERTICK))
- #define TICKS_HIGH(us) (int) (((us)*UTOL/USECPERTICK + 1))
- // receiver states
- #define STATE_IDLE 2
- #define STATE_MARK 3
- #define STATE_SPACE 4
- #define STATE_STOP 5
- // information for the interrupt handler
- typedef struct {
- uint8_t recvpin; // pin for IR data from detector
- uint8_t rcvstate; // state machine
- unsigned int timer; // state timer, counts 50uS ticks.
- unsigned int rawbuf[RAWBUF]; // raw data
- uint8_t rawlen; // counter of entries in rawbuf
- }
- irparams_t;
- // Defined in IRremote.cpp
- extern volatile irparams_t irparams;
- // IR detector output is active low
- #define MARK 0
- #define SPACE 1
- #define TOPBIT 0x80000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement