]>
cloudbase.mooo.com Git - irmp.git/blob - irsndmain.c
1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irsndmain.c - demo main module to test irmp decoder
4 * Copyright (c) 2010-2011 Frank Meyer - frank(at)fli4l.de
8 * Fuses: lfuse: 0xE2 hfuse: 0xDC efuse: 0xF9
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *---------------------------------------------------------------------------------------------------------------------------------------------------
19 #include <util/delay.h>
20 #include <avr/pgmspace.h>
21 #include <avr/interrupt.h>
23 #include "irsndconfig.h"
33 #if defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__) // ATtiny45 / ATtiny85:
34 OCR1C
= (F_CPU
/ F_INTERRUPTS
/ 4) - 1; // compare value: 1/15000 of CPU frequency, presc = 4
35 TCCR1
= (1 << CTC1
) | (1 << CS11
) | (1 << CS10
); // switch CTC Mode on, set prescaler to 4
37 OCR1A
= (F_CPU
/ F_INTERRUPTS
) - 1; // compare value: 1/15000 of CPU frequency
38 TCCR1B
= (1 << WGM12
) | (1 << CS10
); // switch CTC Mode on, set prescaler to 1
42 TIMSK1
= 1 << OCIE1A
; // OCIE1A: Interrupt by timer compare
44 TIMSK
= 1 << OCIE1A
; // OCIE1A: Interrupt by timer compare
48 /*---------------------------------------------------------------------------------------------------------------------------------------------------
49 * timer 1 compare handler, called every 1/10000 sec
50 *---------------------------------------------------------------------------------------------------------------------------------------------------
52 ISR(TIMER1_COMPA_vect
)
54 (void) irsnd_ISR(); // call irsnd ISR
55 // call other timer interrupt routines here...
58 /*---------------------------------------------------------------------------------------------------------------------------------------------------
60 *---------------------------------------------------------------------------------------------------------------------------------------------------
67 irsnd_init(); // initialize irsnd
68 timer1_init(); // initialize timer
69 sei (); // enable interrupts
73 irmp_data
.protocol
= IRMP_NEC_PROTOCOL
;
74 irmp_data
.address
= 0x00FF;
75 irmp_data
.command
= 0x0001;
78 irsnd_send_data (&irmp_data
, TRUE
);