Skip to content

Commit c96c89b

Browse files
committed
bsp_gd32470z-lckfb: 增加维护者信息,完善 SPI Flash 支持与配置说明
1 parent 890a4ba commit c96c89b

File tree

4 files changed

+128
-73
lines changed

4 files changed

+128
-73
lines changed

MAINTAINERS

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ tag: bsp_cvitek
4949
path: bsp/cvitek
5050
owners: Chen Wang(unicornx)<[email protected]>
5151

52+
tag: bsp_gd32470z-lckfb
53+
path: bsp/gd32/arm/gd32470z-lckfb
54+
owners: Wu Ying Xiang(godmial)<[email protected]>
55+
5256
tag: bsp_k230
5357
path: bsp/k230
5458
owners: Chen Wang(unicornx)<[email protected]>
@@ -78,7 +82,3 @@ owners: Bingru Zhang(Rbb666)<[email protected]>, Yuqiang Wang(kurisaW)<2053731441
7882
tag: workflow
7983
path: .github
8084
owners: supper thomas(supperthomas)<[email protected]>, Bingru Zhang(Rbb666)<[email protected]>, Yuqiang Wang(kurisaW)<[email protected]>
81-
82-
tag: gd32470z-lckfb-lcd
83-
path: bsp/gd32/arm/gd32470z-lckfb/board/ports
84-
owners: Wu Ying Xiang(godmial)<[email protected]>

bsp/gd32/arm/gd32470z-lckfb/README.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ GD32470Z-LCKFB梁山派是立创开发板推出的一款GD32F470系列的开发
1313
- GD32F470ZGT6,主频 240MHz,CPU内核:ARM Cortex-M4,1024KB FLASH ,512KB RAM
1414
- 常用外设
1515

16-
- 用户LED :4个,LED1 (PE3),LED2(PD7),LED3(PG3),LED4(PA5)
16+
- 用户LED :4个,LED1PE3),LED2(PD7),LED3(PG3),LED4(PA5)
1717
- 电源指示灯:一个红色LED
1818
- 按键:3个,KEY_UP(PA0),RESET(NRST),BOOT0(PB2)
1919
- General TM * 10、Advanced TM * 2、Basic TM * 2
@@ -44,14 +44,18 @@ GD32470Z-LCKFB梁山派是立创开发板推出的一款GD32F470系列的开发
4444

4545
## 外设支持
4646

47-
本 BSP 目前对外设的支持情况如下:
4847

4948
| **片上外设** | **支持情况** | **备注** |
50-
|:-------- |:--------:|:-------------------------------- |
51-
| GPIO | 支持 | PA0, PA1... ---> PIN: 0, 1...113 |
52-
| UART | 支持 | UART0 - UART7 |
53-
| **扩展模块** | **支持情况** | **备注** |
54-
| LCD+触摸屏 | 支持 | 暂不支持中文显示(因 Keil5 编码限制),使用方法请查看bsp\gd32\arm\gd32470z-lckfb\board\ports\README.md |
49+
|:------------|:------------:|:----------------------------------|
50+
| GPIO | 支持 | PA0, PA1... ---> PIN: 0, 1...113 |
51+
| UART | 支持 | UART0 - UART7 |
52+
| SPI | 支持 | 支持 SPI0 ~ SPI4,可配置多个总线 |
53+
| **扩展模块** | **支持情况** | **备注** |
54+
| LCD+触摸屏 | 支持 | 暂不支持中文显示(因 Keil5 编码限制),使用方法请查看bsp\gd32\arm\gd32470z-lckfb\board\ports\README.md |
55+
| **板载外设** | **支持情况** | **备注** |
56+
| SPI Flash | 支持 | 板载 W25Q64,挂载在 SPI4,总线名:spi4,设备名:spi40 |
57+
58+
5559

5660
## 使用说明
5761

@@ -107,10 +111,27 @@ msh />
107111

108112
## 注意事项
109113

