]>
cloudbase.mooo.com Git - irmp.git/blob - irsndmain.c
1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irsndmain.c - demo main module to test irmp decoder
4 * Copyright (c) 2010 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 *---------------------------------------------------------------------------------------------------------------------------------------------------
17 /*---------------------------------------------------------------------------------------------------------------------------------------------------
18 * uncomment this for codevision compiler:
19 *---------------------------------------------------------------------------------------------------------------------------------------------------
21 // #define CODEVISION // to use Codevision Compiler instead of gcc
26 #define uint8_t unsigned char
27 #define uint16_t unsigned int
28 #define F_CPU 8000000 // change for Codevision here, if you use WinAVR, use Project -> Configuration Options instead
30 // register values from datasheet for ATMega88
46 #include <util/delay.h>
47 #include <avr/pgmspace.h>
48 #include <avr/interrupt.h>
62 OCR1AH
= (( F_CPU
/ F_INTERRUPTS
) >> 8 ) & 0xFF ; // compare value: 1/10000 of CPU frequency (upper byte)
63 OCR1AL
= (( F_CPU
/ F_INTERRUPTS
) - 1 ) & 0xFF ; // compare value: 1/10000 of CPU frequency (lower byte)
65 OCR1A
= ( F_CPU
/ F_INTERRUPTS
) - 1 ; // compare value: 1/10000 of CPU frequency
67 TCCR1B
= ( 1 << WGM12
) | ( 1 << CS10
); // switch CTC Mode on, set prescaler to 1
69 #if defined (__AVR_ATmega8__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega64__) || defined (__AVR_ATmega162__)
70 TIMSK
= 1 << OCIE1A
; // OCIE1A: Interrupt by timer compare (use TIMSK for ATMEGA162)
72 TIMSK1
= 1 << OCIE1A
; // OCIE1A: Interrupt by timer compare (use TIMSK for ATMEGA162)
76 /*---------------------------------------------------------------------------------------------------------------------------------------------------
77 * timer 1 compare handler, called every 1/10000 sec
78 *---------------------------------------------------------------------------------------------------------------------------------------------------
80 // Timer 1 output compare A interrupt service routine
82 interrupt
[ TIM1_COMPA
] void timer1_compa_isr ( void )
84 ISR ( TIMER1_COMPA_vect
)
87 ( void ) irsnd_ISR (); // call irsnd ISR
88 // call other timer interrupt routines...
91 /*---------------------------------------------------------------------------------------------------------------------------------------------------
93 *---------------------------------------------------------------------------------------------------------------------------------------------------
96 // This is the main routine if you use Codevision C Compiler
103 // crystal oscillator division factor: 1
106 #ifdef _OPTIMIZE_SIZE_
110 irsnd_init (); // initialize irsnd
111 timer_init (); // initialize timer
112 #asm( "sei" ); // enable interrupts
116 irmp_data
. protocol
= IRMP_NEC_PROTOCOL
;
117 irmp_data
. address
= 0x00FF ;
118 irmp_data
. command
= 0x0001 ;
120 irsnd_send_data (& irmp_data
);
127 // This is the main routine if you use GCC Compiler
133 irsnd_init (); // initialize irsnd
134 timer_init (); // initialize timer
135 sei (); // enable interrupts
139 irmp_data
. protocol
= IRMP_NEC_PROTOCOL
;
140 irmp_data
. address
= 0x00FF ;
141 irmp_data
. command
= 0x0001 ;
143 irsnd_send_data (& irmp_data
);
148 #endif // CODEVISION / gcc