]>
cloudbase.mooo.com Git - irmp.git/blob - main.c
1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * main.c - demo main module to test irmp decoder
4 * Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de
6 * $Id: main.c,v 1.10 2011/09/08 13:22:16 fm Exp $
10 * Fuses: lfuse: 0xE2 hfuse: 0xDC efuse: 0xF9
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *---------------------------------------------------------------------------------------------------------------------------------------------------
21 #include <util/delay.h>
22 #include <avr/pgmspace.h>
23 #include <avr/interrupt.h>
25 #include "irmpconfig.h"
35 #if defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__) // ATtiny45 / ATtiny85:
36 OCR1C
= (F_CPU
/ F_INTERRUPTS
/ 4) - 1; // compare value: 1/15000 of CPU frequency, presc = 4
37 TCCR1
= (1 << CTC1
) | (1 << CS11
) | (1 << CS10
); // switch CTC Mode on, set prescaler to 4
39 OCR1A
= (F_CPU
/ F_INTERRUPTS
) - 1; // compare value: 1/15000 of CPU frequency
40 TCCR1B
= (1 << WGM12
) | (1 << CS10
); // switch CTC Mode on, set prescaler to 1
44 TIMSK1
= 1 << OCIE1A
; // OCIE1A: Interrupt by timer compare
46 TIMSK
= 1 << OCIE1A
; // OCIE1A: Interrupt by timer compare
50 /*---------------------------------------------------------------------------------------------------------------------------------------------------
51 * Timer 1 output compare A interrupt service routine, called every 1/15000 sec
52 *---------------------------------------------------------------------------------------------------------------------------------------------------
54 #ifdef TIM1_COMPA_vect // ATtiny84
57 ISR(TIMER1_COMPA_vect
)
60 (void) irmp_ISR(); // call irmp ISR
61 // call other timer interrupt routines...
70 irmp_init(); // initialize irmp
71 timer1_init(); // initialize timer 1
72 sei (); // enable interrupts
76 if (irmp_get_data (&irmp_data
))
78 // ir signal decoded, do something here...
79 // irmp_data.protocol is the protocol, see irmp.h
80 // irmp_data.address is the address/manufacturer code of ir sender
81 // irmp_data.command is the command code
82 // irmp_protocol_names[irmp_data.protocol] is the protocol name (if enabled, see irmpconfig.h)