Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
ce87656
Add new target DAKEFPVH743_SLIM
engineer-dakefpv Dec 16, 2025
59532ea
Fix the incorrect pins PC8 and PB7
engineer-dakefpv Dec 16, 2025
cebc906
Refactor OMNIBUSF4 targets into separate directories
sensei-hacker Dec 22, 2025
476a0cb
Clean up dead code and obsolete comments from OMNIBUS split
sensei-hacker Dec 22, 2025
c79e53a
Remove all dead code from OMNIBUSF4 directory
sensei-hacker Dec 22, 2025
e3d0bda
Fix critical OMNIBUSF4V3_ICM configuration bug and remove dead code
sensei-hacker Dec 22, 2025
dce7687
Remove outdated and misleading comments from OMNIBUS split
sensei-hacker Dec 22, 2025
2331e01
Remove dead code from OMNIBUSF4PRO/target.c
sensei-hacker Dec 22, 2025
0fead0f
Remove outdated comments and redundant conditional from OMNIBUS split
sensei-hacker Dec 22, 2025
e6dc927
Fix inconsistent indentation remnants in OMNIBUS split
sensei-hacker Dec 22, 2025
eca5746
Merge upstream/maintenance-9.x - resolve OMNIBUSF4V3_ICM conflicts
sensei-hacker Feb 25, 2026
eb20c74
update AET-H743-Basic - add bmi088 and bmi270 imu
do1234521 Mar 6, 2026
c497d4f
Merge pull request #11604 from P-I-Engineer/dshot-beeper-buzzer-ignor…
sensei-hacker May 30, 2026
e7d5cce
Merge pull request #11622 from iNavFlight/release/9.1
sensei-hacker Jun 6, 2026
d6db20e
fix(gps): guard against NULL serial port when GPS provider changed wi…
daijoubu Jun 8, 2026
68f2797
Add BMI270 support to COREWINGF405WINGV2
sensei-hacker Jun 9, 2026
c0ba786
target/JHEMCUF435: fix UART7 ESC telemetry defaults
dtrbinh Jun 9, 2026
6c6df28
fix(gps): clamp negative uBlox nano field before millis conversion
daijoubu Jun 10, 2026
4939a7f
Merge pull request #11662 from iNavFlight/release/9.1
sensei-hacker Jun 18, 2026
c499f5f
fix(sdcard): remove blocking delay from SDIO retry path
sensei-hacker Jun 23, 2026
2fda3e4
fix(sdcard): fix write-path state management in SDIO driver
sensei-hacker Jun 23, 2026
e172f87
docs(autotune): fix fixed-wing autotune docs to match actual behavior
sensei-hacker Jul 1, 2026
f3527fe
docs(autotune): fix LIMIT mode wording per Qodo review
sensei-hacker Jul 2, 2026
ecef12e
Merge pull request #11677 from sensei-hacker/fix-autotune-docs
sensei-hacker Jul 2, 2026
1ffa80b
Fix int8_t overflow in AAF frequency selection for ICM-42688P/42686P
sensei-hacker Jul 2, 2026
449a645
Merge pull request #11682 from sensei-hacker/fix/icm42688-aaf-freq-ov…
sensei-hacker Jul 2, 2026
a68bb04
Merge pull request #11641 from dtrbinh/fix/jhemcuf435-uart7-missing-swap
sensei-hacker Jul 3, 2026
a75cf92
Merge pull request #11634 from daijoubu/fix/gps-provider-null-guard
sensei-hacker Jul 3, 2026
aa87bb2
Merge pull request #11674 from sensei-hacker/fix/sdio-retry-blocking-…
sensei-hacker Jul 3, 2026
015eeab
Merge pull request #11642 from daijoubu/fix/ublox-nano-rtc-offset
sensei-hacker Jul 3, 2026
cf48e6e
allow USE_UARTx_PIN_SWAP on H7
sensei-hacker Jul 6, 2026
028986c
DAKEFPVH743_SLIM: Fix DMA conflicts
sensei-hacker Jul 6, 2026
e6f3353
DAKEFPV H743 SLIM: Fix beeper and UART7
sensei-hacker Jul 6, 2026
63113da
Merge pull request #11177 from engineer-dakefpv/DAKEFPVH743_SLIM
sensei-hacker Jul 6, 2026
03e8de2
Merge pull request #11687 from sensei-hacker/USE_UARTx_PIN_SWAP-on-H7
sensei-hacker Jul 6, 2026
08cde84
Puya PY25Q128 - updated descriptions.
valeriyc Mar 5, 2026
42f7e52
SOLOGOODF722 - target
valeriyc Mar 2, 2026
2197875
SOLOGOODF722: add config.c for PINIO user boxes
sensei-hacker Jul 6, 2026
90c117d
Merge pull request #11196 from sensei-hacker/refactor/split-omnibusf4…
sensei-hacker Jul 6, 2026
7441bec
AETH743Basic Update BMI270 slow tag in target.c
sensei-hacker Jul 6, 2026
e5a84ed
Merge pull request #11689 from sensei-hacker/sologoodf722-target-91
sensei-hacker Jul 6, 2026
4263507
Merge pull request #11403 from do1234521/master
sensei-hacker Jul 6, 2026
db7e465
Update DAKEFPVF405 target to match current Betaflight config
sensei-hacker Jul 6, 2026
37dc6fe
Note CAMERA_CONTROL_PIN as a future PWM-PINIO migration candidate
sensei-hacker Jul 6, 2026
0631b6e
Clarify CAMERA_CONTROL_PIN comment: functional from 10.0, not permane…
sensei-hacker Jul 6, 2026
a7aff3b
Remove dead USE_IMU_ICM42688P block, document actual detection path
sensei-hacker Jul 6, 2026
4832784
Fix bf2inav.py gaps found while updating DAKEFPVF405
sensei-hacker Jul 6, 2026
6c942bf
Merge pull request #11690 from sensei-hacker/update-dakefpvf405-target
sensei-hacker Jul 6, 2026
b6fbebc
Add AXISFLYINGH743PRO target
sensei-hacker Jul 7, 2026
aff7794
Add LSM6DSV16X/LSM6DSK320X support to LSM6DXX accgyro driver
sensei-hacker Jul 7, 2026
0014dbc
bf2inav.py: update LSM6DSK320X support
sensei-hacker Jul 7, 2026
9f57c17
Merge pull request #11691 from sensei-hacker/fix-bf2inav-gaps
sensei-hacker Jul 7, 2026
a731ebb
Merge pull request #11694 from sensei-hacker/lsm6dsv16x-lsm6dsk320x-d…
sensei-hacker Jul 7, 2026
54b7177
Merge pull request #11638 from sensei-hacker/add/bmi270-corewingf405w…
sensei-hacker Jul 7, 2026
82090e4
Fix LED strip / ADC1 DMA conflict on DAKEFPVH743PRO
sensei-hacker Jul 7, 2026
3110497
Merge pull request #11696 from sensei-hacker/fix-dakefpvh743pro-led-a…
sensei-hacker Jul 7, 2026
cb36ba5
AXISFLYINGH743PRO: remove bogus timers, PINIO_FLAGS_INVERTED
sensei-hacker Jul 7, 2026
baabf43
AXISFLYINGH743PRO: set default features
sensei-hacker Jul 7, 2026
ec55b09
Converting Betaflight Targets.md: default_features
sensei-hacker Jul 7, 2026
27a7bb7
Merge branch 'release/9.1' into feature-axisflyingh743pro-target
sensei-hacker Jul 7, 2026
e519b69
Merge pull request #11693 from sensei-hacker/feature-axisflyingh743pr…
sensei-hacker Jul 7, 2026
1531750
Merge pull request #11697 from iNavFlight/release/9.1
sensei-hacker Jul 8, 2026
0cbd2b2
New Target:XMAV_APH743V2
TompsonTan May 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions docs/Autotune - fixedwing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,35 @@ Getting a good set of roll/pitch/yaw PIFF parameters for your aircraft is essent

