/*--------------------------------------------------------------------------------------------------------------------------------------------------- * main.c - demo main module to test irmp decoder * * Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de * * $Id: main.c,v 1.9 2011/04/11 12:54:25 fm Exp $ * * ATMEGA88 @ 8 MHz * * Fuses: lfuse: 0xE2 hfuse: 0xDC efuse: 0xF9 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *--------------------------------------------------------------------------------------------------------------------------------------------------- */ #include #include #include #include #include #include "irmpconfig.h" #include "irmp.h" #ifndef F_CPU #error F_CPU unkown #endif void timer1_init (void) { #if defined (__AVR_ATtiny85__) // ATtiny85: OCR1A = (F_CPU / (2 * F_INTERRUPTS) / 2) - 1; // compare value: 1/28800 of CPU frequency, presc = 2 TCCR1 = (1 << CTC1) | (1 << CS11); // switch CTC Mode on, set prescaler to 2 #else // ATmegaXX: OCR1A = (F_CPU / (2 * F_INTERRUPTS)) - 1; // compare value: 1/28800 of CPU frequency TCCR1B = (1 << WGM12) | (1 << CS10); // switch CTC Mode on, set prescaler to 1 #endif #ifdef TIMSK1 TIMSK1 = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare #else TIMSK = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare #endif } int main (void) { IRMP_DATA irmp_data; irmp_init(); // initialize irmp timer1_init(); // initialize timer 1 sei (); // enable interrupts for (;;) { if (irmp_get_data (&irmp_data)) { // ir signal decoded, do something here... // irmp_data.protocol is the protocol, see irmp.h // irmp_data.address is the address/manufacturer code of ir sender // irmp_data.command is the command code // irmp_protocol_names[irmp_data.protocol] is the protocol name (if enabled, see irmpconfig.h) } } }