]> cloudbase.mooo.com Git - irmp.git/blame - irsndmain.c
Version 2.0.2: improved jvc decoder (type 2 and 3)
[irmp.git] / irsndmain.c
CommitLineData
4225a882 1/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
2 * irsndmain.c - demo main module to test irmp decoder\r
3 *\r
f50e01e7 4 * Copyright (c) 2010-2011 Frank Meyer - frank(at)fli4l.de\r
4225a882 5 *\r
6 * ATMEGA88 @ 8 MHz\r
7 *\r
8 * Fuses: lfuse: 0xE2 hfuse: 0xDC efuse: 0xF9\r
9 *\r
10 * This program is free software; you can redistribute it and/or modify\r
11 * it under the terms of the GNU General Public License as published by\r
12 * the Free Software Foundation; either version 2 of the License, or\r
13 * (at your option) any later version.\r
14 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
15 */\r
16\r
4225a882 17#include <inttypes.h>\r
18#include <avr/io.h>\r
19#include <util/delay.h>\r
20#include <avr/pgmspace.h>\r
21#include <avr/interrupt.h>\r
22#include "irmp.h"\r
46dd89b7 23#include "irsndconfig.h"\r
4225a882 24#include "irsnd.h"\r
25\r
4225a882 26#ifndef F_CPU\r
27#error F_CPU unkown\r
28#endif\r
29\r
30void\r
1f54e86c 31timer1_init (void)\r
4225a882 32{\r
476267f4 33#if defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__) // ATtiny45 / ATtiny85:\r
b743217b 34 OCR1C = (F_CPU / F_INTERRUPTS / 4) - 1; // compare value: 1/15000 of CPU frequency, presc = 4\r
476267f4 35 TCCR1 = (1 << CTC1) | (1 << CS11) | (1 << CS10); // switch CTC Mode on, set prescaler to 4\r
36#else // ATmegaXX:\r
37 OCR1A = (F_CPU / F_INTERRUPTS) - 1; // compare value: 1/15000 of CPU frequency\r
38 TCCR1B = (1 << WGM12) | (1 << CS10); // switch CTC Mode on, set prescaler to 1\r
1f54e86c 39#endif\r
4225a882 40\r
1f54e86c 41#ifdef TIMSK1\r
476267f4 42 TIMSK1 = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare\r
4225a882 43#else\r
476267f4 44 TIMSK = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare\r
1f54e86c 45#endif\r
4225a882 46}\r
47\r
48/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
49 * timer 1 compare handler, called every 1/10000 sec\r
50 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
51 */\r
4225a882 52ISR(TIMER1_COMPA_vect)\r
4225a882 53{\r
54 (void) irsnd_ISR(); // call irsnd ISR\r
1f54e86c 55 // call other timer interrupt routines here...\r
4225a882 56}\r
57\r
58/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
59 * MAIN: main routine\r
60 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
61 */\r
4225a882 62int\r
63main (void)\r
64{\r
1f54e86c 65 IRMP_DATA irmp_data;\r
66\r
67 irsnd_init(); // initialize irsnd\r
68 timer1_init(); // initialize timer\r
69 sei (); // enable interrupts\r
70\r
71 for (;;)\r
72 {\r
73 irmp_data.protocol = IRMP_NEC_PROTOCOL;\r
74 irmp_data.address = 0x00FF;\r
75 irmp_data.command = 0x0001;\r
76 irmp_data.flags = 0;\r
77\r
78 irsnd_send_data (&irmp_data, TRUE);\r
79 _delay_ms (1000);\r
80 }\r
4225a882 81}\r