Subversion Repositories HomeAutomation

Rev

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

Rev 1483 Rev 1487
Line 138... Line 138...
138
    {
138
    {
139
        drvIrTxChannel[channel].timeout = IR_COMPARE_REG + drvIrTxChannel[channel].txbuf[drvIrTxChannel[channel].txindex++];
139
        drvIrTxChannel[channel].timeout = IR_COMPARE_REG + drvIrTxChannel[channel].txbuf[drvIrTxChannel[channel].txindex++];
140
    }
140
    }
141
    else
141
    else
142
    {
142
    {
-
 
143
        //TODO only mask if noone is sending (checked below)
143
        IR_MASK_COMPARE();
144
        IR_MASK_COMPARE();
144
 
145
 
145
        /* Notify the application that a pulse train has been sent. */
146
        /* Notify the application that a pulse train has been sent. */
146
        drvIrTxChannel[channel].callback(channel);
147
        drvIrTxChannel[channel].callback(channel);
147
    }
148
    }
Line 274... Line 275...
274
        //TODO: if buffer resource coordinator is implemented this is where a buffer should be assinged to this channel
275
        //TODO: if buffer resource coordinator is implemented this is where a buffer should be assinged to this channel
275
    }
276
    }
276
}
277
}
277
#endif
278
#endif
278
 
279
 
279
 
-
 
280
/*-----------------------------------------------------------------------------
-
 
281
 * Public Functions
-
 
282
 *---------------------------------------------------------------------------*/
-
 
283
 
280
 
284
/* call this function like this:
281
/* call this function like this:
285
    IrTransceiver_Init_RX_Channel(channelnumber, buffer, callback, pcint-id, GPIO_D6);
282
    IrTransceiver_Init_RX_Channel(channelnumber, buffer, callback, pcint-id, GPIO_D6);
286
    buffer is a memory location
283
    buffer is a memory location
287
    callback is a function to call when a receive/transmitt is complete
284
    callback is a function to call when a receive/transmitt is complete
Line 290... Line 287...
290
 
287
 
291
#if IR_RX_ENABLE==1
288
#if IR_RX_ENABLE==1
292
void IrTransceiver_InitRxChannel(uint8_t channel, uint16_t *buffer, irRxCallback_t callback, uint8_t pcint_id, volatile uint8_t* port, volatile uint8_t* pin, volatile uint8_t* ddr,uint8_t nr, uint8_t pcint)
289
void IrTransceiver_InitRxChannel(uint8_t channel, uint16_t *buffer, irRxCallback_t callback, uint8_t pcint_id, volatile uint8_t* port, volatile uint8_t* pin, volatile uint8_t* ddr,uint8_t nr, uint8_t pcint)
293
{
290
{
294
    if (channel == 0)
291
    if (channel == 0)
295
    {
292
    {
296
        Pcint_SetCallback(pcint_id, pcint, &IrTransceiver_Store_ch0);
293
        Pcint_SetCallback(pcint_id, pcint, &IrTransceiver_Store_ch0);
297
    }
294
    }
298
    else if (channel == 1)
295
    else if (channel == 1)
299
    {
296
    {
300
        Pcint_SetCallback(pcint_id, pcint, &IrTransceiver_Store_ch1);
297
        Pcint_SetCallback(pcint_id, pcint, &IrTransceiver_Store_ch1);
301
    }
298
    }
302
    else if (channel == 2)
299
    else if (channel == 2)
303
    {
300
    {
304
        Pcint_SetCallback(pcint_id, pcint, &IrTransceiver_Store_ch2);
301
        Pcint_SetCallback(pcint_id, pcint, &IrTransceiver_Store_ch2);
305
    }
302
    }
306
   
303
   
307
    if (channel < 3)
304
    if (channel < 3)
308
    {
305
    {
309
        /* Set port direction to input */
306
        /* Set port direction to input */
310
        *ddr &= ~(1 << nr);
307
        *ddr &= ~(1 << nr);
311
       
308
       
