From a2048b6c76dab0f6300a1900cb63985f6fc15d8c Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Wed, 8 May 2019 16:50:39 +0800 Subject: [PATCH] =?UTF-8?q?[bsp][stm32][pandora]=20=E6=B7=BB=E5=8A=A0=20ic?= =?UTF-8?q?m20608=20=E5=8F=8A=20flash=20=E6=96=87=E4=BB=B6=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=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 | 84 +++++++++---------- .../stm32l475-atk-pandora/board/SConscript | 3 + .../board/ports/drv_qspi_flash.c | 35 +++++++- .../board/ports/sensor_port.c | 31 +++++++ 4 files changed, 108 insertions(+), 45 deletions(-) create mode 100644 bsp/stm32/stm32l475-atk-pandora/board/ports/sensor_port.c diff --git a/bsp/stm32/stm32l475-atk-pandora/board/Kconfig b/bsp/stm32/stm32l475-atk-pandora/board/Kconfig index 90cf83801f..54ee1707d3 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/Kconfig +++ b/bsp/stm32/stm32l475-atk-pandora/board/Kconfig @@ -29,6 +29,15 @@ menu "Onboard Peripheral Drivers" select RT_USING_DFS_ELMFAT default n + config BSP_USING_ICM20608 + bool "Enable icm20608 (i2c3)" + select BSP_USING_I2C + select BSP_USING_I2C3 + select PKG_USING_SENSORS_DRIVERS + select PKG_USING_MPU6XXX + select PKG_USING_MPU6XXX_LATEST_VERSION + default n + endmenu menu "On-chip Peripheral Drivers" @@ -112,55 +121,42 @@ menu "On-chip Peripheral Drivers" bool "Enable QSPI DMA support" default n - menuconfig BSP_USING_I2C1 - bool "Enable I2C1 BUS (software simulation)" + menuconfig BSP_USING_I2C + bool "Enable I2C BUS" default n select RT_USING_I2C select RT_USING_I2C_BITOPS select RT_USING_PIN - if BSP_USING_I2C1 - config BSP_I2C1_SCL_PIN - int "i2c1 scl pin number" - range 1 176 - default 15 - config BSP_I2C1_SDA_PIN - int "I2C1 sda pin number" - range 1 176 - default 16 - endif + if BSP_USING_I2C + menuconfig BSP_USING_I2C3 + bool "Enable I2C3 BUS (software simulation)" + default y + if BSP_USING_I2C3 + comment "Notice: PC0 --> 32; PC1 --> 33" + config BSP_I2C3_SCL_PIN + int "i2c3 scl pin number" + range 1 176 + default 32 + config BSP_I2C3_SDA_PIN + int "I2C3 sda pin number" + range 1 176 + default 33 + endif - menuconfig BSP_USING_I2C2 - bool "Enable I2C2 BUS (software simulation)" - default n - select RT_USING_I2C - select RT_USING_I2C_BITOPS - select RT_USING_PIN - if BSP_USING_I2C2 - config BSP_I2C2_SCL_PIN - int "i2c2 scl pin number" - range 1 176 - default 47 - config BSP_I2C2_SDA_PIN - int "I2C2 sda pin number" - range 1 176 - default 48 - endif - - menuconfig BSP_USING_I2C3 - bool "Enable I2C3 BUS (software simulation)" - default n - select RT_USING_I2CS - select RT_USING_I2C_BITOPS - select RT_USING_PIN - if BSP_USING_I2C3 - config BSP_I2C3_SCL_PIN - int "i2c3 scl pin number" - range 1 176 - default 92 - config BSP_I2C3_SDA_PIN - int "I2C3 sda pin number" - range 1 176 - default 93 + menuconfig BSP_USING_I2C4 + bool "Enable I2C4 BUS (AHT10)" + default n + if BSP_USING_I2C4 + comment "Notice: PC1 --> 33; PD6 --> 54" + config BSP_I2C4_SCL_PIN + int "i2c4 scl pin number" + range 1 176 + default 54 + config BSP_I2C4_SDA_PIN + int "I2C4 sda pin number" + range 1 176 + default 33 + endif endif menuconfig BSP_USING_TIM diff --git a/bsp/stm32/stm32l475-atk-pandora/board/SConscript b/bsp/stm32/stm32l475-atk-pandora/board/SConscript index fb51c3cc0a..05018ba3ab 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/SConscript +++ b/bsp/stm32/stm32l475-atk-pandora/board/SConscript @@ -18,6 +18,9 @@ if GetDepend(['BSP_USING_QSPI_FLASH']): if GetDepend(['BSP_USING_SDCARD']): src += Glob('ports/sdcard_port.c') +if GetDepend(['BSP_USING_ICM20608']): + src += Glob('ports/sensor_port.c') + path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/ports'] diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_qspi_flash.c b/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_qspi_flash.c index 36ecb754e9..aef2226239 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_qspi_flash.c +++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_qspi_flash.c @@ -74,4 +74,37 @@ static int rt_hw_qspi_flash_with_sfud_init(void) } INIT_COMPONENT_EXPORT(rt_hw_qspi_flash_with_sfud_init); -#endif/* BSP_USING_QSPI_FLASH */ +#if defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD) +#include + +#define BLK_DEV_NAME "W25Q128" + +int mnt_init(void) +{ + rt_thread_delay(RT_TICK_PER_SECOND); + + if (dfs_mount(BLK_DEV_NAME, "/", "elm", 0, 0) == 0) + { + rt_kprintf("file system initialization done!\n"); + } + else + { + if(dfs_mkfs("elm", BLK_DEV_NAME) == 0) + { + if (dfs_mount(BLK_DEV_NAME, "/", "elm", 0, 0) == 0) + { + rt_kprintf("file system initialization done!\n"); + } + else + { + rt_kprintf("file system initialization failed!\n"); + } + } + } + + return 0; +} +INIT_ENV_EXPORT(mnt_init); + +#endif /* defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD) */ +#endif /* BSP_USING_QSPI_FLASH */ diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/sensor_port.c b/bsp/stm32/stm32l475-atk-pandora/board/ports/sensor_port.c new file mode 100644 index 0000000000..e755e9ac9c --- /dev/null +++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/sensor_port.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2019-05-08 flaybreak add sensor port file + */ + +#include + +#ifdef BSP_USING_ICM20608 +#include "sensor_inven_mpu6xxx.h" + +int sensor_init(void) +{ + struct rt_sensor_config cfg; + + cfg.intf.type = RT_SENSOR_INTF_I2C; + cfg.intf.dev_name = "i2c3"; + cfg.intf.user_data = (void*)MPU6XXX_ADDR_DEFAULT; + cfg.irq_pin.pin = RT_PIN_NONE; + + rt_hw_mpu6xxx_init("icm", &cfg); + + return 0; +} +INIT_ENV_EXPORT(sensor_init); + +#endif