## What AUTOTUNE does

The AUTOTUNE mode is a flight mode that acts on top of normal ANGLE/HORIZON/ACRO mode and uses changes in flight attitude input by the pilot to learn the tuning values for roll, pitch and yaw tuning.
AUTOTUNE is a modifier you enable on top of ANGLE, HORIZON or ACRO mode. It has no effect at all while flying in MANUAL mode - you can switch it on, but nothing will be tuned until you leave MANUAL. Where it is active, it uses the aircraft's response to your stick inputs to tune, for roll, pitch and yaw independently:

In general pilot needs to activate AUTOTUNE mode while in the air and then fly the plane for a few minutes. While flying the pilot needs to input as many sharp attitude changes as possible so that the autotune code can learn how the aircraft responds and figure out PIFF gains.
* **FeedForward (FF) gain** - in ANGLE, HORIZON or ACRO, whenever you give it enough hard stick input to learn from
* **Rate** (`roll_rate`/`pitch_rate`/`yaw_rate`) - only while flying in ACRO or HORIZON, and only if `fw_autotune_rate_adjustment` is not set to `FIXED` (see below). Rate is never adjusted while flying in ANGLE mode.

**AUTOTUNE never adjusts P or I gains, on any axis.** Tune P and I manually, either before or after using AUTOTUNE. This is a change from older INAV versions - if you're used to AUTOTUNE also setting P/I, that's no longer how it works.

