Subversion Repositories HomeAutomation

Rev

Rev 363 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 363 Rev 365
Line 2... Line 2...
2
 *
2
 *
3
 *                  Main application
3
 *                  Main application
4
 *
4
 *
5
 *********************************************************************
5
 *********************************************************************
6
 * FileName:        $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canIR/Source/Main.c $
6
 * FileName:        $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canIR/Source/Main.c $
7
 * Last changed:    $LastChangedDate: 2007-03-13 18:29:20 +0100 (Tue, 13 Mar 2007) $
7
 * Last changed:    $LastChangedDate: 2007-03-14 13:39:20 +0100 (Wed, 14 Mar 2007) $
8
 * By:              $LastChangedBy: johboh $
8
 * By:              $LastChangedBy: johboh $
9
 * Revision:        $Revision: 363 $
9
 * Revision:        $Revision: 365 $
10
 ********************************************************************/
10
 ********************************************************************/
11
 
11
 
12
 
12
 
13
#include <p18cxxx.h>
13
#include <p18cxxx.h>
14
#include <compiler.h>
14
#include <compiler.h>
Line 30... Line 30...
30
static void mainInit(void);
30
static void mainInit(void);
31
static void loadIrCommands(void);
31
static void loadIrCommands(void);
32
 
32
 
33
#define EE_PACKET_TIMOUT 5*TICK_100MS
33
#define EE_PACKET_TIMOUT 5*TICK_100MS
34
#define IR_TIMOUT 2*TICK_100MS
34
#define IR_TIMOUT 2*TICK_100MS
-
 
35
#define EE_ACK_MAX 7
-
 
36
 
35
 
37
 
36
static BOOL hasCtrlPacket = FALSE;
38
static BOOL hasCtrlPacket = FALSE;
37
static CAN_PACKET ctrlPacket;
39
static CAN_PACKET ctrlPacket;
38
 
40
 
39
typedef struct _IR_COMMAND
41
typedef struct _IR_COMMAND
Line 63... Line 65...
63
    static BYTE ee_programmerId = 0;
65
    static BYTE ee_programmerId = 0;
64
    static BOOL ee_externalEE = FALSE;
66
    static BOOL ee_externalEE = FALSE;
65
    static DWORD ee_pgmAddress = 0;
67
    static DWORD ee_pgmAddress = 0;
66
    static DWORD ee_newPgmAddress = 0;
68
    static DWORD ee_newPgmAddress = 0;
67
    static PGM_CTRL_TYPE ee_ackType = pctEE_ACK;
69
    static PGM_CTRL_TYPE ee_ackType = pctEE_ACK;
-
 
70
    static BYTE ee_ackCount = 0;
68
   
71
   
69
    static BYTE ee_lastLocalIndex = 0;
-
 
70
    CAN_PACKET outCp;
72
    CAN_PACKET outCp;
71
 
73
 
72
    // Inits
74
    // Inits
73
    mainInit();
75
    mainInit();
74
 
76
 
75
    #ifdef USE_IREC
77
    #ifdef USE_IREC
76
        loadIrCommands();
78
        loadIrCommands();
77
    #endif
79
    #endif
78
 
80
 
79
 
81
 
80
    canInit();
82
    canInit();
81
 
83
 
82
    #ifdef USE_IREC
84
    #ifdef USE_IREC
83
        irecInit();
85
        irecInit();
84
    #endif
86
    #endif
85
 
87
 
86
    for(ee_programmerId=0;ee_programmerId<56;ee_programmerId++) pgmData[ee_programmerId]=0xFF;
88
    for(ee_programmerId=0;ee_programmerId<56;ee_programmerId++) pgmData[ee_programmerId]=0xFF;
87
 
89
 
88
    while(1)
90
    while(1)
