Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef SIRF3_H
00019 #define SIRF3_H
00020
00021 #include <usarts.h>
00022
00034 #define SIRF_MAX_PAYLOAD_LENGTH ((1<<10)-1)
00035
00045 #define SIRF_MAX_MSG_LENGTH (SIRF_MAX_PAYLOAD_LENGTH+8)
00046
00047 #define SIRF_START0 ((uint8_t)0xA0)
00048 #define SIRF_START1 ((uint8_t)0xA2)
00049 #define SIRF_END0 ((uint8_t)0xB0)
00050 #define SIRF_END1 ((uint8_t)0xB3)
00051
00052
00053 #define SIRFi_POWER (0x35)
00054 #define SIRFi_INIT (0x80)
00055 #define SIRFi_NMEA (0x81)
00056 #define SIRFi_S_ALMANAC (0x82)
00057 #define SIRFi_DUMPDATA (0x83)
00058 #define SIRFi_VERSION (0x84)
00059 #define SIRFi_DGPS_SRC (0x85)
00060 #define SIRFi_SETPORT (0x86)
00061 #define SIRFi_SETPROTO (0x87)
00062 #define SIRFi_MODE (0x88)
00063 #define SIRFi_DOPMASK (0x89)
00064 #define SIRFi_DGPS_MODE (0x8A)
00065 #define SIRFi_ELE_MASK (0x8B)
00066 #define SIRFi_PWR_MASK (0x8C)
00067 #define SIRFi_STATIC_NAV (0x8F)
00068 #define SIRFi_CLK_STAT (0x90)
00069 #define SIRFi_DGPS_PORT (0x91)
00070 #define SIRFi_P_ALMANAC (0x92)
00071 #define SIRFi_P_EPHEMERIS (0x93)
00072 #define SIRFi_FLASH_UPD (0x94)
00073 #define SIRFi_S_EPHEMERIS (0x95)
00074 #define SIRFi_OPMODE (0x96)
00075 #define SIRFi_TRICKLE (0x97)
00076 #define SIRFi_P_NAVPARM (0x98)
00077 #define SIRFi_UARTCONF (0xA5)
00078 #define SIRFi_MSGRATE (0xA6)
00079 #define SIRFi_LOWPWRACQ (0xA7)
00080 #define SIRFi_P_CMDPARM (0xA8)
00081 #define SIRFi_S_SBASPARM (0xAA)
00082 #define SIRFi_CLASS_DR (0xAC)
00083 #define SIRFi_USR_INPUT (0xAF)
00084 #define SIRFi_USR_INP_BEG (0xB4)
00085 #define SIRFi_USR_INP_END (0xC7)
00086 #define SIRFi_PRESET_CONF (0xB4)
00087 #define SIRFi_UARTCONFOLD (0xB6)
00088 #define SIRFi_SOFT_CTRL (0xCD)
00089 #define SIRFi_INTERNAL (0xE4)
00090 #define SIRFi_EXT_EPHEM (0xE8)
00092
00093 #define SIRFi_PROTO_NULL (0)
00094 #define SIRFi_PROTO_BIN (1)
00095 #define SIRFi_PROTO_NMEA (2)
00096 #define SIRFi_PROTO_ASCII (3)
00097 #define SIRFi_PROTO_RTCM (4)
00098 #define SIRFi_PROTO_USER1 (5)
00099 #define SIRFi_PROTO_SIRFLOC (6)
00100 #define SIRFi_PROTO_STAT (7)
00102
00103 #define SIRFi_SOFT_OFF (0x10)
00105
00106 #define SIRFo_REF_NAV (0x01)
00107 #define SIRFo_NAV (0x02)
00108 #define SIRFo_TRUE_TRACKER (0x03)
00109 #define SIRFo_TRACKER (0x04)
00110 #define SIRFo_RAW_TRACK (0x05)
00111 #define SIRFo_SWVERSION (0x06)
00112 #define SIRFo_CLOCK_STATUS (0x07)
00113 #define SIRFo_SUBFRAME50 (0x08)
00114 #define SIRFo_THROUGHPUT (0x09)
00115 #define SIRFo_ERROR_ID (0x0A)
00116 #define SIRFo_CMD_ACK (0x0B)
00117 #define SIRFo_CMD_NAK (0x0C)
00118 #define SIRFo_VISIBLE (0x0D)
00119 #define SIRFo_DGPS_STAT (0x1B)
00120 #define SIRFo_GEO_NAV (0x29)
00123
00124
00126
00127
00129
00130
00132
00133
00135 extern void sirf_gps_off (usart_control_t * usart);
00136
00138 typedef enum {
00139 SIRFPARSE_UNSYNC,
00140 SIRFPARSE_START0,
00141 SIRFPARSE_START1,
00142 SIRFPARSE_LENGTH_H,
00143 SIRFPARSE_LENGTH_L,
00144 SIRFPARSE_PAYLOAD,
00145 SIRFPARSE_CSUM_H,
00146 SIRFPARSE_CSUM_L,
00147 SIRFPARSE_END0,
00148 SIRFPARSE_END1,
00149 } sirf_parse_state_t;
00150
00152 typedef struct proto_sirf_parser_s {
00153 gps_proto_parser_t base;
00154 sirf_parse_state_t state;
00155 uint16_t msglen;
00156 uint16_t msgidx;
00157 uint16_t csum, csum_recv;
00158 size_t msgsize;
00159 uint8_t *msg;
00160 uint8_t *swversion;
00161 uint16_t gps_week;
00162 uint32_t gps_timeofweek;
00163 uint32_t clk_drift;
00164 uint32_t clk_bias;
00165 uint32_t gps_time;
00166 } proto_sirf_parser_t;
00167
00169 inline uint16_t sirf_getuint16 (const uint8_t * p)
00170 {
00171 uint16_t ret;
00172 #ifdef __AVR__
00173 __asm__ ("ld %B0,%a1\n\t"
00174 "ldd %A0,%a1+1"
00175 : "=&r"(ret)
00176 : "b"(p));
00177 #else
00178 #warning "using generic sirf_getuintxx implementation"
00179 ret = ((uint16_t)p[0] << 8) | p[1];
00180 #endif
00181 return ret;
00182 }
00183
00185 inline uint32_t sirf_getuint32 (const uint8_t * p)
00186 {
00187 uint32_t ret;
00188 #ifdef __AVR__
00189 __asm__ ("ld %D0,%a1\n\t"
00190 "ldd %C0,%a1+1\n\t"
00191 "ldd %B0,%a1+2\n\t"
00192 "ldd %A0,%a1+3\n\t"
00193 : "=&r"(ret)
00194 : "b"(p));
00195 #else
00196 #warning "using generic sirf_getuintxx implementation"
00197 ret = ((uint32_t)p[0] << 24) | ((uint32_t)p[1] << 16)
00198 | ((uint16_t)p[2] << 8) | (p[3]);
00199 #endif
00200 return ret;
00201 }
00202
00204 inline uint32_t sirf_getint32 (const uint8_t * p)
00205 {
00206 int32_t ret;
00207 #ifdef __AVR__
00208 __asm__ ("ld %D0,%a1\n\t"
00209 "ldd %C0,%a1+1\n\t"
00210 "ldd %B0,%a1+2\n\t"
00211 "ldd %A0,%a1+3\n\t"
00212 : "=&r"(ret)
00213 : "b"(p));
00214 #else
00215 #warning "using generic sirf_getintxx implementation"
00216 ret = ((int32_t)p[0] << 24) | ((uint32_t)p[1] << 16)
00217 | ((uint16_t)p[2] << 8) | (p[3]);
00218 #endif
00219 return ret;
00220 }
00221
00222 #endif