gps configuration code open for user

This commit is contained in:
Pascal Brisset
2008-01-28 00:06:34 +00:00
parent 0803357d41
commit cb88b22e9a
4 changed files with 61 additions and 23 deletions
+28 -4
View File
@@ -55,15 +55,12 @@ extern int32_t gps_lat, gps_lon; /* 1e7 deg */
extern uint16_t gps_PDOP;
extern uint32_t gps_Pacc, gps_Sacc;
extern uint8_t gps_numSV;
extern uint8_t gps_status_config;
extern uint8_t gps_configuring;
extern uint16_t gps_reset;
extern uint16_t last_gps_msg_t; /** cputime of the last gps message */
extern bool_t gps_verbose_downlink;
#define GPS_CONFIG_INIT 0
#define GPS_CONFIG_DONE 7
void gps_init( void );
void gps_configure( void );
void parse_gps_msg( void );
@@ -122,5 +119,32 @@ extern struct svinfo gps_svinfos[GPS_NB_CHANNELS];
}
#ifdef GPS_CONFIGURE
#define GpsParseOrConfigure() { \
if (gps_configuring) \
gps_configure(); \
else \
parse_gps_msg(); \
}
#else
#define GpsParseOrConfigure() parse_gps_msg()
#endif
#define GpsEventCheckAndHandle(_callback, _verbose) { \
if (GpsBuffer()) { \
ReadGpsBuffer(); \
} \
if (gps_msg_received) { \
GpsParseOrConfigure(); \
gps_msg_received = FALSE; \
if (gps_pos_available) { \
gps_verbose_downlink = _verbose; \
UseGpsPos(_callback); \
gps_pos_available = FALSE; \
} \
} \
}
#endif /* GPS_H */
+24 -18
View File
@@ -103,30 +103,27 @@ static uint8_t ubx_msg_idx;
static uint8_t ck_a, ck_b;
uint8_t send_ck_a, send_ck_b;
uint8_t gps_status_config;
bool_t gps_configuring;
static uint8_t gps_status_config;
void gps_init( void ) {
ubx_status = UNINIT;
#ifdef GPS_CONFIGURE
gps_status_config = GPS_CONFIG_INIT;
gps_status_config = 0;
gps_configuring = TRUE;
#endif
}
#define UBX_PROTO_MASK 0x0001
#define NMEA_PROTO_MASK 0x0002
#define RTCM_PROTO_MASK 0x0004
#define NAV_DYN_AIRBORNE_1G 5
#define NAV_DYN_AIRBORNE_2G 6
#define NAV_DYN_AIRBORNE_4G 7
#ifdef GPS_CONFIGURE
/* GPS dynamic configuration */
#include "uart.h"
/* Configure the GPS baud rate using the current uart baud rate. Busy
/* Configure the GPS baud rateó< using the current uart baud rate. Busy
wait for the end of the transmit. Then, BEFORE waiting for the ACK,
change the uart rate. */
void gps_configure_uart ( void ) {
@@ -135,15 +132,11 @@ void gps_configure_uart ( void ) {
GpsUartInitParam( UART_BAUD(GPS_BAUD), UART_8N1, UART_FIFO_8);
}
/* GPS configuration. Must be called on ack message reception while
gps_status_config < GPS_CONFIG_DONE */
void gps_configure ( void ) {
if (ubx_class == UBX_ACK_ID) {
if (ubx_id == UBX_ACK_ACK_ID) {
gps_status_config++;
}
}
switch (gps_status_config) {
#ifdef USER_GPS_CONFIGURE
#include USER_GPS_CONFIGURE
#else
static bool_t user_gps_configure(bool_t cpt) {
switch (cpt) {
case 0:
UbxSend_CFG_NAV(NAV_DYN_AIRBORNE_2G, 3, 16, 24, 20, 5, 0, 0x3C, 0x3C, 0x14, 0x03E8 ,0x0000, 0x0, 0x17, 0x00FA, 0x00FA, 0x0064, 0x012C, 0x000F, 0x00, 0x00);
break;
@@ -164,8 +157,21 @@ void gps_configure ( void ) {
break;
case 6:
UbxSend_CFG_RATE(0x00FA, 0x0001, 0x0000);
break;
return FALSE;
}
return TRUE; /* Continue, except for the last case */
}
#endif // ! USER_GPS_CONFIGURE
/* GPS configuration. Must be called on ack message reception while
gps_status_config < GPS_CONFIG_DONE */
void gps_configure ( void ) {
if (ubx_class == UBX_ACK_ID) {
if (ubx_id == UBX_ACK_ACK_ID) {
gps_status_config++;
}
}
gps_configuring = user_gps_configure(gps_status_config);
}
#endif /* GPS_CONFIGURE */
+8
View File
@@ -59,6 +59,14 @@ extern void parse_ubx( uint8_t c );
#define CFG_RST_Reset_Controlled_GPS_stop 0x08
#define CFG_RST_Reset_Controlled_GPS_start 0x09
#define NAV_DYN_STATIONARY 1
#define NAV_DYN_PEDESTRIAN 2
#define NAV_DYN_AUTOMOTIVE 3
#define NAV_DYN_SEA 4
#define NAV_DYN_AIRBORNE_1G 5
#define NAV_DYN_AIRBORNE_2G 6
#define NAV_DYN_AIRBORNE_4G 7
void ubxsend_cfg_rst(uint16_t, uint8_t);
#define gps_ubx_Reset(_val) { gps_reset = _val; if (gps_reset > CFG_RST_BBR_Warmstart) gps_reset = CFG_RST_BBR_Coldstart; ubxsend_cfg_rst(gps_reset, CFG_RST_Reset_Controlled); }
+1 -1
View File
@@ -640,7 +640,7 @@ void event_task_ap( void ) {
if (gps_msg_received) {
/* parse and use GPS messages */
#ifdef GPS_CONFIGURE
if (gps_status_config < GPS_CONFIG_DONE)
if (gps_configuring)
gps_configure();
else
#endif