Skip to content

Commit a2048b6

Browse files
committed
[bsp][stm32][pandora] 添加 icm20608 及 flash 文件系统支持.
1 parent abc5fff commit a2048b6

File tree

4 files changed

+109
-46
lines changed

4 files changed

+109
-46
lines changed

bsp/stm32/stm32l475-atk-pandora/board/Kconfig

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ menu "Onboard Peripheral Drivers"
2929
select RT_USING_DFS_ELMFAT
3030
default n
3131

32+
config BSP_USING_ICM20608
33+
bool "Enable icm20608 (i2c3)"
34+
select BSP_USING_I2C
35+
select BSP_USING_I2C3
36+
select PKG_USING_SENSORS_DRIVERS
37+
select PKG_USING_MPU6XXX
38+
select PKG_USING_MPU6XXX_LATEST_VERSION
39+
default n
40+
3241
endmenu
3342

3443
menu "On-chip Peripheral Drivers"
@@ -112,55 +121,42 @@ menu "On-chip Peripheral Drivers"
112121
bool "Enable QSPI DMA support"
113122
default n
114123

115-
menuconfig BSP_USING_I2C1
116-
bool "Enable I2C1 BUS (software simulation)"
117-
default n
118-
select RT_USING_I2C
119-
select RT_USING_I2C_BITOPS
120-
select RT_USING_PIN
121-
if BSP_USING_I2C1
122-
config BSP_I2C1_SCL_PIN
123-
int "i2c1 scl pin number"
124-
range 1 176
125-
default 15
126-
config BSP_I2C1_SDA_PIN
127-
int "I2C1 sda pin number"
128-
range 1 176
129-
default 16
130-
endif
131-
132-
menuconfig BSP_USING_I2C2
133-
bool "Enable I2C2 BUS (software simulation)"
124+
menuconfig BSP_USING_I2C
125+
bool "Enable I2C BUS"
134126
default n
135127
select RT_USING_I2C
136128
select RT_USING_I2C_BITOPS
137129
select RT_USING_PIN
138-
if BSP_USING_I2C2
139-
config BSP_I2C2_SCL_PIN
140-
int "i2c2 scl pin number"
141-
range 1 176
142-
default 47
143-
config BSP_I2C2_SDA_PIN
144-
int "I2C2 sda pin number"
145-
range 1 176
146-
default 48
147-
endif
148-
149-
menuconfig BSP_USING_I2C3
150-
bool "Enable I2C3 BUS (software simulation)"
151-
default n
152-
select RT_USING_I2CS
153-
select RT_USING_I2C_BITOPS
154-
select RT_USING_PIN
155-
if BSP_USING_I2C3
156-
config BSP_I2C3_SCL_PIN
157-
int "i2c3 scl pin number"
158-
range 1 176
159-
default 92
160-
config BSP_I2C3_SDA_PIN
161-
int "I2C3 sda pin number"
162-
range 1 176
163-
default 93
130+
if BSP_USING_I2C
131+
menuconfig BSP_USING_I2C3
132+
bool "Enable I2C3 BUS (software simulation)"
133+
default y
134+
if BSP_USING_I2C3
135+
comment "Notice: PC0 --> 32; PC1 --> 33"
136+
config BSP_I2C3_SCL_PIN
137+
int "i2c3 scl pin number"
138+
range 1 176
139+
default 32
140+
config BSP_I2C3_SDA_PIN
141+
int "I2C3 sda pin number"
142+
range 1 176
143+
default 33
144+
endif
145+
146+
menuconfig BSP_USING_I2C4
147+
bool "Enable I2C4 BUS (AHT10)"
148+
default n
149+
if BSP_USING_I2C4
150+
comment "Notice: PC1 --> 33; PD6 --> 54"
151+
config BSP_I2C4_SCL_PIN
152+
int "i2c4 scl pin number"
153+
range 1 176
154+
default 54
155+
config BSP_I2C4_SDA_PIN
156+
int "I2C4 sda pin number"
157+
range 1 176
158+
default 33
159+
endif
164160
endif
165161

166162
menuconfig BSP_USING_TIM

bsp/stm32/stm32l475-atk-pandora/board/SConscript

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ if GetDepend(['BSP_USING_QSPI_FLASH']):
1818
if GetDepend(['BSP_USING_SDCARD']):
1919
src += Glob('ports/sdcard_port.c')
2020

21+
if GetDepend(['BSP_USING_ICM20608']):
22+
src += Glob('ports/sensor_port.c')
23+
2124
path = [cwd]
2225
path += [cwd + '/CubeMX_Config/Inc']
2326
path += [cwd + '/ports']

bsp/stm32/stm32l475-atk-pandora/board/ports/drv_qspi_flash.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,37 @@ static int rt_hw_qspi_flash_with_sfud_init(void)
7474
}
7575
INIT_COMPONENT_EXPORT(rt_hw_qspi_flash_with_sfud_init);
7676

77-
#endif/* BSP_USING_QSPI_FLASH */
77+
#if defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD)
78+
#include <dfs_fs.h>
79+
80+
#define BLK_DEV_NAME "W25Q128"
81+
82+
int mnt_init(void)
83+
{
84+
rt_thread_delay(RT_TICK_PER_SECOND);
85+
86+
if (dfs_mount(BLK_DEV_NAME, "/", "elm", 0, 0) == 0)
87+
{
88+
rt_kprintf("file system initialization done!\n");
89+
}
90+
else
91+
{
92+
if(dfs_mkfs("elm", BLK_DEV_NAME) == 0)
93+
{
94+
if (dfs_mount(BLK_DEV_NAME, "/", "elm", 0, 0) == 0)
95+
{
96+
rt_kprintf("file system initialization done!\n");
97+
}
98+
else
99+
{
100+
rt_kprintf("file system initialization failed!\n");
101+
}
102+
}
103+
}
104+
105+
return 0;
106+
}
107+
INIT_ENV_EXPORT(mnt_init);
108+
109+
#endif /* defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD) */
110+
#endif /* BSP_USING_QSPI_FLASH */
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2019-05-08 flaybreak add sensor port file
9+
*/
10+
11+
#include <board.h>
12+
13+
#ifdef BSP_USING_ICM20608
14+
#include "sensor_inven_mpu6xxx.h"
15+
16+
int sensor_init(void)
17+
{
18+
struct rt_sensor_config cfg;
19+
20+
cfg.intf.type = RT_SENSOR_INTF_I2C;
21+
cfg.intf.dev_name = "i2c3";
22+
cfg.intf.user_data = (void*)MPU6XXX_ADDR_DEFAULT;
23+
cfg.irq_pin.pin = RT_PIN_NONE;
24+
25+
rt_hw_mpu6xxx_init("icm", &cfg);
26+
27+
return 0;
28+
}
29+
INIT_ENV_EXPORT(sensor_init);
30+
31+
#endif

0 commit comments

Comments
 (0)