]> cloudbase.mooo.com Git - irmp.git/blame - main.c
version 2.0.0-pre6: added support for ATtiny85, removed support for codevision, added...
[irmp.git] / main.c
CommitLineData
4225a882 1/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
2 * main.c - demo main module to test irmp decoder\r
3 *\r
f50e01e7 4 * Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de\r
4225a882 5 *\r
f50e01e7 6 * $Id: main.c,v 1.9 2011/04/11 12:54:25 fm Exp $\r
cb8474cc 7 *\r
4225a882 8 * ATMEGA88 @ 8 MHz\r
9 *\r
10 * Fuses: lfuse: 0xE2 hfuse: 0xDC efuse: 0xF9\r
11 *\r
12 * This program is free software; you can redistribute it and/or modify\r
13 * it under the terms of the GNU General Public License as published by\r
14 * the Free Software Foundation; either version 2 of the License, or\r
15 * (at your option) any later version.\r
16 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
17 */\r
18\r
4225a882 19#include <inttypes.h>\r
20#include <avr/io.h>\r
21#include <util/delay.h>\r
22#include <avr/pgmspace.h>\r
23#include <avr/interrupt.h>\r
4225a882 24\r
1f54e86c 25#include "irmpconfig.h"\r
26#include "irmp.h"\r
4225a882 27\r
28#ifndef F_CPU\r
29#error F_CPU unkown\r
30#endif\r
31\r
32void\r
1f54e86c 33timer1_init (void)\r
4225a882 34{\r
1f54e86c 35#if defined (__AVR_ATtiny85__) // ATtiny85:\r
36 OCR1A = (F_CPU / (2 * F_INTERRUPTS) / 2) - 1; // compare value: 1/28800 of CPU frequency, presc = 2\r
37 TCCR1 = (1 << CTC1) | (1 << CS11); // switch CTC Mode on, set prescaler to 2\r
38#else // ATmegaXX:\r
39 OCR1A = (F_CPU / (2 * F_INTERRUPTS)) - 1; // compare value: 1/28800 of CPU frequency\r
40 TCCR1B = (1 << WGM12) | (1 << CS10); // switch CTC Mode on, set prescaler to 1\r
41#endif\r
4225a882 42\r
1f54e86c 43#ifdef TIMSK1\r
44 TIMSK1 = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare\r
4225a882 45#else\r
1f54e86c 46 TIMSK = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare\r
47#endif\r
4225a882 48}\r
49\r
4225a882 50int\r
51main (void)\r
52{\r
1f54e86c 53 IRMP_DATA irmp_data;\r
4225a882 54\r
1f54e86c 55 irmp_init(); // initialize irmp\r
56 timer1_init(); // initialize timer 1\r
57 sei (); // enable interrupts\r
4225a882 58\r
1f54e86c 59 for (;;)\r
4225a882 60 {\r
1f54e86c 61 if (irmp_get_data (&irmp_data))\r
62 {\r
63 // ir signal decoded, do something here...\r
64 // irmp_data.protocol is the protocol, see irmp.h\r
65 // irmp_data.address is the address/manufacturer code of ir sender\r
66 // irmp_data.command is the command code\r
67 // irmp_protocol_names[irmp_data.protocol] is the protocol name (if enabled, see irmpconfig.h)\r
68 }\r
4225a882 69 }\r
4225a882 70}\r