Subversion Repositories HomeAutomation

Rev

Rev 1831 | Rev 1871 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1831 Rev 1837
Line 21... Line 21...
21
typedef struct {
21
typedef struct {
22
    uint8_t protocol;
22
    uint8_t protocol;
23
    uint32_t data;
23
    uint32_t data;
24
    uint16_t timeout;
24
    uint16_t timeout;
25
    uint8_t repeats;
25
    uint8_t repeats;
26
    uint8_t modfreq;
26
    uint16_t modfreq;
27
    uint8_t framecnt;
27
    uint8_t framecnt;
28
} Ir_Protocol_Data_t;
28
} Ir_Protocol_Data_t;
29
 
29
 
30
/* Which protocols to use. These should perhaps be configuration options
30
/* Which protocols to use. These should perhaps be configuration options
31
 * (config.inc). Only applies to receiver right now */
31
 * (config.inc). Only applies to receiver right now */
Line 109... Line 109...
109
// defined for the module, uses same definitions for pressed and released as other buttons
109
// defined for the module, uses same definitions for pressed and released as other buttons
110
#define IR_BUTTON_RELEASED  0x0
110
#define IR_BUTTON_RELEASED  0x0
111
#define IR_BUTTON_PRESSED   0x1
111
#define IR_BUTTON_PRESSED   0x1
112
 
112
 
113
 
113
 
114
#define CYCLES_PER_US       (F_CPU/1000000)
114
#define CYCLES_PER_US       (F_CPU/1000000UL)
115
#define TIMER_PRESC         8
115
#define TIMER_PRESC         (8)
116
 
116
 
117
#define IR_MIN_PULSE_WIDTH  5                                   //us
117
#define IR_MIN_PULSE_WIDTH  (5)                                 //us
118
#ifndef IR_MAX_PULSE_WIDTH
118
#ifndef IR_MAX_PULSE_WIDTH
119
#define IR_MAX_PULSE_WIDTH  12000                               //us
119
#define IR_MAX_PULSE_WIDTH  (12000UL)                           //us
120
#endif
120
#endif
121
 
121
 
122
/* RC5 Implementation
122
/* RC5 Implementation
123
 * Receiver: DONE
123
 * Receiver: DONE
124
 * Transmitter: DONE
124
 * Transmitter: DONE
125
 */
125
 */
126
#define IR_PROTO_RC5        0
126
#define IR_PROTO_RC5        (0)
127
#define IR_RC5_HALF_BIT     889*CYCLES_PER_US/TIMER_PRESC       //us
127
#define IR_RC5_HALF_BIT     (889*CYCLES_PER_US/TIMER_PRESC)     //us
128
#define IR_RC5_BIT          889*2*CYCLES_PER_US/TIMER_PRESC     //us
128
#define IR_RC5_BIT          (889*2*CYCLES_PER_US/TIMER_PRESC)   //us
129
#define IR_RC5_TIMEOUT      (117-IR_MAX_PULSE_WIDTH/1000)                                   //ms    (time between ir frames)
129
#define IR_RC5_TIMEOUT      (117-IR_MAX_PULSE_WIDTH/1000)       //ms    (time between ir frames)
130
#define IR_RC5_REPS         1                                   //      (minimum number of times to repeat code)
130
#define IR_RC5_REPS         (1)                                 //      (minimum number of times to repeat code)
131
#define IR_RC5_F_MOD        36                                  //kHz   (modulation frequency)
131
#define IR_RC5_F_MOD        (36)                                //kHz   (modulation frequency)
132
#define IR_RC5_TOL_DIV      4
132
#define IR_RC5_TOL_DIV      (4)
133
 
133
 
134
/* RC6 Implementation
134
/* RC6 Implementation
135
 * Receiver:
135
 * Receiver:
136
 * Transmitter:
136
 * Transmitter:
137
 */
137
 */
138
#define IR_PROTO_RC6        1
138
#define IR_PROTO_RC6        (1)
139
#define IR_RC6_ST_BIT       1*CYCLES_PER_US/TIMER_PRESC         //us
139
#define IR_RC6_ST_BIT       (1*CYCLES_PER_US/TIMER_PRESC)       //us
140
#define IR_RC6_TIMEOUT      (50-IR_MAX_PULSE_WIDTH/1000)                                    //ms    (time between ir frames)
140
#define IR_RC6_TIMEOUT      (50-IR_MAX_PULSE_WIDTH/1000)        //ms    (time between ir frames)
141
#define IR_RC6_REPS         1                                   //      (minimum number of times to repeat code)
141
#define IR_RC6_REPS         (1)                                 //      (minimum number of times to repeat code)
142
#define IR_RC6_F_MOD        36                                  //kHz   (modulation frequency)
142
#define IR_RC6_F_MOD        (36)                                //kHz   (modulation frequency)
143
#define IR_RC6_TOL_DIV      4
143
#define IR_RC6_TOL_DIV      (4)
144
 