89
    {  
91
    {  
90
        TICK currentTick = tickGet();
92
        TICK currentTick = tickGet();
91
 
93
 
92
        static TICK tick_led = 0;
94
        static TICK tick_led = 0;
93
        static TICK tick_ee = 0;
95
        static TICK tick_ee = 0;
94
       
-
 
95
 
96
 
96
 
97
 
97
        if ((currentTick-tick_led)>(1*TICK_1S))
98
        if ((currentTick-tick_led)>(1*TICK_1S))
98
        {
99
        {
99
            //LED0_IO=~LED0_IO;
100
            //LED0_IO=~LED0_IO;
Line 117... Line 118...
117
                    ee_pgmAddress = (((DWORD)ctrlPacket.data[2])<<16)+(((DWORD)ctrlPacket.data[1])<<8)+((DWORD)ctrlPacket.data[0]);
118
                    ee_pgmAddress = (((DWORD)ctrlPacket.data[2])<<16)+(((DWORD)ctrlPacket.data[1])<<8)+((DWORD)ctrlPacket.data[0]);
118
                    tick_ee = currentTick;
119
                    tick_ee = currentTick;
119
                    ee_ackType = pctEE_ACK;
120
                    ee_ackType = pctEE_ACK;
120
                    eesAckNext = eesWAIT_FIRST_DATA;
121
                    eesAckNext = eesWAIT_FIRST_DATA;
121
                    ees = eesSEND_ACK;
122
                    ees = eesSEND_ACK;
-
 
123
                    ee_ackCount = 0;
122
                }
124
                }
123
                break;
125
                break;
124
 
126
 
125
            case eesSEND_ACK:
127
            case eesSEND_ACK:
126
                // send ack
128
                // send ack
Line 128... Line 130...
128
                outCp.pgm.class = pcCTRL;
130
                outCp.pgm.class = pcCTRL;
129
                outCp.pgm.id = ee_ackType;
131
                outCp.pgm.id = ee_ackType;
130
                outCp.length=0;
132
                outCp.length=0;
131
                tick_ee = currentTick;
133
                tick_ee = currentTick;
132
                ees = eesAckNext;
134
                ees = eesAckNext;
133
                while(!canSendMessage(outCp,PRIO_HIGH));
135
                while(!canSendMessage(outCp,PRIO_HIGH));
-
 
136
 
-
 
137
                if (++ee_ackCount>EE_ACK_MAX) ees = eesWAITING_START;
134
                break;
138
                break;
135
 
139
 
136
            case eesWAIT_FIRST_DATA:
140
            case eesWAIT_FIRST_DATA:
137
                // Wait for first pgm packet. use offset to determine data index.
141
                // Wait for first pgm packet. use offset to determine data index.
138
                // When receiving crc from host, check crc for offsets bytes.
142
                // When receiving crc from host, check crc for offsets bytes.
139
               
143
               
140
                if ((currentTick-tick_ee)>EE_PACKET_TIMOUT)
144
                if ((currentTick-tick_ee)>EE_PACKET_TIMOUT)
141
                {
145
                {
142
                    // Timeout, resend ack/nack.
146
                    // Timeout, resend ack/nack.
143
                    eesAckNext = eesWAIT_FIRST_DATA;
147
                    eesAckNext = eesWAIT_FIRST_DATA;
Line 145... Line 149...
145
                }              
149
                }              
146
 
150
 
147
                if (hasCtrlPacket == TRUE && ctrlPacket.pgm.id==pctEE_PGM)
151
                if (hasCtrlPacket == TRUE && ctrlPacket.pgm.id==pctEE_PGM)
148
                {
152
                {
149
                    BYTE localIndex = ctrlPacket.data[7];
153
                    BYTE localIndex = ctrlPacket.data[7];
150
                    ee_lastLocalIndex = localIndex;
-
 
151
                    pgmData[localIndex+0]=ctrlPacket.data[0]; pgmData[localIndex+1]=ctrlPacket.data[1]; pgmData[localIndex+2]=ctrlPacket.data[2]; pgmData[localIndex+3]=ctrlPacket.data[3];
154
                    pgmData[localIndex+0]=ctrlPacket.data[0]; pgmData[localIndex+1]=ctrlPacket.data[1]; pgmData[localIndex+2]=ctrlPacket.data[2]; pgmData[localIndex+3]=ctrlPacket.data[3];
152
                    pgmData[localIndex+4]=ctrlPacket.data[4]; pgmData[localIndex+5]=ctrlPacket.data[5]; pgmData[localIndex+6]=ctrlPacket.data[6];
155
                    pgmData[localIndex+4]=ctrlPacket.data[4]; pgmData[localIndex+5]=ctrlPacket.data[5]; pgmData[localIndex+6]=ctrlPacket.data[6];
153
                    ees = eesWAIT_DATA_OR_CRC;
156
                    ees = eesWAIT_DATA_OR_CRC;
154
                }
157
                }
155
 
158
 
156
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_START)
159
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_START)
157
                {
160
                {
158
                    ees   = eesWAITING_START;
161
                    ees   = eesWAITING_START;
159
                }
162
                }
