Go to the documentation of this file.00001
00027 #include <avr/io.h>
00028 #include <avr/interrupt.h>
00029 #include <avr/pgmspace.h>
00030 #include <util/delay.h>
00031 #include <stdlib.h>
00032
00033
00034 #include "lcd.h"
00035 #include "uart.h"
00036 #include "button.h"
00037 #include "buzzer.h"
00038
00039 uint8_t cnt=0;
00040 uint8_t cnt2=0;
00041 extern uint8_t scroll;
00042
00043 #define DISPLAY_bp 4
00044 #define BACKLIGHT_bp 5
00045
00046
00047
00053 inline void timer2_init(void) {
00054
00055 TCCR2 = (1<<CS22) | (1<<CS21);
00056 TIMSK |= (1<<TOIE2);
00057 }
00058
00059
00060 int main(void) {
00061
00062 uint8_t data;
00063
00064 uart_init();
00065 button_init();
00066 buzzer_init();
00067
00068 timer2_init();
00069
00070
00071 DDRB |= (1<<DISPLAY_bp) ;
00072 PORTB &= ~(1<<DISPLAY_bp);
00073 DDRB |= (1<<BACKLIGHT_bp);
00074 PORTB &= ~(1<<BACKLIGHT_bp);
00075
00076 sei();
00077
00078 lcd_init();
00079 print_buffer();
00080
00081
00082 while(1) {
00083 if(uart_getbyte(&data)) {
00084 lcd_putchar(data, NULL);
00085 }
00086
00087
00088 if(scroll && cnt>40) {
00089 cnt=0;
00090 lcd_scroll();
00091 }
00092
00093
00094 if(cnt2>1) {
00095 cnt2=0;
00096 button_process();
00097
00098 }
00099
00100 }
00101 }
00102
00103
00104
00105 ISR(TIMER2_OVF_vect ){
00106 cnt++;
00107 cnt2++;
00108 }
00109
00110