1 /* 2 * Copyright (c) 2006-2023, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2016-09-28 armink first version. 9 * 2024-10-24 yekai Add C++ support 10 */ 11 12 #ifndef __DEV_SPI_FLASH_SFUD_H__ 13 #define __DEV_SPI_FLASH_SFUD_H__ 14 15 #include <rtthread.h> 16 #include <rtdevice.h> 17 #include "./sfud/inc/sfud.h" 18 #include "dev_spi_flash.h" 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /** 25 * Probe SPI flash by SFUD(Serial Flash Universal Driver) driver library and though SPI device. 26 * 27 * @param spi_flash_dev_name the name which will create SPI flash device 28 * @param spi_dev_name using SPI device name 29 * 30 * @return probed SPI flash device, probe failed will return RT_NULL 31 */ 32 rt_spi_flash_device_t rt_sfud_flash_probe(const char *spi_flash_dev_name, const char *spi_dev_name); 33 34 /** 35 * Probe SPI flash by SFUD (Serial Flash Universal Driver) driver library and though SPI device by specified configuration. 36 * 37 * @param spi_flash_dev_name the name which will create SPI flash device 38 * @param spi_dev_name using SPI device name 39 * @param spi_cfg SPI device configuration 40 * @param qspi_cfg QSPI device configuration 41 * 42 * @return probed SPI flash device, probe failed will return RT_NULL 43 */ 44 rt_spi_flash_device_t rt_sfud_flash_probe_ex(const char *spi_flash_dev_name, const char *spi_dev_name, 45 struct rt_spi_configuration *spi_cfg, struct rt_qspi_configuration *qspi_cfg); 46 47 /** 48 * Delete SPI flash device 49 * 50 * @param spi_flash_dev SPI flash device 51 * 52 * @return the operation status, RT_EOK on successful 53 */ 54 rt_err_t rt_sfud_flash_delete(rt_spi_flash_device_t spi_flash_dev); 55 56 /** 57 * Find sfud flash device by SPI device name 58 * 59 * @param spi_dev_name using SPI device name 60 * 61 * @return sfud flash device if success, otherwise return RT_NULL 62 */ 63 sfud_flash_t rt_sfud_flash_find(const char *spi_dev_name); 64 65 /** 66 * Find sfud flash device by flash device name 67 * 68 * @param flash_dev_name using flash device name 69 * 70 * @return sfud flash device if success, otherwise return RT_NULL 71 */ 72 sfud_flash_t rt_sfud_flash_find_by_dev_name(const char *flash_dev_name); 73 74 #ifdef __cplusplus 75 } 76 #endif 77 78 #endif /* __DEV_SPI_FLASH_SFUD_H__ */ 79