160
 
163
 
161
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_CRC)
164
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_CRC)
162
                {
165
                {
163
                    ees   = eesWAIT_DATA_OR_CRC;
166
                    ees   = eesWAIT_DATA_OR_CRC;
164
                }
167
                }
165
 
168
 
166
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_DONE)
169
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_DONE)
167
                {
170
                {
-
 
171
                    irValids = (BYTE)((((WORD)ctrlPacket.data[1]<<8) + ctrlPacket.data[0]) >> 3);
168
                    ees = eesDONE;
172
                    ees = eesDONE;
169
                }
173
                }
170
 
174
 
171
 
175
 
172
                break;
176
                break;
Line 176... Line 180...
176
                // When receiving crc from host, check crc for offsets bytes.
180
                // When receiving crc from host, check crc for offsets bytes.
177
               
181
               
178
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_CRC)
182
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_CRC)
179
                {
183
                {
180
                    WORD crc16 = (((WORD)ctrlPacket.data[4])<<8)+((WORD)ctrlPacket.data[3]);
184
                    WORD crc16 = (((WORD)ctrlPacket.data[4])<<8)+((WORD)ctrlPacket.data[3]);
181
                    WORD crc16calc = calc_crc(pgmData,56);
185
                    WORD crc16calc = calc_crc(pgmData,56);
182
 
186
 
183
                    // check CRC.
187
                    // check CRC.
184
                    if (crc16calc==crc16)
188
                    if (crc16calc==crc16)
185
                    {
189
                    {
186
                        ee_newPgmAddress = (((DWORD)ctrlPacket.data[2])<<16)+(((DWORD)ctrlPacket.data[1])<<8)+((DWORD)ctrlPacket.data[0]);
190
                        ee_newPgmAddress = (((DWORD)ctrlPacket.data[2])<<16)+(((DWORD)ctrlPacket.data[1])<<8)+((DWORD)ctrlPacket.data[0]);
187
                        eesAckNext = eesWAIT_FIRST_DATA;
191
                        eesAckNext = eesWAIT_FIRST_DATA;
Line 191... Line 195...
191
                    {
195
                    {
192
                        tick_ee = currentTick;
196
                        tick_ee = currentTick;
193
                        ee_ackType = pctEE_NACK;
197
                        ee_ackType = pctEE_NACK;
194
                        eesAckNext = eesWAIT_FIRST_DATA;
198
                        eesAckNext = eesWAIT_FIRST_DATA;
195
                        ees = eesSEND_ACK;
199
                        ees = eesSEND_ACK;
-
 
200
                        ee_ackCount = 0;
196
                    }
201
                    }
197
                }
202
                }
198
               
203
               
199
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_PGM)
204
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_PGM)
200
                {
205
                {
201
                    BYTE localIndex = ctrlPacket.data[7];
206
                    BYTE localIndex = ctrlPacket.data[7];
202
                    ee_lastLocalIndex = localIndex;
-
 
203
                    pgmData[localIndex+0]=ctrlPacket.data[0]; pgmData[localIndex+1]=ctrlPacket.data[1]; pgmData[localIndex+2]=ctrlPacket.data[2]; pgmData[localIndex+3]=ctrlPacket.data[3];
207
                    pgmData[localIndex+0]=ctrlPacket.data[0]; pgmData[localIndex+1]=ctrlPacket.data[1]; pgmData[localIndex+2]=ctrlPacket.data[2]; pgmData[localIndex+3]=ctrlPacket.data[3];
204
                    pgmData[localIndex+4]=ctrlPacket.data[4]; pgmData[localIndex+5]=ctrlPacket.data[5]; pgmData[localIndex+6]=ctrlPacket.data[6];
208
                    pgmData[localIndex+4]=ctrlPacket.data[4]; pgmData[localIndex+5]=ctrlPacket.data[5]; pgmData[localIndex+6]=ctrlPacket.data[6];
205
                }
209
                }
206
 
210
 
207
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_START)
211
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_START)
208
                {
212
                {
209
                    ees   = eesWAITING_START;
213
                    ees   = eesWAITING_START;
210
                }
214
                }
211
 
215
 
212
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_DONE)
216
                if (hasCtrlPacket==TRUE && ctrlPacket.pgm.id==pctEE_DONE)
