[bsp][stm32][pandora] 添加 icm20608 及 flash 文件系统支持.

This commit is contained in:
guozhanxin 2019-05-08 16:50:39 +08:00
parent abc5fff696
commit a2048b6c76
4 changed files with 108 additions and 45 deletions

View File

@ -29,6 +29,15 @@ menu "Onboard Peripheral Drivers"
select RT_USING_DFS_ELMFAT select RT_USING_DFS_ELMFAT
default n 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 endmenu
menu "On-chip Peripheral Drivers" menu "On-chip Peripheral Drivers"
@ -112,55 +121,42 @@ menu "On-chip Peripheral Drivers"
bool "Enable QSPI DMA support" bool "Enable QSPI DMA support"
default n default n
menuconfig BSP_USING_I2C1 menuconfig BSP_USING_I2C
bool "Enable I2C1 BUS (software simulation)" bool "Enable I2C BUS"
default n default n
select RT_USING_I2C select RT_USING_I2C
select RT_USING_I2C_BITOPS select RT_USING_I2C_BITOPS
select RT_USING_PIN select RT_USING_PIN
if BSP_USING_I2C1 if BSP_USING_I2C
config BSP_I2C1_SCL_PIN menuconfig BSP_USING_I2C3
int "i2c1 scl pin number" bool "Enable I2C3 BUS (software simulation)"
range 1 176 default y
default 15 if BSP_USING_I2C3
config BSP_I2C1_SDA_PIN comment "Notice: PC0 --> 32; PC1 --> 33"
int "I2C1 sda pin number" config BSP_I2C3_SCL_PIN
range 1 176 int "i2c3 scl pin number"
default 16 range 1 176
endif default 32
config BSP_I2C3_SDA_PIN
int "I2C3 sda pin number"
range 1 176
default 33
endif
menuconfig BSP_USING_I2C2 menuconfig BSP_USING_I2C4
bool "Enable I2C2 BUS (software simulation)" bool "Enable I2C4 BUS (AHT10)"
default n default n
select RT_USING_I2C if BSP_USING_I2C4
select RT_USING_I2C_BITOPS comment "Notice: PC1 --> 33; PD6 --> 54"
select RT_USING_PIN config BSP_I2C4_SCL_PIN
if BSP_USING_I2C2 int "i2c4 scl pin number"
config BSP_I2C2_SCL_PIN range 1 176
int "i2c2 scl pin number" default 54
range 1 176 config BSP_I2C4_SDA_PIN
default 47 int "I2C4 sda pin number"
config BSP_I2C2_SDA_PIN range 1 176
int "I2C2 sda pin number" default 33
range 1 176 endif
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
endif endif
menuconfig BSP_USING_TIM menuconfig BSP_USING_TIM

View File

@ -18,6 +18,9 @@ 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']):
src += Glob('ports/sensor_port.c')
path = [cwd] path = [cwd]
path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/CubeMX_Config/Inc']
path += [cwd + '/ports'] path += [cwd + '/ports']

View File

@ -74,4 +74,37 @@ static int rt_hw_qspi_flash_with_sfud_init(void)
} }
INIT_COMPONENT_EXPORT(rt_hw_qspi_flash_with_sfud_init); 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 <dfs_fs.h>
#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 */

View File

@ -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 <board.h>
#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