1 /*
2  * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
3  *
4  * SPDX-License-Identifier: Apache-2.0.
5  *
6  * @Date: 2021-04-25 14:01:16
7  * @LastEditTime: 2021-04-30 14:43:12
8  * @Description:  This files is for
9  *
10  * @Modify History:
11  *  Ver   Who        Date         Changes
12  * ----- ------     --------    --------------------------------------
13  */
14 
15 #include <board.h>
16 #include <drv_spi.h>
17 #include <rtdevice.h>
18 #include <rthw.h>
19 #include <finsh.h>
20 #include "ft_spi.h"
21 
22 #ifdef BSP_USE_SPI
23 
24 #include "dev_spi_flash.h"
25 #include "dev_spi_flash_sfud.h"
26 
rt_hw_spi_flash_init(void)27 static int rt_hw_spi_flash_init(void)
28 {
29     uint16_t cs_pin = 5;
30     rt_hw_spi_device_attach(SPI_BUS_NAME, SPI_DEV_NAME, cs_pin);
31 
32     rt_kprintf("attach spi flash\r\n");
33     /* lookup flah */
34     if (RT_NULL == rt_sfud_flash_probe("S25FS256S", SPI_DEV_NAME))
35     {
36         rt_kprintf("attach spi flash failed\r\n");
37         return -RT_ERROR;
38     }
39 
40     return RT_EOK;
41 }
42 INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);
43 #endif
44