Exemplo n.º 1
0
bool GPS_Init(void) {
	// Initialize pins
	TRACE_INFO("GPS  > Init pins");
	palSetPadMode(PORT(GPS_RESET), PIN(GPS_RESET), PAL_MODE_OUTPUT_PUSHPULL);	// GPS reset
	palSetPadMode(PORT(GPS_EN), PIN(GPS_EN), PAL_MODE_OUTPUT_PUSHPULL);			// GPS off
	palSetPadMode(PORT(GPS_TIMEPULSE), PIN(GPS_TIMEPULSE), PAL_MODE_INPUT);		// GPS timepulse

	// Switch MOSFET
	TRACE_INFO("GPS  > Switch on");
	palSetPad(PORT(GPS_RESET), PIN(GPS_RESET));	// Pull up GPS reset
	palSetPad(PORT(GPS_EN), PIN(GPS_EN));		// Switch on GPS
	
	// Wait for GPS startup
	chThdSleepMilliseconds(3000);

	uint8_t status = 1;

	// Configure GPS
	TRACE_INFO("GPS  > Initialize GPS");
	if(gps_disable_nmea_output()) {
		TRACE_INFO("GPS  > Disable NMEA output OK");
	} else {
		TRACE_ERROR("GPS  > Disable NMEA output FAILED");
		status = 0;
	}

	#if GPS_TYPE == MAX7 || GPS_TYPE == MAX8
	// MAX6 does not support anything else than GPS
	if(gps_set_gps_only()) {
		TRACE_INFO("GPS  > Set GPS only OK");
	} else {
		TRACE_ERROR("GPS  > Set GPS only FAILED");
		status = 0;
	}
	#endif

	if(gps_set_airborne_model()) {
		TRACE_INFO("GPS  > Set airborne model OK");
	} else {
		TRACE_ERROR("GPS  > Set airborne model FAILED");
		status = 0;
	}
	if(gps_set_power_save()) {
		TRACE_INFO("GPS  > Configure power save OK");
	} else {
		TRACE_ERROR("GPS  > Configure power save FAILED");
		status = 0;
	}
	if(gps_power_save(0)) {
		TRACE_INFO("GPS  > Disable power save OK");
	} else {
		TRACE_ERROR("GPS  > Disable power save FAILED");
		status = 0;
	}

	return status;
}
Exemplo n.º 2
0
/**
 * Switches GPS on (if MOSFET switch available) and initializes
 * ublox MAX7/8 GPS receivers:
 * - Activates NMEA compactibility
 * - Switches off unnecessary NMEA sentences (only GPRMC and GPGGA are left)
 * - Activates high altitude support
 * - Configures power save mode
 * - Disables power save mode (has to be activated separately)
 */
void GPS_PowerOn(void) {
	#ifdef USE_GPS_HW_SW
	gps_hw_switch(true);					// Power up GPS
	delay(3000);							// Just to be sure GPS has booted completely
	#endif

//	gps_set_nmeaCompatibility();			// Configure compatibility mode, this must be done because the code assumes specific NMEA parameter lengths
//	delay(100);
	gps_set_gps_only();						// Switch off GLONASS, Baidoo, QZSS, Galileo
	delay(100);
	gps_configureActiveNMEASentences();		// Switch off unnecessary NMEA sentences (only GPRMC and GPGGA needed)
	delay(100);
	gps_set_airborne_model();				// Switch to airborne model (activates GPS support over 12km altitude)
	delay(100);
	gps_configure_power_save();				// Configure power save mode
	delay(100);
	gps_disable_power_save();				// Switch off power save mode

	isOn = true;
}