]>
cloudbase.mooo.com Git - irmp.git/blob - irsndmain.c
1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irsndmain.c - demo main module to test irsnd encoder
4 * Copyright (c) 2010-2012 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 *---------------------------------------------------------------------------------------------------------------------------------------------------
25 #if defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__) // ATtiny45 / ATtiny85:
26 OCR1C
= (F_CPU
/ F_INTERRUPTS
/ 4) - 1; // compare value: 1/15000 of CPU frequency, presc = 4
27 TCCR1
= (1 << CTC1
) | (1 << CS11
) | (1 << CS10
); // switch CTC Mode on, set prescaler to 4
29 OCR1A
= (F_CPU
/ F_INTERRUPTS
) - 1; // compare value: 1/15000 of CPU frequency
30 TCCR1B
= (1 << WGM12
) | (1 << CS10
); // switch CTC Mode on, set prescaler to 1
34 TIMSK1
= 1 << OCIE1A
; // OCIE1A: Interrupt by timer compare
36 TIMSK
= 1 << OCIE1A
; // OCIE1A: Interrupt by timer compare
40 /*---------------------------------------------------------------------------------------------------------------------------------------------------
41 * timer 1 compare handler, called every 1/10000 sec
42 *---------------------------------------------------------------------------------------------------------------------------------------------------
44 ISR(TIMER1_COMPA_vect
)
46 (void) irsnd_ISR(); // call irsnd ISR
47 // call other timer interrupt routines here...
50 /*---------------------------------------------------------------------------------------------------------------------------------------------------
52 *---------------------------------------------------------------------------------------------------------------------------------------------------
59 irsnd_init(); // initialize irsnd
60 timer1_init(); // initialize timer
61 sei (); // enable interrupts
65 irmp_data
.protocol
= IRMP_NEC_PROTOCOL
;
66 irmp_data
.address
= 0x00FF;
67 irmp_data
.command
= 0x0001;
70 irsnd_send_data (&irmp_data
, TRUE
);