2018-12-05 19:04:47 +08:00
|
|
|
/*
|
2021-03-17 02:26:35 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2018-12-05 19:04:47 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2021-03-17 02:26:35 +08:00
|
|
|
|
|
|
|
#include "drv_spi.h"
|
2018-12-05 19:04:47 +08:00
|
|
|
#include "drv_spi_flash.h"
|
|
|
|
|
2021-03-17 02:26:35 +08:00
|
|
|
#include "rtthread.h"
|
|
|
|
#include "rtdevice.h"
|
2018-12-05 19:04:47 +08:00
|
|
|
#include "spi_flash.h"
|
|
|
|
#include "spi_flash_sfud.h"
|
|
|
|
|
|
|
|
#define RT_SPI_FLASH_CS_PIN (2)
|
|
|
|
|
|
|
|
int rt_hw_flash_init(void)
|
|
|
|
{
|
2021-03-17 02:26:35 +08:00
|
|
|
rt_err_t result;
|
|
|
|
|
|
|
|
result = lpc_spi_bus_attach_device("spi2", "spi20", RT_SPI_FLASH_CS_PIN);
|
|
|
|
if(result != RT_EOK)
|
2018-12-05 19:04:47 +08:00
|
|
|
{
|
2021-03-17 02:26:35 +08:00
|
|
|
return result;
|
2018-12-05 19:04:47 +08:00
|
|
|
}
|
2021-03-17 02:26:35 +08:00
|
|
|
|
|
|
|
if(rt_sfud_flash_probe("flash0", "spi20") == RT_NULL)
|
2018-12-05 19:04:47 +08:00
|
|
|
{
|
|
|
|
return RT_ERROR;
|
|
|
|
}
|
|
|
|
|
2021-03-17 02:26:35 +08:00
|
|
|
return RT_EOK;
|
2018-12-05 19:04:47 +08:00
|
|
|
}
|
2021-03-17 02:26:35 +08:00
|
|
|
INIT_DEVICE_EXPORT(rt_hw_flash_init);
|