1 /* 2 * Copyright (c) 2006-2021, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include "drv_spi.h" 8 #include "drv_spi_flash.h" 9 10 #include "rtthread.h" 11 #include "rtdevice.h" 12 #include "dev_spi_flash.h" 13 #include "dev_spi_flash_sfud.h" 14 15 #define RT_SPI_FLASH_CS_PIN (2) 16 rt_hw_flash_init(void)17int rt_hw_flash_init(void) 18 { 19 rt_err_t result; 20 21 result = lpc_spi_bus_attach_device("spi2", "spi20", RT_SPI_FLASH_CS_PIN); 22 if(result != RT_EOK) 23 { 24 return result; 25 } 26 27 if(rt_sfud_flash_probe("flash0", "spi20") == RT_NULL) 28 { 29 return -RT_ERROR; 30 } 31 32 return RT_EOK; 33 } 34 INIT_DEVICE_EXPORT(rt_hw_flash_init); 35