new Xadow GPS module

Dependents:   xadow_smartstrap_for_pebble Avnet_ATT_Cellular_IOT Xadow-M0_Xadow-OLED_Accelerometer

Committer:
KillingJacky
Date:
Thu Nov 05 04:03:05 2015 +0000
Revision:
2:cf4d22190de4
Parent:
1:97f0865ea131
added satellite in view function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
KillingJacky 0:0cbe7e15999a 1 /**
KillingJacky 0:0cbe7e15999a 2 * \file xadow_gps.h
KillingJacky 0:0cbe7e15999a 3 * \brief Module to handle GPS message interface of Xadow kit
KillingJacky 0:0cbe7e15999a 4 */
KillingJacky 0:0cbe7e15999a 5
KillingJacky 0:0cbe7e15999a 6 #ifndef _XADOW_GPS_H_
KillingJacky 0:0cbe7e15999a 7 #define _XADOW_GPS_H_
KillingJacky 0:0cbe7e15999a 8
KillingJacky 0:0cbe7e15999a 9 #include "mbed.h"
KillingJacky 0:0cbe7e15999a 10
KillingJacky 0:0cbe7e15999a 11 /*!
KillingJacky 0:0cbe7e15999a 12 \def GPS_DEVICE_ADDR
KillingJacky 0:0cbe7e15999a 13 The I2C address GPS
KillingJacky 0:0cbe7e15999a 14
KillingJacky 0:0cbe7e15999a 15 \def GPS_SCAN_ID
KillingJacky 0:0cbe7e15999a 16 The id of scan data, the format is 0,0,0,Device address
KillingJacky 0:0cbe7e15999a 17 \def GPS_SCAN_SIZE
KillingJacky 0:0cbe7e15999a 18 The length of scan data
KillingJacky 0:0cbe7e15999a 19
KillingJacky 0:0cbe7e15999a 20 \def GPS_UTC_DATE_TIME_ID
KillingJacky 0:0cbe7e15999a 21 The id of utc date and time, the format is YMDHMS
KillingJacky 0:0cbe7e15999a 22 \def GPS_UTC_DATE_TIME_SIZE
KillingJacky 0:0cbe7e15999a 23 The length of utc date and time data
KillingJacky 0:0cbe7e15999a 24
KillingJacky 0:0cbe7e15999a 25 \def GPS_STATUS_ID
KillingJacky 0:0cbe7e15999a 26 The id of GPS status, the format is A/V
KillingJacky 0:0cbe7e15999a 27 \def GPS_STATUS_SIZE
KillingJacky 0:0cbe7e15999a 28 The length of GPS status data
KillingJacky 0:0cbe7e15999a 29
KillingJacky 0:0cbe7e15999a 30 \def GPS_LATITUDE_ID
KillingJacky 0:0cbe7e15999a 31 The id of latitude, the format is dd.dddddd
KillingJacky 0:0cbe7e15999a 32 \def GPS_LATITUDE_SIZE
KillingJacky 0:0cbe7e15999a 33 The length of latitude data
KillingJacky 0:0cbe7e15999a 34
KillingJacky 0:0cbe7e15999a 35 \def GPS_NS_ID
KillingJacky 0:0cbe7e15999a 36 The id of latitude direction, the format is N/S
KillingJacky 0:0cbe7e15999a 37 \def GPS_NS_SIZE
KillingJacky 0:0cbe7e15999a 38 The length of latitude direction data
KillingJacky 0:0cbe7e15999a 39
KillingJacky 0:0cbe7e15999a 40 \def GPS_LONGITUDE_ID
KillingJacky 0:0cbe7e15999a 41 The id of longitude, the format is ddd.dddddd
KillingJacky 0:0cbe7e15999a 42 \def GPS_LONGITUDE_SIZE
KillingJacky 0:0cbe7e15999a 43 The length of longitude data
KillingJacky 0:0cbe7e15999a 44
KillingJacky 0:0cbe7e15999a 45 \def GPS_EW_ID
KillingJacky 0:0cbe7e15999a 46 The id of longitude direction, the format is E/W
KillingJacky 0:0cbe7e15999a 47 \def GPS_EW_SIZE
KillingJacky 0:0cbe7e15999a 48 The length of longitude direction data
KillingJacky 0:0cbe7e15999a 49
KillingJacky 0:0cbe7e15999a 50 \def GPS_SPEED_ID
KillingJacky 0:0cbe7e15999a 51 The id of speed, the format is 000.0~999.9 Knots
KillingJacky 0:0cbe7e15999a 52 \def GPS_SPEED_SIZE
KillingJacky 0:0cbe7e15999a 53 The length of speed data
KillingJacky 0:0cbe7e15999a 54
KillingJacky 0:0cbe7e15999a 55 \def GPS_COURSE_ID
KillingJacky 0:0cbe7e15999a 56 The id of course, the format is 000.0~359.9
KillingJacky 0:0cbe7e15999a 57 \def GPS_COURSE_SIZE
KillingJacky 0:0cbe7e15999a 58 The length of course data
KillingJacky 0:0cbe7e15999a 59
KillingJacky 0:0cbe7e15999a 60 \def GPS_POSITION_FIX_ID
KillingJacky 0:0cbe7e15999a 61 The id of position fix status, the format is 0,1,2,6
KillingJacky 0:0cbe7e15999a 62 \def GPS_POSITION_FIX_SIZE
KillingJacky 0:0cbe7e15999a 63 The length of position fix status data
KillingJacky 0:0cbe7e15999a 64
KillingJacky 0:0cbe7e15999a 65 \def GPS_SATE_USED_ID
KillingJacky 0:0cbe7e15999a 66 The id of state used, the format is 00~12
KillingJacky 0:0cbe7e15999a 67 \def GPS_SATE_USED_SIZE
KillingJacky 0:0cbe7e15999a 68 The length of sate used data
KillingJacky 0:0cbe7e15999a 69
KillingJacky 0:0cbe7e15999a 70 \def GPS_ALTITUDE_ID
KillingJacky 0:0cbe7e15999a 71 The id of altitude, the format is -9999.9~99999.9
KillingJacky 0:0cbe7e15999a 72 \def GPS_ALTITUDE_SIZE
KillingJacky 0:0cbe7e15999a 73 The length of altitude data
KillingJacky 0:0cbe7e15999a 74
KillingJacky 0:0cbe7e15999a 75 \def GPS_MODE_ID
KillingJacky 0:0cbe7e15999a 76 The id of locate mode, the format is A/M
KillingJacky 0:0cbe7e15999a 77 \def GPS_MODE_SIZE
KillingJacky 0:0cbe7e15999a 78 The length of locate mode data
KillingJacky 0:0cbe7e15999a 79
KillingJacky 0:0cbe7e15999a 80 \def GPS_MODE2_ID
KillingJacky 0:0cbe7e15999a 81 The id of current status, the format is 1,2,3
KillingJacky 0:0cbe7e15999a 82 \def GPS_MODE2_SIZE
KillingJacky 0:0cbe7e15999a 83 The length of current status data
KillingJacky 0:0cbe7e15999a 84 */
KillingJacky 0:0cbe7e15999a 85
KillingJacky 0:0cbe7e15999a 86 /* Data format:
KillingJacky 0:0cbe7e15999a 87 * Data_id(1 byte), Data_length(1 byte), Data 1, Data 2, ... Data n (n bytes, n = data length)
KillingJacky 0:0cbe7e15999a 88 * For example, get the scan data.
KillingJacky 0:0cbe7e15999a 89 * First, Send GPS_SCAN_ID(1 byte) to device.
KillingJacky 0:0cbe7e15999a 90 * Second, Receive scan data(Data_id + Data_length + GPS_SCAN_SIZE = 6 bytes).
KillingJacky 0:0cbe7e15999a 91 * Third, The scan data begin from the third data of received.
KillingJacky 0:0cbe7e15999a 92 * End
KillingJacky 0:0cbe7e15999a 93 */
KillingJacky 0:0cbe7e15999a 94
KillingJacky 1:97f0865ea131 95 #define GPS_DEVICE_ADDR (0x05<<1)
KillingJacky 0:0cbe7e15999a 96
KillingJacky 0:0cbe7e15999a 97 #define GPS_SCAN_ID 0 // 4 bytes
KillingJacky 0:0cbe7e15999a 98 #define GPS_SCAN_SIZE 4 // 0,0,0,Device address
KillingJacky 0:0cbe7e15999a 99
KillingJacky 0:0cbe7e15999a 100 #define GPS_UTC_DATE_TIME_ID 1 // YMDHMS
KillingJacky 0:0cbe7e15999a 101 #define GPS_UTC_DATE_TIME_SIZE 6 // 6 bytes
KillingJacky 0:0cbe7e15999a 102
KillingJacky 0:0cbe7e15999a 103 #define GPS_STATUS_ID 2 // A/V
KillingJacky 0:0cbe7e15999a 104 #define GPS_STATUS_SIZE 1 // 1 byte
KillingJacky 0:0cbe7e15999a 105
KillingJacky 0:0cbe7e15999a 106 #define GPS_LATITUDE_ID 3 // dd.dddddd
KillingJacky 0:0cbe7e15999a 107 #define GPS_LATITUDE_SIZE 9 // 9 bytes
KillingJacky 0:0cbe7e15999a 108
KillingJacky 0:0cbe7e15999a 109 #define GPS_NS_ID 4 // N/S
KillingJacky 0:0cbe7e15999a 110 #define GPS_NS_SIZE 1 // 1 byte
KillingJacky 0:0cbe7e15999a 111
KillingJacky 0:0cbe7e15999a 112 #define GPS_LONGITUDE_ID 5 // ddd.dddddd
KillingJacky 0:0cbe7e15999a 113 #define GPS_LONGITUDE_SIZE 10 // 10 bytes
KillingJacky 0:0cbe7e15999a 114
KillingJacky 0:0cbe7e15999a 115 #define GPS_EW_ID 6 // E/W
KillingJacky 0:0cbe7e15999a 116 #define GPS_EW_SIZE 1 // 1 byte
KillingJacky 0:0cbe7e15999a 117
KillingJacky 0:0cbe7e15999a 118 #define GPS_SPEED_ID 7 // 000.0~999.9 Knots
KillingJacky 0:0cbe7e15999a 119 #define GPS_SPEED_SIZE 5 // 5 bytes
KillingJacky 0:0cbe7e15999a 120
KillingJacky 0:0cbe7e15999a 121 #define GPS_COURSE_ID 8 // 000.0~359.9
KillingJacky 0:0cbe7e15999a 122 #define GPS_COURSE_SIZE 5 // 5 bytes
KillingJacky 0:0cbe7e15999a 123
KillingJacky 0:0cbe7e15999a 124 #define GPS_POSITION_FIX_ID 9 // 0,1,2,6
KillingJacky 0:0cbe7e15999a 125 #define GPS_POSITION_FIX_SIZE 1 // 1 byte
KillingJacky 0:0cbe7e15999a 126
KillingJacky 0:0cbe7e15999a 127 #define GPS_SATE_USED_ID 10 // 00~12
KillingJacky 0:0cbe7e15999a 128 #define GPS_SATE_USED_SIZE 2 // 2 bytes
KillingJacky 0:0cbe7e15999a 129
KillingJacky 0:0cbe7e15999a 130 #define GPS_ALTITUDE_ID 11 // -9999.9~99999.9
KillingJacky 0:0cbe7e15999a 131 #define GPS_ALTITUDE_SIZE 7 // 7 bytes
KillingJacky 0:0cbe7e15999a 132
KillingJacky 0:0cbe7e15999a 133 #define GPS_MODE_ID 12 // A/M
KillingJacky 0:0cbe7e15999a 134 #define GPS_MODE_SIZE 1 // 1 byte
KillingJacky 0:0cbe7e15999a 135
KillingJacky 0:0cbe7e15999a 136 #define GPS_MODE2_ID 13 // 1,2,3
KillingJacky 0:0cbe7e15999a 137 #define GPS_MODE2_SIZE 1 // 1 byte
KillingJacky 0:0cbe7e15999a 138
KillingJacky 2:cf4d22190de4 139 #define GPS_SATE_IN_VIEW_ID 14 // 0~12
KillingJacky 2:cf4d22190de4 140 #define GPS_SATE_IN_VIEW_SIZE 1 // 1 byte
KillingJacky 2:cf4d22190de4 141
KillingJacky 0:0cbe7e15999a 142
KillingJacky 0:0cbe7e15999a 143 /**
KillingJacky 0:0cbe7e15999a 144 * \brief Get the status of the device.
KillingJacky 0:0cbe7e15999a 145 *
KillingJacky 0:0cbe7e15999a 146 * \return Return TRUE or FALSE. TRUE is on line, FALSE is off line.
KillingJacky 0:0cbe7e15999a 147 *
KillingJacky 0:0cbe7e15999a 148 */
KillingJacky 0:0cbe7e15999a 149 unsigned char gps_check_online(void);
KillingJacky 0:0cbe7e15999a 150
KillingJacky 0:0cbe7e15999a 151 /**
KillingJacky 0:0cbe7e15999a 152 * \brief Get the utc date and time.
KillingJacky 0:0cbe7e15999a 153 *
KillingJacky 0:0cbe7e15999a 154 * \return Return the pointer of utc date sand time, the format is YMDHMS.
KillingJacky 0:0cbe7e15999a 155 *
KillingJacky 0:0cbe7e15999a 156 */
KillingJacky 0:0cbe7e15999a 157 unsigned char* gps_get_utc_date_time(void);
KillingJacky 0:0cbe7e15999a 158
KillingJacky 0:0cbe7e15999a 159 /**
KillingJacky 0:0cbe7e15999a 160 * \brief Get the status of GPS.
KillingJacky 0:0cbe7e15999a 161 *
KillingJacky 0:0cbe7e15999a 162 * \return Return A or V. A is orientation, V is navigation.
KillingJacky 0:0cbe7e15999a 163 *
KillingJacky 0:0cbe7e15999a 164 */
KillingJacky 0:0cbe7e15999a 165 unsigned char gps_get_status(void);
KillingJacky 0:0cbe7e15999a 166
KillingJacky 0:0cbe7e15999a 167 /**
KillingJacky 1:97f0865ea131 168 * \brief Get the latitude.
KillingJacky 0:0cbe7e15999a 169 *
KillingJacky 1:97f0865ea131 170 * \return Return latitude data. The format is dd.dddddd.
KillingJacky 0:0cbe7e15999a 171 *
KillingJacky 0:0cbe7e15999a 172 */
KillingJacky 0:0cbe7e15999a 173 float gps_get_latitude(void);
KillingJacky 0:0cbe7e15999a 174
KillingJacky 0:0cbe7e15999a 175 /**
KillingJacky 1:97f0865ea131 176 * \brief Get the latitude direction.
KillingJacky 0:0cbe7e15999a 177 *
KillingJacky 1:97f0865ea131 178 * \return Return latitude direction data. The format is N/S. N is north, S is south.
KillingJacky 0:0cbe7e15999a 179 *
KillingJacky 0:0cbe7e15999a 180 */
KillingJacky 0:0cbe7e15999a 181 unsigned char gps_get_ns(void);
KillingJacky 0:0cbe7e15999a 182
KillingJacky 0:0cbe7e15999a 183 /**
KillingJacky 0:0cbe7e15999a 184 * \brief Get the longitude.
KillingJacky 0:0cbe7e15999a 185 *
KillingJacky 0:0cbe7e15999a 186 * \return Return longitude data. The format is ddd.dddddd.
KillingJacky 0:0cbe7e15999a 187 *
KillingJacky 0:0cbe7e15999a 188 */
KillingJacky 0:0cbe7e15999a 189 float gps_get_longitude(void);
KillingJacky 0:0cbe7e15999a 190
KillingJacky 0:0cbe7e15999a 191 /**
KillingJacky 0:0cbe7e15999a 192 * \brief Get the longitude direction.
KillingJacky 0:0cbe7e15999a 193 *
KillingJacky 0:0cbe7e15999a 194 * \return Return longitude direction data. The format is E/W. E is east, W is west.
KillingJacky 0:0cbe7e15999a 195 *
KillingJacky 0:0cbe7e15999a 196 */
KillingJacky 0:0cbe7e15999a 197 unsigned char gps_get_ew(void);
KillingJacky 0:0cbe7e15999a 198
KillingJacky 0:0cbe7e15999a 199 /**
KillingJacky 0:0cbe7e15999a 200 * \brief Get the speed.
KillingJacky 0:0cbe7e15999a 201 *
KillingJacky 0:0cbe7e15999a 202 * \return Return speed data. The format is 000.0~999.9 Knots.
KillingJacky 0:0cbe7e15999a 203 *
KillingJacky 0:0cbe7e15999a 204 */
KillingJacky 0:0cbe7e15999a 205 float gps_get_speed(void);
KillingJacky 0:0cbe7e15999a 206
KillingJacky 0:0cbe7e15999a 207 /**
KillingJacky 0:0cbe7e15999a 208 * \brief Get the course.
KillingJacky 0:0cbe7e15999a 209 *
KillingJacky 0:0cbe7e15999a 210 * \return Return course data. The format is 000.0~359.9.
KillingJacky 0:0cbe7e15999a 211 *
KillingJacky 0:0cbe7e15999a 212 */
KillingJacky 0:0cbe7e15999a 213 float gps_get_course(void);
KillingJacky 0:0cbe7e15999a 214
KillingJacky 0:0cbe7e15999a 215 /**
KillingJacky 0:0cbe7e15999a 216 * \brief Get the status of position fix.
KillingJacky 0:0cbe7e15999a 217 *
KillingJacky 1:97f0865ea131 218 * \return Return the status of position fix. The format is 0,1,2,6.
KillingJacky 1:97f0865ea131 219 * 0 - Invalid, 1 - GPS fix, 2 - DGPS fix, 6 - evaluation
KillingJacky 0:0cbe7e15999a 220 *
KillingJacky 0:0cbe7e15999a 221 */
KillingJacky 0:0cbe7e15999a 222 unsigned char gps_get_position_fix(void);
KillingJacky 0:0cbe7e15999a 223
KillingJacky 0:0cbe7e15999a 224 /**
KillingJacky 0:0cbe7e15999a 225 * \brief Get the number of state used.
KillingJacky 0:0cbe7e15999a 226 *
KillingJacky 0:0cbe7e15999a 227 * \return Return number of state used. The format is 0-12.
KillingJacky 0:0cbe7e15999a 228 *
KillingJacky 0:0cbe7e15999a 229 */
KillingJacky 0:0cbe7e15999a 230 unsigned char gps_get_sate_used(void);
KillingJacky 0:0cbe7e15999a 231
KillingJacky 0:0cbe7e15999a 232 /**
KillingJacky 0:0cbe7e15999a 233 * \brief Get the altitude. the format is -9999.9~99999.9
KillingJacky 0:0cbe7e15999a 234 *
KillingJacky 0:0cbe7e15999a 235 * \return Return altitude data. The format is -9999.9~99999.9.
KillingJacky 0:0cbe7e15999a 236 *
KillingJacky 0:0cbe7e15999a 237 */
KillingJacky 0:0cbe7e15999a 238 float gps_get_altitude(void);
KillingJacky 0:0cbe7e15999a 239
KillingJacky 0:0cbe7e15999a 240 /**
KillingJacky 0:0cbe7e15999a 241 * \brief Get the mode of location.
KillingJacky 0:0cbe7e15999a 242 *
KillingJacky 0:0cbe7e15999a 243 * \return Return mode of location. The format is A/M. A:automatic, M:manual.
KillingJacky 0:0cbe7e15999a 244 *
KillingJacky 0:0cbe7e15999a 245 */
KillingJacky 1:97f0865ea131 246 char gps_get_mode(void);
KillingJacky 0:0cbe7e15999a 247
KillingJacky 0:0cbe7e15999a 248 /**
KillingJacky 0:0cbe7e15999a 249 * \brief Get the current status of GPS.
KillingJacky 0:0cbe7e15999a 250 *
KillingJacky 0:0cbe7e15999a 251 * \return Return current status. The format is 1,2,3. 1:null, 2:2D, 3:3D.
KillingJacky 0:0cbe7e15999a 252 *
KillingJacky 0:0cbe7e15999a 253 */
KillingJacky 0:0cbe7e15999a 254 unsigned char gps_get_mode2(void);
KillingJacky 0:0cbe7e15999a 255
KillingJacky 2:cf4d22190de4 256 /**
KillingJacky 2:cf4d22190de4 257 * \brief Get the number of sate in view.
KillingJacky 2:cf4d22190de4 258 *
KillingJacky 2:cf4d22190de4 259 * \return Return the number of sate in view.
KillingJacky 2:cf4d22190de4 260 *
KillingJacky 2:cf4d22190de4 261 */
KillingJacky 2:cf4d22190de4 262 unsigned char gps_get_sate_in_veiw(void);
KillingJacky 2:cf4d22190de4 263
KillingJacky 0:0cbe7e15999a 264
KillingJacky 0:0cbe7e15999a 265 #endif