当前位置:网站首页>RT thread configuration SPI flash (w25q256)
RT thread configuration SPI flash (w25q256)
2022-04-22 13:03:00 【Fan Ziqi】
RT-Thread To configure SPI-Flash(W25Q256)
1. Turn on SPI Bus
Create a new blank RT-Thread project , This article is based on STM32F103 chip .
First, in the drivers Open in directory board.h file , find SPI The corresponding part . According to the instructions , Step by step .

1.1 open SPI And SFUD
open RT-Thread Settings, Click more configurations to go to the component column , Check below .

1.2 open SPI Macro definition
board.h In file , open SPI Macro definition .

1.3 Generate initialization function
Use stm32cubemx Generate initialization function , Paste it on board.c end of file .

Then choose the chip model -> Fill in the project name , double-click IOC After the file, operate as shown in the figure .

Copy the initialization function to board.c file .
1.4 open SPI drive
stay drivers In the catalog stm32f1xx_hal_conf.h Open... In file SPI drive .

Configuration complete , Compile and download , Use list_device Command view device , You can see SPI The bus already exists .

2. Outside the mount flash
Next , We're going to take off the film flash(W25Q256) Hang up SPI On the bus .
stay application Under the table of contents , newly added flash.c file .
static int rt_hw_spi_flash_init(void)
{
// Here is the chip selection pin
rt_hw_spi_device_attach(W25Q_SPI_BUS_NAME, W25Q_SPI_DEVICE_NAME, GPIOA, GPIO_PIN_4);
//flash The name should be correct
if (RT_NULL == rt_sfud_flash_probe("W25Q256", W25Q_SPI_DEVICE_NAME))
{
return -RT_ERROR;
};
return RT_EOK;
}
/* Export to automatic initialization */
INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);
After verification ,flash Successfully mounted .

Let's start building FAL.
3. build FAL Abstraction layer
FAL yes RT-Thread A software package for , Mainly for Flash The implementation of the abstraction layer , Responsible for managing the Flash Equipment and Flash Partition . About FAL Detailed features of , You can refer to RT-Thread Package Links . The documentation is very detailed , Reference is also made here to the contents of the document .
3.1 add to FAL
open RT-Thread Settings Click Add now , And then the search FAL.




3.2 To configure FAL
Because we only use off film flash, So you can fal_cfg.h About off film flash Delete the part of , And define your own partition table .
take samples->porting->fal_cfg.h Copied to the inc And modify it to :
#ifndef _FAL_CFG_H_
#define _FAL_CFG_H_
#include <rtconfig.h>
#include <board.h>
#define NOR_FLASH_DEV_NAME "W25Q256" /* Make sure it's your own flash name */
/* ===================== Flash device Configuration ========================= */
extern struct fal_flash_dev nor_flash0;
/* flash device table( Define device table , Deleted the film flash) */
#define FAL_FLASH_DEV_TABLE \ {
\ &nor_flash0, \ }
/* ====================== Partition Configuration ========================== */
#ifdef FAL_PART_HAS_TABLE_CFG
/* partition table ps: It can be partitioned as needed */
#define FAL_PART_TABLE \ {
\ {
FAL_PART_MAGIC_WORD, "easyflash", NOR_FLASH_DEV_NAME, 0, 1024*1024, 0}, \ {
FAL_PART_MAGIC_WORD, "download", NOR_FLASH_DEV_NAME, 1024*1024, 1024*1024, 0}, \ }
#endif /* FAL_PART_HAS_TABLE_CFG */
#endif /* _FAL_CFG_H_ */
Not much has been changed here for the time being , You can partition according to your needs 、 name .
3.3 initialization FAL
stay main.c In file , contain fal.h And call fal_init() Initializer .

3.4 verification

版权声明
本文为[Fan Ziqi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221300407545.html
边栏推荐
- Day code 300 lines learning notes day 47
- R语言使用qnorm函数生成正太分布分位数函数数据、使用plot函数可视化正太分布分位数函数数据(Normal distribution)
- @Preauthorize annotation for permission verification
- How to use colormaps and customize your favorite colorbar?
- 利用OpenCV的函数threshold()对图像作基于OTSU的阈值化处理---并附比较好的介绍OTSU原理的博文链接
- Chrome多设备书签同步方案
- ROS2——参数的使用
- 2022年上半年软考备考冲刺攻略
- ROS2——手把手教你编写一个话题
- sprintf格式化字符串
猜你喜欢

English writing artifact quillbot --- how to use the free premium function

The data in MATLAB is forcibly converted from double type to uint8, which is rounded, and the basic data type of MATLAB is attached

CubeMX配置SPI-Flash(W25Q256)

redis的key都变成了backup,值也都不见了,这是为什么呢?

从构建到治理,业内首本微服务治理技术白皮书正式发布(含免费下载链接)

Download and installation of redis

做相关性分析时,如何排除奇异值Outliers,以增加相关分析的准确性

11. Container with the most water

396. Rotation function

sprintf格式化字符串
随机推荐
The system solution of digital commerce cloud home appliance mall optimizes the procurement and supply chain management of the electrical appliance mall, reduces inventory and improves capital utiliza
vnpy本地导入csv数据
Rsync remote synchronization
Node debugging guide - inspector protocol
ROS机器人学习——TF坐标变换
Understanding of rxbus and rxbus2
柔性印刷电路板(PCB)的设计方法、类型等详细解析
ROS2——什么是接口
JS foundation 9
mysql数据库已经成功启动,可是show不是内部或外部命令,该如何解决呢?
R language uses dhyper function to generate hypergeometric distribution density data and plot function to visualize hypergeometric distribution density data
vnpy本地導入csv數據
The data in MATLAB is forcibly converted from double type to uint8, which is rounded, and the basic data type of MATLAB is attached
Calloc and realloc
C#自定义Button实现源码
Far planner之 障碍物的图搜索
RT-Thread配置SPI-Flash(W25Q256)
Download and installation of redis
Sprintf format string
Vnpy importation locale de données CSV