Skip to content

Commit a1232ce

Browse files
authored
Merge pull request #1 from betaflight/master
Rebase test
2 parents 1217893 + 93cd834 commit a1232ce

File tree

11 files changed

+26
-91
lines changed

11 files changed

+26
-91
lines changed

src/main/drivers/accgyro/accgyro.h

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "drivers/bus.h"
2828
#include "drivers/sensor.h"
2929
#include "drivers/accgyro/accgyro_mpu.h"
30-
#include "sensors/gyro.h"
30+
3131
#pragma GCC diagnostic push
3232
#if defined(SIMULATOR_BUILD) && defined(SIMULATOR_MULTITHREAD)
3333
#include <pthread.h>
@@ -39,6 +39,25 @@
3939
#define MPU_I2C_INSTANCE I2C_DEVICE
4040
#endif
4141

42+
typedef enum {
43+
GYRO_NONE = 0,
44+
GYRO_DEFAULT,
45+
GYRO_MPU6050,
46+
GYRO_L3G4200D,
47+
GYRO_MPU3050,
48+
GYRO_L3GD20,
49+
GYRO_MPU6000,
50+
GYRO_MPU6500,
51+
GYRO_MPU9250,
52+
GYRO_ICM20601,
53+
GYRO_ICM20602,
54+
GYRO_ICM20608G,
55+
GYRO_ICM20649,
56+
GYRO_ICM20689,
57+
GYRO_BMI160,
58+
GYRO_FAKE
59+
} gyroHardware_e;
60+
4261
typedef enum {
4362
GYRO_HARDWARE_LPF_NORMAL,
4463
GYRO_HARDWARE_LPF_1KHZ_SAMPLE,
@@ -77,7 +96,6 @@ typedef struct gyroDev_s {
7796
int32_t gyroADCRawPrevious[XYZ_AXIS_COUNT];
7897
int16_t gyroADCRaw[XYZ_AXIS_COUNT];
7998
int16_t temperature;
80-
mpuConfiguration_t mpuConfiguration;
8199
mpuDetectionResult_t mpuDetectionResult;
82100
sensor_align_e gyroAlign;
83101
gyroRateKHz_e gyroRateKHz;
@@ -88,7 +106,7 @@ typedef struct gyroDev_s {
88106
uint8_t mpuDividerDrops;
89107
ioTag_t mpuIntExtiTag;
90108
uint8_t gyroHasOverflowProtection;
91-
gyroSensor_e gyroHardware;
109+
gyroHardware_e gyroHardware;
92110
} gyroDev_t;
93111

94112
typedef struct accDev_s {

src/main/drivers/accgyro/accgyro_mpu.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454
#include "drivers/accgyro/accgyro_spi_mpu9250.h"
5555
#include "drivers/accgyro/accgyro_mpu.h"
5656

57-
mpuResetFnPtr mpuResetFn;
58-
5957
#ifndef MPU_I2C_INSTANCE
6058
#define MPU_I2C_INSTANCE I2C_DEVICE
6159
#endif
@@ -250,7 +248,6 @@ static bool detectSPISensorsAndUpdateDetectionResult(gyroDev_t *gyro)
250248
sensor = mpu9250SpiDetect(&gyro->bus);
251249
if (sensor != MPU_NONE) {
252250
gyro->mpuDetectionResult.sensor = sensor;
253-
gyro->mpuConfiguration.resetFn = mpu9250SpiResetGyro;
254251
return true;
255252
}
256253
#endif

src/main/drivers/accgyro/accgyro_mpu.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,6 @@
140140
// RF = Register Flag
141141
#define MPU_RF_DATA_RDY_EN (1 << 0)
142142

143-
typedef void (*mpuResetFnPtr)(void);
144-
145-
extern mpuResetFnPtr mpuResetFn;
146-
147-
typedef struct mpuConfiguration_s {
148-
mpuResetFnPtr resetFn;
149-
} mpuConfiguration_t;
150-
151143
enum gyro_fsr_e {
152144
INV_FSR_250DPS = 0,
153145
INV_FSR_500DPS,

src/main/drivers/accgyro/accgyro_spi_mpu9250.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,6 @@ static bool mpu9250SpiSlowReadRegisterBuffer(const busDevice_t *bus, uint8_t reg
7575
return true;
7676
}
7777

78-
void mpu9250SpiResetGyro(void)
79-
{
80-
#if 0
81-
// XXX This doesn't work. Need a proper busDevice_t.
82-
// Device Reset
83-
#ifdef MPU9250_CS_PIN
84-
busDevice_t bus = { .spi = { .csnPin = IOGetByTag(IO_TAG(MPU9250_CS_PIN)) } };
85-
mpu9250SpiWriteRegister(&bus, MPU_RA_PWR_MGMT_1, MPU9250_BIT_RESET);
86-
delay(150);
87-
#endif
88-
#endif
89-
}
90-
9178
void mpu9250SpiGyroInit(gyroDev_t *gyro)
9279
{
9380
mpuGyroInit(gyro);

src/main/drivers/system_stm32f4xx.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ void SetSysClock(void);
3434

3535
void systemReset(void)
3636
{
37-
if (mpuResetFn) {
38-
mpuResetFn();
39-
}
40-
4137
__disable_irq();
4238
NVIC_SystemReset();
4339
}
@@ -47,10 +43,6 @@ PERSISTENT uint32_t bootloaderRequest = 0;
4743

4844
void systemResetToBootloader(void)
4945
{
50-
if (mpuResetFn) {
51-
mpuResetFn();
52-
}
53-
5446
bootloaderRequest = BOOTLOADER_REQUEST_COOKIE;
5547

5648
__disable_irq();

src/main/drivers/system_stm32f7xx.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,12 @@ void SystemClock_Config(void);
3838

3939
void systemReset(void)
4040
{
41-
if (mpuResetFn) {
42-
mpuResetFn();
43-
}
44-
4541
__disable_irq();
4642
NVIC_SystemReset();
4743
}
4844

4945
void systemResetToBootloader(void)
5046
{
51-
if (mpuResetFn) {
52-
mpuResetFn();
53-
}
54-
5547
(*(__IO uint32_t *) (BKPSRAM_BASE + 4)) = 0xDEADBEEF; // flag that will be readable after reboot
5648

5749
__disable_irq();

src/main/drivers/usb_msc_f4xx.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ void mscWaitForButton(void)
147147

148148
void systemResetToMsc(void)
149149
{
150-
if (mpuResetFn) {
151-
mpuResetFn();
152-
}
153-
154150
*((uint32_t *)0x2001FFF0) = MSC_MAGIC;
155151

156152
__disable_irq();

src/main/drivers/usb_msc_f7xx.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ void mscWaitForButton(void)
153153

154154
void systemResetToMsc(void)
155155
{
156-
if (mpuResetFn) {
157-
mpuResetFn();
158-
}
159-
160156
*((__IO uint32_t*) BKPSRAM_BASE + 16) = MSC_MAGIC;
161157

162158
__disable_irq();

src/main/sensors/gyro.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -241,19 +241,6 @@ const busDevice_t *gyroSensorBusByDevice(uint8_t whichSensor)
241241
}
242242
#endif // USE_GYRO_REGISTER_DUMP
243243

244-
const mpuConfiguration_t *gyroMpuConfiguration(void)
245-
{
246-
#ifdef USE_DUAL_GYRO
247-
if (gyroToUse == GYRO_CONFIG_USE_GYRO_2) {
248-
return &gyroSensor2.gyroDev.mpuConfiguration;
249-
} else {
250-
return &gyroSensor1.gyroDev.mpuConfiguration;
251-
}
252-
#else
253-
return &gyroSensor1.gyroDev.mpuConfiguration;
254-
#endif
255-
}
256-
257244
const mpuDetectionResult_t *gyroMpuDetectionResult(void)
258245
{
259246
#ifdef USE_DUAL_GYRO
@@ -267,9 +254,9 @@ const mpuDetectionResult_t *gyroMpuDetectionResult(void)
267254
#endif
268255
}
269256

270-
STATIC_UNIT_TESTED gyroSensor_e gyroDetect(gyroDev_t *dev)
257+
STATIC_UNIT_TESTED gyroHardware_e gyroDetect(gyroDev_t *dev)
271258
{
272-
gyroSensor_e gyroHardware = GYRO_DEFAULT;
259+
gyroHardware_e gyroHardware = GYRO_DEFAULT;
273260

274261
switch (gyroHardware) {
275262
case GYRO_DEFAULT:
@@ -447,10 +434,9 @@ static bool gyroInitSensor(gyroSensor_t *gyroSensor)
447434
|| defined(USE_ACC_MPU6050) || defined(USE_GYRO_SPI_MPU9250) || defined(USE_GYRO_SPI_ICM20601) || defined(USE_GYRO_SPI_ICM20649) || defined(USE_GYRO_SPI_ICM20689)
448435

449436
mpuDetect(&gyroSensor->gyroDev);
450-
mpuResetFn = gyroSensor->gyroDev.mpuConfiguration.resetFn; // must be set after mpuDetect
451437
#endif
452438

453-
const gyroSensor_e gyroHardware = gyroDetect(&gyroSensor->gyroDev);
439+
const gyroHardware_e gyroHardware = gyroDetect(&gyroSensor->gyroDev);
454440
gyroSensor->gyroDev.gyroHardware = gyroHardware;
455441
if (gyroHardware == GYRO_NONE) {
456442
return false;

src/main/sensors/gyro.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,6 @@
2929

3030
#include "pg/pg.h"
3131

32-
typedef enum {
33-
GYRO_NONE = 0,
34-
GYRO_DEFAULT,
35-
GYRO_MPU6050,
36-
GYRO_L3G4200D,
37-
GYRO_MPU3050,
38-
GYRO_L3GD20,
39-
GYRO_MPU6000,
40-
GYRO_MPU6500,
41-
GYRO_MPU9250,
42-
GYRO_ICM20601,
43-
GYRO_ICM20602,
44-
GYRO_ICM20608G,
45-
GYRO_ICM20649,
46-
GYRO_ICM20689,
47-
GYRO_BMI160,
48-
GYRO_FAKE
49-
} gyroSensor_e;
50-
5132
typedef struct gyro_s {
5233
uint32_t targetLooptime;
5334
float gyroADCf[XYZ_AXIS_COUNT];
@@ -124,8 +105,6 @@ void gyroInitFilters(void);
124105
void gyroUpdate(timeUs_t currentTimeUs);
125106
bool gyroGetAccumulationAverage(float *accumulation);
126107
const busDevice_t *gyroSensorBus(void);
127-
struct mpuConfiguration_s;
128-
const struct mpuConfiguration_s *gyroMpuConfiguration(void);
129108
struct mpuDetectionResult_s;
130109
const struct mpuDetectionResult_s *gyroMpuDetectionResult(void);
131110
void gyroStartCalibration(bool isFirstArmingCalibration);

0 commit comments

Comments
 (0)