From 327a4a58b21deb0fdd847675863e4280f1e684ac Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sun, 7 Nov 2021 23:42:16 +0100 Subject: [PATCH] boards: add ST L3Gxxxx 3-axis gyro family --- boards/stm32f3discovery/Kconfig | 5 +++++ boards/stm32f3discovery/Makefile.dep | 7 +++++++ boards/stm32f3discovery/doc.txt | 9 ++++++--- boards/stm32f3discovery/include/board.h | 10 ++++++++++ boards/stm32f429i-disc1/Kconfig | 5 +++++ boards/stm32f429i-disc1/Makefile.dep | 7 +++++++ boards/stm32f429i-disc1/include/board.h | 14 ++++++++++++-- 7 files changed, 52 insertions(+), 5 deletions(-) diff --git a/boards/stm32f3discovery/Kconfig b/boards/stm32f3discovery/Kconfig index fdad3c17cf..aecb3f95f2 100644 --- a/boards/stm32f3discovery/Kconfig +++ b/boards/stm32f3discovery/Kconfig @@ -28,4 +28,9 @@ config BOARD_STM32F3DISCOVERY select HAVE_SAUL_GPIO select HAVE_LSM303DLHC + # L3Gxxxx gyro + select HAVE_L3GXXXX_SPI + select HAVE_I3G4250D + select HAVE_L3GD20 + source "$(RIOTBOARD)/common/stm32/Kconfig" diff --git a/boards/stm32f3discovery/Makefile.dep b/boards/stm32f3discovery/Makefile.dep index a5757c8067..670da09ba2 100644 --- a/boards/stm32f3discovery/Makefile.dep +++ b/boards/stm32f3discovery/Makefile.dep @@ -1,4 +1,11 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_gpio USEMODULE += lsm303dlhc + USEMODULE += l3gxxxx +endif + +ifneq (,$(filter l3gxxxx,$(USEMODULE))) + USEMODULE += i3g4250d + USEMODULE += l3gd20 + USEMODULE += l3gxxxx_spi endif diff --git a/boards/stm32f3discovery/doc.txt b/boards/stm32f3discovery/doc.txt index 10d96f9123..f509d5c261 100644 --- a/boards/stm32f3discovery/doc.txt +++ b/boards/stm32f3discovery/doc.txt @@ -92,11 +92,12 @@ e-compass. An 3-axis gyroscope is soldered on the board. -| Sensor | L3GD20 | +| Sensor | L3GD20/I3G4250D [1] | |:------------- |:--------------------- | | Type | Gyroscope | | Vendor | ST Microelectronics | -| Datasheet | [Datasheet](https://www.mouser.de/datasheet/2/389/l3gd20-954745.pdf) | +| Datasheet L3GD20 | [Datasheet](https://www.mouser.de/datasheet/2/389/l3gd20-954745.pdf) | +| Datasheet I3G4250D | [Datasheet](https://www.st.com/resource/en/datasheet/i3g4250d.pdf) | | Connected to | SPI_0 | | Pin Config: | | | Device | SPI1 | @@ -107,6 +108,8 @@ An 3-axis gyroscope is soldered on the board. | INT1 | PE0 (IN) | | INT2/DRDY | PE1 (IN) | +[1] L3GD20 (up to rev. D01), IG34250D (from rev. E02) +The driver detects automatically which sensor variant is on the board. ## Implementation Status @@ -123,7 +126,7 @@ An 3-axis gyroscope is soldered on the board. | | Inpute Capture| no | | | Accelerometer | LSM303DLHC | no | planned | | Magnetometer | LSM303DLHC | no | planned | -| Gyroscope | L3GD20 | no | planned | +| Gyroscope | L3GD20/I3G4250D | yes | | ## Flashing the device diff --git a/boards/stm32f3discovery/include/board.h b/boards/stm32f3discovery/include/board.h index 7f0f9c99b8..384f6edf26 100644 --- a/boards/stm32f3discovery/include/board.h +++ b/boards/stm32f3discovery/include/board.h @@ -97,6 +97,16 @@ extern "C" { #define LSM303DLHC_PARAM_MAG_PIN GPIO_PIN(PORT_E, 2) /** @} */ +/** + * @name L3GD20 (Rev. C01, D01), I3G4250D (Rev. E02) + * @{ + */ +#define L3GXXXX_SPI_DEV SPI_DEV(0) /**< SPI bus used for L3Gxxxx */ +#define L3GXXXX_SPI_CS GPIO_PIN(PORT_E, 3) /**< SPI CS pin used for L3Gxxxx */ +#define L3GXXXX_INT1_PIN GPIO_PIN(PORT_E, 0) /**< INT1 pin used for L3Gxxxx */ +#define L3GXXXX_INT2_PIN GPIO_PIN(PORT_E, 1) /**< INT2/DRDY pin used for L3Gxxxx */ +/** @} */ + #ifdef __cplusplus } #endif diff --git a/boards/stm32f429i-disc1/Kconfig b/boards/stm32f429i-disc1/Kconfig index 9c629325c4..98929a0101 100644 --- a/boards/stm32f429i-disc1/Kconfig +++ b/boards/stm32f429i-disc1/Kconfig @@ -32,4 +32,9 @@ config BOARD_STM32F429I_DISC1 select HAVE_ILI9341 select HAVE_STMPE811_I2C + # L3Gxxxx gyro + select HAVE_L3GXXXX_SPI + select HAVE_I3G4250D + select HAVE_L3GD20 + source "$(RIOTBOARD)/common/stm32/Kconfig" diff --git a/boards/stm32f429i-disc1/Makefile.dep b/boards/stm32f429i-disc1/Makefile.dep index a5fa0c5e0b..1b5ae322af 100644 --- a/boards/stm32f429i-disc1/Makefile.dep +++ b/boards/stm32f429i-disc1/Makefile.dep @@ -1,5 +1,6 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_gpio + USEMODULE += l3gxxxx endif ifneq (,$(filter disp_dev,$(USEMODULE))) @@ -9,3 +10,9 @@ endif ifneq (,$(filter touch_dev,$(USEMODULE))) USEMODULE += stmpe811_i2c endif + +ifneq (,$(filter l3gxxxx,$(USEMODULE))) + USEMODULE += i3g4250d + USEMODULE += l3gd20 + USEMODULE += l3gxxxx_spi +endif diff --git a/boards/stm32f429i-disc1/include/board.h b/boards/stm32f429i-disc1/include/board.h index 733bee800e..3fcb6d1888 100644 --- a/boards/stm32f429i-disc1/include/board.h +++ b/boards/stm32f429i-disc1/include/board.h @@ -46,13 +46,23 @@ extern "C" { /** @} */ /** - * @brief User button + * @name User button * @{ */ -#define BTN0_PIN GPIO_PIN(PORT_A, 0) +#define BTN0_PIN GPIO_PIN(PORT_A, 0) /**< GPIO used for BTN0 */ #define BTN0_MODE GPIO_IN /** @} */ +/** + * @name L3GD20 (Rev. B01, C01), I3G4250D (Rev. D02, E01) + * @{ + */ +#define L3GXXXX_SPI_DEV SPI_DEV(0) /**< SPI bus used for L3Gxxxx */ +#define L3GXXXX_SPI_CS GPIO_PIN(PORT_C, 1) /**< SPI CS pin used for L3Gxxxx */ +#define L3GXXXX_INT1_PIN GPIO_PIN(PORT_A, 1) /**< INT1 pin used for L3Gxxxx */ +#define L3GXXXX_INT2_PIN GPIO_PIN(PORT_A, 2) /**< INT2/DRDY pin used for L3Gxxxx */ +/** @} */ + #ifdef __cplusplus } #endif