summaryrefslogtreecommitdiff
path: root/bsp/lpc54114-lite/drivers/drv_spi_flash.c
blob: 65433ce30cd9b267a79d46c33f624098582310c1 (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-2018, 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 "spi_flash.h"
#include "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);