213
                {
217
                {
-
 
218
                    irValids = (BYTE)((((WORD)ctrlPacket.data[1]<<8) + ctrlPacket.data[0]) >> 3);
214
                    ees = eesDONE;
219
                    ees = eesDONE;
215
                }
220
                }
216
 
221
 
217
                break;
222
                break;
218
 
223
 
219
 
224
 
220
            case eesWRITE_DATA:
225
            case eesWRITE_DATA:
221
 
226
 
222
                ClrWdt();
227
                ClrWdt();
223
 
228
 
224
                // Write EE and send ack.
229
                // Write EE and send ack.
225
 
230
 
226
                if (ee_externalEE == FALSE)
231
                if (ee_externalEE == FALSE)
227
                {
232
                {
228
                    BYTE i;
233
                    BYTE i;
229
 
234
 
230
                    ee_pgmAddress = EE_IR_START+1+(WORD)((EE_INTERNAL_SIZE-1) & ee_pgmAddress);
235
                    ee_pgmAddress = EE_IR_START+1+(WORD)((EE_INTERNAL_SIZE-1) & ee_pgmAddress);
231
 
236
 
232
                    for(i=0;i<56;i++)
237
                    for(i=0;i<56;i++)
233
                    {
238
                    {
234
                        EEWrite(ee_pgmAddress+i,pgmData[i]);
239
                        EEWrite(ee_pgmAddress+i,pgmData[i]);
-
 
240
                        pgmData[i]=0xFF;
-
 
241
                    }  
-
 
242
 
235
 
243
 
236
                        pgmData[i]=0xFF;
-
 
237
                    }  
-
 
238
 
-
 
239
 
-
 
240
                }
244
                }
241
 
245
 
242
                ee_pgmAddress   = ee_newPgmAddress;
246
                ee_pgmAddress   = ee_newPgmAddress;
243
                ee_ackType      = pctEE_ACK;       
247
                ee_ackType      = pctEE_ACK;       
244
                ees             = eesSEND_ACK;
248
                ees             = eesSEND_ACK;
-
 
249
                ee_ackCount     = 0;
245
 
250
 
246
            break;
251
            break;
247
 
252
 
248
            case eesDONE:
253
            case eesDONE:
249
                EEWrite(EE_IR_START,32);
254
                EEWrite(EE_IR_START,irValids);
250
                loadIrCommands();
255
                loadIrCommands();
251
 
256
 
252
                ees = eesWAITING_START;
257
                ees = eesWAITING_START;
253
            break;
258
            break;
254
 
259
 
255
       
260
       
256
            default:
261
            default:
257
                ees = eesWAITING_START;
262
                ees = eesWAITING_START;
258
            break;
263
            break;
259
 
264
 
260
        }
265
        }
261
 
266
 
262
            hasCtrlPacket = FALSE;
267
            hasCtrlPacket = FALSE;
263
 
268
 
264
    }
269
    }
265
}
270
}
266
 
271
 
267
 
272
 
268
#pragma interrupt high_isr
273
#pragma interrupt high_isr
269
void high_isr(void)
274
void high_isr(void)
Line 271... Line 276...
271
    canISR();
276
    canISR();
272
 
277
 
273
    #ifdef USE_IREC
278
    #ifdef USE_IREC
274
        irecISR();
279
        irecISR();
275
    #endif
280
    #endif
276
 
281
 
277
}
282
}
278
 
283
 
279
 
284
 
280
#pragma interrupt low_isr
285
#pragma interrupt low_isr
281
void low_isr(void)
286
void low_isr(void)
282
{
287
{
283
 
288
 
284
}
289
}
285
 
290
 
