From 9c246173c614bc92a6d3f072e66ab0074bed6806 Mon Sep 17 00:00:00 2001 From: yangjie Date: Fri, 10 May 2019 14:49:49 +0800 Subject: [PATCH] =?UTF-8?q?[bsp][stm32/stm32l475-atk-pandora]=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20sensor=20=E6=A1=86=E6=9E=B6=E4=B8=8B=20aht10=20?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/stm32/stm32l475-atk-pandora/board/Kconfig | 9 ++++++++ .../stm32l475-atk-pandora/board/SConscript | 2 +- .../board/ports/sensor_port.c | 21 ++++++++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/bsp/stm32/stm32l475-atk-pandora/board/Kconfig b/bsp/stm32/stm32l475-atk-pandora/board/Kconfig index 54ee1707d..f167be8b1 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/Kconfig +++ b/bsp/stm32/stm32l475-atk-pandora/board/Kconfig @@ -37,6 +37,15 @@ menu "Onboard Peripheral Drivers" select PKG_USING_MPU6XXX select PKG_USING_MPU6XXX_LATEST_VERSION default n + + config BSP_USING_AHT10 + bool "Enable aht10 (i2c4)" + select BSP_USING_I2C + select BSP_USING_I2C4 + select PKG_USING_SENSORS_DRIVERS + select PKG_USING_AHT10 + select PKG_USING_AHT10_LATEST_VERSION + default n endmenu diff --git a/bsp/stm32/stm32l475-atk-pandora/board/SConscript b/bsp/stm32/stm32l475-atk-pandora/board/SConscript index 05018ba3a..a525708b6 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/SConscript +++ b/bsp/stm32/stm32l475-atk-pandora/board/SConscript @@ -18,7 +18,7 @@ if GetDepend(['BSP_USING_QSPI_FLASH']): if GetDepend(['BSP_USING_SDCARD']): src += Glob('ports/sdcard_port.c') -if GetDepend(['BSP_USING_ICM20608']): +if GetDepend(['BSP_USING_ICM20608']) or GetDepend(['BSP_USING_AHT10']): src += Glob('ports/sensor_port.c') path = [cwd] diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/sensor_port.c b/bsp/stm32/stm32l475-atk-pandora/board/ports/sensor_port.c index e755e9ac9..d253cc179 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/ports/sensor_port.c +++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/sensor_port.c @@ -19,7 +19,7 @@ int sensor_init(void) cfg.intf.type = RT_SENSOR_INTF_I2C; cfg.intf.dev_name = "i2c3"; - cfg.intf.user_data = (void*)MPU6XXX_ADDR_DEFAULT; + cfg.intf.user_data = (void *)MPU6XXX_ADDR_DEFAULT; cfg.irq_pin.pin = RT_PIN_NONE; rt_hw_mpu6xxx_init("icm", &cfg); @@ -29,3 +29,22 @@ int sensor_init(void) INIT_ENV_EXPORT(sensor_init); #endif + +#ifdef BSP_USING_AHT10 +#include "sensor_asair_aht10.h" + +#define AHT10_I2C_BUS "i2c4" + +int rt_hw_aht10_port(void) +{ + struct rt_sensor_config cfg; + + cfg.intf.dev_name = AHT10_I2C_BUS; + cfg.intf.user_data = (void *)AHT10_I2C_ADDR; + + rt_hw_aht10_init("aht10", &cfg); + + return RT_EOK; +} +INIT_ENV_EXPORT(rt_hw_aht10_port); +#endif -- GitLab