diff --git a/bsp/stm32/README.md b/bsp/stm32/README.md
index a23f5e9380..90b123c505 100644
--- a/bsp/stm32/README.md
+++ b/bsp/stm32/README.md
@@ -10,4 +10,11 @@ STM32 系列 BSP 目前支持情况如下表所示:
| stm32f429-atk-apollo | 正点原子 F429 阿波罗开发板 |
| stm32f429-fire-challenger | 野火 F429 挑战者开发板 |
+了解每个 BSP 的详细情况可以阅读该 BSP 下的 readme 文件,如需使用 BSP 更多功能可参考 docs 文件夹下提供的说明文档:
+
+| 文档名称 | 简介 |
+| -------------------- | ------------------------------------------------- |
+| BSP 进阶使用指南 | 介绍如何使用 BSP 提供的高级功能以及添加更多新功能 |
+| STM32系列BSP添加教程 | 介绍如何添加一个新的 STM32 系列的 BSP |
+| STM32系列BSP制作规范 | 介绍一个新 STM32 系列 BSP 的制作规范 |
diff --git a/bsp/stm32/docs/BSP进阶使用指南.md b/bsp/stm32/docs/BSP进阶使用指南.md
new file mode 100644
index 0000000000..887aa619dd
--- /dev/null
+++ b/bsp/stm32/docs/BSP进阶使用指南.md
@@ -0,0 +1,115 @@
+# BSP 进阶使用指南
+
+## 简介
+
+本文档是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。
+
+主要包括以下内容:
+
+1. 如何使用开发板上更多的板载资源
+2. 如何使用更多的片上资源
+3. 如何添加更多片上资源选项
+
+## 前提要求
+
+- 学会如何使用 ENV 工具,参考:[RT-Thread env 工具用户手册](https://www.rt-thread.org/document/site/rtthread-development-guide/rtthread-tool-manual/env/env-user-manual/)
+
+## 如何使用更多的板载资源
+
+开发板上一般有很多的板载资源,如 Flash、SD卡、以太网等,但是 BSP 工程默认没有添加对这些外设的支持。如何在工程里添加这些外设的支持呢?这就需要使用 ENV 工具了。下面以在正点原子阿波罗 F429 开发板上开启 SPI Flash 支持为例,一步步的展示如何使用 ENV 工具对 BSP 进行配置。
+
+### 1)打开配置工具
+
+在目录 `rt-thread\bsp\stm32\stm32f429-atk-apollo` 下打开 menuconfig 配置界面。
+
+![打开 menuconfig](figures/menuconfig_apolo.png)
+
+打开的配置工具界面如下所示:
+
+![RT-Thread 配置菜单](figures/config1.png)
+
+通过键盘上的上下键移动光标,选中 `Hardware Drivers Config`然后按回车键进入硬件驱动配置菜单。
+
+### 2)进入硬件驱动配置菜单
+
+在硬件配置菜单里有三个选项,分别是 **板载外设配置菜单**、**片上外设配置菜单**和**扩展模块配置菜单**,按回车键进入板载外设配置菜单。
+
+![硬件驱动 配置菜单](figures/config2.png)
+
+### 3)在板载外设配置菜单里开启 SPI Flash 选项
+
+![板载外设 配置菜单](figures/spi_flash.png)
+
+### 4)保存退出
+
+然后右移光标选中 Save 按回车键保存,然后按 Esc 键退出配置工具。
+
+![保存退出](figures/save.png)
+
+### 5)更新软件包
+
+输入命令 `pkgs --update` 使软件包配置生效。
+
+![1543477036034](figures/update.png)
+
+### 6)生成 MDK5 工程
+
+输入命令 `scons --target=mdk5 -s` 重新生成 MDK5 的工程。
+
+![1543477194829](figures/scons_mdk5.png)
+
+### 7)编译下载
+
+打开生成的 MDK5 工程文件,编译并下载。
+
+![1543478492157](figures/complise.png)
+
+### 8)查看运行结果
+
+程序运行后,输入命令 `list_device` 可以看到名为 W25Q256 的块设备,此时 `SPI Flash` 设备已经可以使用了。
+
+![1543478742034](figures/run_flash.png)
+
+## 如何使用更多的片上资源
+
+如果想要使用除了当前支持的片上资源(GPIO 和 UART1),又不想开启板载资源的支持,可以通过直接配置 **片上外设配置菜单** 的方式,使用更多片上资源。
+
+配置方法和上一章节介绍的 **如何使用更多的板载资源的配置方法** 一样,只是本次需要进入 `片上外设配置菜单`。
+
+![1543481275711](figures/on_chip_config.png)
+
+## 如何添加更多的片上资源选项
+
+如果想使用的片上外设是 `片上外设配置菜单` 里没有的,就需要自己添加了。下面以添加 SPI3 的驱动支持为例讲解如何添加更多片上外设支持。
+
+> 没有安装 stm32cubemx 软件的移步 STM32cube中文网: ,在 `资源下载` 里下载 stm32cubemx 软件。
+
+添加 SPI3 的外设支持需要以下几步:
+
+### 1)打开 Cube 的工程
+
+![1543486779576](figures/cubemx.png)
+
+### 2)配置好 SPI3 的引脚,并生成代码
+
+按照图中所示步骤操作:
+
+![1543487684698](figures/cube_spi3.png)
+
+### 3)修改 Konfig 文件
+
+打开board文件夹下的 Konfig 文件,拷贝 SPI2 的配置项,并重命名 SPI2 为 SPI3。
+
+![1543542657074](figures/Kconfig2.png)
+
+### 4)重新配置工程
+
+经过上一步的修改,此时重新打开 ENV 工具,在 menuconfig 中就会出现添加的 SPI3 的配置项。
+
+![1543543081284](figures/config5.png)
+
+### 5)生成工程,编译下载
+
+重新生成工程之后,编译下载到开发板,程序会自动开始运行。输入 `list_device` 命令可以看到 spi3 总线设备已经挂载成功了。
+
+![1543543446786](figures/run_spi3.png)
diff --git a/bsp/stm32/libraries/templates/STM32系列BSP添加教程.md b/bsp/stm32/docs/STM32系列BSP添加教程.md
similarity index 98%
rename from bsp/stm32/libraries/templates/STM32系列BSP添加教程.md
rename to bsp/stm32/docs/STM32系列BSP添加教程.md
index f23fd40de6..2ac0f6b48e 100644
--- a/bsp/stm32/libraries/templates/STM32系列BSP添加教程.md
+++ b/bsp/stm32/docs/STM32系列BSP添加教程.md
@@ -112,6 +112,8 @@ STM32 BSP 由三部分组成,分别是 (1) 通用库、(2) BSP 模板和 (3)
| SOC_STM32F103RB | 芯片型号 | SOC_STM32xxx |
| SOC_SERIES_STM32F1 | 芯片系列| SOC_SERIES_STM32xx |
+用户可参考这个链接学习 Kconfig语法:(https://blog.csdn.net/jianwen_hi/article/details/53398141)
+
### 修改工程构建相关文件
接下来需要修改用于构建工程相关的文件。
diff --git a/bsp/stm32/libraries/templates/figures/CubeMX_1.png b/bsp/stm32/docs/figures/CubeMX_1.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/CubeMX_1.png
rename to bsp/stm32/docs/figures/CubeMX_1.png
diff --git a/bsp/stm32/libraries/templates/figures/CubeMX_2.png b/bsp/stm32/docs/figures/CubeMX_2.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/CubeMX_2.png
rename to bsp/stm32/docs/figures/CubeMX_2.png
diff --git a/bsp/stm32/libraries/templates/figures/CubeMX_3.png b/bsp/stm32/docs/figures/CubeMX_3.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/CubeMX_3.png
rename to bsp/stm32/docs/figures/CubeMX_3.png
diff --git a/bsp/stm32/libraries/templates/figures/CubeMX_4.png b/bsp/stm32/docs/figures/CubeMX_4.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/CubeMX_4.png
rename to bsp/stm32/docs/figures/CubeMX_4.png
diff --git a/bsp/stm32/libraries/templates/figures/CubeMX_5.png b/bsp/stm32/docs/figures/CubeMX_5.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/CubeMX_5.png
rename to bsp/stm32/docs/figures/CubeMX_5.png
diff --git a/bsp/stm32/docs/figures/Kconfig.png b/bsp/stm32/docs/figures/Kconfig.png
new file mode 100644
index 0000000000..8c5748df13
Binary files /dev/null and b/bsp/stm32/docs/figures/Kconfig.png differ
diff --git a/bsp/stm32/docs/figures/Kconfig2.png b/bsp/stm32/docs/figures/Kconfig2.png
new file mode 100644
index 0000000000..960709f4f2
Binary files /dev/null and b/bsp/stm32/docs/figures/Kconfig2.png differ
diff --git a/bsp/stm32/libraries/templates/figures/SConscript.png b/bsp/stm32/docs/figures/SConscript.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/SConscript.png
rename to bsp/stm32/docs/figures/SConscript.png
diff --git a/bsp/stm32/libraries/templates/figures/board_1.png b/bsp/stm32/docs/figures/board_1.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/board_1.png
rename to bsp/stm32/docs/figures/board_1.png
diff --git a/bsp/stm32/libraries/templates/figures/board_2.png b/bsp/stm32/docs/figures/board_2.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/board_2.png
rename to bsp/stm32/docs/figures/board_2.png
diff --git a/bsp/stm32/docs/figures/complise.png b/bsp/stm32/docs/figures/complise.png
new file mode 100644
index 0000000000..283d5243af
Binary files /dev/null and b/bsp/stm32/docs/figures/complise.png differ
diff --git a/bsp/stm32/docs/figures/config.png b/bsp/stm32/docs/figures/config.png
new file mode 100644
index 0000000000..53183c2868
Binary files /dev/null and b/bsp/stm32/docs/figures/config.png differ
diff --git a/bsp/stm32/docs/figures/config1.png b/bsp/stm32/docs/figures/config1.png
new file mode 100644
index 0000000000..e6ca8f5b3c
Binary files /dev/null and b/bsp/stm32/docs/figures/config1.png differ
diff --git a/bsp/stm32/docs/figures/config2.png b/bsp/stm32/docs/figures/config2.png
new file mode 100644
index 0000000000..498b0f99c1
Binary files /dev/null and b/bsp/stm32/docs/figures/config2.png differ
diff --git a/bsp/stm32/docs/figures/config3.png b/bsp/stm32/docs/figures/config3.png
new file mode 100644
index 0000000000..565532e3ac
Binary files /dev/null and b/bsp/stm32/docs/figures/config3.png differ
diff --git a/bsp/stm32/docs/figures/config4.png b/bsp/stm32/docs/figures/config4.png
new file mode 100644
index 0000000000..c2734caf6d
Binary files /dev/null and b/bsp/stm32/docs/figures/config4.png differ
diff --git a/bsp/stm32/docs/figures/config5.png b/bsp/stm32/docs/figures/config5.png
new file mode 100644
index 0000000000..b995b52c3e
Binary files /dev/null and b/bsp/stm32/docs/figures/config5.png differ
diff --git a/bsp/stm32/libraries/templates/figures/copy.png b/bsp/stm32/docs/figures/copy.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/copy.png
rename to bsp/stm32/docs/figures/copy.png
diff --git a/bsp/stm32/docs/figures/cube_spi3.png b/bsp/stm32/docs/figures/cube_spi3.png
new file mode 100644
index 0000000000..a30e29bc96
Binary files /dev/null and b/bsp/stm32/docs/figures/cube_spi3.png differ
diff --git a/bsp/stm32/docs/figures/cubemx.png b/bsp/stm32/docs/figures/cubemx.png
new file mode 100644
index 0000000000..d339c2efb4
Binary files /dev/null and b/bsp/stm32/docs/figures/cubemx.png differ
diff --git a/bsp/stm32/docs/figures/exit.png b/bsp/stm32/docs/figures/exit.png
new file mode 100644
index 0000000000..a8e41300db
Binary files /dev/null and b/bsp/stm32/docs/figures/exit.png differ
diff --git a/bsp/stm32/libraries/templates/figures/frame.png b/bsp/stm32/docs/figures/frame.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/frame.png
rename to bsp/stm32/docs/figures/frame.png
diff --git a/bsp/stm32/libraries/templates/figures/linker_scripts.png b/bsp/stm32/docs/figures/linker_scripts.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/linker_scripts.png
rename to bsp/stm32/docs/figures/linker_scripts.png
diff --git a/bsp/stm32/docs/figures/menuconfig.png b/bsp/stm32/docs/figures/menuconfig.png
new file mode 100644
index 0000000000..f272f53cd8
Binary files /dev/null and b/bsp/stm32/docs/figures/menuconfig.png differ
diff --git a/bsp/stm32/libraries/templates/figures/menuconfig_1.png b/bsp/stm32/docs/figures/menuconfig_1.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/menuconfig_1.png
rename to bsp/stm32/docs/figures/menuconfig_1.png
diff --git a/bsp/stm32/libraries/templates/figures/menuconfig_2.png b/bsp/stm32/docs/figures/menuconfig_2.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/menuconfig_2.png
rename to bsp/stm32/docs/figures/menuconfig_2.png
diff --git a/bsp/stm32/libraries/templates/figures/menuconfig_3.png b/bsp/stm32/docs/figures/menuconfig_3.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/menuconfig_3.png
rename to bsp/stm32/docs/figures/menuconfig_3.png
diff --git a/bsp/stm32/libraries/templates/figures/menuconfig_4.png b/bsp/stm32/docs/figures/menuconfig_4.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/menuconfig_4.png
rename to bsp/stm32/docs/figures/menuconfig_4.png
diff --git a/bsp/stm32/docs/figures/menuconfig_apolo.png b/bsp/stm32/docs/figures/menuconfig_apolo.png
new file mode 100644
index 0000000000..a5738a290e
Binary files /dev/null and b/bsp/stm32/docs/figures/menuconfig_apolo.png differ
diff --git a/bsp/stm32/docs/figures/on_chip_config.png b/bsp/stm32/docs/figures/on_chip_config.png
new file mode 100644
index 0000000000..bc90fc747b
Binary files /dev/null and b/bsp/stm32/docs/figures/on_chip_config.png differ
diff --git a/bsp/stm32/docs/figures/run_flash.png b/bsp/stm32/docs/figures/run_flash.png
new file mode 100644
index 0000000000..5a463c3835
Binary files /dev/null and b/bsp/stm32/docs/figures/run_flash.png differ
diff --git a/bsp/stm32/docs/figures/run_spi3.png b/bsp/stm32/docs/figures/run_spi3.png
new file mode 100644
index 0000000000..a73b86d47b
Binary files /dev/null and b/bsp/stm32/docs/figures/run_spi3.png differ
diff --git a/bsp/stm32/docs/figures/save.png b/bsp/stm32/docs/figures/save.png
new file mode 100644
index 0000000000..ce905c0fe4
Binary files /dev/null and b/bsp/stm32/docs/figures/save.png differ
diff --git a/bsp/stm32/docs/figures/scons_mdk5.png b/bsp/stm32/docs/figures/scons_mdk5.png
new file mode 100644
index 0000000000..dbb833f028
Binary files /dev/null and b/bsp/stm32/docs/figures/scons_mdk5.png differ
diff --git a/bsp/stm32/docs/figures/spi_flash.png b/bsp/stm32/docs/figures/spi_flash.png
new file mode 100644
index 0000000000..b749928c2c
Binary files /dev/null and b/bsp/stm32/docs/figures/spi_flash.png differ
diff --git a/bsp/stm32/libraries/templates/figures/template_1.png b/bsp/stm32/docs/figures/template_1.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/template_1.png
rename to bsp/stm32/docs/figures/template_1.png
diff --git a/bsp/stm32/libraries/templates/figures/template_2.png b/bsp/stm32/docs/figures/template_2.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/template_2.png
rename to bsp/stm32/docs/figures/template_2.png
diff --git a/bsp/stm32/libraries/templates/figures/template_3.png b/bsp/stm32/docs/figures/template_3.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/template_3.png
rename to bsp/stm32/docs/figures/template_3.png
diff --git a/bsp/stm32/docs/figures/update.png b/bsp/stm32/docs/figures/update.png
new file mode 100644
index 0000000000..fa1531ae85
Binary files /dev/null and b/bsp/stm32/docs/figures/update.png differ
diff --git a/bsp/stm32/libraries/templates/figures/xCubeMX_1.png b/bsp/stm32/docs/figures/xCubeMX_1.png
similarity index 100%
rename from bsp/stm32/libraries/templates/figures/xCubeMX_1.png
rename to bsp/stm32/docs/figures/xCubeMX_1.png
diff --git a/bsp/stm32/libraries/HAL_Drivers/config/f1/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/f1/spi_config.h
index 18f3190a0f..a910847e39 100644
--- a/bsp/stm32/libraries/HAL_Drivers/config/f1/spi_config.h
+++ b/bsp/stm32/libraries/HAL_Drivers/config/f1/spi_config.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-06 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/config/f1/uart_config.h b/bsp/stm32/libraries/HAL_Drivers/config/f1/uart_config.h
index f34bff5fc7..fd7482f4e6 100644
--- a/bsp/stm32/libraries/HAL_Drivers/config/f1/uart_config.h
+++ b/bsp/stm32/libraries/HAL_Drivers/config/f1/uart_config.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-10-30 BalanceTWK change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/config/f4/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/f4/spi_config.h
index a3c890b858..791c51bd27 100644
--- a/bsp/stm32/libraries/HAL_Drivers/config/f4/spi_config.h
+++ b/bsp/stm32/libraries/HAL_Drivers/config/f4/spi_config.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-06 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/config/f4/uart_config.h b/bsp/stm32/libraries/HAL_Drivers/config/f4/uart_config.h
index a0909ad5cb..d8fab2c361 100644
--- a/bsp/stm32/libraries/HAL_Drivers/config/f4/uart_config.h
+++ b/bsp/stm32/libraries/HAL_Drivers/config/f4/uart_config.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-10-30 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/config/l4/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/l4/spi_config.h
index 52bf207fd1..054f55ff77 100644
--- a/bsp/stm32/libraries/HAL_Drivers/config/l4/spi_config.h
+++ b/bsp/stm32/libraries/HAL_Drivers/config/l4/spi_config.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-06 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/config/l4/uart_config.h b/bsp/stm32/libraries/HAL_Drivers/config/l4/uart_config.h
index 9b430bbcce..46d5414f55 100644
--- a/bsp/stm32/libraries/HAL_Drivers/config/l4/uart_config.h
+++ b/bsp/stm32/libraries/HAL_Drivers/config/l4/uart_config.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-06 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_common.c b/bsp/stm32/libraries/HAL_Drivers/drv_common.c
index 5a95937ac5..1f54ebc800 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_common.c
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_common.c
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-7 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_common.h b/bsp/stm32/libraries/HAL_Drivers/drv_common.h
index bc052c184c..a897c178d3 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_common.h
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_common.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-7 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_config.h b/bsp/stm32/libraries/HAL_Drivers/drv_config.h
index 30f860f716..33b94d2829 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_config.h
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_config.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-10-30 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_dma.h b/bsp/stm32/libraries/HAL_Drivers/drv_dma.h
index d5bd45b51a..62236ac3f8 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_dma.h
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_dma.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-10 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_emac.c b/bsp/stm32/libraries/HAL_Drivers/drv_emac.c
index b28d31112a..5b6c0eed99 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_emac.c
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_emac.c
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-19 SummerGift first version
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_gpio.c b/bsp/stm32/libraries/HAL_Drivers/drv_gpio.c
index 9207c2d468..d35c71c0e9 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_gpio.c
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_gpio.c
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-06 balanceTWK change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_gpio.h b/bsp/stm32/libraries/HAL_Drivers/drv_gpio.h
index 8b87cf5fd5..a62370cae4 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_gpio.h
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_gpio.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-06 balanceTWK change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_qspi.c b/bsp/stm32/libraries/HAL_Drivers/drv_qspi.c
index 5aad91a2bd..5fa182899c 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_qspi.c
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_qspi.c
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-27 zylx change to new framework
@@ -19,10 +18,7 @@
#define LOG_TAG "drv.qspi"
#include
-#if !defined(BSP_USING_QSPI)
- #error "Please define at least one BSP_USING_QSPI"
- /* this driver can be disabled at menuconfig ? RT-Thread Components ? Device Drivers */
-#endif
+#if defined(BSP_USING_QSPI)
struct stm32_hw_spi_cs
{
@@ -33,6 +29,9 @@ struct stm32_qspi_bus
{
QSPI_HandleTypeDef QSPI_Handler;
char *bus_name;
+#ifdef BSP_QSPI_USING_DMA
+ DMA_HandleTypeDef hdma_quadspi;
+#endif
};
struct rt_spi_bus _qspi_bus1;
@@ -94,6 +93,33 @@ static int stm32_qspi_init(struct rt_qspi_device *device, struct rt_qspi_configu
LOG_E("qspi init failed (%d)!", result);
}
+#ifdef BSP_QSPI_USING_DMA
+ /* QSPI interrupts must be enabled when using the HAL_QSPI_Receive_DMA */
+ HAL_NVIC_SetPriority(QUADSPI_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(QUADSPI_IRQn);
+ HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
+
+ /* init QSPI DMA */
+ __HAL_RCC_DMA1_CLK_ENABLE();
+ HAL_DMA_DeInit(qspi_bus->QSPI_Handler.hdma);
+ qspi_bus->hdma_quadspi.Instance = DMA1_Channel5;
+ qspi_bus->hdma_quadspi.Init.Request = DMA_REQUEST_5;
+ qspi_bus->hdma_quadspi.Init.Direction = DMA_PERIPH_TO_MEMORY;
+ qspi_bus->hdma_quadspi.Init.PeriphInc = DMA_PINC_DISABLE;
+ qspi_bus->hdma_quadspi.Init.MemInc = DMA_MINC_ENABLE;
+ qspi_bus->hdma_quadspi.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
+ qspi_bus->hdma_quadspi.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
+ qspi_bus->hdma_quadspi.Init.Mode = DMA_NORMAL;
+ qspi_bus->hdma_quadspi.Init.Priority = DMA_PRIORITY_LOW;
+ if (HAL_DMA_Init(&qspi_bus->hdma_quadspi) != HAL_OK)
+ {
+ LOG_E("qspi dma init failed (%d)!", result);
+ }
+
+ __HAL_LINKDMA(&qspi_bus->QSPI_Handler,hdma,qspi_bus->hdma_quadspi);
+#endif /* BSP_QSPI_USING_DMA */
+
return result;
}
@@ -205,7 +231,6 @@ static rt_uint32_t qspixfer(struct rt_spi_device *device, struct rt_spi_message
{
if (HAL_QSPI_Transmit(&qspi_bus->QSPI_Handler, (rt_uint8_t *)sndb, 5000) == HAL_OK)
{
-
len = length;
}
else
@@ -222,12 +247,17 @@ static rt_uint32_t qspixfer(struct rt_spi_device *device, struct rt_spi_message
}
else if (rcvb)/* recv data */
{
-
qspi_send_cmd(qspi_bus, qspi_message);
-
+#ifdef BSP_QSPI_USING_DMA
+ if (HAL_QSPI_Receive_DMA(&qspi_bus->QSPI_Handler, rcvb) == HAL_OK)
+#else
if (HAL_QSPI_Receive(&qspi_bus->QSPI_Handler, rcvb, 5000) == HAL_OK)
+#endif
{
len = length;
+#ifdef BSP_QSPI_USING_DMA
+ while(qspi_bus->QSPI_Handler.RxXferCount != 0);
+#endif
}
else
{
@@ -283,20 +313,22 @@ static int stm32_qspi_register_bus(struct stm32_qspi_bus *qspi_bus, const char *
*/
rt_err_t stm32_qspi_bus_attach_device(const char *bus_name, const char *device_name, rt_uint32_t pin, rt_uint8_t data_line_width, void (*enter_qspi_mode)(), void (*exit_qspi_mode)())
{
+ struct rt_qspi_device *qspi_device = RT_NULL;
+ struct stm32_hw_spi_cs *cs_pin = RT_NULL;
rt_err_t result = RT_EOK;
RT_ASSERT(bus_name != RT_NULL);
RT_ASSERT(device_name != RT_NULL);
RT_ASSERT(data_line_width == 1 || data_line_width == 2 || data_line_width == 4);
- struct rt_qspi_device *qspi_device = (struct rt_qspi_device *)rt_malloc(sizeof(struct rt_qspi_device));
+ qspi_device = (struct rt_qspi_device *)rt_malloc(sizeof(struct rt_qspi_device));
if (qspi_device == RT_NULL)
{
LOG_E("no memory, qspi bus attach device failed!");
result = RT_ENOMEM;
goto __exit;
}
- struct stm32_hw_spi_cs *cs_pin = (struct stm32_hw_spi_cs *)rt_malloc(sizeof(struct stm32_hw_spi_cs));
+ cs_pin = (struct stm32_hw_spi_cs *)rt_malloc(sizeof(struct stm32_hw_spi_cs));
if (qspi_device == RT_NULL)
{
LOG_E("no memory, qspi bus attach device failed!");
@@ -333,10 +365,35 @@ __exit:
return result;
}
+#ifdef BSP_QSPI_USING_DMA
+void QUADSPI_IRQHandler(void)
+{
+ /* enter interrupt */
+ rt_interrupt_enter();
+
+ HAL_QSPI_IRQHandler(&_stm32_qspi_bus.QSPI_Handler);
+
+ /* leave interrupt */
+ rt_interrupt_leave();
+}
+
+void DMA1_Channel5_IRQHandler(void)
+{
+ /* enter interrupt */
+ rt_interrupt_enter();
+
+ HAL_DMA_IRQHandler(&_stm32_qspi_bus.hdma_quadspi);
+
+ /* leave interrupt */
+ rt_interrupt_leave();
+}
+#endif /* BSP_QSPI_USING_DMA */
+
static int rt_hw_qspi_bus_init(void)
{
return stm32_qspi_register_bus(&_stm32_qspi_bus, "qspi1");
}
INIT_BOARD_EXPORT(rt_hw_qspi_bus_init);
+#endif /* BSP_USING_QSPI */
#endif /* RT_USING_QSPI */
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_qspi.h b/bsp/stm32/libraries/HAL_Drivers/drv_qspi.h
index c9d779a9bd..28dbf437d1 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_qspi.h
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_qspi.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-27 zylx change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_spi.c b/bsp/stm32/libraries/HAL_Drivers/drv_spi.c
index 45bd46b24f..a07391a095 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_spi.c
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_spi.c
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-5 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_spi.h b/bsp/stm32/libraries/HAL_Drivers/drv_spi.h
index 34eee8d9f0..710f3fa59c 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_spi.h
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_spi.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-5 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_usart.c b/bsp/stm32/libraries/HAL_Drivers/drv_usart.c
index d803f5558f..c54f304ada 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_usart.c
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_usart.c
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-10-30 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_usart.h b/bsp/stm32/libraries/HAL_Drivers/drv_usart.h
index 451c72ad20..1dc3b702f1 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_usart.h
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_usart.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018.10.30 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/templates/figures/Kconfig.png b/bsp/stm32/libraries/templates/figures/Kconfig.png
deleted file mode 100644
index 29504e2f27..0000000000
Binary files a/bsp/stm32/libraries/templates/figures/Kconfig.png and /dev/null differ
diff --git a/bsp/stm32/libraries/templates/stm32f10x/applications/main.c b/bsp/stm32/libraries/templates/stm32f10x/applications/main.c
index 9b786fb7f1..22ff66584c 100644
--- a/bsp/stm32/libraries/templates/stm32f10x/applications/main.c
+++ b/bsp/stm32/libraries/templates/stm32f10x/applications/main.c
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-06 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/templates/stm32f10x/board/board.c b/bsp/stm32/libraries/templates/stm32f10x/board/board.c
index 5ffc0fe751..36c127c5b7 100644
--- a/bsp/stm32/libraries/templates/stm32f10x/board/board.c
+++ b/bsp/stm32/libraries/templates/stm32f10x/board/board.c
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-06 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/templates/stm32f10x/board/board.h b/bsp/stm32/libraries/templates/stm32f10x/board/board.h
index 164595a05d..2c56c5548b 100644
--- a/bsp/stm32/libraries/templates/stm32f10x/board/board.h
+++ b/bsp/stm32/libraries/templates/stm32f10x/board/board.h
@@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*
- *
* Change Logs:
* Date Author Notes
* 2018-11-5 SummerGift change to new framework
diff --git a/bsp/stm32/libraries/templates/stm32f10x/project.ewp b/bsp/stm32/libraries/templates/stm32f10x/project.ewp
index 957c50b46c..1e0457c86a 100644
--- a/bsp/stm32/libraries/templates/stm32f10x/project.ewp
+++ b/bsp/stm32/libraries/templates/stm32f10x/project.ewp
@@ -651,7 +651,7 @@