286
void loadIrCommands()
291
void loadIrCommands()
287
{
292
{
288
 
293
 
289
    // Load IRs
294
    // Load IRs
290
    BYTE i;
295
    BYTE i;
291
    irValids = EERead(EE_IR_START);
296
    irValids = EERead(EE_IR_START);
292
    for(i=0;(i<irValids && i<IR_COUNT);i++)
297
    for(i=0;(i<irValids && i<IR_COUNT);i++)
293
    {
298
    {
Line 299... Line 304...
299
        buf_ptr[i].data = EERead(EE_IR_START+3+(i<<3));
304
        buf_ptr[i].data = EERead(EE_IR_START+3+(i<<3));
300
        buf_ptr[i].pgm_class = EERead(EE_IR_START+4+(i<<3));
305
        buf_ptr[i].pgm_class = EERead(EE_IR_START+4+(i<<3));
301
        buf_ptr[i].pgm_id = ((WORD)EERead(EE_IR_START+5+(i<<3)) << 8)+(WORD)EERead(EE_IR_START+6+(i<<3));
306
        buf_ptr[i].pgm_id = ((WORD)EERead(EE_IR_START+5+(i<<3)) << 8)+(WORD)EERead(EE_IR_START+6+(i<<3));
302
        buf_ptr[i].pgm_data[1] = EERead(EE_IR_START+7+(i<<3));
307
        buf_ptr[i].pgm_data[1] = EERead(EE_IR_START+7+(i<<3));
303
        buf_ptr[i].pgm_data[0] = EERead(EE_IR_START+8+(i<<3));
308
        buf_ptr[i].pgm_data[0] = EERead(EE_IR_START+8+(i<<3));
304
 
-
 
305
        /*
-
 
306
        buf_ptr[0].repeat = 5;
-
 
307
        buf_ptr[0].addr = 5;
-
 
308
        buf_ptr[0].data = 5;
-
 
309
        buf_ptr[0].pgm_class = 5;
-
 
310
        buf_ptr[0].pgm_id = 5;
-
 
311
        buf_ptr[0].pgm_data[1] = 5;
-
 
312
        buf_ptr[0].pgm_data[0] = 5;
-
 
313
 
-
 
314
        buf_ptr[1].repeat = 7;
-
 
315
        buf_ptr[1].addr = 7;
-
 
316
        buf_ptr[1].data = 7;
-
 
317
        buf_ptr[1].pgm_class = 7;
-
 
318
        buf_ptr[1].pgm_id = 7;
-
 
319
        buf_ptr[1].pgm_data[1] = 7;
-
 
320
        buf_ptr[1].pgm_data[0] = 7;
-
 
321
 
-
 
322
        buf_ptr[2].repeat = 9;
-
 
323
        buf_ptr[2].addr = 9;
-
 
324
        buf_ptr[2].data = 9;
-
 
325
        buf_ptr[2].pgm_class = 9;
-
 
326
        buf_ptr[2].pgm_id = 9;
-
 
327
        buf_ptr[2].pgm_data[1] = 9;
-
 
328
        buf_ptr[2].pgm_data[0] = 9;
-
 
329
        */
-
 
330
    }
309
    }
331
}
310
}
332
 
311
 
333
 
312
 
