Commit Graph

79 Commits

Author SHA1 Message Date
Hugo Chiang 949730bda2 add support for lsm6dsl imu 2022-12-12 16:37:01 +08:00
Hugo Chiang b654e758e2 add support for lsm6ds3 imu 2022-12-09 15:16:16 +08:00
Steve Evans 9f0a6129a9 Simplify SPI CLK speed setting during gyro detection 2022-05-28 17:15:55 +01:00
Steve Evans 3af0ee7a73 Fix ICM20689 initialisation 2022-05-05 21:32:53 +01:00
Steve Evans 4a3bb45a56 Fix comment typo 2022-04-28 20:00:47 +01:00
Dominic Clifton d0de9ac1f8 EXTI - Remove boolean argument from EXTIEnable.
It's confusing to have a method called EXTIEnable that takes an argument
that can DISABLE the line.

There are usually 3 options for this:
1. Use two methods, one for enable, one for disable.
2. Use enum constants instead of the boolean argument.
3. Rename to '*Set', e.g. EXTISet(...)

This commit applies option 1 above, as it's cleaner and the most common
use case in the codebase.
2022-03-06 11:24:16 +01:00
Steve Evans fc8640154a Interrupt/DMA driven SX1280 interaction for ELRS 2022-02-28 19:50:36 +00:00
Steve Evans bdff13fd24 Fix merge error of gyro register offset 2022-01-17 18:47:28 +00:00
Steve Evans 4aab87539f Implement queuing of SPI request segments
Use union in busSegment_t as per ledvinap feedback
2022-01-06 01:18:18 +00:00
Steve Evans 5ef34f79d5 Allow for HALF/NOMINAL/DOUBLE frequency of MAX7456 SPI clock 2022-01-06 01:18:17 +00:00
Steve Evans 2d770f747e Make gyroDataIndex const 2022-01-06 01:18:16 +00:00
Steve Evans e2f73cd7e5 Add DMA support for ICM-42688-P 2022-01-06 01:18:16 +00:00
Steve Evans ab1baccc66 Track state execution time for OSD, baro, rx and GPS tasks and inform scheduler of next state execution time 2021-12-17 15:40:01 +00:00
Steve Evans 8998644b7f Fix BMI270 gyro sync on H743 2021-11-01 20:26:47 +00:00
Steve Evans 7ef7795944 Support dual gyros sharing a common SPI bus 2021-10-05 17:40:21 +01:00
Steve Evans d5f62be013 Trigger gyro SPI DMA reads in EXTI handler if supported and lock gyroTask loop to gyro to eliminate missed updates and jitter 2021-09-28 01:38:18 +13:00
Dominic Clifton e69ed4f581 ICM42688P - Combine with ICM42605 driver. 2021-08-10 22:30:09 +02:00
Dominic Clifton 46c62cfcf2 ICM42688P - Initial sensor support based on ICM42605 driver. 2021-08-10 21:09:34 +02:00
Michael Keller f4d840f5f8 Changed naming of SPI DMA resources to reflect the SPI bus number. 2021-07-28 00:55:55 +12:00
Steve Evans 87c8847c13 New SPI API supporting DMA
Call targetConfiguration() once before config is loaded and again afterwards in case the config needs to be changed to load from SD card etc

Drop SPI clock during binding

Remove debug

Add per device SPI DMA enable

Fix sdioPinConfigure() declaration warning

Reduce clock speed during SPI RX initialisation
2021-07-25 12:40:25 +12:00
Bruce Luckcuck 140471adc6 Speed up gyro device detection; fix MPU6000 initialization
The detection logic in the MPU6000 and ICM20689 drivers had unnecessary "retry" logic that would try to read the `WHOAMI` register 5 times for MPU6000 and 20(!) times for ICM20689 - with a 150ms delay for each iteration. So the problem is that all the enabled drivers need to be probed in order so on a board that had a LSM6DSO for example (or any sensor further down the list) it would introduce about 4 seconds of initialization delay (dual gyro board would take 8 seconds!). Revised logic completes in about 0.4 seconds in the worst case.

After removing the unnecessary retry/repeat logic for the MPU6000 an initialization problem became visible. The driver was not following the datasheet guidelines and clearing the signal path after resetting the device. This lead to detection issues on warm reboots that were accidentally masked by the excessive delays with the retry logic.

