/** * Initialise the gps module * \return -1 if initialisation failed * \return 0 on success */ int32_t GPSInitialize(void) { gpsPort = PIOS_COM_GPS; uint8_t gpsProtocol; #ifdef MODULE_GPS_BUILTIN module_enabled = true; #else uint8_t module_state[MODULESETTINGS_ADMINSTATE_NUMELEM]; ModuleSettingsAdminStateGet(module_state); if (module_state[MODULESETTINGS_ADMINSTATE_GPS] == MODULESETTINGS_ADMINSTATE_ENABLED) { module_enabled = true; } else { module_enabled = false; } #endif // These things are only conditional on small F1 targets. // Expected to be always present otherwise. #ifdef SMALLF1 if (gpsPort && module_enabled) { #endif GPSPositionInitialize(); GPSVelocityInitialize(); #if !defined(PIOS_GPS_MINIMAL) GPSTimeInitialize(); GPSSatellitesInitialize(); HomeLocationInitialize(); UBloxInfoInitialize(); #endif #if defined(PIOS_GPS_PROVIDES_AIRSPEED) AirspeedActualInitialize(); #endif updateSettings(); #ifdef SMALLF1 } #endif if (gpsPort && module_enabled) { ModuleSettingsGPSDataProtocolGet(&gpsProtocol); switch (gpsProtocol) { case MODULESETTINGS_GPSDATAPROTOCOL_NMEA: gps_rx_buffer = PIOS_malloc(NMEA_MAX_PACKET_LENGTH); break; case MODULESETTINGS_GPSDATAPROTOCOL_UBX: gps_rx_buffer = PIOS_malloc(sizeof(struct UBXPacket)); break; default: gps_rx_buffer = NULL; } PIOS_Assert(gps_rx_buffer); return 0; } return -1; }
/** * Initialise the gps module * \return -1 if initialisation failed * \return 0 on success */ int32_t GPSInitialize(void) { GPSPositionInitialize(); GPSTimeInitialize(); GPSSatellitesInitialize(); #ifdef PIOS_GPS_SETS_HOMELOCATION HomeLocationInitialize(); #endif // TODO: Get gps settings object gpsPort = PIOS_COM_GPS; return 0; }
/** * Function used to initialize the first instance of each object. * This file is automatically updated by the UAVObjectGenerator. */ void UAVObjectsInitializeAll() { ActuatorCommandInitialize(); ActuatorDesiredInitialize(); ActuatorSettingsInitialize(); AHRSCalibrationInitialize(); AHRSSettingsInitialize(); AhrsStatusInitialize(); AttitudeActualInitialize(); AttitudeDesiredInitialize(); AttitudeRawInitialize(); AttitudeSettingsInitialize(); BaroAltitudeInitialize(); ExampleObject1Initialize(); ExampleObject2Initialize(); ExampleSettingsInitialize(); FlightBatteryStateInitialize(); FlightTelemetryStatsInitialize(); GCSTelemetryStatsInitialize(); GPSPositionInitialize(); GPSSatellitesInitialize(); GPSTimeInitialize(); HomeLocationInitialize(); ManualControlCommandInitialize(); ManualControlSettingsInitialize(); MixerSettingsInitialize(); MixerStatusInitialize(); ObjectPersistenceInitialize(); PositionActualInitialize(); StabilizationSettingsInitialize(); SystemAlarmsInitialize(); SystemSettingsInitialize(); SystemStatsInitialize(); TelemetrySettingsInitialize(); VTOLSettingsInitialize(); VTOLStatusInitialize(); }
/** * Initialise the gps module * \return -1 if initialisation failed * \return 0 on success */ int32_t GPSInitialize(void) { gpsPort = PIOS_COM_GPS; uint8_t gpsProtocol; #ifdef MODULE_GPS_BUILTIN module_enabled = true; #else uint8_t module_state[MODULESETTINGS_ADMINSTATE_NUMELEM]; ModuleSettingsAdminStateGet(module_state); if (module_state[MODULESETTINGS_ADMINSTATE_GPS] == MODULESETTINGS_ADMINSTATE_ENABLED) { module_enabled = true; } else { module_enabled = false; } #endif #if defined(REVOLUTION) // These objects MUST be initialized for Revolution // because the rest of the system expects to just // attach to their queues GPSPositionInitialize(); GPSVelocityInitialize(); GPSTimeInitialize(); GPSSatellitesInitialize(); HomeLocationInitialize(); UBloxInfoInitialize(); updateSettings(); #else if (gpsPort && module_enabled) { GPSPositionInitialize(); GPSVelocityInitialize(); #if !defined(PIOS_GPS_MINIMAL) GPSTimeInitialize(); GPSSatellitesInitialize(); #endif #if defined(PIOS_GPS_PROVIDES_AIRSPEED) AirspeedActualInitialize(); #endif updateSettings(); } #endif if (gpsPort && module_enabled) { ModuleSettingsGPSDataProtocolGet(&gpsProtocol); switch (gpsProtocol) { case MODULESETTINGS_GPSDATAPROTOCOL_NMEA: gps_rx_buffer = pvPortMalloc(NMEA_MAX_PACKET_LENGTH); break; case MODULESETTINGS_GPSDATAPROTOCOL_UBX: gps_rx_buffer = pvPortMalloc(sizeof(struct UBXPacket)); break; default: gps_rx_buffer = NULL; } PIOS_Assert(gps_rx_buffer); return 0; } return -1; }