ir2.h
#ifndef _IR2_H
#define _IR2_H
#include "stdint.h"
#define T1_RELOAD_H 0
#define T1_RELOAD_L 0
#define IR_RAW_SUPPORT 1
#define IR_RC5_SUPPORT 1
#define IR_RC6_SUPPORT 1
#define IR_NEC_SUPPORT 1
#define IR_JVC_SUPPORT 1
#define IR_SONY_SUPPORT 1
#define IR_SHARP_SUPPORT 1
#define IR_PACE_SUPPORT 1
typedef enum {
IR_NEC,
IR_NEC_EXTENDED,
IR_JVC,
IR_RC5,
IR_RC6,
IR_SONY_12BITS,
IR_SONY_15BITS,
IR_SONY_20BITS,
IR_SHARP,
IR_PACE
} ir_type_t;
typedef union {
struct {
unsigned first :1;
unsigned edge :1;
unsigned timeout :1;
unsigned decoded :1;
};
uint8_t raw;
} ir_flags_t;
typedef struct {
ir_type_t type;
uint8_t command;
uint16_t address;
uint8_t extra;
} ir_t;
#if IR_RAW_SUPPORT == 1
#define IR_RAW_SIZE 192
#endif
#if IR_RC5_SUPPORT == 1
#define RC5_SHORT_MIN 10
#define RC5_SHORT_MAX 16
#define RC5_LONG_MIN 24
#define RC5_LONG_MAX 30
typedef struct {
union {
struct {
unsigned invalid :1;
unsigned last :1;
unsigned last2 :1;
unsigned x :1;
unsigned same :1;
};
uint8_t raw;
} flags;
uint16_t data;
} rc5_t;
#endif
#if IR_RC6_SUPPORT == 1
#define RC6_FIRST_MIN 40
#define RC6_FIRST_MAX 44
#define RC6_SECOND_MIN 9
#define RC6_SECOND_MAX 13
#define RC6_SHORT_MIN 4
#define RC6_SHORT_MAX 8
#define RC6_LONG_MIN 10
#define RC6_LONG_MAX 16
typedef struct {
union {
struct {
unsigned invalid :1;
unsigned last :1;
unsigned last2 :1;
unsigned x :1;
unsigned same :1;
unsigned first :1;
unsigned second :1;
};
uint8_t raw;
} flags;
uint8_t bitcount;
uint24_t data;
} rc6_t;
#endif
#if IR_JVC_SUPPORT == 1
#define JVC_FIRST_MIN 128
#define JVC_FIRST_MAX 136
#define JVC_SECOND_MIN 60
#define JVC_SECOND_MAX 68
#define JVC_SHORT_MIN 6
#define JVC_SHORT_MAX 11
#define JVC_LONG_MIN 21
#define JVC_LONG_MAX 25
#define JVC_TIMEOUT 200
typedef struct {
union {
struct {
unsigned invalid :1;
unsigned last :1;
unsigned first :1;
unsigned second :1;
unsigned pulse :1;
unsigned rbit :1;
};
uint8_t raw;
} flags;
uint8_t bitcount;
uint16_t data;
} jvc_t;
#endif
#if IR_NEC_SUPPORT == 1
#define NEC_FIRST_MIN 136
#define NEC_FIRST_MAX 144
#define NEC_SECOND_MIN 64
#define NEC_SECOND_MAX 72
#define NEC_SHORT_MIN 6
#define NEC_SHORT_MAX 11
#define NEC_LONG_MIN 22
#define NEC_LONG_MAX 27
#define NEC_TIMEOUT 200
typedef struct {
union {
struct {
unsigned invalid :1;
unsigned last :1;
unsigned first :1;
unsigned second :1;
unsigned pulse :1;
};
uint8_t raw;
} flags;
uint8_t bitcount;
uint32_t data;
} nec_t;
#endif
#if IR_SONY_SUPPORT == 1
#define SONY_FIRST_MIN 35
#define SONY_FIRST_MAX 40
#define SONY_SHORT_MIN 6
#define SONY_SHORT_MAX 11
#define SONY_LONG_MIN 17
#define SONY_LONG_MAX 21
#define SONY_TIMEOUT 150
typedef struct {
union {
struct {
unsigned invalid :1;
unsigned last :1;
unsigned first :1;
unsigned gap :1;
};
uint8_t raw;
} flags;
uint8_t bitcount;
uint24_t data;
} sony_t;
#endif
#if IR_SHARP_SUPPORT == 1
#define SHARP_SHORT_MIN 3
#define SHARP_SHORT_MAX 6
#define SHARP_ZERO_MIN 9
#define SHARP_ZERO_MAX 13
#define SHARP_ONE_MIN 25
#define SHARP_ONE_MAX 29
typedef struct {
union {
struct {
unsigned invalid :1;
unsigned last :1;
unsigned gap :1;
unsigned second :1;
};
uint8_t raw;
} flags;
uint16_t data;
uint16_t prev;
} sharp_t;
#endif
#if IR_PACE_SUPPORT == 1
#define PACE_SHORT_MIN 7
#define PACE_SHORT_MAX 12
#define PACE_SECOND_MIN 46
#define PACE_SECOND_MAX 50
#define PACE_ONE_MIN 104
#define PACE_ONE_MAX 110
#define PACE_ZERO_MIN 66
#define PACE_ZERO_MAX 70
typedef struct {
union {
struct {
unsigned invalid :1;
unsigned last :1;
unsigned pulse :1;
unsigned first :1;
unsigned second :1;
};
uint8_t raw;
} flags;
uint16_t data;
} pace_t;
#endif
extern void ir_init(void);
extern void ir_enable(void);
extern void ir_disable(void);
extern void ir_interrupt(void);
extern void ir_timeout(void);
extern ir_t ir;
extern ir_flags_t ir_flags;
#endif