334
/*
313
/*
335
*   Function: mainInit
314
*   Function: mainInit
336
*
315
*
Line 348... Line 327...
348
    INTCONbits.GIEH = 1;
327
    INTCONbits.GIEH = 1;
349
    INTCONbits.GIEL = 1;
328
    INTCONbits.GIEL = 1;
350
 
329
 
351
    // Enable interrupt prirority
330
    // Enable interrupt prirority
352
    RCONbits.IPEN=1;
331
    RCONbits.IPEN=1;
353
   
332
   
354
 
333
 
355
}
334
}
356
 
335
 
357
/*
336
/*
358
*   Function: canParse
337
*   Function: canParse
359
*
338
*
360
*   Input:  Received can message
339
*   Input:  Received can message
361
*   Output: none
340
*   Output: none
Line 412... Line 391...
412
    outCp.data[2]   = toggle;
391
    outCp.data[2]   = toggle;
413
    outCp.data[1]   = addr;
392
    outCp.data[1]   = addr;
414
    outCp.data[0]   = data;
393
    outCp.data[0]   = data;
415
    while(!canSendMessage(outCp,PRIO_HIGH));
394
    while(!canSendMessage(outCp,PRIO_HIGH));
416
 
395
 
-
 
396
    /*
417
    // DUMP
397
    // DUMP
418
    if (addr==0x15 && data>=0x00)
398
    if (addr==0x15 && data==0x00)
419
    {
399
    {
420
        for(i=0;i<7;i++)
400
        for(i=0;i<irValids;i++)
421
        {
401
        {
422
            outCp.type      = ptPGM;
402
            outCp.type      = ptPGM;
423
            outCp.pgm.class = 0x05;
403
            outCp.pgm.class = 0x05;
424
            outCp.pgm.id    = 0x91;
404
            outCp.pgm.id    = 0x91;
425
            outCp.length    = 8;
405
            outCp.length    = 8;
426
            outCp.data[7] = buf_ptr[i].repeat;
406
            outCp.data[7] = buf_ptr[i].repeat;
427
            outCp.data[6]=buf_ptr[i].addr;
407
            outCp.data[6]=buf_ptr[i].addr;
428
            outCp.data[5]=buf_ptr[i].data;
408
            outCp.data[5]=buf_ptr[i].data;
429
            outCp.data[4]=buf_ptr[i].pgm_class;
409
            outCp.data[4]=buf_ptr[i].pgm_class;
430
            outCp.data[3]=(BYTE)((buf_ptr[i].pgm_id & 0xFF00) >> 8);
410
            outCp.data[3]=(BYTE)((buf_ptr[i].pgm_id & 0xFF00) >> 8);
431
            outCp.data[2]=(BYTE)buf_ptr[i].pgm_id;
411
            outCp.data[2]=(BYTE)buf_ptr[i].pgm_id;
432
            outCp.data[1]=buf_ptr[i].pgm_data[1];
412
            outCp.data[1]=buf_ptr[i].pgm_data[1];
433
            outCp.data[0]=buf_ptr[i].pgm_data[0];
413
            outCp.data[0]=buf_ptr[i].pgm_data[0];
434
            while(!canSendMessage(outCp,PRIO_HIGH));
414
            while(!canSendMessage(outCp,PRIO_HIGH));
435
        }      
415
        }      
436
    }
-
 
437
 
-
 
438
    /*
-
 
439
    if (addr==0x15 && data>=0x09)
-
 
440
    {
-
 
441
        for(i=0;i<7;i++)
-
 
442
        {
-
 
443
            outCp.type      = ptPGM;
-
 
444
            outCp.pgm.class = 0x05;
-
 
445
            outCp.pgm.id    = 0x91;
-
 
446
            outCp.length    = 8;
-
 
447
            outCp.data[7] = pgmData[i*8];
-
 
448
            outCp.data[6]=pgmData[i*8+1];
-
 
449
            outCp.data[5]=pgmData[i*8+2];
-
 
450
            outCp.data[4]=pgmData[i*8+3];
-
 
451
            outCp.data[3]=pgmData[i*8+4];
-
 
452
            outCp.data[2]=pgmData[i*8+5];
-
 
453
            outCp.data[1]=pgmData[i*8+6];
-
 
454
            outCp.data[0]=pgmData[i*8+7];
-
 
455
            while(!canSendMessage(outCp,PRIO_HIGH));
-
 
456
        }
-
 
457
    }
416
    }
458
    */
417
*/
459
 
418
   
460
    // slow? bad?
419
    // slow? bad?
461
    for(i=0;(i<irValids && i<IR_COUNT);i++)
420
    for(i=0;(i<irValids && i<IR_COUNT);i++)
462
    {
421
    {
463
        if (buf_ptr[i].addr==addr && buf_ptr[i].data==data && ((buf_ptr[i].repeat == 0 && (lastToogle != toggle || irCounts==1)) || (buf_ptr[i].repeat == irCounts)))
422
        if (buf_ptr[i].addr==addr && buf_ptr[i].data==data && ((buf_ptr[i].repeat == 0 && (lastToogle != toggle || irCounts==1)) || (buf_ptr[i].repeat == irCounts)))
464
        {
423
        {
465
            outCp.type      = ptPGM;
424
            outCp.type      = ptPGM;
466
            outCp.pgm.class = buf_ptr[i].pgm_class;
425
            outCp.pgm.class = buf_ptr[i].pgm_class;
467
            outCp.pgm.id    = buf_ptr[i].pgm_id;
426
            outCp.pgm.id    = buf_ptr[i].pgm_id;
Line 471... Line 430...
471
            while(!canSendMessage(outCp,PRIO_HIGH));
430
            while(!canSendMessage(outCp,PRIO_HIGH));
472
 
431
 
473
            if (buf_ptr[i].repeat>0) irCounts = 0;
432
            if (buf_ptr[i].repeat>0) irCounts = 0;
474
        }
433
        }
475
    }
434
    }
476
 
-
 
477
 
435
 
478
    lastToogle  = toggle;
436
    lastToogle  = toggle;
479
 
437
 
480
}
438
}
481
#endif
439
#endif