144
 
145
/* RCMM Implementation
145
/* RCMM Implementation
146
 * Receiver:
146
 * Receiver:
147
 * Transmitter:
147
 * Transmitter:
148
 */
148
 */
149
#define IR_PROTO_RCMM       2
149
#define IR_PROTO_RCMM       (2)
150
#define IR_RCMM_ST_BIT      256*CYCLES_PER_US/TIMER_PRESC       //us
150
#define IR_RCMM_ST_BIT      (256*CYCLES_PER_US/TIMER_PRESC)     //us
151
#define IR_RCMM_TIMEOUT     (170-IR_MAX_PULSE_WIDTH/1000)                                   //ms    (time between ir frames)
151
#define IR_RCMM_TIMEOUT     (170-IR_MAX_PULSE_WIDTH/1000)       //ms    (time between ir frames)
152
#define IR_RCMM_REPS        1                                   //      (minimum number of times to repeat code)
152
#define IR_RCMM_REPS        (1)                                 //      (minimum number of times to repeat code)
153
#define IR_RCMM_F_MOD       36                                  //kHz   (modulation frequency)
153
#define IR_RCMM_F_MOD       (36)                                //kHz   (modulation frequency)
154
#define IR_RCMM_TOL_DIV     4
154
#define IR_RCMM_TOL_DIV     (4)
155
 
155
 
156
/* SIRC Implementation
156
/* SIRC Implementation
157
 * Receiver: DONE
157
 * Receiver: DONE
158
 * Transmitter: DONE
158
 * Transmitter: DONE
159
 */
159
 */
160
#define IR_PROTO_SIRC       3
160
#define IR_PROTO_SIRC       (3)
161
#define IR_SIRC_ST_BIT      2400*CYCLES_PER_US/TIMER_PRESC      //us
161
#define IR_SIRC_ST_BIT      (2400*CYCLES_PER_US/TIMER_PRESC)    //us
162
#define IR_SIRC_LOW         600*CYCLES_PER_US/TIMER_PRESC       //us
162
#define IR_SIRC_LOW         (600*CYCLES_PER_US/TIMER_PRESC)     //us
163
#define IR_SIRC_HIGH_ONE    1200*CYCLES_PER_US/TIMER_PRESC      //us
163
#define IR_SIRC_HIGH_ONE    (1200*CYCLES_PER_US/TIMER_PRESC)    //us
164
#define IR_SIRC_HIGH_ZERO   600*CYCLES_PER_US/TIMER_PRESC       //us
164
#define IR_SIRC_HIGH_ZERO   (600*CYCLES_PER_US/TIMER_PRESC)     //us
165
#define IR_SIRC_TIMEOUT     (52-IR_MAX_PULSE_WIDTH/1000)                                    //ms    (time between ir frames)
165
#define IR_SIRC_TIMEOUT     (52-IR_MAX_PULSE_WIDTH/1000)                                    //ms    (time between ir frames)
166
#define IR_SIRC_REPS        3                                   //      (minimum number of times to repeat code)
166
#define IR_SIRC_REPS        (3)                                 //      (minimum number of times to repeat code)
167
#define IR_SIRC_F_MOD       40                                  //kHz   (modulation frequency)
167
#define IR_SIRC_F_MOD       (40)                                //kHz   (modulation frequency)
168
#define IR_SIRC_TOL_DIV     4
168
#define IR_SIRC_TOL_DIV     (4)
169
 
169
 
170
/* Sharp Implementation
170
/* Sharp Implementation
171
 * Receiver: DONE
171
 * Receiver: DONE
172
 * Transmitter:
172
 * Transmitter:
173
 */
173
 */
