1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-14 06:29:18 +01:00

LP-580 Change PIOS_INCLUDE_HMC5X83 to PIOS_INCLUDE_SENSORS_AUXMAG where it applies to general auxmag support.

This commit is contained in:
Vladimir Zidar 2018-02-23 13:16:20 +01:00
parent f0ebe8f780
commit f64a1ba822
7 changed files with 22 additions and 24 deletions

View File

@ -51,6 +51,9 @@
#include "NMEA.h" #include "NMEA.h"
#include "UBX.h" #include "UBX.h"
#include "DJI.h" #include "DJI.h"
#ifdef PIOS_INCLUDE_SENSORS_AUXMAG
#include "sensors.h"
#endif
#if defined(PIOS_INCLUDE_GPS_UBX_PARSER) && !defined(PIOS_GPS_MINIMAL) #if defined(PIOS_INCLUDE_GPS_UBX_PARSER) && !defined(PIOS_GPS_MINIMAL)
#include "inc/ubx_autoconfig.h" #include "inc/ubx_autoconfig.h"
#define FULL_UBX_PARSER #define FULL_UBX_PARSER
@ -72,7 +75,7 @@ PERF_DEFINE_COUNTER(counterParse);
#if defined(ANY_GPS_PARSER) && !defined(PIOS_GPS_MINIMAL) #if defined(ANY_GPS_PARSER) && !defined(PIOS_GPS_MINIMAL)
#define ANY_FULL_GPS_PARSER #define ANY_FULL_GPS_PARSER
#endif #endif
#if (defined(PIOS_INCLUDE_HMC5X83) || defined(PIOS_INCLUDE_GPS_UBX_PARSER) || defined(PIOS_INCLUDE_GPS_DJI_PARSER)) && !defined(PIOS_GPS_MINIMAL) #if (defined(PIOS_INCLUDE_SENSORS_AUXMAG) || defined(PIOS_INCLUDE_GPS_UBX_PARSER) || defined(PIOS_INCLUDE_GPS_DJI_PARSER)) && !defined(PIOS_GPS_MINIMAL)
#define ANY_FULL_MAG_PARSER #define ANY_FULL_MAG_PARSER
#endif #endif
@ -653,8 +656,8 @@ void AuxMagSettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
#if defined(PIOS_INCLUDE_GPS_DJI_PARSER) #if defined(PIOS_INCLUDE_GPS_DJI_PARSER)
dji_load_mag_settings(); dji_load_mag_settings();
#endif #endif
#if defined(PIOS_INCLUDE_HMC5X83) #if defined(PIOS_INCLUDE_SENSORS_AUXMAG)
aux_hmc5x83_load_mag_settings(); sensors_auxmag_load_mag_settings();
#endif #endif
} }
#endif /* defined(ANY_FULL_MAG_PARSER) */ #endif /* defined(ANY_FULL_MAG_PARSER) */

View File

@ -677,6 +677,5 @@ uint32_t parse_ubx_message(struct UBXPacket *, GPSPositionSensorData *);
int parse_ubx_stream(uint8_t *rx, uint16_t len, char *, GPSPositionSensorData *, struct GPS_RX_STATS *); int parse_ubx_stream(uint8_t *rx, uint16_t len, char *, GPSPositionSensorData *, struct GPS_RX_STATS *);
void op_gpsv9_load_mag_settings(); void op_gpsv9_load_mag_settings();
void aux_hmc5x83_load_mag_settings();
#endif /* UBX_H */ #endif /* UBX_H */

View File

@ -34,5 +34,6 @@
#include "openpilot.h" #include "openpilot.h"
int32_t SensorsInitialize(void); int32_t SensorsInitialize(void);
void sensors_auxmag_load_mag_settings(void);
#endif // SENSORS_H #endif // SENSORS_H

View File

