1 /* 2 * Copyright (c) 2006-2021, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2018-02-08 RT-Thread the first version 9 */ 10 11 #include <rtthread.h> 12 #include <rthw.h> 13 #include <rtdevice.h> 14 15 #define DBG_TAG "FLASH" 16 #define DBG_LVL DBG_LOG 17 #include <rtdbg.h> 18 19 #define SPI_FLASH_DEVICE_NAME "spi00" 20 #define SPI_FLASH_CHIP "gd25qxx" 21 22 //#define DEBUG 23 24 #ifdef DEBUG 25 #define DEBUG_PRINTF(...) rt_kprintf(__VA_ARGS__) 26 #else 27 #define DEBUG_PRINTF(...) 28 #endif 29 30 #if defined(TINA_USING_SPI_FLASH) && defined(RT_USING_SFUD) 31 #include "dev_spi_flash.h" 32 #include <dev_spi_flash_sfud.h> 33 rt_spi_flash_device_t spi_device; rt_hw_spi_flash_with_sfud_init(void)34int rt_hw_spi_flash_with_sfud_init(void) 35 { 36 DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__); 37 spi_device = rt_sfud_flash_probe(SPI_FLASH_CHIP, SPI_FLASH_DEVICE_NAME); 38 if (spi_device == NULL) 39 { 40 DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__); 41 return -RT_ERROR; 42 }; 43 44 DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__); 45 return RT_EOK; 46 } 47 INIT_PREV_EXPORT(rt_hw_spi_flash_with_sfud_init); 48 #endif /* defined(TINA_USING_SPI_FLASH) && defined(RT_USING_SFUD) */ 49