174
#define IR_PROTO_SHARP      4
174
#define IR_PROTO_SHARP      (4)
175
#define IR_SHARP_HIGH       280*CYCLES_PER_US/TIMER_PRESC       //us
175
#define IR_SHARP_HIGH       (280*CYCLES_PER_US/TIMER_PRESC)     //us
176
#define IR_SHARP_LOW_ONE    1850*CYCLES_PER_US/TIMER_PRESC      //us
176
#define IR_SHARP_LOW_ONE    (1850*CYCLES_PER_US/TIMER_PRESC)    //us
177
#define IR_SHARP_LOW_ZERO   780*CYCLES_PER_US/TIMER_PRESC       //us
177
#define IR_SHARP_LOW_ZERO   (780*CYCLES_PER_US/TIMER_PRESC)     //us
178
#define IR_SHARP_TIMEOUT    (67-IR_MAX_PULSE_WIDTH/1000)                                    //ms    (time between ir frames)
178
#define IR_SHARP_TIMEOUT    (67-IR_MAX_PULSE_WIDTH/1000)        //ms    (time between ir frames)
179
#define IR_SHARP_REPS       2                                   //      (minimum number of times to repeat code)
179
#define IR_SHARP_REPS       (2)                                 //      (minimum number of times to repeat code)
180
#define IR_SHARP_F_MOD      38                                  //kHz   (modulation frequency)
180
#define IR_SHARP_F_MOD      (38)                                //kHz   (modulation frequency)
181
#define IR_SHARP_TOL_DIV    4
181
#define IR_SHARP_TOL_DIV    (4)
182
 
182
 
183
/* NEC Implementation
183
/* NEC Implementation
184
 * Receiver: DONE
184
 * Receiver: DONE
185
 * Transmitter: DONE
185
 * Transmitter: DONE
186
 */
186
 */
187
#define IR_PROTO_NEC        5
187
#define IR_PROTO_NEC        (5)
188
#define IR_NEC_ST_BIT       9000*CYCLES_PER_US/TIMER_PRESC      //us
188
#define IR_NEC_ST_BIT       (9000*CYCLES_PER_US/TIMER_PRESC)    //us
189
#define IR_NEC_ST_PAUSE     4500*CYCLES_PER_US/TIMER_PRESC      //us
189
#define IR_NEC_ST_PAUSE     (4500*CYCLES_PER_US/TIMER_PRESC)    //us
190
#define IR_NEC_LOW_ONE      1690*CYCLES_PER_US/TIMER_PRESC      //us
190
#define IR_NEC_LOW_ONE      (1690*CYCLES_PER_US/TIMER_PRESC)    //us
191
#define IR_NEC_LOW_ZERO     560*CYCLES_PER_US/TIMER_PRESC       //us
191
#define IR_NEC_LOW_ZERO     (560*CYCLES_PER_US/TIMER_PRESC)     //us
192
#define IR_NEC_HIGH         560*CYCLES_PER_US/TIMER_PRESC       //us
192
#define IR_NEC_HIGH         (560*CYCLES_PER_US/TIMER_PRESC)     //us
193
#define IR_NEC_TIMEOUT      (122-IR_MAX_PULSE_WIDTH/1000)                                   //ms    (time between ir frames)
193
#define IR_NEC_TIMEOUT      (122-IR_MAX_PULSE_WIDTH/1000)       //ms    (time between ir frames)
194
#define IR_NEC_ST_TIMEOUT   65                                  //ms    (time between first ir frames and second)
194
#define IR_NEC_ST_TIMEOUT   (65)                                //ms    (time between first ir frames and second)
195
#define IR_NEC_REPS         1                                   //      (minimum number of times to repeat code)
195
#define IR_NEC_REPS         (1)                                 //      (minimum number of times to repeat code)
196
#define IR_NEC_F_MOD        38                                  //kHz   (modulation frequency)
196
#define IR_NEC_F_MOD        (38)                                //kHz   (modulation frequency)
197
#define IR_NEC_TOL_DIV      4
197
#define IR_NEC_TOL_DIV      (4)
198
 
198
 
199
/* Samsung Implementation
199
/* Samsung Implementation
200
 * Receiver: DONE
200
 * Receiver: DONE
201
 * Transmitter: DONE
201
 * Transmitter: DONE
202
 */
202
 */