The improvement in boot speed depends on the device's position in the list. So any device with a MPU6000 won't see any difference. All other devices will boot about 1 second faster (like ICM20602, ICM20689). Devices after the ICM20689 (like BMI160/270, LSM6DSO) will boot about 4 seconds faster.
2020-08-15 18:24:10 -04:00
mikeller 386be8d742 Added registration for bus devices. 2020-07-08 21:34:31 +12:00
Bruce Luckcuck 99a9543968 Add support for LSM6DSO gyro/acc
Also supports the LSM6DSOX variant which has the additional machine learning core (not used by Betaflight).
2020-06-21 16:22:29 -04:00
Bruce Luckcuck 447cbac988 Add support for Bosch BMI270 gyro/accelerometer sensor 2020-03-08 18:56:50 -04:00
Bruce Luckcuck f584780944 Gyro native rate sampling, filtering, and scheduler restructuring 2020-02-04 18:19:35 -05:00
jflyper a2e43174b8 [G4] Handle symbol collisions for universal EXTI wrapper 2020-01-17 22:09:48 +09:00
Dominic Clifton 3b3ead25f0 ICM42605 - Initial sensor support. 2019-12-26 20:09:47 +01:00
mikeller 5000b385cc Fixed gyro detection some more. 2019-04-11 06:23:53 +12:00
mikeller e44f75b4a7 Fixed gyro detection for multi gyro setups. 2019-04-04 00:39:55 +13:00
AJ Christensen 4fdee6ec1c Gyro Sensors: Remove 32kHz gyro sampling mode(s) and associated code 2019-02-13 22:41:21 +13:00
jflyper a33316c1f5 Setup I2C bus correctly for gyro detection 2019-02-08 03:09:45 +09:00
mikeller fdd5869054 Update L3GD20 gyro to modern gyro API. 2018-12-19 01:25:39 +13:00
jflyper 9ea1428d11 Introduce per device pin pre-init 2018-12-13 11:15:26 +09:00
jflyper ba5938c5c8 Remove stale MPU_INT_EXTI def 2018-11-26 01:47:14 +09:00
jflyper 8a9bca2514 Unified EXTIConfig API for all MCU types 2018-10-31 07:59:27 +09:00
jflyper 9690f37b46 Handle NULL SPI instance before calling spiBusSetInstance 2018-09-19 22:27:00 +09:00
jflyper 4193890b27 Handle NULL SPI instance case 2018-09-16 03:09:45 +09:00
jflyper fc6c24c38e Configurable acc/gyro 2018-09-10 17:55:52 +09:00
jflyper 58647e678f Remove reset facility 2018-09-06 20:07:09 +09:00
Bruce Luckcuck ec038c7db4 Changes from review - add default clause and update PG version 2018-08-22 17:26:23 -04:00
Bruce Luckcuck 0e8e5b3c16 Disable DLPF EXPERIMENTAL mode for MPU60x0; remove experimental support from F3
Officially Invensense lists the experimentl mode as "unsupported" on the MPU60x0 series. Previously it was added to allow testing.  It's been determined that it's not a viable gyro filtering operational mode.

