准备
潘多拉,打开板载 spi flash
示例代码
简单的进行测试:
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
#include <spi_flash_sfud.h>
int main(void)
{
sfud_err result;
uint8_t *read_data;//读取到的数据
uint8_t *write_data;//将要写入的数据
sfud_flash *sfud_dev = NULL;
#if 0 // 法1:获取 sfud_dev
sfud_dev = rt_sfud_flash_find_by_dev_name("W25Q128");
if (sfud_dev != RT_NULL)
{
rt_kprintf("Find sfud_dev success, sfud_dev name = %s\n", sfud_dev->name);
}
#else // 法2:获取 sfud_dev
sfud_dev = rt_sfud_flash_find("qspi10");
if (sfud_dev != RT_NULL)
{
rt_kprintf("Find sfud_dev success, sfud_dev name = %s\n", sfud_dev->name);
}
#endif
/* 擦除从 0 开始的 4096 字节 */
result = sfud_erase(sfud_dev, 0, 4096);
if (result == SFUD_SUCCESS)
{
r