未验证 提交 04083301 编写于 作者: lymzzyh's avatar lymzzyh 提交者: GitHub

Merge pull request #1613 from brucechousz/master

[BSP][STM32F4xx-HAL]更新norflash驱动,增加对sfud的支持
...@@ -325,12 +325,12 @@ config RT_USING_SPI3 ...@@ -325,12 +325,12 @@ config RT_USING_SPI3
endif endif
if RT_USING_W25QXX if RT_USING_W25QXX || RT_USING_SFUD
config RT_W25QXX_CS_PIN config RT_FLASH_CS_PIN
int "W25QXX CS Pin index" int "SPI NOR Flash CS pin index"
default 0 default 0
config RT_W25QXX_SPI_BUS_NAME config RT_FLASH_SPI_BUS_NAME
string "W25QXX Spi bus name" string "SPI NOR Flash Spi bus name"
default "spi1" default "spi1"
endif endif
......
...@@ -19,7 +19,7 @@ if GetDepend(['RT_USING_SERIAL']): ...@@ -19,7 +19,7 @@ if GetDepend(['RT_USING_SERIAL']):
if GetDepend(['RT_USING_SPI']): if GetDepend(['RT_USING_SPI']):
src += ['drv_spi.c'] src += ['drv_spi.c']
if GetDepend(['RT_USING_W25QXX']): if GetDepend(['RT_USING_W25QXX']) or GetDepend(['RT_USING_SFUD']):
src += ['drv_spiflash.c'] src += ['drv_spiflash.c']
if GetDepend(['RT_USING_WDT']): if GetDepend(['RT_USING_WDT']):
......
...@@ -12,13 +12,32 @@ ...@@ -12,13 +12,32 @@
* 2017-11-08 ZYH the first version * 2017-11-08 ZYH the first version
*/ */
#include <rtthread.h> #include <rtthread.h>
#if defined(RT_USING_W25QXX) || defined(RT_USING_SFUD)
#include <drv_spi.h>
#ifdef RT_USING_W25QXX #ifdef RT_USING_W25QXX
#include <drv_spi.h> #include "spi_flash_w25qxx.h"
#include "spi_flash_w25qxx.h" #elif defined(RT_USING_SFUD)
int rt_w25qxx_init(void) #include "string.h"
#include "spi_flash.h"
#include "spi_flash_sfud.h"
sfud_flash sfud_norflash0;
rt_spi_flash_device_t spi_device;
#endif
int rt_nor_flash_init(void)
{ {
stm32_spi_bus_attach_device(RT_W25QXX_CS_PIN, RT_W25QXX_SPI_BUS_NAME, "w25qxx"); stm32_spi_bus_attach_device(RT_FLASH_CS_PIN, RT_FLASH_SPI_BUS_NAME, "norspi");
return w25qxx_init("flash0", "w25qxx"); #ifdef RT_USING_W25QXX
return w25qxx_init("flash0", "norspi");
#elif defined(RT_USING_SFUD)
spi_device = rt_sfud_flash_probe("flash0", "norspi");
if (spi_device == RT_NULL)
{
return -RT_ERROR;
}
memcpy(&sfud_norflash0, spi_device->user_data, sizeof(sfud_flash));
return 0;
#endif
} }
INIT_DEVICE_EXPORT(rt_w25qxx_init); INIT_DEVICE_EXPORT(rt_nor_flash_init);
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册