/********************************************* * Author: Elmar Benninghaus, Copyright: GPL * This program is the base program for board * elavr32 * Chip type : ATmega32/16 * Clock frequency :14,7456Mhz MHz A simple base program for the BOARD ELAVR32 using the RTC, LCD, KEY's, and the timer int for showing, and setting the time. *********************************************/ #include "prog.h" #include "../../inc/global.h" #include "../../inc/utils.c" #include "../../inc/lcd.c" #include "../../inc/serial.c" #include "../../inc/i2csig.c" #include "../../inc/pfc8583.c" #include "../../inc/key.c" #include "../inc/int.c" #include "../inc/usr.c" prog_char row_version[16] = "Version 1.02\0"; prog_char row_name[16] = "ELAVR32 - BASE\0"; prog_char row_menu[3][32] = { " \0", "SET DATE \0", "SET TIME \0" }; int main(void) { int oldsecond,menuptr; unsigned char key,flag; /////////////////////////////////////////////////////// //// BOARD - FIRST - SIGNALSETUP - START ////////////// /////////////////////////////////////////////////////// // After startup all Ports set as input // with value 0 ( no pullups ). //PORT A Signals - LCD, Analog-Keyinput /* Port A0 is analog input for keys Port A1 is output ENABLE for LCD Port A2 is output RS for LCD Port A3 is output RD/-WR for LCD Port A4,A5,A6,A7 is 5 bit dataport to LCD Startup situation should be: PA0 input no pullup PA1 output low PA2 output low PA3 output low PA4,5,6,7 output high */ DDRA = 0xFE; //set io-pins on PortA Porta1, to Porta7 //as output, but leave Porta0 as it is. PORTA = 0; //all to 0 //???? SFIOR&=!(1< 2 ){ menuptr = 0; } LCDPos(0,0); LCDWriteP((char *)&row_menu[menuptr]); } if( key == KEY_ACK ){ LCDCls(); switch( menuptr ){ case 0: break; case 1: cbi( TIMSK, TOIE0);//disable timer0 overflow int if( setusrDate() ){ rtc_set_time(); } else { sbi( TIMSK, TOIE0);//enable timer0 overflow int } menuptr = 0; break; case 2: cbi( TIMSK, TOIE0);//disable timer0 overflow int if( setusrTime() ){ rtc_set_time(); } else { sbi( TIMSK, TOIE0);//enable timer0 overflow int } menuptr = 0; break; default:break; } LCDCls(); LCDWriteP((char *)&row_menu[menuptr]); } key = 0; } if( oldsecond != SECOND ){ oldsecond = SECOND; printDateTime(); } //normally, all stuff before is for configurations if( flag ){ //preparations for programloop LCDCls(); while( flag ){ //here is the loop for the functionality program } } } } /* //menupoint, - usr sets time */