/* havrapp.c Henriks AVR application Copyright Henrik Björkman www.eit.se/hb 2005 All rights reserved etc etc... For hardware see: H:\d\eget\projects\inteligent_electronic_thermostat\hw\0.1 History 2005-02-14 want to use serial port. Have adapted some code I found at http://www.lka.ch/projects/avr/ Henrik Bjorkman 2005-02-20 Will try to interpret some commands Henrik */ #include #include #include #include #include #include #include #include "avr_cfg.h" #include "avr_uart.h" #include "avr_tmr0.h" int mainTimer; int mainCounter=0; int main( void ) { wdt_enable(WDTO_2S); // we relay on boot loader to initialize uart. //uart_init(); avr_tmr0_init(); sei(); // enable global interrupts uart_print_P(PSTR("\r\n" VERSION_STRING "\r\n")); wdt_reset(); mainTimer=avr_tmr0_gettick()+AVR_TMR0_TICKS_PER_SEC(); for(;;) { int t=avr_tmr0_gettick(); wdt_reset(); int c=uart_getchar(); if (c>0) { if (c>='a') { c-=0x20; } uart_putchar(c); } if ((t-mainTimer)>0) { uart_putchar('0'+mainCounter); if (mainCounter>=9) { mainCounter=0; } else { mainCounter++; } mainTimer=t+AVR_TMR0_TICKS_PER_SEC(); } } return(0); } // end main()