summaryrefslogtreecommitdiff
path: root/bsp/nxp/lpc/lpc54114-lite/drivers/drv_spi_flash.c
blob: 35adfcfcee408441d7ce4a938bbfebaa6410ab4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include "drv_spi.h"
#include "drv_spi_flash.h"

#include "rtthread.h"
#include "rtdevice.h"
#include "dev_spi_flash.h"
#include "dev_spi_flash_sfud.h"

#define RT_SPI_FLASH_CS_PIN (2)

int rt_hw_flash_init(void)
{
    rt_err_t result;

    result = lpc_spi_bus_attach_device("spi2", "spi20", RT_SPI_FLASH_CS_PIN);
    if(result != RT_EOK)
    {
        return result;
    }

    if(rt_sfud_flash_probe("flash0", "spi20") == RT_NULL)
    {
        return -RT_ERROR;
    }

    return RT_EOK;
}
INIT_DEVICE_EXPORT(rt_hw_flash_init);