203
#define IR_PROTO_SAMS       6
203
#define IR_PROTO_SAMS       (6)
204
#define IR_SAMS_ST_BIT      4500*CYCLES_PER_US/TIMER_PRESC      //us
204
#define IR_SAMS_ST_BIT      (4500*CYCLES_PER_US/TIMER_PRESC)    //us
205
#define IR_SAMS_ST_PAUSE    4500*CYCLES_PER_US/TIMER_PRESC      //us
205
#define IR_SAMS_ST_PAUSE    (4500*CYCLES_PER_US/TIMER_PRESC)    //us
206
#define IR_SAMS_LOW_ONE     1720*CYCLES_PER_US/TIMER_PRESC      //us
206
#define IR_SAMS_LOW_ONE     (1720*CYCLES_PER_US/TIMER_PRESC)    //us
207
#define IR_SAMS_LOW_ZERO    650*CYCLES_PER_US/TIMER_PRESC       //us
207
#define IR_SAMS_LOW_ZERO    (650*CYCLES_PER_US/TIMER_PRESC)     //us
208
#define IR_SAMS_HIGH        500*CYCLES_PER_US/TIMER_PRESC       //us
208
#define IR_SAMS_HIGH        (500*CYCLES_PER_US/TIMER_PRESC)     //us
209
#define IR_SAMS_TIMEOUT     (62-IR_MAX_PULSE_WIDTH/1000)                                    //ms    (time between ir frames)
209
#define IR_SAMS_TIMEOUT     (62-IR_MAX_PULSE_WIDTH/1000)        //ms    (time between ir frames)
210
#define IR_SAMS_REPS        1                                   //      (minimum number of times to repeat code)
210
#define IR_SAMS_REPS        (1)                                 //      (minimum number of times to repeat code)
211
#define IR_SAMS_F_MOD       38                                  //kHz   (modulation frequency)
211
#define IR_SAMS_F_MOD       (38)                                //kHz   (modulation frequency)
212
#define IR_SAMS_TOL_DIV     4
212
#define IR_SAMS_TOL_DIV     (4)
213
 
213
 
214
/* Marantz Implementation
214
/* Marantz Implementation
215
 * Receiver: DONE (has not been tested with odd adressbits)
215
 * Receiver: DONE (has not been tested with odd adressbits)
216
 * Transmitter: DONE
216
 * Transmitter: DONE
217
 */
217
 */
218
#define IR_PROTO_MARANTZ        7
218
#define IR_PROTO_MARANTZ        (7)
219
#define IR_MARANTZ_HALF_BIT     889*CYCLES_PER_US/TIMER_PRESC       //us
219
#define IR_MARANTZ_HALF_BIT     (889*CYCLES_PER_US/TIMER_PRESC)     //us
220
#define IR_MARANTZ_BIT          889*2*CYCLES_PER_US/TIMER_PRESC     //us
220
#define IR_MARANTZ_BIT          (889*2*CYCLES_PER_US/TIMER_PRESC)   //us
221
#define IR_MARANTZ_TIMEOUT      (117-IR_MAX_PULSE_WIDTH/1000)                                   //ms    (time between ir frames)
221
#define IR_MARANTZ_TIMEOUT      (117-IR_MAX_PULSE_WIDTH/1000)       //ms    (time between ir frames)
222
#define IR_MARANTZ_REPS         1                                   //      (minimum number of times to repeat code)
222
#define IR_MARANTZ_REPS         (1)                                 //      (minimum number of times to repeat code)
223
#define IR_MARANTZ_F_MOD        36                                  //kHz   (modulation frequency)
223
#define IR_MARANTZ_F_MOD        (36)                                //kHz   (modulation frequency)
224
#define IR_MARANTZ_TOL_DIV      4
224
#define IR_MARANTZ_TOL_DIV      (4)
225
 
225
 
226
/* Panasonic Implementation
226
/* Panasonic Implementation
227
 * Receiver: DONE
227
 * Receiver: DONE
228
 * Transmitter: DONE
228
 * Transmitter: DONE
229
 */
229
 */
230
#define IR_PROTO_PANASONIC  8
230
#define IR_PROTO_PANASONIC  (8)
231
#define IR_PANA_ST_BIT      3570*CYCLES_PER_US/TIMER_PRESC      //us
231
#define IR_PANA_ST_BIT      (3570*CYCLES_PER_US/TIMER_PRESC)    //us
232
#define IR_PANA_ST_PAUSE    1630*CYCLES_PER_US/TIMER_PRESC      //us
232
#define IR_PANA_ST_PAUSE    (1630*CYCLES_PER_US/TIMER_PRESC)    //us
233
#define IR_PANA_LOW_ONE     1240*CYCLES_PER_US/TIMER_PRESC      //us
233
#define IR_PANA_LOW_ONE     (1240*CYCLES_PER_US/TIMER_PRESC)    //us
234
#define IR_PANA_LOW_ZERO    400*CYCLES_PER_US/TIMER_PRESC       //us
234
#define IR_PANA_LOW_ZERO    (400*CYCLES_PER_US/TIMER_PRESC)     //us
235
#define IR_PANA_HIGH        495*CYCLES_PER_US/TIMER_PRESC       //us
235
#define IR_PANA_HIGH        (495*CYCLES_PER_US/TIMER_PRESC)     //us
236
#define IR_PANA_TIMEOUT     (92-IR_MAX_PULSE_WIDTH/1000)                                    //ms    (time between ir frames)
236
#define IR_PANA_TIMEOUT     (92-IR_MAX_PULSE_WIDTH/1000)        //ms    (time between ir frames)
237
#define IR_PANA_REPS        1                                   //      (minimum number of times to repeat code)
237
#define IR_PANA_REPS        (1)                                 //      (minimum number of times to repeat code)
238
#define IR_PANA_F_MOD       38                                  //kHz   (modulation frequency)
238
#define IR_PANA_F_MOD       (38)                                //kHz   (modulation frequency)
239
#define IR_PANA_TOL_DIV     4
239
#define IR_PANA_TOL_DIV     (4)
240
 
