diff --git a/src/main/build/debug.h b/src/main/build/debug.h index 8111bb94643..3a09da50daf 100644 --- a/src/main/build/debug.h +++ b/src/main/build/debug.h @@ -71,5 +71,6 @@ typedef enum { DEBUG_AUTOTUNE, DEBUG_RATE_DYNAMICS, DEBUG_LANDING, + DEBUG_POS_EST, DEBUG_COUNT } debugType_e; diff --git a/src/main/common/time.c b/src/main/common/time.c index f1204c57f4a..8214398d26b 100644 --- a/src/main/common/time.c +++ b/src/main/common/time.c @@ -35,6 +35,10 @@ #include "fc/settings.h" +#ifdef SITL_BUILD +#include +#endif + // For the "modulo 4" arithmetic to work, we need a leap base year #define REFERENCE_YEAR 2000 // Offset (seconds) from the UNIX epoch (1970-01-01) to 2000-01-01 @@ -310,11 +314,16 @@ bool rtcHasTime(void) bool rtcGet(rtcTime_t *t) { +#ifdef SITL_BUILD + *t = (rtcTime_t)(time(NULL) * 1000); + return true; +#else if (!rtcHasTime()) { return false; } *t = started + millis(); return true; +#endif } bool rtcSet(rtcTime_t *t) @@ -323,6 +332,7 @@ bool rtcSet(rtcTime_t *t) return true; } + bool rtcGetDateTime(dateTime_t *dt) { rtcTime_t t; diff --git a/src/main/config/config_streamer.h b/src/main/config/config_streamer.h index 87b688406f5..33c0954874c 100644 --- a/src/main/config/config_streamer.h +++ b/src/main/config/config_streamer.h @@ -57,3 +57,7 @@ int config_streamer_flush(config_streamer_t *c); int config_streamer_finish(config_streamer_t *c); int config_streamer_status(config_streamer_t *c); + +#if defined(CONFIG_IN_FILE) +bool configFileSetPath(char* path); +#endif diff --git a/src/main/config/config_streamer_file.c b/src/main/config/config_streamer_file.c index c3fdbba95c8..379155c22e1 100644 --- a/src/main/config/config_streamer_file.c +++ b/src/main/config/config_streamer_file.c @@ -16,6 +16,7 @@ */ #include +#include #include "platform.h" #include "drivers/system.h" #include "config/config_streamer.h" @@ -26,21 +27,32 @@ #include #include + #define FLASH_PAGE_SIZE (0x400) static FILE *eepromFd = NULL; - static bool streamerLocked = true; +static char eepromPath[260] = EEPROM_FILENAME; + +bool configFileSetPath(char* path) +{ + if(!path || strlen(path) > 260) { + return false; + } + + strcpy(eepromPath, path); + return true; +} void config_streamer_impl_unlock(void) { if (eepromFd != NULL) { - fprintf(stderr, "[EEPROM] Unable to load %s\n", EEPROM_FILENAME); + fprintf(stderr, "[EEPROM] Unable to load %s\n", eepromPath); return; } // open or create - eepromFd = fopen(EEPROM_FILENAME,"r+"); + eepromFd = fopen(eepromPath,"r+"); if (eepromFd != NULL) { // obtain file size: fseek(eepromFd , 0 , SEEK_END); @@ -49,16 +61,16 @@ void config_streamer_impl_unlock(void) size_t n = fread(eepromData, 1, sizeof(eepromData), eepromFd); if (n == size) { - printf("[EEPROM] Loaded '%s' (%ld of %ld bytes)\n", EEPROM_FILENAME, size, sizeof(eepromData)); + fprintf(stderr,"[EEPROM] Loaded '%s' (%ld of %ld bytes)\n", eepromPath, size, sizeof(eepromData)); streamerLocked = false; } else { - fprintf(stderr, "[EEPROM] Failed to load '%s'\n", EEPROM_FILENAME); + fprintf(stderr, "[EEPROM] Failed to load '%s'\n", eepromPath); } } else { - printf("[EEPROM] Created '%s', size = %ld\n", EEPROM_FILENAME, sizeof(eepromData)); + printf("[EEPROM] Created '%s', size = %ld\n", eepromPath, sizeof(eepromData)); streamerLocked = false; - if ((eepromFd = fopen(EEPROM_FILENAME, "w+")) == NULL) { - fprintf(stderr, "[EEPROM] Failed to create '%s'\n", EEPROM_FILENAME); + if ((eepromFd = fopen(eepromPath, "w+")) == NULL) { + fprintf(stderr, "[EEPROM] Failed to create '%s'\n", eepromPath); streamerLocked = true; } if (fwrite(eepromData, sizeof(eepromData), 1, eepromFd) != 1) { @@ -66,8 +78,6 @@ void config_streamer_impl_unlock(void) streamerLocked = true; } } - - } void config_streamer_impl_lock(void) @@ -78,7 +88,7 @@ void config_streamer_impl_lock(void) fwrite(eepromData, 1, sizeof(eepromData), eepromFd); fclose(eepromFd); eepromFd = NULL; - printf("[EEPROM] Saved '%s'\n", EEPROM_FILENAME); + fprintf(stderr, "[EEPROM] Saved '%s'\n", eepromPath); streamerLocked = false; } else { fprintf(stderr, "[EEPROM] Unlock error\n"); @@ -93,9 +103,9 @@ int config_streamer_impl_write_word(config_streamer_t *c, config_streamer_buffer if ((c->address >= (uintptr_t)eepromData) && (c->address < (uintptr_t)ARRAYEND(eepromData))) { *((uint32_t*)c->address) = *buffer; - printf("[EEPROM] Program word %p = %08x\n", (void*)c->address, *((uint32_t*)c->address)); + fprintf(stderr, "[EEPROM] Program word %p = %08x\n", (void*)c->address, *((uint32_t*)c->address)); } else { - printf("[EEPROM] Program word %p out of range!\n", (void*)c->address); + fprintf(stderr, "[EEPROM] Program word %p out of range!\n", (void*)c->address); } c->address += CONFIG_STREAMER_BUFFER_SIZE; diff --git a/src/main/drivers/accgyro/accgyro_mpu.h b/src/main/drivers/accgyro/accgyro_mpu.h index b7a462fbf5c..62c2778b45b 100644 --- a/src/main/drivers/accgyro/accgyro_mpu.h +++ b/src/main/drivers/accgyro/accgyro_mpu.h @@ -19,11 +19,7 @@ #include "drivers/sensor.h" #include "drivers/accgyro/accgyro.h" -#define MPU_I2C_ADDRESS 0x68 -// MPU6050 -#define MPU_RA_WHO_AM_I_LEGACY 0x00 -#define MPUx0x0_WHO_AM_I_CONST (0x68) // MPU6000 and 6050 #define MPU6000_WHO_AM_I_CONST (0x68) #define MPU6500_WHO_AM_I_CONST (0x70) #define MPU9250_WHO_AM_I_CONST (0x71) diff --git a/src/main/drivers/bus.h b/src/main/drivers/bus.h index 0349d212c7b..eca213b7218 100644 --- a/src/main/drivers/bus.h +++ b/src/main/drivers/bus.h @@ -77,7 +77,6 @@ typedef enum { /* Combined ACC/GYRO chips */ DEVHW_MPU6000, - DEVHW_MPU6050, DEVHW_MPU6500, DEVHW_BMI160, DEVHW_BMI088_GYRO, diff --git a/src/main/sensors/acceleration.h b/src/main/sensors/acceleration.h index f696eba1c53..d81a83a9084 100644 --- a/src/main/sensors/acceleration.h +++ b/src/main/sensors/acceleration.h @@ -35,7 +35,6 @@ typedef enum { ACC_NONE = 0, ACC_AUTODETECT, - ACC_MPU6050, ACC_MPU6000, ACC_MPU6500, ACC_MPU9250, diff --git a/src/main/sensors/gyro.c b/src/main/sensors/gyro.c index b9394c69edf..a586ce6df6b 100644 --- a/src/main/sensors/gyro.c +++ b/src/main/sensors/gyro.c @@ -39,7 +39,6 @@ #include "drivers/accgyro/accgyro.h" #include "drivers/accgyro/accgyro_mpu.h" #include "drivers/accgyro/accgyro_mpu6000.h" -#include "drivers/accgyro/accgyro_mpu6050.h" #include "drivers/accgyro/accgyro_mpu6500.h" #include "drivers/accgyro/accgyro_mpu9250.h" @@ -135,15 +134,6 @@ STATIC_UNIT_TESTED gyroSensor_e gyroDetect(gyroDev_t *dev, gyroSensor_e gyroHard switch (gyroHardware) { case GYRO_AUTODETECT: FALLTHROUGH; - -#ifdef USE_IMU_MPU6050 - case GYRO_MPU6050: - if (mpu6050GyroDetect(dev)) { - gyroHardware = GYRO_MPU6050; - break; - } - FALLTHROUGH; -#endif #ifdef USE_IMU_MPU6000 case GYRO_MPU6000: diff --git a/src/main/sensors/gyro.h b/src/main/sensors/gyro.h index 2b3bac46254..669f8fbee46 100644 --- a/src/main/sensors/gyro.h +++ b/src/main/sensors/gyro.h @@ -34,7 +34,6 @@ typedef enum { GYRO_NONE = 0, GYRO_AUTODETECT, - GYRO_MPU6050, GYRO_MPU6000, GYRO_MPU6500, GYRO_MPU9250,