Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
521 arune 1
#ifndef IRCOMMON_H_
2
#define IRCOMMON_H_
3
 
4
/*-----------------------------------------------------------------------------
5
 * Includes
6
 *---------------------------------------------------------------------------*/
7
#include <stdio.h>
8
 
9
/*-----------------------------------------------------------------------------
10
 * Defines
11
 *---------------------------------------------------------------------------*/
533 arune 12
 
521 arune 13
#define IR_OK               1
14
#define IR_NO_PROTOCOL      2
15
#define IR_TIME_OVFL        3
16
#define IR_NO_DATA          4
17
#define IR_NOT_CORRECT_DATA 5
526 arune 18
#define IR_TO_MUCH_DATA     6
548 arune 19
#define IR_NOT_FINISHED     7
521 arune 20
 
548 arune 21
#define IR_BUTTON_DOWN      0x0
22
#define IR_BUTTON_UP        0xf
23
 
521 arune 24
#define CYCLES_PER_US       (F_CPU/1000000)
524 arune 25
#define TIMER_PRESC         8
521 arune 26
 
533 arune 27
#define IR_MIN_PULSE_WIDTH  5                                   //us
28
#define IR_MAX_PULSE_WIDTH  12000                               //us
524 arune 29
 
533 arune 30
#define TIM_OVFL_RELOAD_VAL (65536-(IR_MAX_PULSE_WIDTH*CYCLES_PER_US/TIMER_PRESC))  //timeout of 12ms, no pulses may be longer than this
31
 
548 arune 32
#define TIM_1MS_RELOAD_VAL (65536-(1000*CYCLES_PER_US/TIMER_PRESC))
33
 
533 arune 34
/* RC5 Implementation
35
 * Receiver: DONE
36
 * Transmitter:
37
 */
521 arune 38
#define IR_PROTO_RC5        0
526 arune 39
#define IR_RC5_HALF_BIT     889*CYCLES_PER_US/TIMER_PRESC       //us
40
#define IR_RC5_BIT          889*2*CYCLES_PER_US/TIMER_PRESC     //us
548 arune 41
#define IR_RC5_REPETITION   105                                 //ms    (time between ir frames)
42
#define IR_RC5_REPS         1                                   //      (minimum number of times to repeat code)
524 arune 43
#define IR_RC5_F_MOD        36                                  //kHz   (modulation frequency)
531 arune 44
#define IR_RC5_TOL_DIV      4
521 arune 45
 
533 arune 46
/* RC6 Implementation
47
 * Receiver:
48
 * Transmitter:
49
 */
521 arune 50
#define IR_PROTO_RC6        1
524 arune 51
#define IR_RC6_ST_BIT       1*CYCLES_PER_US/TIMER_PRESC         //us
548 arune 52
#define IR_RC6_REPETITION   1                                   //ms    (time between ir frames)
53
#define IR_RC6_REPS         1                                   //      (minimum number of times to repeat code)
524 arune 54
#define IR_RC6_F_MOD        36                                  //kHz   (modulation frequency)
531 arune 55
#define IR_RC6_TOL_DIV      4
521 arune 56
 
533 arune 57
/* RCMM Implementation
58
 * Receiver:
59
 * Transmitter:
60
 */
61
#define IR_PROTO_RCMM       2
524 arune 62
#define IR_RCMM_ST_BIT      256*CYCLES_PER_US/TIMER_PRESC       //us
548 arune 63
#define IR_RCMM_REPETITION 158                                  //ms    (time between ir frames)
64
#define IR_RCMM_REPS        1                                   //      (minimum number of times to repeat code)
524 arune 65
#define IR_RCMM_F_MOD       36                                  //kHz   (modulation frequency)
531 arune 66
#define IR_RCMM_TOL_DIV     4
521 arune 67
 
533 arune 68
/* SIRC Implementation
69
 * Receiver: DONE
70
 * Transmitter:
71
 */
