[bsp][stm32/stm32l475-atk-pandora]添加 sensor 框架下 aht10 的支持

This commit is contained in:
yangjie 2019-05-10 14:49:49 +08:00
parent 1dd364b45a
commit 9c246173c6
3 changed files with 30 additions and 2 deletions

View File

@ -38,6 +38,15 @@ menu "Onboard Peripheral Drivers"
select PKG_USING_MPU6XXX_LATEST_VERSION select PKG_USING_MPU6XXX_LATEST_VERSION
default n 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 endmenu
menu "On-chip Peripheral Drivers" menu "On-chip Peripheral Drivers"

View File

@ -18,7 +18,7 @@ if GetDepend(['BSP_USING_QSPI_FLASH']):
if GetDepend(['BSP_USING_SDCARD']): if GetDepend(['BSP_USING_SDCARD']):
src += Glob('ports/sdcard_port.c') 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') src += Glob('ports/sensor_port.c')
path = [cwd] path = [cwd]

View File

@ -19,7 +19,7 @@ int sensor_init(void)
cfg.intf.type = RT_SENSOR_INTF_I2C; cfg.intf.type = RT_SENSOR_INTF_I2C;
cfg.intf.dev_name = "i2c3"; 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; cfg.irq_pin.pin = RT_PIN_NONE;
rt_hw_mpu6xxx_init("icm", &cfg); rt_hw_mpu6xxx_init("icm", &cfg);
@ -29,3 +29,22 @@ int sensor_init(void)
INIT_ENV_EXPORT(sensor_init); INIT_ENV_EXPORT(sensor_init);
#endif #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