@ -71,6 +71,7 @@
#include <CoordinateConversions.h> #include <CoordinateConversions.h>
#include <pios_board_info.h> #include <pios_board_info.h>
#include <string.h> #include <string.h>
#include "sensors.h"
// Private constants // Private constants
#define STACK_SIZE_BYTES 1000 #define STACK_SIZE_BYTES 1000
@ -131,10 +132,6 @@ PERF_DEFINE_COUNTER(counterBaroPeriod);
PERF_DEFINE_COUNTER(counterSensorPeriod); PERF_DEFINE_COUNTER(counterSensorPeriod);
PERF_DEFINE_COUNTER(counterSensorResets); PERF_DEFINE_COUNTER(counterSensorResets);
#if defined(PIOS_INCLUDE_HMC5X83)
void aux_hmc5x83_load_settings();
#endif
// Private functions // Private functions
static void SensorsTask(void *parameters); static void SensorsTask(void *parameters);
static void settingsUpdatedCb(UAVObjEvent *objEv); static void settingsUpdatedCb(UAVObjEvent *objEv);
@ -148,7 +145,7 @@ static void clearContext(sensor_fetch_context *sensor_context);
static void handleAccel(float *samples, float temperature); static void handleAccel(float *samples, float temperature);
static void handleGyro(float *samples, float temperature, uint32_t timestamp); static void handleGyro(float *samples, float temperature, uint32_t timestamp);
static void handleMag(float *samples, float temperature); static void handleMag(float *samples, float temperature);
#if defined(PIOS_INCLUDE_HMC5X83) #if defined(PIOS_INCLUDE_SENSORS_AUXMAG)
static void handleAuxMag(float *samples); static void handleAuxMag(float *samples);
#endif #endif
static void handleBaro(float sample, float temperature); static void handleBaro(float sample, float temperature);
@ -193,7 +190,7 @@ static float baro_temp_bias = 0;
static float baro_temperature = NAN; static float baro_temperature = NAN;
static uint8_t baro_temp_calibration_count = 0; static uint8_t baro_temp_calibration_count = 0;
#if defined(PIOS_INCLUDE_HMC5X83) #if defined(PIOS_INCLUDE_SENSORS_AUXMAG)
// Allow AuxMag to be disabled without reboot // Allow AuxMag to be disabled without reboot
// because the other mags are that way // because the other mags are that way
static bool useAuxMag = false; static bool useAuxMag = false;
@ -211,7 +208,7 @@ int32_t SensorsInitialize(void)
MagSensorInitialize(); MagSensorInitialize();
BaroSensorInitialize(); BaroSensorInitialize();
#if defined(PIOS_INCLUDE_HMC5X83) #if defined(PIOS_INCLUDE_SENSORS_AUXMAG)
// for auxmagsupport.c helpers // for auxmagsupport.c helpers
AuxMagSensorInitialize(); AuxMagSensorInitialize();
#endif #endif
@ -388,7 +385,7 @@ static void processSamples3d(sensor_fetch_context *sensor_context, const PIOS_SE
float inv_count = 1.0f / (float)sensor_context->count; float inv_count = 1.0f / (float)sensor_context->count;
if ((sensor->type & PIOS_SENSORS_TYPE_3AXIS_ACCEL) if ((sensor->type & PIOS_SENSORS_TYPE_3AXIS_ACCEL)
|| (sensor->type == PIOS_SENSORS_TYPE_3AXIS_MAG) || (sensor->type == PIOS_SENSORS_TYPE_3AXIS_MAG)
#if defined(PIOS_INCLUDE_HMC5X83) #if defined(PIOS_INCLUDE_SENSORS_AUXMAG)
|| (sensor->type == PIOS_SENSORS_TYPE_3AXIS_AUXMAG) || (sensor->type == PIOS_SENSORS_TYPE_3AXIS_AUXMAG)
#endif #endif
) { ) {
@ -403,7 +400,7 @@ static void processSamples3d(sensor_fetch_context *sensor_context, const PIOS_SE
PERF_MEASURE_PERIOD(counterMagPeriod); PERF_MEASURE_PERIOD(counterMagPeriod);
return; return;
#if defined(PIOS_INCLUDE_HMC5X83) #if defined(PIOS_INCLUDE_SENSORS_AUXMAG)
case PIOS_SENSORS_TYPE_3AXIS_AUXMAG: case PIOS_SENSORS_TYPE_3AXIS_AUXMAG:
handleAuxMag(samples); handleAuxMag(samples);
PERF_MEASURE_PERIOD(counterMagPeriod); PERF_MEASURE_PERIOD(counterMagPeriod);
@ -502,7 +499,7 @@ static void handleMag(float *samples, float temperature)
MagSensorSet(&mag); MagSensorSet(&mag);
} }
#if defined(PIOS_INCLUDE_HMC5X83) #if defined(PIOS_INCLUDE_SENSORS_AUXMAG)
static void handleAuxMag(float *samples) static void handleAuxMag(float *samples)
{ {
if (useAuxMag) { if (useAuxMag) {
@ -641,8 +638,8 @@ static void settingsUpdatedCb(__attribute__((unused)) UAVObjEvent *objEv)
fabsf(baroCorrection.d) > 1e-9f)); fabsf(baroCorrection.d) > 1e-9f));
} }
#if defined(PIOS_INCLUDE_HMC5X83) #if defined(PIOS_INCLUDE_SENSORS_AUXMAG)
void aux_hmc5x83_load_mag_settings() void sensors_auxmag_load_mag_settings()
{ {
uint8_t magType = auxmagsupport_get_type(); uint8_t magType = auxmagsupport_get_type();

View File

@ -228,16 +228,10 @@ static filterResult complementaryFilter(struct data *this, float gyro[3], float
// During initialization and // During initialization and
if (this->first_run) { if (this->first_run) {
#if defined(PIOS_INCLUDE_HMC5X83)
// wait until mags have been updated // wait until mags have been updated
if (!this->magUpdated && this->useMag) { if (!this->magUpdated && this->useMag) {
return FILTERRESULT_ERROR; return FILTERRESULT_ERROR;
} }
#else
mag[0] = 100.0f;
mag[1] = 0.0f;
mag[2] = 0.0f;
#endif
pseudo_windowed_variance_init(&this->gyro_var[0], VARIANCE_WINDOW_SIZE); pseudo_windowed_variance_init(&this->gyro_var[0], VARIANCE_WINDOW_SIZE);
pseudo_windowed_variance_init(&this->gyro_var[1], VARIANCE_WINDOW_SIZE); pseudo_windowed_variance_init(&this->gyro_var[1], VARIANCE_WINDOW_SIZE);

View File

@ -150,7 +150,7 @@ void PIOS_BOARD_Sensors_Configure()
# endif /* PIOS_INCLUDE_HMC5X83_INTERNAL */ # endif /* PIOS_INCLUDE_HMC5X83_INTERNAL */
# if defined(PIOS_INCLUDE_HMC5X83) || defined(PIOS_INCLUDE_QMC5883L) # ifdef PIOS_INCLUDE_SENSORS_AUXMAG
AuxMagSettingsInitialize(); AuxMagSettingsInitialize();
AuxMagSettingsTypeOptions option; AuxMagSettingsTypeOptions option;
@ -197,7 +197,7 @@ void PIOS_BOARD_Sensors_Configure()
AlarmsSet(SYSTEMALARMS_ALARM_I2C, (qmc5883l_dev) ? SYSTEMALARMS_ALARM_OK : SYSTEMALARMS_ALARM_WARNING); AlarmsSet(SYSTEMALARMS_ALARM_I2C, (qmc5883l_dev) ? SYSTEMALARMS_ALARM_OK : SYSTEMALARMS_ALARM_WARNING);
# endif /* PIOS_INCLUDE_QMC5883L */ # endif /* PIOS_INCLUDE_QMC5883L */
} }
# endif /* PIOS_INCLUDE_HMC5X83 || PIOS_INCLUDE_QMC5883L */ # endif /* PIOS_INCLUDE_SENSORS_AUXMAG */
// internal ms5611 baro // internal ms5611 baro
#ifdef PIOS_INCLUDE_MS56XX #ifdef PIOS_INCLUDE_MS56XX

View File

@ -339,6 +339,10 @@ extern "C" {
/* Performance counters */ /* Performance counters */
/* #define IDLE_COUNTS_PER_SEC_AT_NO_LOAD 995998 */ /* #define IDLE_COUNTS_PER_SEC_AT_NO_LOAD 995998 */
#if defined(PIOS_INCLUDE_HMC5X83) || defined(PIOS_INCLUDE_QMC5883L)
#define PIOS_INCLUDE_SENSORS_AUXMAG
#endif
#endif /* USE_SIM_POSIX */ #endif /* USE_SIM_POSIX */