VSF Documented
flash.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __HAL_DRIVER_${SERIES/FLASH_IP}_FLASH_H__
19#define __HAL_DRIVER_${SERIES/FLASH_IP}_FLASH_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_FLASH == ENABLED
26
27// HW/IPCore
32// HW/IPCore end
33
34/*\note Refer to template/README.md for usage cases.
35 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
36 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
37 * For emulated drivers, **** No reimplementation ****.
38 */
39
40/*\note Includes CAN ONLY be put here. */
41/*\note If current header is for a peripheral driver(hw driver), and inherit from an IPCore driver, include IPCore header here. */
42
43// IPCore
44#if defined(__VSF_HAL_${FLASH_IP}_FLASH_CLASS_IMPLEMENT)
45# define __VSF_CLASS_IMPLEMENT__
46#elif defined(__VSF_HAL_${FLASH_IP}_FLASH_CLASS_INHERIT__)
47# define __VSF_CLASS_INHERIT__
48#endif
49
50#include "utilities/ooc_class.h"
51// IPCore end
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
57/*============================ MACROS ========================================*/
58
59/*\note VSF_${FLASH_IP}_FLASH_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
60 * while VSF_HW_FLASH_CFG_MULTI_CLASS should be in flash.c.
61 */
62
63// IPCore
64#ifndef VSF_${FLASH_IP}_FLASH_CFG_MULTI_CLASS
65# define VSF_${FLASH_IP}_FLASH_CFG_MULTI_CLASS VSF_FLASH_CFG_MULTI_CLASS
66#endif
67// IPCore end
68
69// HW
70/*\note hw FLASH driver can reimplement following types:
71 * To enable reimplementation, please enable macro below:
72 * VSF_FLASH_CFG_REIMPLEMENT_TYPE_STATUS for vsf_flash_status_t
73 * VSF_FLASH_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_flash_irq_mask_t
74 * VSF_FLASH_CFG_REIMPLEMENT_TYPE_CTRL for vsf_flash_ctrl_t
75 * VSF_FLASH_CFG_REIMPLEMENT_TYPE_CFG for vsf_flash_cfg_t
76 * VSF_FLASH_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_flash_capability_t
77 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
78 * *** DO NOT reimplement these in emulated drivers. ***
79 */
80
81#define VSF_FLASH_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
82#define VSF_FLASH_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
83#define VSF_FLASH_CFG_REIMPLEMENT_TYPE_CTRL ENABLED
84#define VSF_FLASH_CFG_REIMPLEMENT_TYPE_CFG ENABLED
85#define VSF_FLASH_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
86
87#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
88# undef VSF_FLASH_CFG_REIMPLEMENT_TYPE_FLASH_SIZE
89# define VSF_FLASH_CFG_REIMPLEMENT_TYPE_FLASH_SIZE ENABLED
90#endif
91
92// HW end
93
94/*============================ TYPES =========================================*/
95
96// IPCore
97vsf_class(vsf_${flash_ip}_flash_t) {
98#if VSF_${FLASH_IP}_CFG_MULTI_CLASS == ENABLED
99 public_member(
100 vsf_flash_t vsf_flash;
101 )
102#endif
103
104/*\note You can add more member in vsf_${flash_ip}_flash_t instance.
105 * For members accessible from child, put in protected_member.
106 * Else, put in private_member.
107 */
108
109 protected_member(
110 vsf_${flash_ip}_flash_reg_t *reg;
113};
114// IPCore end
115
116// HW/IPCore, not for emulated drivers
117#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
126#endif
127
128#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_FLASH_SIZE == ENABLED
130#endif
131
132#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
134typedef void vsf_flash_isr_handler_t(void *target_ptr, vsf_flash_t *flash_ptr, vsf_flash_irq_mask_t mask);
135typedef struct vsf_flash_isr_t {
137 void *target_ptr;
140typedef struct vsf_flash_cfg_t {
143#endif
144
145#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_STATUS == ENABLED
146typedef struct vsf_flash_status_t {
147 union {
149 struct {
150 uint32_t is_busy : 1;
151 };
152 };
154#endif
155
156#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
157typedef struct vsf_flash_capability_t {
158#if VSF_FLASH_CFG_INHERIT_HAL_CAPABILITY == ENABLED
160#endif
166 struct {
169 };
171#endif
172
173#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_CTRL == ENABLED
174typedef enum vsf_flash_ctrl_t {
177#endif
178// HW/IPCore end
179
180/*============================ GLOBAL VARIABLES ==============================*/
181/*============================ PROTOTYPES ====================================*/
182
183// IPCore
184/*\note Extern APIs for ip core diriver.
185 * There is no requirement about how APIs of IPCore drivers should be implemented.
186 * Just consider the simplicity for actual peripheral drivers.
187 */
188// IPCore end
189
190#ifdef __cplusplus
191}
192#endif
193
194// IPCore
195#undef __VSF_HAL_${FLASH_IP}_FLASH_CLASS_IMPLEMENT
196#undef __VSF_HAL_${FLASH_IP}_FLASH_CLASS_INHERIT__
197// IPCore end
198
199#endif // VSF_HAL_USE_FLASH
200#endif // __HAL_DRIVER_${SERIES/FLASH_IP}_FLASH_H__
201/* EOF */
vsf_flash_irq_mask_t
Definition flash.h:70
@ VSF_FLASH_IRQ_ERASE_MASK
Definition flash.h:72
@ VSF_FLASH_IRQ_READ_MASK
Definition flash.h:76
@ VSF_FLASH_IRQ_WRITE_ERROR_MASK
Definition flash.h:80
@ VSF_FLASH_IRQ_WRITE_MASK
Definition flash.h:74
@ VSF_FLASH_IRQ_ERASE_ERROR_MASK
Definition flash.h:78
@ VSF_FLASH_IRQ_READ_ERROR_MASK
Definition flash.h:82
struct vsf_flash_status_t vsf_flash_status_t
void vsf_flash_isr_handler_t(void *target_ptr, vsf_flash_t *flash_ptr, vsf_flash_irq_mask_t mask)
Definition flash.h:83
struct vsf_flash_capability_t vsf_flash_capability_t
struct vsf_flash_cfg_t vsf_flash_cfg_t
struct vsf_flash_isr_t vsf_flash_isr_t
uint_fast32_t vsf_flash_size_t
Definition flash.h:78
Definition adc.h:94
vsf_arch_prio_t
Definition cortex_a_generic.h:88
#define vsf_class(__name)
Definition ooc_class.h:48
const i_spi_t vsf_spi_irq_mask_t irq_mask
Definition spi_interface.h:38
unsigned uint32_t
Definition stdint.h:9
unsigned int uint_fast32_t
Definition stdint.h:27
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_template_flash.h:277
vsf_flash_size_t max_size
Definition vsf_template_flash.h:284
uint8_t none_sector_aligned_read
Definition vsf_template_flash.h:290
vsf_flash_size_t write_sector_size
Definition vsf_template_flash.h:286
inherit(vsf_peripheral_capability_t) vsf_flash_irq_mask_t irq_mask
vsf_flash_size_t base_address
Definition vsf_template_flash.h:283
vsf_flash_size_t erase_sector_size
Definition vsf_template_flash.h:285
uint8_t none_sector_aligned_write
Definition vsf_template_flash.h:289
Definition vsf_template_flash.h:253
vsf_flash_isr_t isr
Interrupt configuration.
Definition vsf_template_flash.h:254
Definition vsf_template_flash.h:248
vsf_flash_isr_handler_t * handler_fn
Interrupt handler function.
Definition vsf_template_flash.h:249
vsf_arch_prio_t prio
Interrupt priority.
Definition vsf_template_flash.h:251
void * target_ptr
User target pointer.
Definition vsf_template_flash.h:250
Flash status structure that can be reimplemented in specific HAL drivers.
Definition flash.h:87
Definition vsf_template_flash.h:365
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
vsf_flash_irq_mask_t
Definition flash.h:118
void vsf_flash_isr_handler_t(void *target_ptr, vsf_flash_t *flash_ptr, vsf_flash_irq_mask_t mask)
Definition flash.h:134
vsf_flash_isr_t isr
Definition flash.h:112
vsf_flash_ctrl_t
Definition flash.h:174
@ __VSF_FLASH_CTRL_DUMMY
Definition flash.h:175
class vsf_$ * reg
uint_fast32_t vsf_flash_size_t
Definition flash.h:129
vsf_flash_ctrl_t
Predefined VSF Flash control commands that can be reimplemented in specific HAL drivers.
Definition vsf_template_flash.h:315
Generated from commit: vsfteam/vsf@8634e61