1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 11:29:58 +03:00

Allow overriding the spi clock speed for icm42688 (#13346)

There was a report of glitches on the raw gyro output of an icm42688
which were resolved by reducing the the SPI clock speed. I don't think
a single report justifies changing the default speed or even adding a
CLI command to make it configurable, but it's relatively low impact to
allow the speed to be set at compile time by passing the value via
EXTRA_FLAGS and this will make it easier to see if changing the speed
solves any future cases that might turn up. Passing the original macro
name caused the cloud builds to fail, so this PR introduces a new, shorter
macro for setting the override value; ICM426XX_CLOCK

When passing a value for a macro through EXTRA_FLAGS for a manual compile
we need to use single quotes, e.g. to set 12MHz we could use

-D'ICM426XX_CLOCK=12000000'

When using the configurator to start a cloud build the value can be placed
in the "Custom Defines" text box as

ICM426XX_CLOCK=12000000

(or whatever value is desired)
This commit is contained in:
James 2024-02-08 09:17:25 -05:00 committed by GitHub
parent 744ab454b1
commit 3726df1b71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -45,8 +45,16 @@
#include "sensors/gyro.h"
// 24 MHz max SPI frequency
// Allows frequency to be set from the compile line EXTRA_FLAGS by adding e.g.
// -D'ICM426XX_CLOCK=12000000'. If using the configurator this simply becomes
// ICM426XX_CLOCK=12000000 in the custom settings text box.
#ifndef ICM426XX_CLOCK
// Default: 24 MHz max SPI frequency
#define ICM426XX_MAX_SPI_CLK_HZ 24000000
#else
// Use the supplied value
#define ICM426XX_MAX_SPI_CLK_HZ ICM426XX_CLOCK
#endif
#define ICM426XX_RA_REG_BANK_SEL 0x76
#define ICM426XX_BANK_SELECT0 0x00