110-
暂无
114+
115+
- 目前DFS支持有问题,若需使用板载 SPI Flash,请在 `menuconfig` 中启用以下配置:
116+
117+
```
118+
RT-Thread Components --->
119+
DFS: device virtual file system --->
120+
[ ] DFS: device virtual file system (RT_USING_DFS) 关闭DFS
121+
Device Drivers --->
122+
[*] Enable SPI BUS support (RT_USING_SPI)
123+
[*] Enable SFUD for SPI Flash (RT_USING_SFUD)
124+
125+
Hardware Drivers Config --->
126+
On-chip Peripheral Drivers --->
127+
[*] Enable SPI BUS (BSP_USING_SPI)
128+
[*] Enable SPI4 BUS (BSP_USING_SPI4)
129+
```
130+
111131

112132
## 联系人信息
113133

114134
维护人:
115135

136+
- [godmial](https://github.com/godmial), 邮箱:<[email protected]>
116137
- [yuanzihao](https://github.com/zihao-yuan/), 邮箱:<[email protected]>

bsp/gd32/arm/gd32470z-lckfb/board/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,21 @@ menu "On-chip Peripheral Drivers"
319319
depends on BSP_USING_SPI1
320320
select BSP_SPI1_TX_USING_DMA
321321
default n
322+
323+
config BSP_USING_SPI4
324+
bool "Enable SPI4 BUS"
325+
default n
326+
327+
config BSP_SPI4_TX_USING_DMA
328+
bool "Enable SPI4 TX DMA"
329+
depends on BSP_USING_SPI4
330+
default n
331+
332+
config BSP_SPI4_RX_USING_DMA
333+
bool "Enable SPI4 RX DMA"
334+
depends on BSP_USING_SPI4
335+
select BSP_SPI4_TX_USING_DMA
336+
default n
322337
endif
323338

324339
menuconfig BSP_USING_I2C1
Lines changed: 80 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
/*
2-
* Copyright (c) 2006-2022, RT-Thread Development Team
3-
*
4-
* SPDX-License-Identifier: Apache-2.0
5-
*
6-
* Change Logs:
7-
* Date Author Notes
8-
* 2021-12-31 BruceOu first implementation
9-
* 2023-06-03 CX fixed sf probe error bug
10-
*/
111
#include <board.h>
122
#include "drv_spi.h"
133
#include "dev_spi_flash.h"
@@ -19,72 +9,101 @@
199
#include <rthw.h>
2010
#include <finsh.h>
2111

22-
#define SPI_BUS_NAME "spi0"
23-
#define SPI_DEVICE_NAME "spi01"
24-
#define SPI_FLASH_DEVICE_NAME "gd25q"
25-
26-
#define GD25Q_SPI_CS_GPIOX_CLK RCU_GPIOE
27-
#define GD25Q_SPI_CS_GPIOX GPIOE
28-
#define GD25Q_SPI_CS_GPIOX_PIN_X GPIO_PIN_3
12+
#ifdef RT_USING_DFS
13+
#include <dfs_fs.h>
14+
#endif
2915

30-
static int rt_hw_spi_flash_init(void)
16+
struct spi_flash_config
3117
{
32-
rt_err_t res;
33-
static struct rt_spi_device spi_dev_gd25q; /* SPI device */
34-
static struct gd32_spi_cs spi_cs;
35-
spi_cs.GPIOx = GD25Q_SPI_CS_GPIOX;
36-
spi_cs.GPIO_Pin = GD25Q_SPI_CS_GPIOX_PIN_X;
18+
const char *bus_name;
19+
const char *device_name;
20+
const char *flash_name;
21+
rt_base_t cs_pin;
22+
};
3723

38-
rcu_periph_clock_enable(GD25Q_SPI_CS_GPIOX_CLK);
39-
#if defined SOC_SERIES_GD32F4xx
40-
gpio_mode_set(spi_cs.GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, spi_cs.GPIO_Pin);
41-
gpio_output_options_set(spi_cs.GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, spi_cs.GPIO_Pin);
24+
static const struct spi_flash_config flash_configs[] =
25+
{
26+
#ifdef BSP_USING_SPI0
27+
{
28+
.bus_name = "spi0",
29+
.device_name = "spi00",
30+
.flash_name = "gd25q_spi0",
31+
.cs_pin = GET_PIN(A, 4),
32+
},
33+
#endif
4234

43-
gpio_bit_set(spi_cs.GPIOx, spi_cs.GPIO_Pin);
44-
#else
45-
gpio_init(spi_cs.GPIOx, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, spi_cs.GPIO_Pin);
35+
#ifdef BSP_USING_SPI1
36+
{
37+
.bus_name = "spi1",
38+
.device_name = "spi10",
39+
.flash_name = "gd25q_spi1",
40+
.cs_pin = GET_PIN(B, 9),
41+
},
42+
#endif
4643

44+
#ifdef BSP_USING_SPI2
45+
{
46+
.bus_name = "spi2",
47+
.device_name = "spi20",
48+
.flash_name = "gd25q_spi2",
49+
.cs_pin = GET_PIN(B, 12),
50+
},
4751
#endif
48-
res = rt_spi_bus_attach_device(&spi_dev_gd25q, SPI_FLASH_DEVICE_NAME, SPI_BUS_NAME, (void*)&spi_cs);
4952

50-
if (res != RT_EOK)
51-
{
52-
rt_kprintf("rt_spi_bus_attach_device() run failed!\n");
53-
return res;
54-
}
53+
#ifdef BSP_USING_SPI3
54+
{
55+
.bus_name = "spi3",
56+
.device_name = "spi30",
57+
.flash_name = "gd25q_spi3",
58+
.cs_pin = GET_PIN(E, 4),
59+
},
60+
#endif
5561

56-
return RT_EOK;
57-
}
58-
INIT_DEVICE_EXPORT(rt_hw_spi_flash_init);
62+
#ifdef BSP_USING_SPI4
63+
{
64+
.bus_name = "spi4",
65+
.device_name = "spi40",
66+
.flash_name = "gd25qsp",
67+
.cs_pin = GET_PIN(F, 6),
68+
},
69+
#endif
70+
};
5971

60-
#ifdef RT_USING_SFUD
61-
static int rt_hw_spi_flash_with_sfud_init(void)
72+
static int spi_flash_init(void)
6273
{
63-
if (RT_NULL == rt_sfud_flash_probe(SPI_FLASH_DEVICE_NAME, SPI_DEVICE_NAME))
74+
int result = RT_EOK;
75+
76+
for (size_t i = 0; i < sizeof(flash_configs) / sizeof(flash_configs[0]); i++)
6477
{
65-
return -RT_ERROR;
66-
};
78+
const struct spi_flash_config *cfg = &flash_configs[i];
6779

68-
return RT_EOK;
69-
}
70-
INIT_COMPONENT_EXPORT(rt_hw_spi_flash_with_sfud_init);
80+
result = rt_hw_spi_device_attach(cfg->bus_name, cfg->device_name, cfg->cs_pin);
81+
if (result != RT_EOK)
82+
{
83+
rt_kprintf("Failed to attach device %s on bus %s\n", cfg->device_name, cfg->bus_name);
84+
continue;
85+
}
86+
87+
#ifdef RT_USING_SFUD
88+
if (RT_NULL == rt_sfud_flash_probe(cfg->flash_name, cfg->device_name))
89+
{
90+
rt_kprintf("SFUD probe failed: %s\n", cfg->flash_name);
91+
continue;
92+
}
7193
#endif
7294

7395
#ifdef RT_USING_DFS
74-
#include <dfs_fs.h>
75-
76-
int mnt_init(void)
77-
{
78-
if (dfs_mount(SPI_FLASH_DEVICE_NAME, "/", "elm", 0, 0) == 0)
79-
{
80-
rt_kprintf("spi flash mount success !\n");
81-
}
82-
else
83-
{
84-
rt_kprintf("spi flash mount failed!\n");
96+
if (dfs_mount(cfg->flash_name, "/", "elm", 0, 0) == RT_EOK)
97+
{
98+
rt_kprintf("SPI flash %s mount success!\n", cfg->flash_name);
99+
}
100+
else
101+
{
102+
rt_kprintf("SPI flash %s mount failed!\n", cfg->flash_name);
103+
}
104+
#endif
85105
}
86106

87-
return 0;
107+
return result;
88108
}
89-
MSH_CMD_EXPORT(mnt_init, mount spi flash to file system);
90-
#endif
109+
INIT_COMPONENT_EXPORT(spi_flash_init);

0 commit comments

Comments
 (0)