]>
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.12 2012/02/13 10:59:07 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:
37 #if F_CPU >= 16000000L
38 OCR1C
= (F_CPU
/ F_INTERRUPTS
/ 8) - 1; // compare value: 1/15000 of CPU frequency, presc = 8
39 TCCR1
= (1 << CTC1
) | (1 << CS12
); // switch CTC Mode on, set prescaler to 8
41 OCR1C
= (F_CPU
/ F_INTERRUPTS
/ 4) - 1; // compare value: 1/15000 of CPU frequency, presc = 4
42 TCCR1
= (1 << CTC1
) | (1 << CS11
) | (1 << CS10
); // switch CTC Mode on, set prescaler to 4
46 OCR1A
= (F_CPU
/ F_INTERRUPTS
) - 1; // compare value: 1/15000 of CPU frequency
47 TCCR1B
= (1 << WGM12
) | (1 << CS10
); // switch CTC Mode on, set prescaler to 1
51 TIMSK1
= 1 << OCIE1A
; // OCIE1A: Interrupt by timer compare
53 TIMSK
= 1 << OCIE1A
; // OCIE1A: Interrupt by timer compare
57 /*---------------------------------------------------------------------------------------------------------------------------------------------------
58 * Timer 1 output compare A interrupt service routine, called every 1/15000 sec
59 *---------------------------------------------------------------------------------------------------------------------------------------------------
61 #ifdef TIM1_COMPA_vect // ATtiny84
64 ISR(TIMER1_COMPA_vect
)
67 (void) irmp_ISR(); // call irmp ISR
68 // call other timer interrupt routines...
77 irmp_init(); // initialize irmp
78 timer1_init(); // initialize timer 1
79 sei (); // enable interrupts
83 if (irmp_get_data (&irmp_data
))
85 // ir signal decoded, do something here...
86 // irmp_data.protocol is the protocol, see irmp.h
87 // irmp_data.address is the address/manufacturer code of ir sender
88 // irmp_data.command is the command code
89 // irmp_protocol_names[irmp_data.protocol] is the protocol name (if enabled, see irmpconfig.h)