TestDoxygen
1.0.21
Test for Doxygen
|
00001 00005 /* 00006 Header for simulator and receiver program versions 00007 TODO Move data definitions and enums to appropriate header files 00008 00009 MRU JR 110905 00010 110919 Moved HW definitions to the appropriate header files 00011 110905 Minor changes 00012 110705 Added enable pullup in INIT_BUTTONS, Sven HW 00013 110619 Added enable pullup to LW_INIT 00014 110613 Added enable pullup in INIT_BUTTONS, JR HW 00015 110604 Changed DOGM CS to D7, pin C6 was dead 00016 110418 Added UNDEFTX to enum LWSIG 00017 110316 Added DOGM power on/off macros 00018 110303 Corrected DOGM initialisation macro 00019 110203 Changed SPI initialisation for SW_OSD 00020 110122 Tidied up file, no changes 00021 110119 Added some macros for LW and GPS sync status 00022 110118 Added GPS_ALARM, changed PPS_ABSENT to GPS_ABSENT 00023 110115 Changed definition for RXPOLL 00024 110114 Reversed red LED signal output in JR_DEFS 00025 110113 Added FASTTICK, SLOWTICK and TIMERFREQ 00026 110103 Changed SPI clock frequency to Fosc/4 00027 101220 Changed INIT_SPI 00028 101211 Moved initialisation back to SIMRCV.h, easier to manage 00029 101206 Moved all initialisation to the appropriate modules 00030 Execution depends on the modules configured in config.h 00031 101123 Added definitions for EEflags 00032 101119 Added JR_DEFS for HW 00033 101117 Changed TICKSPERSEC to 1000 if MAX7456 (receiver or sim) 00034 101116 Changed DSPLINES struct to include start char position 00035 101109 Added definitions for JR HW 00036 101105 First created 00037 00038 ***** Bugs ***** 00039 00040 ***** TTDL ***** 00041 00042 ************************* 00043 defines, typedefs and include files 00044 ************************* 00045 00046 */ 00047 #ifndef _SIMRCV_H_ 00048 #define _SIMRCV_H_ 00049 00050 #define SWMAJREV 1 00051 #define SWMNRREV 1 00052 #define SWBLDNO 21 00053 00054 #include "myportbits.h" 00055 #include <inttypes.h> 00056 #include "config.h" 00057 #include "errorno.h" 00058 00059 /* Length of the site name in EEPROM */ 00060 #define SITENAMELN 16 00061 00062 /* ******************************* 00063 defines, typedefs and structs follow, they are 00064 grouped according to the various modules 00065 *********************************/ 00066 00067 /* **************** TIMER1 ****************/ 00068 /* *************** Controls ***************/ 00069 /* ************** SIM or RCV **************/ 00070 /* Define a string in flash, do this to save RAM */ 00071 #define PGMSTRING(STRNAME, STR) const char PROGMEM pgm ## STRNAME[] = STR; 00072 #define EXTPGMSTRING(STRNAME) extern const char pgm ## STRNAME[]; 00073 00074 #if (VTIDEVICE == MAX7456OSD) 00075 #define MAXSCREENTXTLN 30 00076 #endif /* MAX7456OSD */ 00077 /* Only time for about 26 characters with SW OSD */ 00078 #if (VTIDEVICE == SW_OSD) 00079 #define MAXSCREENTXTLN 26 00080 #endif /* SW_OSD */ 00081 /* **************** RS232 *****************/ 00082 /* ****** SWOSD or MAX7456 or neither *****/ 00083 /* Letter in time line for odd/even field, this is set in the field 00084 end ISR, variable oddoreven 00085 */ 00086 #define ODDLETTER 'O' 00087 #define EVENLETTER 'E' 00088 00089 /* Definitions for the field counter. To save time in coversion to the 00090 display format (string) it's in BCD. Six digits are enough for 00091 20000 sec in PAL, or 16666 2/3 sec in NTSC 00092 */ 00093 #define BCDDIGITCNT 6 00094 #define BCDBYTES ((BCDDIGITCNT + 1) / 2) 00095 typedef uint8_t BCD[BCDBYTES]; 00096 00097 /* Video signal format, distinguish by line count in field in SW_OSD, 00098 or by STAT register bits 1,0 in MAX7456 00099 */ 00100 enum VFORMAT {UNDEFVIDEO, NTSC, PAL}; 00101 00102 /* For font table in SWOSD.c */ 00103 #define FONT_LINES 7 00104 #define FIRST_CHAR ' ' 00105 #define LAST_CHAR 'Z' 00106 #define FONT_CHARS (LAST_CHAR - FIRST_CHAR + 1) 00107 00108 typedef uint8_t FONT_ARRAY[FONT_CHARS][FONT_LINES]; 00109 00110 #define MAXDSPLINES 5 /* Maximum number of lines to be displayed */ 00111 /* Indices in the DISPLAYLINE array, see below */ 00112 enum dspndx {HEADNDX, INFO1NDX, INFO2NDX, TIMENDX, SPARENDX}; 00113 00122 typedef struct displayline 00123 { 00124 /* for SW_OSD this is the scan line, or for MAX7456 the line no, this 00125 depends on whether it's NTSC (13 lines) or PAL (16 lines) 00126 */ 00127 int scanline; 00128 uint8_t attributes; 00129 int8_t startpos; 00130 uint8_t textlng; 00131 char *linetext; 00132 } DISPLAYLINE; 00133 00134 /* ************ DOGM optional *************/ 00135 /* *********** GPSRCV or GPSSIM ***********/ 00136 00137 #if (defined GPSSIM) || (defined GPSRCV) 00138 #if (GPSMODEL == GARMINLVC18x) 00139 /* Maximum number of characters in a GPS 18x sentence + 1 for NUL */ 00140 #define BFRLNG 83 00141 /* maximum field length in GPRMC */ 00142 #define GPRMCMXFLD 10 00143 /* Latitude is ddmm.dddd = 9 char */ 00144 #define GPSLATLEN 9 00145 /* Longitude is dddmm.dddd = 10 char */ 00146 #define GPSLONGLEN 10 00147 /* For GPGGA */ 00148 #define GPGGAMXFLD 10 00149 #define GPGGAHDOPLN 4 00150 #define GPGGAANHGTLN 7 00151 #define GPGGAGHGT 6 00152 #define GPGGANSATLN 2 /* number of satellites, 2 characters */ 00153 00154 /* Length of PPS pulse is a multiple (n + 1) * PPSUNIT ms 0 <= n <= 48 00155 for the GPS 18x, max n is different for GPS18x 5, see manual 00156 It is changed by field 13 of the PGMRC sentence 00157 */ 00158 #define PPSUNIT 20 00159 /* Default length of the PPS pulse in ms, min is 1 unit */ 00160 #define PPSLENGTH ((4 + 1) * PPSUNIT) 00161 #endif /* GARMINLVC18x */ 00162 #endif /* GPSSIM || GPSRCV */ 00163 00164 /* Maximum length of a GPS sentence name */ 00165 #define MAXNAMELN 6 00166 00167 /* For setting the offset between PPS and timer 1 in prescaler ticks. This 00168 should prevent jitter of the 1ms counter in tm_msec if the quarz 00169 frequency isn't exact. Used in the PPS interrupt. It ensures that the 00170 PPS interrupt always comes after the TIMER1 interrupt, simplifies the code 00171 */ 00172 #define GPSOFFSET 4 00173 00174 /* Tolerances for the difference between the internal clock and the PPS 00175 INTPPSTOL is for drift between INTtime and PPS arrival time, we don't correct 00176 the internal clock if the error is <= INTPPSTOL prescaler ticks 00177 PPSARVTOL is for error in the arrival time of the PPS relative to PPS. A large error 00178 may be caused by spurious PPS pulses. IN this case we'll drop back to the internal 00179 clock and resync on the next PPS 00180 */ 00181 #define INTPPSTOL 1 /* Predivider ticks, F_CPU / PREDIV */ 00182 #define PPSARVTOL 5 00183 00184 #define FIXDELAY 10 /* Time to first fix in sec for simulator < 60sec */ 00185 /* Number of equal GPStime and INTtime comparisons until the 00186 INTtime is defined as synchronised with GPStime 00187 */ 00188 #define GPSSYNCCOUNT 10 00189 /* flags for error_flags variable to control the output */ 00190 #define POSLEAPSECERR ((uint8_t) (1 << 0)) /* Transmit a positive leap second */ 00191 #define NEGLEAPSECERR ((uint8_t) (1 << 1)) /* Transmit a negative leap second */ 00192 #define DELAYFIX ((uint8_t) (1 << 2)) /* Send GPRMC with status V for FIXDELAY sec */ 00193 #define PARITYERR ((uint8_t) (1 << 3)) /* Parity error in GPRMC */ 00194 #define PPSARVERR ((uint8_t) (1 << 4)) /* make error in PPS arrival time */ 00195 #define PPSNSRTERR ((uint8_t) (1 << 5)) /* insert a PPS pulse */ 00196 #define RMTCROSSSEC ((uint8_t) (1 << 6)) /* GPRMC starts in one sec, finishes next */ 00197 00198 /* default latitude and longitude, only needed for SIMULATOR */ 00199 #if (PGMFUNCTION == SIMULATOR) 00200 #define DEFLATITUDE "5006.9910" 00201 #define DEFLATHEMIS 'N' 00202 #define DEFLONGITUDE "0829.9120" 00203 #define DEFLONGHEMIS 'E' 00204 /* For GPGGA */ 00205 #define DEFHDOP "12.1" /* For GPGGA, HDOP */ 00206 #define DEFANTHGT "146.0" /* For GPGGA, antenna height M */ 00207 #define DEFGDHGT "0050.0" /* For GPGGA, geoid height, M */ 00208 #else 00209 #define DEFLATITUDE "" 00210 #define DEFLATHEMIS 'N' 00211 #define DEFLONGITUDE "" 00212 #define DEFLONGHEMIS 'E' 00213 /* For GPGGA */ 00214 #define DEFHDOP "" /* For GPGGA, HDOP */ 00215 #define DEFANTHGT "" /* For GPGGA, antenna height M */ 00216 #define DEFGDHGT "" /* For GPGGA, geoid height, M */ 00217 #endif 00218 /* For GPGSA */ 00219 00220 /* For testing errors in PPS interval in SIMULATOR, not used yet */ 00221 #define PPSSHORTINT (TICKSPERSEC - PPSARVTOL - 1) 00222 #define PPSLONGINT (TICKSPERSEC + PPSARVTOL + 1) 00223 00224 /* ******* LW_SIM or LW_RCV or none *******/ 00225 00226 /* Bits for EEflags and RAMflags */ 00227 #define LWNEGSIG ((uint8_t) 0x00) /* Signal is negative pulse */ 00228 #define LWPOSSIG ((uint8_t) 0x01) /* Signal is positive pulse */ 00229 #define LWPOLMSK ((uint8_t) 0x01) /* LW polarity mask */ 00230 00231 /* Names of LW signals, used in evaluating signal, this is in LWsignal 00232 in EEPROM. LWTRNCNT is a counter for the number of transmitters 00233 If you change the values here you must change the PROM tables in 00234 LW.c correspondingly. Must be consecutive values for -SIG up to LWTRNCNT 00235 */ 00236 enum LWSIG{UNDEFTX = -1, DCF77SIG = 0, MSFSIG, WWVBSIG, JJYSIG, LWTRNCNT}; 00237 00238 /* Tolerances for LW (DCF77, WWVB etc.) time signals. Change these after 00239 measurements. We measure the arrival time error of the negative LW 00240 flank over a minute, and correct at the end of the minute. LWcalcError() 00241 delivers the error in prescalar ticks 00242 */ 00243 #define INTLWTOL 5 00244 #define LWARVTOL (1 * PREDVPERMS) /* digits = number of msec */ 00245 00246 /* For testing errors in LW interval in LW_SIM, not used yet */ 00247 #define LWSHORTINT (TICKSPERSEC - LWARVTOL - 1) 00248 #define LWLONGINT (TICKSPERSEC + LWARVTOL + 1) 00249 00250 /* Error codes when checking LW data, used for example is DCFtest() */ 00251 #define DCFA1ERR 1 /* DCF bit A1, flag ZNCCHGA error */ 00252 #define DCFZ1Z2ERR 2 /* Flag STFLAG error */ 00253 #define DCFLPSERR 3 /* Leap second announcement error */ 00254 #define DCFUNXPERR 4 /* unexpected error */ 00255 #define TMCMPERR 5 /* tmcmp() returned error in DCFtest */ 00256 #define DCFCHECKERR 6 /* DCFcheck() returned error */ 00257 00258 /* Definitions for LW operations. The execution is specific to a 00259 particular transmitter, If you change the values of LWINIT etc you 00260 must change the PROM tables in LW.c correspondingly 00261 */ 00262 enum LWOPS 00263 { LWINIT, /* initialise the LW simulator/receiver */ 00264 LWWASMARK, /* Was the mark at the previous second? receiver */ 00265 LWCHECK, /* Check signal integrity in receiver */ 00266 LWSIG2TIME, /* convert signal to struct GPSTM in receiver */ 00267 LWTIME2SIG /* convert struct GPSTM in simulator */ 00268 }; 00269 /* For field counter, use BCD to make it faster and shorter, 3 bytes are 00270 enough for 20000 seconds PAL, 16666 2/3 sec NTSC 00271 */ 00272 00273 /* *********** SHUTTER optional ***********/ 00274 00275 /* Definitions for timer functions */ 00276 00277 typedef struct timer 00278 { uint16_t tmr_ms; 00279 uint16_t tmr_param; 00280 uint8_t tmr_event; 00281 } TIMER_STRUCT; 00282 00283 /* Number of timers */ 00284 #define TIMER_COUNT 3 00285 00286 /* Flags for timing events and errors, max 16, these are used in reporting errors */ 00287 enum timerflags 00288 { tmrLEAPMS = 0x0001, /* correction to millisecond counter */ 00289 tmrLEAPPS = 0x0002, /* correction to prescaler tick */ 00290 tmrNOPPS = 0x0004, /* PPS missing when expected */ 00291 tmrPPSARV = 0x0008, /* Unexpected PPS arrival time */ 00292 tmrRMCPAR = 0x0010, /* GPRMC parity error */ 00293 tmrINTRMC = 0x0020, /* Internal time and GPRMC time/date not equal */ 00294 tmrLWSYNC = 0x0040, /* LW clock is now in sync */ 00295 tmrLWSNCERR = 0x0080, /* LW signal and clock comparison error */ 00296 tmrRMCXSEC = 0x0100 /* GPRMC started in one sec, end in next */ 00297 }; 00298 00299 /* ********** dispatcher,always ***********/ 00300 /* ************ string_util.c *************/ 00301 00302 00303 /****************************************** 00304 Some general definitions, used in more than one module 00305 ******************************************/ 00306 00307 /* Definitions used after pin change interrupt */ 00308 #define POS_FLANK 1 00309 #define NEG_FLANK 0 00310 /* IN PC_FLANK() REG must be the pin register, not the port */ 00311 #define PC_FLANK(REG, BITNO) \ 00312 (((REG & (1 << BITNO)) != (uint8_t) 0) ? POS_FLANK : NEG_FLANK) 00313 00314 00315 /* The following definitions are hardware dependent for devices with one 00316 SPI channel 00317 Port and bit definitions for all modules are here to make it easier 00318 to avoid conflicting definitions 00319 Macro definitions are in the appropriate module .h file 00320 */ 00321 /* Pin definitions for SPI, this is when I'm master SPI */ 00322 #define DDR_SPI DDRB /* Data direction register for SPI */ 00323 #define PINR_SPI PINB /* Pin register for SPI */ 00324 #define SPI_SS PB2 /* Chip select, user control when master */ 00325 #define SPI_MOSI PB3 /* Set to output, data to slave */ 00326 #define SPI_MISO PB4 /* enable SPI makes this an input */ 00327 #define SPI_SCK PB5 /* Clock output */ 00328 /* INIT_SPIPINS sets MOSI, SCK and SS pins as output 00329 The clock phase (CPOL/CPHA) and speed are set differently for MAX7456 and 00330 SW_OSD, MAX7456 and DOGM, see below 00331 */ 00332 #define INIT_SPIPINS DDRB |= ((1 << SPI_MOSI) | (1 << SPI_SCK) | (1 << SPI_SS)); 00333 00334 #if (defined SW_OSD) || (defined MAX7456OSD) 00335 #if (VTIDEVICE == SW_OSD) 00336 #define SPISPEED (1 << SPI2X) /* double speed */ 00337 #else 00338 #define SPISPEED 0 /* single speed */ 00339 #endif 00340 #endif /* (defined SW_OSD) || (defined MAX7456OSD) */ 00341 00342 /* Need different setup for DOGM */ 00343 #ifndef DOGMDISPLAY 00344 #define INIT_DOGMSPI 00345 #endif /* DOGMDISPLAY */ 00346 00350 enum daysofweek {MONDAY = 1, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, 00351 SUNDAY}; 00352 /* Function definitions */ 00353 /* 00354 int8_t isleapyear(GPSTM *gpstime); 00355 void ticksec(GPSTM *gpstime); 00356 void clearBCD(BCD *bcdp); 00357 void incBCD(BCD *bcdp); 00358 void initGPS(void); 00359 */ 00360 #endif /* _SIMRCV_H_ */