//*****************************************************************************
//
// File Name : 'global.h'
// Title : AVR project global include
// Author : Pascal Stang
// Created : 7/12/2001
// Revised : 9/30/2002
// Version : 1.1
// Target MCU : Atmel AVR series
// Editor Tabs : 4
//
// Description : This include file is designed to contain items useful to all
// code files and projects.
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************
#ifndef GLOBAL_H
#define GLOBAL_H
// global AVRLIB defines
#include "avrlibdefs.h"
// global AVRLIB types definitions
#include "avrlibtypes.h"
// project/system dependent defines
// constants/macros/typdefs
typedef struct struct_SysState
{
u08 pumpActivated; //1 on; 0 inactive
u08 pumpSoundOn; //1 on; 0 off
u08 alarmOn; //1 on; 0 off
u08 alarmCount;
u08 displayPage; //=kPage0_Norm:kPage5_PumpStart
u08 displayState; //=kState_Normal:kState_Edit
u08 displayTimeout;
u08 displayPrevPage;
u08 bntOneCycCnt;
u08 bntTwoCycCnt;
u08 bntIncCycCnt;
u08 bntDecCycCnt;
u08 update_rtc_year;
u08 update_rtc_month;
u08 update_rtc_day;
u08 update_rtc_sunsat;
u08 update_rtc_hour;
u08 update_rtc_minute;
u08 update_rtc_second;
u08 update_info;
u08 update_info_num;
u08 update_alm_hour;
u08 update_alm_minute;
u08 update_alm_second;
u08 update_alm_sound;
u08 update_pa_active;
u08 update_pa_sound;
u08 update_pd_minute;
u08 update_pd_second;
u08 update_pf_day;
u08 update_pf_hour;
u08 update_pf_minute;
u08 update_pn_year;
u08 update_pn_month;
u08 update_pn_day;
u08 update_pn_hour;
u08 update_pn_minute;
u08 update_pn_second;
u08 fieldAdjusted;
u08 spkPosVolt;
u08 spkNoteNum;
} SysStateType;
//----- Defines ---------------------------------------------------------------
#define LCD_DATAPORTO PORTA
#define LCD_DATAPORTR DDRA
#define LCD_CNTLPORTO PORTD
#define LCD_CNTLPORTR DDRD
#define LCD_CNTLPORTI PIND
#define SW_PORTR DDRB
#define SW_PORTI PINB
#define SW_BTNONE 0x01 //PB0: next
#define SW_BTNTWO 0x02 //PB1: switch view/edit
#define SW_BTNINC 0x04 //PB2: increase
#define SW_BTNDEC 0x08 //PB3: decrease
#define SPK_PORTR DDRC
#define SPK_PORTO PORTC
#define SPK_POSPIN 0 //PC0
#define PUMP_POSPIN 5 //PC5
#define kState_View 1
#define kState_Edit 2
#define kPage0_Norm 0
#define kPage1_Alarm 1
#define kPage2_PumpActive 2
#define kPage3_PumpDuration 3
#define kPage4_PumpFreq 4
#define kPage5_PumpNext 5
#define kIgnoreClickDuration 8 //cycles in timer0
#define kPageViewTimeout 10 //seconds
#define kAlarmTimeout 120 //seconds
// temporary work-around for the Mega323
#define CTC1 CTC10
// CPU clock speed
//#define F_CPU 16000000 // 16MHz processor
//#define F_CPU 14745000 // 14.745MHz processor
//#define F_CPU 8000000 // 8MHz processor
//#define F_CPU 7372800 // 7.37MHz processor
//#define F_CPU 4000000 // 4MHz processor
#define F_CPU 3686400 // 3.69MHz processor
// CYCLES_PER_US is used by some short delay loops
#define CYCLES_PER_US ((F_CPU+500000)/1000000) // cpu cycles per microsecond
#endif