In general the pilot needs to activate AUTOTUNE while in the air and then fly the plane for a few minutes. While flying the pilot needs to input as many sharp attitude changes as possible, on all three axes, so that the autotune code can learn how the aircraft responds. An axis that isn't given hard stick input won't be tuned - it's easy to spend a whole flight on hard rolls and pitches and forget yaw entirely.

## Before flying with AUTOTUNE

Before taking off you need to set up a few parameters for your airplane:

parameter | explanation
--------- | -----------
roll_rate | Maximum roll rate limit for your ariplane. Must not exceed physical limit of your plane
pitch_rate | Maximum pitch rate limit for your ariplane. Must not exceed physical limit of your plane
yaw_rate | Maximum yaw rate limit for your ariplane. Must not exceed physical limit of your plane
roll_rate | Starting roll rate for your airplane. Unless you set `fw_autotune_rate_adjustment` to `FIXED` (see below), AUTOTUNE will change this value while you fly - it's a starting point, not a ceiling it respects
pitch_rate | Starting pitch rate for your airplane. Same caveat as `roll_rate`
yaw_rate | Starting yaw rate for your airplane. Same caveat as `roll_rate`
fw_autotune_rate_adjustment | Controls whether/how AUTOTUNE changes `roll_rate`/`pitch_rate`/`yaw_rate` while tuning. `AUTO` (default) raises or lowers rates to match what the plane can achieve. `LIMIT` adjusts rates the same way but caps them at your starting value - it can still raise a rate it previously lowered, just never above where you started. `FIXED` leaves rates untouched - use this if you want AUTOTUNE to tune FeedForward only
fw_autotune_min_stick | Minimum stick deflection [%] (default 50) before AUTOTUNE starts recording a maneuver as tuning data
fw_autotune_max_rate_deflection | Target servo/mixer deflection [%] (default 90) AUTOTUNE aims for when calculating an achievable rate in `AUTO`/`LIMIT`
fw_p_level | Self-leveling strength. Bigger value means sharper response
fw_i_level | Self-leveling filtering. Usual value for airplanes is 1-5 Hz
max_angle_inclination_rll | Maximum roll angle in [0.1 deg] units
max_angle_inclination_pit | Maximum pitch angle in [0.1 deg] units
tpa_breakpoint | Cruise throttle (expected throttle that you would be flying most of the time)
tpa_rate | Amount of TPS curve to apply (usually should be in range 50-80 for most airplanes)

For most hobby-sized airplanes roll/pitch rate limits should be in range 70-120 deg/s (7-12 for `roll_rate` and `pitch_rate` values). Small and agile flying wings can reach 180-200 deg/s.
For most hobby-sized airplanes, starting roll/pitch rates in the range 70-120 deg/s (7-12 for `roll_rate` and `pitch_rate` values) work well. Small and agile flying wings can reach 180-200 deg/s. With the default `AUTO` setting, don't worry about getting this exactly right - AUTOTUNE will adjust it based on what your airplane actually does, down to a floor of 40 deg/s on roll/pitch and 10 deg/s on yaw, up to a ceiling of 720 deg/s.

Other things to check:

Expand All @@ -38,15 +46,16 @@ Other things to check:

Once you are all setup you can take off normally and switch to AUTOTUNE mode once you have gained altitude.

When you engage AUTOTUNE mode a few things will happen:
When you engage AUTOTUNE a few things will happen:

