#ifndef __int_h_ #define __int_h_ #include "../../inc/global.h" #include "cfg.h" extern volatile unsigned char FLAGS; extern volatile unsigned char FLAGS2; extern volatile int YEAR; extern volatile int MONTH; extern volatile int DAY; extern volatile int HOUR; extern volatile int MINUTE; extern volatile int SECOND; extern volatile int MSECOND; extern volatile unsigned char timer36; extern volatile unsigned char thismdays; extern volatile long il_last; extern volatile long calctarget_hor; extern volatile long calctarget_ver; extern volatile long calctarget_fr; extern volatile long pos_hor; extern volatile long pos_ver; extern volatile long pos_fr; extern volatile long origin_hor; extern volatile long origin_ver; extern volatile long origin_fr; extern volatile long hor_360; extern volatile long ver_360; extern volatile long fr_360; //------------------------- extern volatile int epos_hor; extern volatile int epos_ver; extern volatile int originenc_hor; extern volatile int originenc_ver; extern volatile unsigned char spictr; extern volatile unsigned char spiout[22]; extern volatile unsigned char spiin[22]; extern volatile unsigned char addr_hor; extern volatile unsigned char addr_ver; extern volatile unsigned char addr_fr; extern void spi_init(void); extern void spi_stop(void); extern unsigned char spi_start(void); extern void spi_config( void ); extern void rtc_set_time( void ); extern void rtc_get_time( void ); #define STARDAYSEC400LASTLONG 34465636 #define CLEARALLFLAGS FLAGS=0 #define CLEARALLFLAGS2 FLAGS2=0 #define CLRFLAGRUN FLAGS=FLAGS&254 #define CLRFLAG1 FLAGS=FLAGS&253 #define CLRFLAG2 FLAGS=FLAGS&251 #define CLRFLAGSPIFORCEOFF FLAGS=FLAGS&247 #define CLRFLAGSPIFORCESTOP FLAGS=FLAGS&239 #define CLRFLAGSPIFORCEORIGIN FLAGS=FLAGS&223 #define CLRFLAGSPIFORCETARGET FLAGS=FLAGS&191 #define CLRFLAGSPIFORCECFG FLAGS=FLAGS&127 #define CLRFLAGSSPIFORCESEND FLAGS=FLAGS&240 #define SETFLAGRUN FLAGS=FLAGS|1 #define SETFLAG1 FLAGS=FLAGS|2 #define SETFLAG2 FLAGS=FLAGS|4 #define SETFLAGSPIFORCEOFF FLAGS=FLAGS|8 #define SETFLAGSPIFORCESTOP FLAGS=FLAGS|16 #define SETFLAGSPIFORCEORIGIN FLAGS=FLAGS|32 #define SETFLAGSPIFORCETARGET FLAGS=FLAGS|64 #define SETFLAGSPIFORCECFG FLAGS=FLAGS|128 #define ISFLAGRUN (FLAGS&1) #define ISFLAG1 (FLAGS&2) #define ISFLAG2 (FLAGS&4) #define ISFLAGSPIFORCEOFF (FLAGS&8) #define ISFLAGSPIFORCESTOP (FLAGS&16) #define ISFLAGSPIFORCEORIGIN (FLAGS&32) #define ISFLAGSPIFORCETARGET (FLAGS&64) #define ISFLAGSPIFORCECFG (FLAGS&128) #define ISFLAGSSPIFORCESEND (FLAGS&15) #define CLRFLAGSPI0 FLAGS2=FLAGS2&254 #define CLRFLAGSPI1 FLAGS2=FLAGS2&253 #define CLRFLAGSPISTEPON FLAGS2=FLAGS2&251 #define CLRFLAGSPION FLAGS2=FLAGS2&247 #define CLRFLAGSPISTOP FLAGS2=FLAGS2&239 #define CLRFLAGSPIORIGIN FLAGS2=FLAGS2&223 #define CLRFLAGSPITARGET FLAGS2=FLAGS2&191 #define CLRFLAGSPICFG FLAGS2=FLAGS2&127 #define CLRFLAGSSPISEND FLAGS2=FLAGS2&240 #define SETFLAGSPI0 FLAGS2=FLAGS2|1 #define SETFLAGSPI1 FLAGS2=FLAGS2|2 #define SETFLAGSPISTEPON FLAGS2=FLAGS2|4 #define SETFLAGSPION FLAGS2=FLAGS2|8 #define SETFLAGSPISTOP FLAGS2=FLAGS2|16 #define SETFLAGSPIORIGIN FLAGS2=FLAGS2|32 #define SETFLAGSPITARGET FLAGS2=FLAGS2|64 #define SETFLAGSPICFG FLAGS2=FLAGS2|128 #define ISFLAGSPI0 (FLAGS2&1) #define ISFLAGSPI1 (FLAGS2&2) #define ISFLAGSPISTEPON (FLAGS2&4) #define ISFLAGSPION (FLAGS2&8) #define ISFLAGSPISTOP (FLAGS2&16) #define ISFLAGSPIORIGIN (FLAGS2&32) #define ISFLAGSPITARGET (FLAGS2&64) #define ISFLAGSPICFG (FLAGS2&128) #define ISFLAGSSPISEND (FLAGS2&15) //NOTE: //ver_, or _ver means vertical, so if az-alt this is the az-axis, if ra/dec the ra-axis. //hor_, or _hor means horizontal, so if az-alt this is the alt-axis, if ra/dec the dec axis. //fr_, or _fr means fieldrotator //en_, or _en means encoder #define DIR_LEFT 0 #define DIR_RIGHT 1 #define DIR_UP 2 #define DIR_DOWN 3 #define EEPROM_START 32 #define EEPROM_INITADDR EEPROM_START #define EEPROM_DBSTART EEPROM_INITADDR + 2 #define EEPROM_INITIALIZER1 153 #define EEPROM_INITIALIZER2 73 //############################################################# //########### MOTOR ROUTINES ################################## //############################################################# extern void mot_target( long hor, long ver, long fr ); extern void mot_stop( void ); extern void mot_origin( long hor, long ver, long fr, int ehor, int ever ); //############################################################# //########### SPI ROUTINES #################################### //############################################################# extern void spi_init(void); extern void spi_stop(void); extern unsigned char spi_start(void); extern void spi_config( void ); //############################################################# //########### RTC ROUTINES #################################### //############################################################# extern void rtc_set_time( void ); extern void rtc_get_time( void ); //############################################################# //########### EEPROM ROUTINES ################################# //############################################################# //ATTENTION: reading, writeing from/to eeprom should never be //doing if an interrupt can occure, during timesensitive eeprom operations. //For avoiding this, we go another way. //The only interrupt we have run is the 1/7200 timerint. //For every call of one of these two functions, we wait hard till this interrupt //occures, and the end is reached. Immediately after this we do our eeprom-operations. //This means we read/write with a speed of up to 1/3600 chars per second. //The only stuff, we use the eeprom is reading, writing databaseentries per 20 Bytes, //outside any motor-depending stuff. So one read/write of 20 Bytes uses up to 1/180 second, //which should be more then enough. //We calculate that we have absolutely min. 500 OP's place between the interrupts, //for having place of programm calculations. ( The wish is to have 2/3 place for //program, and 1/3 for interrupt, for doing our min. 120 calculations on programside. //Attention: use this functions only if interrupt is running ( after doing the sei() :-) extern void EEPROM_write( unsigned int uiAddress, unsigned char ucData ); extern unsigned char EEPROM_read(unsigned int uiAddress); #endif //__int_h_