Also change "experimental" DLPF support available for F4 or higher. Few F3 boards have gyros that can use this mode anyway.  Saves 200 bytes.
2018-08-22 09:50:10 -04:00
jflyper 6c044829cc Mark unused acc/gyro support toward retirement. 2018-05-16 14:31:39 +09:00
blckmn a9f74cd6df Removed excess trailing spaces before new lines on licenses. 2018-04-25 20:58:00 +10:00
blckmn 46fe22b4bd Direct license replacement 2018-04-22 09:22:46 +10:00
etracer65 062ef77276 Rework gyro sample rate and DLPF configuration and expose additional filter cutoffs (#5483)
The old gyro_lpf setting was based on the DLPF_CFG values for the MPU6050 gyro and the enumeration was inaccurate and misleading.  For example, the default "OFF" setting did not disable the DLPF, but actually set it to around 250hz.  The actual cutoff frequency for each setting varies by gyro hardware so the literal frequencies in the enumeration were also incorrect.

Removed gyro_lpf and replaced it with gyro_hardware_lpf (8KHz) and gyro_32khz_hardware_lpf (32KHz).  The parameters were renamed to indicate that they are hardware filtering options to differentiate from the many software lowpass filtering options.

gyro_hardware_lpf - This parameter sets the filtering and sample rate options for 8KHz gyros (or 32KHz capable gyros running in 8KHz mode).

- NORMAL - default setting that is equivalent to the previous "OFF" setting.  Configures 8KHz sampling with ~250Hz filter cutoff.
- EXPERIMENTAL - 8KHz sampling with a higher frequency filter cutoff (around 3000hz).  Considerably more noisy and requires additional software filtering.  Note that for the MPU6000 Invensense doesn't officially document the filter cutoff frequency for this selection and simply lists it as "reserved".  In testing it's clear that a higher frequency filter cutoff is being selected due to the increased noise, but the actual cutoff frequency is unknown.
- 1KHZ_SAMPLING - 1KHz sample rate with and approximate 188Hz filter cutoff.

Note that the following additional 1KHz sample rate options with lower filter cutoffs have been eliminated - "98HZ", "42HZ", "20HZ", "10HZ", "5HZ".  It seems unlikely that these are still needed are probably no longer viable and flight performance would be very poor.

gyro_32khz_hardware_lpf - This parameter sets the filtering options while running in 32KHz mode on capable gyros.  It also exposes a new high frequency filter cutoff mode.

- NORMAL - The default and matches the current settings used for 32KHz mode.  Provides a filter cutoff around 3000Hz.
- EXPERIMENTAL - Selects a filter cutoff around 8000Hz.  This is a very noisy setting and will require substantial software filtering.

The default values for both 8KHz and 32KHz sample rates were chosen to match the previous defaults and users should not experience any performance differences.

Normalized the gyro initialization.  Previously there was little consistency on how the initialization was performed and the settings interpreted.  For example, MPU9250 used a completely different logic tree when configuring the registers.

Disconnected the literal parameter value from the gyro initialization.  The gyro_lpf parameter contained a number from 0-7 that was literally applied to the configuration register during the gyro initialization.  This caused some older gyro initializations to be incorrect as they used a different register layout (MPU3050 and L3G4200D).  By transitioning to a logical selection the actual value applied to the hardware register is abstracted.  This will better future-proof the design as new gyros may have a different register structure that may be incompatible with the old method.

Added a gyroregisters command to the CLI that is used to read the current register settings from the gyro and dump them to the CLI.  This is used to verify the configuration in comparison to the datasheets for the various gyros.  Testing empirically by looking at the relative noise from the gyros can give a rough estimate whether the different options are selecting correctly, but it's not very precise.  The code for the gyroregisters CLI command is wrapped inside #ifdef USE_GYRO_REGISTER_DUMP blocks to allow easy disabling.  It's currently enabled for all targets but we may decide to disable before release or only limit to targets with more available space (>=F4).
2018-03-22 14:02:30 +13:00
Andrey Mironov 8319c6c6d1 Unified enabling of EXTI for gyro on F7 with other targets (#5364) 2018-03-04 11:49:36 +13:00
Dominic Clifton cde9a9517b SPRacingF7DUAL - Dual SIMULTANEOUS gyro support. (#5264)
* CF/BF - Set STM32F7 SPI FAST clock to 13.5Mhz - Gyros not stable at
27mhz.

* CF/BF - Initial SPRacingF7DUAL commit.

Support two simultaneous gyro support (code by Dominic Clifton and Martin Budden)
There are new debug modes so you can see the difference between each gyro.

Notes:
* spi bus instance caching broke spi mpu detection because the detection
tries I2C first which overwrites the selected bus instance when using
dual gyro.
* ALL other dual-gyro boards have one sensor per bus.  SPRacingF7DUAL is has two per bus and thus commit has a lot of changes to fix SPI/BUS/GYRO initialisation issues.

* CF/BF - Add SPRacingF4EVODG target.

This target adds a second gyro to the board using the SPI pads on the back of the board.

* CF/BF - Temporarily disable Gyro EXTI pin to allow NEO target to build.
2018-03-04 11:29:31 +13:00
Bruce Luckcuck e9686c0ef8 Change gyro_overflow_detect to use filtered instead of raw gyro data - 2nd try
Noise and momentary spikes in gyro data (particularly in 32K mode) were causing false triggering of the gyro overflow detection. Changing to using filtered instead of raw gyro data eliminates the false triggering.

Also adjusted the trigger and reset rates slightly (approx. 1950dps and 1850dps respectively).

Fixed bug for gyros that may not be +-2000dps full scale. The trigger threshold will be 97.5% full-scale and reset at 92.5% (corresponds to 1950 and 1850 for 2000dps gyros).
2018-02-22 18:56:15 -05:00
Michael Keller e5364ee764
Revert "Change gyro_overflow_detect to use filtered instead of raw gyro data" 2018-02-18 09:25:04 +13:00
Bruce Luckcuck b49a9ec928 Change gyro_overflow_detect to use filtered instead of raw gyro data
Noise and momentary spikes in gyro data (particularly in 32K mode) were causing false triggering of the gyro overflow detection.

Also adjusted the trigger and reset rates slightly (approx. 1950dps and 1850dps respectively).

Optimized the gyro loop slightly by eliminating 3 floating point multiplies.

Fixed bug for gyros that may not be +-2000dps full scale.
2018-02-14 17:50:09 -05:00