From b715f408f8f9b4bcbe7b3e1fbf68f593fa4d0329 Mon Sep 17 00:00:00 2001 From: Christophe De Wagter Date: Thu, 8 Sep 2011 15:54:19 +0200 Subject: [PATCH] Removed GPS_CONFIGURE + added I2C config: please use the UCENTER module now --- sw/airborne/firmwares/fixedwing/main_ap.c | 6 -- sw/airborne/modules/gps/gps_ubx_ucenter.c | 14 ++- sw/airborne/subsystems/gps/gps_ubx.c | 120 ---------------------- sw/airborne/subsystems/gps/gps_ubx.h | 51 ++------- 4 files changed, 15 insertions(+), 176 deletions(-) diff --git a/sw/airborne/firmwares/fixedwing/main_ap.c b/sw/airborne/firmwares/fixedwing/main_ap.c index 2b4dca044d..89c1e9c589 100644 --- a/sw/airborne/firmwares/fixedwing/main_ap.c +++ b/sw/airborne/firmwares/fixedwing/main_ap.c @@ -581,12 +581,6 @@ void init_ap( void ) { /** wait 0.5s (historical :-) */ sys_time_usleep(500000); -#ifdef GPS_CONFIGURE -#ifndef SITL - gps_configure_uart(); -#endif -#endif - #if defined DATALINK #if DATALINK == XBEE diff --git a/sw/airborne/modules/gps/gps_ubx_ucenter.c b/sw/airborne/modules/gps/gps_ubx_ucenter.c index 0161ec72f2..a1b0997403 100644 --- a/sw/airborne/modules/gps/gps_ubx_ucenter.c +++ b/sw/airborne/modules/gps/gps_ubx_ucenter.c @@ -197,10 +197,6 @@ static bool_t gps_ubx_ucenter_autobaud(uint8_t nr) #define _UBX_GPS_BAUD(_u) __UBX_GPS_BAUD(_u) #define UBX_GPS_BAUD _UBX_GPS_BAUD(GPS_LINK) -#if GPS_PORT_ID == GPS_PORT_UART1 || GPS_PORT_ID == GPS_PORT_UART2 -#else -#endif - #define IGNORED 0 #define RESERVED 0 @@ -238,7 +234,15 @@ static bool_t user_gps_configure(uint8_t nr) { // Use old baudrate to issue a baudrate change command gps_ubx_ucenter.reply = GPS_UBX_UCENTER_REPLY_NONE; - UbxSend_CFG_PRT(GPS_PORT_ID, 0x0, 0x0, 0x000008D0, 38400, UBX_PROTO_MASK, UBX_PROTO_MASK, 0x0, 0x0); + + // I2C Interface + #if GPS_PORT_ID == GPS_PORT_DDC + UbxSend_CFG_PRT(GPS_PORT_ID, 0x0, 0x0, GPS_I2C_SLAVE_ADDR, 0x0, UBX_PROTO_MASK, UBX_PROTO_MASK, 0x0, 0x0); + #endif + // UART Interface + #if GPS_PORT_ID == GPS_PORT_UART1 || GPS_PORT_ID == GPS_PORT_UART2 + UbxSend_CFG_PRT(GPS_PORT_ID, 0x0, 0x0, 0x000008D0, 38400, UBX_PROTO_MASK, UBX_PROTO_MASK, 0x0, 0x0); + #endif break; case 6: // Now the GPS baudrate should have changed diff --git a/sw/airborne/subsystems/gps/gps_ubx.c b/sw/airborne/subsystems/gps/gps_ubx.c index 7c4234e614..002263bfb0 100644 --- a/sw/airborne/subsystems/gps/gps_ubx.c +++ b/sw/airborne/subsystems/gps/gps_ubx.c @@ -79,20 +79,11 @@ struct GpsUbx gps_ubx; -#ifdef GPS_CONFIGURE -bool_t gps_configuring; -static uint8_t gps_status_config; -#endif - void gps_impl_init(void) { gps_ubx.status = UNINIT; gps_ubx.msg_available = FALSE; gps_ubx.error_cnt = 0; gps_ubx.error_last = GPS_UBX_ERR_NONE; -#ifdef GPS_CONFIGURE - gps_status_config = 0; - gps_configuring = TRUE; -#endif gps_ubx.have_velned = 0; } @@ -276,117 +267,6 @@ void gps_ubx_parse( uint8_t c ) { return; } - - -/* - * - * - * GPS dynamic configuration - * - * - */ -#ifdef GPS_CONFIGURE - -#define UBX_PROTO_MASK 0x0001 -#define NMEA_PROTO_MASK 0x0002 -#define RTCM_PROTO_MASK 0x0004 - -#define GPS_PORT_DDC 0x00 -#define GPS_PORT_UART1 0x01 -#define GPS_PORT_UART2 0x02 -#define GPS_PORT_USB 0x03 -#define GPS_PORT_SPI 0x04 - -#ifndef GPS_PORT_ID -#define GPS_PORT_ID GPS_PORT_UART1 -#endif - -#define __UBX_GPS_BAUD(_u) _u##_BAUD -#define _UBX_GPS_BAUD(_u) __UBX_GPS_BAUD(_u) -#define UBX_GPS_BAUD _UBX_GPS_BAUD(GPS_LINK) - -/* 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. */ -#if GPS_PORT_ID == GPS_PORT_UART1 || GPS_PORT_ID == GPS_PORT_UART2 -void gps_configure_uart(void) { -#ifdef FMS_PERIODIC_FREQ - UbxSend_CFG_PRT(GPS_PORT_ID, 0x0, 0x0, 0x000008D0, 38400, UBX_PROTO_MASK, UBX_PROTO_MASK, 0x0, 0x0); - uint8_t loop=0; - while (GpsUartRunning) { - //doesn't work unless some printfs are used, so : - if (loop<9) { - printf("."); loop++; - } else { - printf("\b"); loop--; - } - } -#else - UbxSend_CFG_PRT(GPS_PORT_ID, 0x0, 0x0, 0x000008D0, UBX_GPS_BAUD, UBX_PROTO_MASK, UBX_PROTO_MASK, 0x0, 0x0); - while (GpsUartRunning); /* FIXME */ -#endif - - GpsUartSetBaudrate(UBX_GPS_BAUD); -} -#endif - -#if GPS_PORT_ID == GPS_PORT_DDC -void gps_configure_uart(void) { - UbxSend_CFG_PRT(GPS_PORT_ID, 0x0, 0x0, GPS_I2C_SLAVE_ADDR, 0x0, UBX_PROTO_MASK, UBX_PROTO_MASK, 0x0, 0x0); -} -#endif - -#define IGNORED 0 -#define RESERVED 0 - -#ifdef USER_GPS_CONFIGURE -#include USER_GPS_CONFIGURE -#else -static bool_t user_gps_configure(bool_t cpt) { - switch (cpt) { - case 0: - //New ublox firmware v5 or higher uses CFG_NAV5 message, CFG_NAV is no longer available - //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); - UbxSend_CFG_NAV5(0x05, NAV5_DYN_AIRBORNE_2G, NAV5_3D_ONLY, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, RESERVED, RESERVED, RESERVED, RESERVED); - break; - case 1: - UbxSend_CFG_MSG(UBX_NAV_ID, UBX_NAV_POSUTM_ID, 0, 1, 0, 0); - break; - case 2: - UbxSend_CFG_MSG(UBX_NAV_ID, UBX_NAV_VELNED_ID, 0, 1, 0, 0); - break; - case 3: - UbxSend_CFG_MSG(UBX_NAV_ID, UBX_NAV_STATUS_ID, 0, 1, 0, 0); - break; - case 4: - UbxSend_CFG_MSG(UBX_NAV_ID, UBX_NAV_SVINFO_ID, 0, 4, 0, 0); - break; - case 5: - UbxSend_CFG_MSG(UBX_NAV_ID, UBX_NAV_SOL_ID, 0, 8, 0, 0); - break; - case 6: - UbxSend_CFG_SBAS(0x00, 0x00, 0x00, 0x00, 0x00); - break; - case 7: - UbxSend_CFG_RATE(0x00FA, 0x0001, 0x0000); - 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 (gps_ubx.msg_class == UBX_ACK_ID) { - if (gps_ubx.msg_id == UBX_ACK_ACK_ID) { - gps_status_config++; - } - } - gps_configuring = user_gps_configure(gps_status_config); -} -#endif /* GPS_CONFIGURE */ - #ifdef GPS_UBX_UCENTER #include GPS_UBX_UCENTER #endif diff --git a/sw/airborne/subsystems/gps/gps_ubx.h b/sw/airborne/subsystems/gps/gps_ubx.h index e31f43272c..f31e314066 100644 --- a/sw/airborne/subsystems/gps/gps_ubx.h +++ b/sw/airborne/subsystems/gps/gps_ubx.h @@ -27,6 +27,10 @@ #ifndef GPS_UBX_H #define GPS_UBX_H +#ifdef GPS_CONFIGURE +#warning "Please use gps_ubx_ucenter.xml module instead" +#endif + #include "mcu_periph/uart.h" /** Includes macros generated from ubx.xml */ @@ -66,18 +70,6 @@ extern struct GpsUbx gps_ubx; #define GpsBuffer() GpsLink(ChAvailable()) -#ifdef GPS_CONFIGURE -extern bool_t gps_configuring; -#define GpsParseOrConfigure() { \ - if (gps_configuring) \ - gps_configure(); \ - else \ - gps_ubx_read_message(); \ - } -#else -#define GpsParseOrConfigure() gps_ubx_read_message() -#endif - #ifndef GPS_UBX_UCENTER #define gps_ubx_ucenter_event() {} #endif @@ -92,8 +84,8 @@ extern bool_t gps_configuring; ReadGpsBuffer(); \ } \ if (gps_ubx.msg_available) { \ - GpsParseOrConfigure(); \ - gps_ubx_ucenter_event(); \ + gps_ubx_read_message(); \ + gps_ubx_ucenter_event(); \ if (gps_ubx.msg_class == UBX_NAV_ID && \ (gps_ubx.msg_id == UBX_NAV_VELNED_ID || \ (gps_ubx.msg_id == UBX_NAV_SOL_ID && \ @@ -139,35 +131,4 @@ extern void ubxsend_cfg_rst(uint16_t, uint8_t); } -/* - * dynamic GPS configuration - */ -#ifdef GPS_CONFIGURE -#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 - -#define NAV5_DYN_PORTABLE 0 -#define NAV5_DYN_FIXED 1 -#define NAV5_DYN_STATIONARY 2 -#define NAV5_DYN_PEDESTRIAN 3 -#define NAV5_DYN_AUTOMOTIVE 4 -#define NAV5_DYN_SEA 5 -#define NAV5_DYN_AIRBORNE_1G 6 -#define NAV5_DYN_AIRBORNE_2G 7 -#define NAV5_DYN_AIRBORNE_4G 8 - -#define NAV5_2D_ONLY 1 -#define NAV5_3D_ONLY 2 -#define NAV5_AUTO 3 - -extern void gps_configure(void); -extern void gps_configure_uart(void); -#endif - - #endif /* GPS_UBX_H */