312
        drvIrRxChannel[channel].rxbuf = buffer;
309
        drvIrRxChannel[channel].rxbuf = buffer;
313
        drvIrRxChannel[channel].rxlen = 0;
310
        drvIrRxChannel[channel].rxlen = 0;
314
        drvIrRxChannel[channel].storeEnable = FALSE;
311
        drvIrRxChannel[channel].storeEnable = FALSE;
315
        drvIrRxChannel[channel].timeoutEnable = FALSE;
312
        drvIrRxChannel[channel].timeoutEnable = FALSE;
316
        drvIrRxChannel[channel].callback = callback;
313
        drvIrRxChannel[channel].callback = callback;
317
        drvIrRxChannel[channel].enable = TRUE;
314
        drvIrRxChannel[channel].enable = TRUE;
318
    }
315
    }
319
}
316
}
320
 
317
 
321
/* call this function like this:
318
/* call this function like this:
322
    IrTransceiver_DeInit_RX_Channel(channelnumber, pcint-id, GPIO_D6);
319
    IrTransceiver_DeInit_RX_Channel(channelnumber, pcint-id, GPIO_D6);
Line 333... Line 330...
333
        drvIrRxChannel[channel].enable = FALSE;
330
        drvIrRxChannel[channel].enable = FALSE;
334
        drvIrRxChannel[channel].rxlen = 0;
331
        drvIrRxChannel[channel].rxlen = 0;
335
        drvIrRxChannel[channel].storeEnable = FALSE;
332
        drvIrRxChannel[channel].storeEnable = FALSE;
336
        drvIrRxChannel[channel].timeoutEnable = FALSE;
333
        drvIrRxChannel[channel].timeoutEnable = FALSE;
337
        drvIrRxChannel[channel].callback = 0;
334
        drvIrRxChannel[channel].callback = 0;
338
    }
335
    }
339
}
336
}
340
 
337
 
341
uint8_t IrTransceiver_GetStoreEnableRx(uint8_t channel)
338
uint8_t IrTransceiver_GetStoreEnableRx(uint8_t channel)
342
{
339
{
343
    return drvIrRxChannel[channel].storeEnable;
340
    return drvIrRxChannel[channel].storeEnable;
344
}
341
}
345
 
342
 
Line 349... Line 346...
349
    {
346
    {
350
        /* Soft disable channel */
347
        /* Soft disable channel */
351
        drvIrRxChannel[channel].enable = FALSE;
348
        drvIrRxChannel[channel].enable = FALSE;
352
    }
349
    }
353
}
350
}
-
 
351
 
354
void IrTransceiver_EnableRx(uint8_t channel)
352
void IrTransceiver_EnableRx(uint8_t channel)
355
{
353
{
356
    if (channel < 3)
354
    if (channel < 3)
357
    {
355
    {
358
        /* Soft enable channel */
356
        /* Soft enable channel */
359
        drvIrRxChannel[channel].enable = TRUE;
357
        drvIrRxChannel[channel].enable = TRUE;
360
    }
358
    }
361
}
359
}
-
 
360
 
362
void IrTransceiver_ResetRx(uint8_t channel)
361
void IrTransceiver_ResetRx(uint8_t channel)
363
{
362
{
364
    if (channel < 3)
363
    if (channel < 3)
365
    {
364
    {
366
        /* Reset channel */
365
        /* Reset channel */
367
        drvIrRxChannel[channel].rxlen = 0;
366
        drvIrRxChannel[channel].rxlen = 0;
368
        drvIrRxChannel[channel].storeEnable = FALSE;
367
        drvIrRxChannel[channel].storeEnable = FALSE;
369
        drvIrRxChannel[channel].timeoutEnable = FALSE;
368
        drvIrRxChannel[channel].timeoutEnable = FALSE;
370
    }
369
    }
371
}
370
}
372
 
-
 
373
#endif
371
#endif
374
 
372
 
375
 
373
 
376
void IrTransceiver_Init(void)
374
void IrTransceiver_Init(void)
377
{
375
{