]>
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>
50 #include "irsndconfig.h"
63 OCR1AH
= (( F_CPU
/ F_INTERRUPTS
) >> 8 ) & 0xFF ; // compare value: 1/10000 of CPU frequency (upper byte)
64 OCR1AL
= (( F_CPU
/ F_INTERRUPTS
) - 1 ) & 0xFF ; // compare value: 1/10000 of CPU frequency (lower byte)
66 OCR1A
= ( F_CPU
/ F_INTERRUPTS
) - 1 ; // compare value: 1/10000 of CPU frequency
68 TCCR1B
= ( 1 << WGM12
) | ( 1 << CS10
); // switch CTC Mode on, set prescaler to 1
70 #if defined (__AVR_ATmega8__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega64__) || defined (__AVR_ATmega162__)
71 TIMSK
= 1 << OCIE1A
; // OCIE1A: Interrupt by timer compare (use TIMSK for ATMEGA162)
73 TIMSK1
= 1 << OCIE1A
; // OCIE1A: Interrupt by timer compare (use TIMSK for ATMEGA162)
77 /*---------------------------------------------------------------------------------------------------------------------------------------------------
78 * timer 1 compare handler, called every 1/10000 sec
79 *---------------------------------------------------------------------------------------------------------------------------------------------------
81 // Timer 1 output compare A interrupt service routine
83 interrupt
[ TIM1_COMPA
] void timer1_compa_isr ( void )
85 ISR ( TIMER1_COMPA_vect
)
88 ( void ) irsnd_ISR (); // call irsnd ISR
89 // call other timer interrupt routines...
92 /*---------------------------------------------------------------------------------------------------------------------------------------------------
94 *---------------------------------------------------------------------------------------------------------------------------------------------------
97 // This is the main routine if you use Codevision C Compiler
104 // crystal oscillator division factor: 1
107 #ifdef _OPTIMIZE_SIZE_
111 irsnd_init (); // initialize irsnd
112 timer_init (); // initialize timer
113 #asm( "sei" ); // enable interrupts
117 irmp_data
. protocol
= IRMP_NEC_PROTOCOL
;
118 irmp_data
. address
= 0x00FF ;
119 irmp_data
. command
= 0x0001 ;
122 irsnd_send_data (& irmp_data
);
129 // This is the main routine if you use GCC Compiler
135 irsnd_init (); // initialize irsnd
136 timer_init (); // initialize timer
137 sei (); // enable interrupts
141 irmp_data
. protocol
= IRMP_NEC_PROTOCOL
;
142 irmp_data
. address
= 0x00FF ;
143 irmp_data
. command
= 0x0001 ;
146 irsnd_send_data (& irmp_data
, TRUE
);
151 #endif // CODEVISION / gcc