summaryrefslogtreecommitdiff
path: root/components/drivers/spi/dev_spi_flash.h
blob: b7fd5bf314c7d4ed79ead067bbbfd92f7123f633 (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
35
36
37
38
39
40
41
42
43
/*
 * Copyright (c) 2006-2025 RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2016/5/20      bernard      the first version
 * 2020/1/7       redoc        add include
 * 2025-10-30     wdfk-prog    enable interrupt-safe operations using spinlocks
 */

#ifndef __DEV_SPI_FLASH_H__
#define __DEV_SPI_FLASH_H__

#include <rtdevice.h>

struct spi_flash_device
{
    struct rt_device                flash_device;
    struct rt_device_blk_geometry   geometry;
    struct rt_spi_device *          rt_spi_device;
    struct rt_mutex                 lock;
#ifdef RT_USING_SPI_ISR
    rt_base_t _isr_lvl;
    struct rt_spinlock _spinlock;
#endif /* RT_USING_SPI_ISR */
    void *                          user_data;
};

typedef struct spi_flash_device *rt_spi_flash_device_t;

#ifdef RT_USING_MTD_NOR
struct spi_flash_mtd
{
    struct rt_mtd_nor_device            mtd_device;
    struct rt_spi_device *              rt_spi_device;
    struct rt_mutex                     lock;
    void *                              user_data;
};
#endif

#endif