* The autotune system will immediately setup some default values for your roll, pitch and yaw P and I gains
* The autotune system will monitor requested roll and pitch rates (as determined by your transmitter stick movements). When the demanded roll or pitch rate exceeds certain threshold the autotune system will use the response of the aircraft to learn roll or pitch tuning values
* Every 5 seconds the autotune system will store the snapshot of parameters you have. When you switch out of AUTOTUNE mode the last remembered parameters are restored
* The autotune system will monitor requested roll, pitch and yaw rates (as determined by your transmitter stick movements, once deflection passes `fw_autotune_min_stick`). When the demanded rate on an axis exceeds that threshold the autotune system will use the response of the aircraft to learn FeedForward (and, depending on `fw_autotune_rate_adjustment` and mode, Rate) for that axis
* Every 5 seconds the autotune system will store a snapshot of the current values. When you switch out of AUTOTUNE the last snapshot is restored - so if you exit within 5 seconds of enabling it, nothing changes
* You may find the plane is quite sluggish when you first enter AUTOTUNE. You will find that as the tune progresses this will get better. Make sure your flight area has plenty of room for slow large-radius turns.
* Don't land in AUTOTUNE mode - during landing airplane doesn't reach it full performance which may be read by autotune system as insufficient gains.

The key to a successful autotune is to input rapid movements with the transmitter sticks. You should only do one of either roll or pitch at a time, and you should move the stick rapidly to the maximum deflection.
The key to a successful autotune is to input rapid movements with the transmitter sticks. You should only exercise one of roll, pitch or yaw at a time, and you should move the stick rapidly to the maximum deflection. Don't neglect yaw - it's easy to spend the whole flight on rolls and pitches and leave yaw untuned.

Fly in ACRO if you can - AUTOTUNE only learns Rate in modes where stick position maps directly to a commanded rotation rate (ACRO, and mostly HORIZON). In ANGLE mode the stick commands an angle instead, so AUTOTUNE will still tune FeedForward but will not touch Rate at all while you're in ANGLE. AUTOTUNE has no effect whatsoever in MANUAL mode - don't fly it there.

## Don't stop too early

Expand Down
28 changes: 10 additions & 18 deletions docs/development/Converting Betaflight Targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Locate your Flight Controller target config.h in BetaFlight's repo, eg.: [config

It is also advisable to record the output of the timer command from BetaFlight, as it will provide useful information on `timer` usage that can be used to adjust the generated target later.

The script generates `CAMERA_CONTROL_PIN` and PINIO `permanentId` wiring in `config.c` automatically when present in the source `config.h`.

```
# timer
timer B08 AF3
Expand Down Expand Up @@ -38,37 +40,27 @@ Using the BETAFPVF405 target mentioned above, to create the target now we need t
3. Create a target folder that will be used as the output folder for the `bf2inav.py` script, eg: `inav/src/main/targets/BETAFPVF405`
4. Navigate to the script folder in `inav/src/utils/`
5. `python3 ./bf2inav.py -i config.h -o ../main/target/BETAFPVF405/`
6. Edit generated `target.c` and chose the correct timer definitions to match Betaflight's timer definitions.
6. Edit generated `target.c` and chose the correct timer definitions to match Betaflight's timer definitions for motor, servo, and LED timers (not gyro).
```
timerHardware_t timerHardware[] = {
DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM8, CH2N, PB0, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM1, CH2N, PB0, TIM_USE_OUTPUT_AUTO, 0, 0),

DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM8, CH3N, PB1, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM1, CH3N, PB1, TIM_USE_OUTPUT_AUTO, 0, 0),

//DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM9, CH2, PA3, TIM_USE_OUTPUT_AUTO, 0, 0),
DEF_TIM(TIM2, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0),

//DEF_TIM(TIM5, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM9, CH1, PA2, TIM_USE_OUTPUT_AUTO, 0, 0),
DEF_TIM(TIM2, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 0),

DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM3, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0),

DEF_TIM(TIM1, CH1, PA8, TIM_USE_OUTPUT_AUTO, 0, 0),

//DEF_TIM(TIM3, CH1, PB4, TIM_USE_BEEPER, 0, 0),

