Skip to content

STMicro LIS2MDL mag support #13150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 5, 2023
Merged

Conversation

SteveCEvans
Copy link
Member

This PR adds support for the STMicro LIS2MDL magnetometer.

This has been tested on a MATEKH743 and STMicro STEVAL-MKI181V1 eval card using the following config changes with the eval board wired to I2C bus 1 and the eval card CS pin tied to Vdd.

diff --git a/configs/MATEKH743/config.h b/configs/MATEKH743/config.h
index d404381..c413121 100644
--- a/configs/MATEKH743/config.h
+++ b/configs/MATEKH743/config.h
@@ -39,6 +39,8 @@
 #define USE_BARO
 #define USE_BARO_BMP280
 #define USE_BARO_DPS310
+#define USE_MAG
+#define USE_MAG_LIS2MDL
 #define USE_MAX7456
 #define USE_SDCARD

image

Copy link

Do you want to test this code? You can flash it directly from Betaflight Configurator:

  • Simply put #13150 (this pull request number) in the Select commit field of the Configurator firmware flasher tab (you need to Enable expert mode, Show release candidates and Development).

WARNING: It may be unstable. Use only for testing!

Copy link
Member

@haslinghuis haslinghuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haslinghuis haslinghuis added this to the 4.5 milestone Oct 31, 2023
@sugaarK
Copy link
Member

sugaarK commented Nov 1, 2023

Don’t have one yet @SteveCEvans but it’s comi bf from airbot

@blckmn
Copy link
Member

blckmn commented Nov 1, 2023

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> FAIL
  • assigned to a milestone -> PASS
  • cooling off period lapsed -> PASS
  • commit count less or equal to three -> PASS
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> PASS
  • Tested label found -> FAIL
  • assigned to an approver -> PASS
  • approver count at least three -> FAIL

@@ -204,6 +205,22 @@ bool compassDetect(magDev_t *magDev, uint8_t *alignment)
#endif
FALLTHROUGH;

case MAG_LIS2MDL:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's almost time to use some cleaner way to do initialization.. The code duplication is incredible ...

@SteveCEvans
Copy link
Member Author

Should we use https://github.com/betaflight/betaflight/blob/master/DEFAULT_LICENCE.md on new files?

Fixed. Thanks.

@ctzsnooze
Copy link
Member

Thanks, Steve.
100Hz ODR should work well.
Link to datasheet.

@SteveCEvans
Copy link
Member Author

Thanks, Steve.
100Hz ODR should work well.
Link to datasheet.

The datasheet is linked in the description 😉

@ctzsnooze
Copy link
Member

Let's get this merged, to be included with 4.5 RC1.

@blckmn blckmn merged commit 465b05e into betaflight:master Dec 5, 2023
freasy pushed a commit to freasy/betaflight that referenced this pull request Jan 22, 2024
* STMicro LIS2MDL mag support

* Fix copyright headers

* Update PG_COMPASS_CONFIG
davidbitton pushed a commit to davidbitton/betaflight that referenced this pull request Feb 5, 2024
* STMicro LIS2MDL mag support

* Fix copyright headers

* Update PG_COMPASS_CONFIG
@dakejahl
Copy link
Contributor

@SteveCEvans Is there any reason why BDU and OFF_CANC are not used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

7 participants