521 arune 72
#define IR_PROTO_SIRC       3
524 arune 73
#define IR_SIRC_ST_BIT      2400*CYCLES_PER_US/TIMER_PRESC      //us
526 arune 74
#define IR_SIRC_LOW         600*CYCLES_PER_US/TIMER_PRESC       //us
75
#define IR_SIRC_HIGH_ONE    1200*CYCLES_PER_US/TIMER_PRESC      //us
76
#define IR_SIRC_HIGH_ZERO   600*CYCLES_PER_US/TIMER_PRESC       //us
548 arune 77
#define IR_SIRC_REPETITION  40                                  //ms    (time between ir frames)
78
#define IR_SIRC_REPS        1                                   //      (minimum number of times to repeat code)
533 arune 79
#define IR_SIRC_F_MOD       40                                  //kHz   (modulation frequency)
531 arune 80
#define IR_SIRC_TOL_DIV     4
521 arune 81
 
533 arune 82
/* Sharp Implementation
83
 * Receiver: DONE
84
 * Transmitter:
85
 */
86
#define IR_PROTO_SHARP      4
529 arune 87
#define IR_SHARP_HIGH       280*CYCLES_PER_US/TIMER_PRESC       //us
88
#define IR_SHARP_LOW_ONE    1850*CYCLES_PER_US/TIMER_PRESC      //us
89
#define IR_SHARP_LOW_ZERO   780*CYCLES_PER_US/TIMER_PRESC       //us
548 arune 90
#define IR_SHARP_REPETITION 55                                  //ms    (time between ir frames)
91
#define IR_SHARP_REPS       2                                   //      (minimum number of times to repeat code)
524 arune 92
#define IR_SHARP_F_MOD      38                                  //kHz   (modulation frequency)
531 arune 93
#define IR_SHARP_TOL_DIV    4
521 arune 94
 
533 arune 95
/* NEC Implementation
96
 * Receiver: DONE
97
 * Transmitter:
98
 */
530 arune 99
#define IR_PROTO_NEC        5
100
#define IR_NEC_ST_BIT       9000*CYCLES_PER_US/TIMER_PRESC      //us
531 arune 101
#define IR_NEC_ST_PAUSE     4500*CYCLES_PER_US/TIMER_PRESC      //us
530 arune 102
#define IR_NEC_LOW_ONE      1690*CYCLES_PER_US/TIMER_PRESC      //us
103
#define IR_NEC_LOW_ZERO     560*CYCLES_PER_US/TIMER_PRESC       //us
531 arune 104
#define IR_NEC_HIGH         560*CYCLES_PER_US/TIMER_PRESC       //us
548 arune 105
#define IR_NEC_REPETITION   110                                 //ms    (time between ir frames)
106
#define IR_NEC_REPS         1                                   //      (minimum number of times to repeat code)
533 arune 107
#define IR_NEC_F_MOD        38                                  //kHz   (modulation frequency)
531 arune 108
#define IR_NEC_TOL_DIV      4
521 arune 109
 
533 arune 110
/* Samsung Implementation
111
 * Receiver: DONE
112
 * Transmitter:
113
 */
531 arune 114
#define IR_PROTO_SAMS       6
115
#define IR_SAMS_ST_BIT      4500*CYCLES_PER_US/TIMER_PRESC      //us
116
#define IR_SAMS_ST_PAUSE    4500*CYCLES_PER_US/TIMER_PRESC      //us
533 arune 117
#define IR_SAMS_LOW_ONE     1720*CYCLES_PER_US/TIMER_PRESC      //us
118
#define IR_SAMS_LOW_ZERO    650*CYCLES_PER_US/TIMER_PRESC       //us
119
#define IR_SAMS_HIGH        500*CYCLES_PER_US/TIMER_PRESC       //us
548 arune 120
#define IR_SAMS_REPETITION  50                                  //ms    (time between ir frames)
121
#define IR_SAMS_REPS        1                                   //      (minimum number of times to repeat code)
531 arune 122
#define IR_SAMS_F_MOD       38                                  //kHz   (modulation frequency)
533 arune 123
#define IR_SAMS_TOL_DIV     4
530 arune 124
 
526 arune 125
#define IR_PROTO_UNKNOWN    0xff                                //
521 arune 126
 
533 arune 127
/*-----------------------------------------------------------------------------
128
 * Public Function Prototypes
129
 *---------------------------------------------------------------------------*/
130
 
131
void initTimer(void);
132
uint8_t isTimerOvfl(void);
133
uint16_t getTimerVal(void);
134
void setTimerVal(uint16_t value);
135
 
521 arune 136
#endif /*IRCOMMON_H_*/