位置:
首页

>

>

QSPI FLASH和SD卡同时支持fatfs文件系统
时间:
在上一篇文章中,我们已经在QSPI FLASH上支持fatfs文件系统:这次我们继续在此代码上支持SD卡文件系统。 ST官员在维护CubeMX上多个硬件驱动程序的fatfs兼容性方面做得非常出色,因此或者使用STM32CubeMX对其进行配置:熊发送硬件SD卡接口:& nbsp; 1,SD卡配置STM32Cube-19 |使用SDMMC接口读取和写入SD卡数据2,SD卡Fatfs配置STM32Cube-20(补充)|将FATFS文件系统移植到SD卡。
由于我们已经在上一节中配置了fatfs的参数,并且STM32CubeMX已经支持SD卡,因此我们可以选中此选项,其余的可以默认设置,然后直接生成Code engineering。 3.编写程序以同时测试QSPI FLASH和SD卡Fatf。
幸运的是,该官员已帮助我们编写了所有代码。无需写一行,只需输入应用程序编程即可。
由于代码太长,因此在此处显示所有代码很不方便。如果您有兴趣,请转到我的代码云上的克隆项目进行下载和测试。
/ **& nbsp; *& nbsp; @ brief& nbsp;& nbsp;该应用程序入口点。 nbsp; @ retval& nbsp; int& nbsp; * / int& nbsp; main(void){& nbsp;& nbsp; & nbsp; / *& nbsp; USER& nbsp; CODE& nbsp; BEGIN& nbsp; 1& nbsp; * /& nbsp;& nbsp;& nbsp;& nbsp; / * & nbsp; USER& nbsp; END& nbsp; 1& nbsp; * /& nbsp;& nbsp;& nbsp;& nbsp; / *& nbsp; MCU& nbsp;配置- -------------------------------------------- ------ ----- * /& nbsp;& nbsp;& nbsp; / *& nbsp;重置所有外围设备,并初始化;  Flash& nbsp;界面和  Systick。
& nbsp; * / & nbsp;& nbsp;& nbsp;& nbsp; HAL_Init();& nbsp; ; nbsp;& nbsp; / *& nbsp; USER& nbsp; CODE& nbsp; BEGIN& nbsp; Init& nbsp; * /& nbsp;& nbsp;& nbsp ;& / *& nbsp; USER& nbsp;代码& nbsp; END& nbsp; Init& nbsp; * /& nbsp;& nbsp;& nbsp;& nbsp; / **& nbsp ;配置& nbsp;系统& nbsp;时钟& nbsp; * /& nbsp;& nbsp;& nbsp;& nbsp; SystemCloc k_Config();& nbsp;& nbsp;& nbsp; / *& nbsp; USER& nbsp; CODE& nbsp; BEGIN& nbsp; SysInit& nbsp; * /& nbsp;& nbsp;& nbsp; / *& nbsp; USER& nbsp; C ODE& nbsp; END& nbsp; SysInit& nbsp; * /& nbsp;& nbsp;& nbsp;         ; / *& nbsp;初始化所有已配置的nbsp;外围设备  * / & nbsp;& nbsp;& nbsp; MX_GPIO_Init();& nbsp;& nbsp; ;& nbsp;& nbsp; MX_I2C1_Init();& nbsp;& nbsp;& nbsp; MX_USART1_UART_Init();& nbsp;& nbsp;& nbsp;& nbsp; MX_QUADSPI_Init();& n nbsp;& nbsp;& nbsp; MX_FATFS_Init();& nbsp;& nbsp; _Init& nbsp;& nbsp;& nbsp;& nbsp;& nbsp; / ** ; USER& nbsp; BEGIN& nbsp; 2& nbsp; * /& nbsp;& nbsp;& nbsp;& nbsp; Mount_SD_Fatfs();& nbsp;& nbsp;& nbsp; ;  Mount_QSPI_FLASH_Fatfs();  & nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp; test_get_sd_card_cap(cap)& nbsp;& nbsp;& nbsp;& nbsp;& nbsp; nbsp; test_sd_card_fatfs();& nbsp;& nbsp; test_spi_flash_fatfs()& nbsp;& nbsp; / *& nbsp; USER& nbsp; END& b ; 2& nbsp;& nbsp;& nbsp;& nbsp; / *& nbsp; Infinite& nbsp; loop& nbsp; * /& nbsp;& nbsp;& nbsp ;& / *& nbsp; USER& nbsp;代码(*)而(1)和(nbsp)和{nbsp;& nbsp;& nbsp;& nbsp;& nbsp;    ;& nbsp;& nbsp; / *& nbsp; USER& nbsp; CODE& nbsp; END& nbsp; WHILE& nbsp; * /& nbsp;& nbsp;& n ; nbsp;& nbsp;& nbsp; & nbsp; / *& nbsp; USER& nbsp; CODE& nbsp; BEGIN& nbsp; 3& nbsp; * /&nbsp ;& nbsp;& nbsp;}& nbsp;& nbsp;& nbsp; / *& nbsp; USER& nbsp; CODE& nbsp; END& nbsp; 3& * /}运行结果:获取完整的演示:代码云仓库:https://gitee.com/morixinguan/ bear-pi / tree / master / 20.QSPI_SD_Card_Sync_Mount_Fatfs如何获取:git clone https:// gitee。 com / morixinguan / bear-pi.git来获取此实验项目的所有代码。
免责声明:本文内容经21ic授权后发布,版权归原作者所有。该平台仅提供信息存储服务。
本文仅代表作者的个人观点,并不代表该平台的立场。如有任何疑问,请与我们联系,谢谢!。
产品资料
行业信息