240
 
241
/* Sky Implementation
241
/* Sky Implementation
242
 * Receiver: DONE
242
 * Receiver: DONE
243
 * Transmitter:
243
 * Transmitter:
244
 */
244
 */
245
#define IR_PROTO_SKY        9
245
#define IR_PROTO_SKY        (9)
246
#define IR_SKY_ST_BIT       2800*CYCLES_PER_US/TIMER_PRESC      //us
246
#define IR_SKY_ST_BIT       (2800*CYCLES_PER_US/TIMER_PRESC)    //us
247
#define IR_SKY_SHORT        460*CYCLES_PER_US/TIMER_PRESC       //us
247
#define IR_SKY_SHORT        (460*CYCLES_PER_US/TIMER_PRESC)     //us
248
#define IR_SKY_LONG         920*CYCLES_PER_US/TIMER_PRESC       //us
248
#define IR_SKY_LONG         (920*CYCLES_PER_US/TIMER_PRESC)     //us
249
#define IR_SKY_TIMEOUT      (162-IR_MAX_PULSE_WIDTH/1000)                                   //ms    (time between ir frames)
249
#define IR_SKY_TIMEOUT      (162-IR_MAX_PULSE_WIDTH/1000)       //ms    (time between ir frames)
250
#define IR_SKY_REPS         1                                   //      (minimum number of times to repeat code)
250
#define IR_SKY_REPS         (1)                                 //      (minimum number of times to repeat code)
251
#define IR_SKY_F_MOD        38                                  //kHz   (modulation frequency)
251
#define IR_SKY_F_MOD        (38)                                //kHz   (modulation frequency)
252
#define IR_SKY_TOL_DIV      4
252
#define IR_SKY_TOL_DIV      (4)
253
 
253
 
254
 
254
 
255
/* Nexa2 Implementation
255
/* Nexa2 Implementation
256
 * Receiver:
256
 * Receiver:
257
 * Transmitter:
257
 * Transmitter:
258
 */
258
 */
259
#define IR_PROTO_NEXA2      10
259
#define IR_PROTO_NEXA2      (10)
260
#define IR_NEXA2_START      2500*CYCLES_PER_US/TIMER_PRESC      //us
260
#define IR_NEXA2_START      (2500*CYCLES_PER_US/TIMER_PRESC)    //us
261
#define IR_NEXA2_HIGH       320*CYCLES_PER_US/TIMER_PRESC       //us
261
#define IR_NEXA2_HIGH       (320*CYCLES_PER_US/TIMER_PRESC)     //us
262
#define IR_NEXA2_LOW_ONE    210*CYCLES_PER_US/TIMER_PRESC       //us
262
#define IR_NEXA2_LOW_ONE    (210*CYCLES_PER_US/TIMER_PRESC)     //us
263
#define IR_NEXA2_LOW_ZERO   1200*CYCLES_PER_US/TIMER_PRESC      //us
263
#define IR_NEXA2_LOW_ZERO   (1200*CYCLES_PER_US/TIMER_PRESC)    //us
264
#define IR_NEXA2_TIMEOUT    (22-IR_MAX_PULSE_WIDTH/1000)                                    //ms    (time between ir frames)
264
#define IR_NEXA2_TIMEOUT    (22-IR_MAX_PULSE_WIDTH/1000)        //ms    (time between ir frames)
265
#define IR_NEXA2_REPS       4                                   //      (minimum number of times to repeat code)
265
#define IR_NEXA2_REPS       (4)                                 //      (minimum number of times to repeat code)
-
 
266
#define IR_NEXA2_F_MOD      (38)                                //kHz   (modulation frequency)
266
#define IR_NEXA2_TOL_DIV    4
267
#define IR_NEXA2_TOL_DIV    (4)
267
 
268
 
268
 
269
 
269
#define IR_PROTO_HASH       0xfe
270
#define IR_PROTO_HASH       0xfe
270
#define IR_PROTO_UNKNOWN    0xff                                //
271
#define IR_PROTO_UNKNOWN    0xff                                //
271
 
272