DEF_TIM(TIM4, CH1, PB6, TIM_USE_LED, 0, 0),

};
```
In this particular example, PA3, PA2 were changed to match Betaflight's mapping, and the timer PB4 was disabled, due to a timer conflict. Normal channels are prefered over N channels (CH1, over CH1N) or C channels in AT32 architectures.
7. Now update yout build scripts by running `cmake` and build the target you just created. The target name can be checked in the generated `CMakeLists.txt`, but should match the Betaflight target name.
Normal channels are prefered over N channels (CH1, over CH1N) or C channels in AT32 architectures.

The typical value to be set in target.h for DEFAULT_FEATURES is:
#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_TELEMETRY | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TX_PROF_SEL | FEATURE_BLACKBOX)

7. Now update your build scripts by running `cmake` and build the target you just created. The target name can be checked in the generated `CMakeLists.txt`, but should match the Betaflight target name.

For information on how to build INAV, check the documents in the [docs/development](https://github.com/iNavFlight/inav/tree/master/docs/development) folder.
For information on how to build INAV, check the documents in the [docs/development](https://github.com/iNavFlight/inav/tree/master/docs/development) folder.
2 changes: 1 addition & 1 deletion src/main/drivers/accgyro/accgyro_icm42605.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ static const aafConfig_t *getGyroAafConfig(icm42605Variant_e variant, const uint
aafConfigs = aafLUT42605;
}
int i;
int8_t selectedFreq = aafConfigs[0].freq;
uint16_t selectedFreq = aafConfigs[0].freq;
const aafConfig_t * candidate = &aafConfigs[0];

// Choose closest supported LPF value
Expand Down
96 changes: 94 additions & 2 deletions src/main/drivers/accgyro/accgyro_lsm6dxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,19 @@ typedef struct __attribute__ ((__packed__)) lsm6DContextData_s {
#define LSM6DSO_CHIP_ID 0x6C
#define LSM6DSL_CHIP_ID 0x6A
#define LSM6DS3_CHIP_ID 0x69
// "Gen V" chips - reorganized register map vs. the DSO/DSL/DS3 above, see lsm6dxxConfigGenV()
#define LSM6DSV16X_CHIP_ID 0x70
#define LSM6DSK320X_CHIP_ID 0x75

// Single physical instance assumed: set once by lsm6dxxDetect() and read by lsm6dxxConfig()/
// lsm6dxxIsGenV() afterward for the same instance - gyro detect always runs before config.
static uint8_t lsm6dID = 0x6C;

static inline bool lsm6dxxIsGenV(void)
{
return lsm6dID == LSM6DSV16X_CHIP_ID || lsm6dID == LSM6DSK320X_CHIP_ID;
}

static void lsm6dxxWriteRegister(const busDevice_t *dev, lsm6dxxRegister_e registerID, uint8_t value, unsigned delayMs)
{
busWrite(dev, registerID, value);
Expand Down Expand Up @@ -85,8 +95,88 @@ static uint8_t getLsmDlpfBandwidth(gyroDev_t *gyro)
return 0;
}

// LPF1 bandwidth options for the Gen V chips, at the fixed 7.68kHz LPF1+LPF2 table row this
// driver uses. Values cross-checked against atbetaflight's accgyro_spi_lsm6dsv16x.c, which
// uses this same mapping on real hardware.
static uint8_t getLsmVDlpfBandwidth(gyroDev_t *gyro)
{
switch (gyro->lpf) {
case GYRO_HARDWARE_LPF_NORMAL:
return LSM6DXX_VAL_CTRL6_C_V_LPF1_BW_288HZ;
case GYRO_HARDWARE_LPF_OPTION_1:
return LSM6DXX_VAL_CTRL6_C_V_LPF1_BW_157HZ;
case GYRO_HARDWARE_LPF_OPTION_2:
return LSM6DXX_VAL_CTRL6_C_V_LPF1_BW_215HZ;
case GYRO_HARDWARE_LPF_EXPERIMENTAL:
return LSM6DXX_VAL_CTRL6_C_V_LPF1_BW_455HZ;
}
return LSM6DXX_VAL_CTRL6_C_V_LPF1_BW_288HZ;
}

// Configuration for LSM6DSV16X / LSM6DSK320X ("Gen V" chips - see lsm6dxxIsGenV()). These
// reorganized CTRL1_XL/CTRL2_G to hold ODR + operating mode only (full scale moved to
// CTRL6_C/CTRL8_XL) with a different ODR bit encoding, so they need their own config sequence
// rather than sharing the legacy DSO/DSL/DS3 one below. Sequence and register values are
// cross-checked against the LSM6DSV16X and LSM6DSK320X datasheets and atbetaflight's
// accgyro_spi_lsm6dsv16x.c (hardware-validated there for LSM6DSV16X).
static void lsm6dxxConfigGenV(gyroDev_t *gyro)
{
busDevice_t * dev = gyro->busDev;

busSetSpeed(dev, BUS_SPEED_INITIALIZATION);

// Software reset, then wait for the device to clear the bit itself
lsm6dxxWriteRegister(dev, LSM6DXX_REG_CTRL3_C, LSM6DXX_MASK_CTRL3_C_RESET, 0);
uint8_t ctrl3 = LSM6DXX_MASK_CTRL3_C_RESET;
unsigned attemptsRemaining = 10;
while ((ctrl3 & LSM6DXX_MASK_CTRL3_C_RESET) && attemptsRemaining--) {
delay(1);
if (!busRead(dev, LSM6DXX_REG_CTRL3_C, &ctrl3)) {
break; // bus read failed - fall through to config once attempts are exhausted below
}
}

// Auto-increment addresses for burst reads; hold output registers stable across a burst read
lsm6dxxWriteRegister(dev, LSM6DXX_REG_CTRL3_C, LSM6DXX_VAL_CTRL3_C_IF_INC | LSM6DXX_VAL_CTRL3_C_BDU, 0);

// Selects the high-accuracy ODR table used by the CTRL1_XL/CTRL2_G writes below
lsm6dxxWriteRegister(dev, LSM6DXX_REG_HAODR_CFG, LSM6DXX_VAL_HAODR_CFG_MODE1, 0);

// Accelerometer: high-accuracy mode, 1kHz ODR, +-16g full scale
lsm6dxxWriteRegister(dev, LSM6DXX_REG_CTRL1_XL,
(LSM6DXX_VAL_CTRL1_XL_V_OPMODE_HIGH_ACCURACY << 4) | LSM6DXX_VAL_CTRL1_XL_V_ODR_1000HZ_HAODR1, 0);
lsm6dxxWriteRegister(dev, LSM6DXX_REG_CTRL8_XL, LSM6DXX_VAL_CTRL8_XL_V_FS_16G, 0);

// Gyroscope: high-accuracy mode, 8kHz ODR, +-2000dps full scale, LPF1 bandwidth per user setting
lsm6dxxWriteRegister(dev, LSM6DXX_REG_CTRL2_G,
(LSM6DXX_VAL_CTRL2_G_V_OPMODE_HIGH_ACCURACY << 4) | LSM6DXX_VAL_CTRL2_G_V_ODR_8000HZ_HAODR1, 0);
// LSM6DSK320X requires bit 3 of this register set to 1 ("must be set to 1 for correct operation of
// the device" per its datasheet) - it isn't part of the FS_G field there like it is on LSM6DSV16X
lsm6dxxWriteRegister(dev, LSM6DXX_REG_CTRL6_C,
(getLsmVDlpfBandwidth(gyro) << 4) | LSM6DXX_VAL_CTRL6_C_V_FS_G_2000DPS
| (lsm6dID == LSM6DSK320X_CHIP_ID ? LSM6DXX_VAL_CTRL6_C_V_DSK320X_RESERVED_BIT3 : 0), 0);
lsm6dxxWriteRegister(dev, LSM6DXX_REG_CTRL7_G, LSM6DXX_VAL_CTRL7_G_V_LPF1_EN, 0);

// Data-ready interrupt is a pulse (no read required to clear it), routed to pin 1
lsm6dxxWriteRegister(dev, LSM6DXX_REG_CTRL4_C, LSM6DXX_VAL_CTRL4_C_V_DRDY_PULSED, 0);
lsm6dxxWriteRegister(dev, LSM6DXX_REG_INT1_CTRL, LSM6DXX_VAL_INT1_CTRL, 0);

// Datasheet section 4.1 (Mechanical characteristics): 70mdps/LSB at +-2000dps full scale.
// This differs from the 1/16.4 constant the legacy DSO/DSL/DS3 path below uses - that
// existing value is left untouched since it's out of scope here and already shipped.
gyro->scale = 0.070f;
gyro->sampleRateIntervalUs = 125; // 8kHz gyro ODR configured above

busSetSpeed(dev, BUS_SPEED_FAST);
}

static void lsm6dxxConfig(gyroDev_t *gyro)
{
{
if (lsm6dxxIsGenV()) {
lsm6dxxConfigGenV(gyro);
return;
}

busDevice_t * dev = gyro->busDev;
const gyroFilterAndRateConfig_t * config = mpuChooseGyroConfig(gyro->lpf, 1000000 / gyro->requestedSampleIntervalUs);
gyro->sampleRateIntervalUs = 1000000 / config->gyroRateHz;
Expand Down Expand Up @@ -153,7 +243,9 @@ static bool lsm6dxxDetect(busDevice_t * dev)

switch (tmp) {
case LSM6DSO_CHIP_ID:
case LSM6DSL_CHIP_ID:
case LSM6DSL_CHIP_ID:
case LSM6DSV16X_CHIP_ID:
case LSM6DSK320X_CHIP_ID:
lsm6dID = tmp;
// Compatible chip detected
return true;
Expand Down
Loading