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 flashecific 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_MODE for vsf_flash_mode_t
73 * VSF_FLASH_CFG_REIMPLEMENT_TYPE_STATUS for vsf_flash_status_t
74 * VSF_FLASH_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_flash_irq_mask_t
75 * VSF_FLASH_CFG_REIMPLEMENT_TYPE_CTRL for vsf_flash_ctrl_t
76 * VSF_FLASH_CFG_REIMPLEMENT_TYPE_CFG for vsf_flash_cfg_t
77 * VSF_FLASH_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_flash_capability_t
78 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
79 * *** DO NOT reimplement these in emulated drivers. ***
80 */
81
82#define VSF_FLASH_CFG_REIMPLEMENT_TYPE_MODE ENABLED
83#define VSF_FLASH_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
84#define VSF_FLASH_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
85#define VSF_FLASH_CFG_REIMPLEMENT_TYPE_CTRL ENABLED
86#define VSF_FLASH_CFG_REIMPLEMENT_TYPE_CFG ENABLED
87#define VSF_FLASH_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
88
89#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
90# undef VSF_FLASH_CFG_REIMPLEMENT_TYPE_FLASH_SIZE
91# define VSF_FLASH_CFG_REIMPLEMENT_TYPE_FLASH_SIZE ENABLED
92#endif
93
94// HW end
95
96/*============================ TYPES =========================================*/
97
98// IPCore
99vsf_class(vsf_${flash_ip}_flash_t) {
100#if VSF_${FLASH_IP}_CFG_MULTI_CLASS == ENABLED
101 public_member(
102 vsf_flash_t vsf_flash;
103 )
104#endif
105
106/*\note You can add more member in vsf_${flash_ip}_flash_t instance.
107 * For members accessible from child, put in protected_member.
108 * Else, put in private_member.
109 */
110
111 protected_member(
112 vsf_${flash_ip}_flash_reg_t *reg;
115};
116// IPCore end
117
118// HW/IPCore, not for emulated drivers
119#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
128#endif
129
130#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_FLASH_SIZE == ENABLED
132#endif
133
134#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
136typedef void vsf_flash_isr_handler_t(void *target_ptr, vsf_flash_t *flash_ptr, vsf_flash_irq_mask_t mask);
137typedef struct vsf_flash_isr_t {
139 void *target_ptr;
142typedef struct vsf_flash_cfg_t {
145#endif
146
147#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_STATUS == ENABLED
148typedef struct vsf_flash_status_t {
149 union {
151 struct {
152 uint32_t is_busy : 1;
153 };
154 };
156#endif
157
158#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
159typedef struct vsf_flash_capability_t {
160#if VSF_FLASH_CFG_INHERIT_HAL_CAPABILITY == ENABLED
162#endif
168 struct {
171 };
173#endif
174// HW/IPCore end
175
176/*============================ GLOBAL VARIABLES ==============================*/
177/*============================ PROTOTYPES ====================================*/
178
179// IPCore
180/*\note Extern APIs for ip core diriver.
181 * There is no requirement about how APIs of IPCore drivers should be implemented.
182 * Just consider the simplicity for actual peripheral drivers.
183 */
184// IPCore end
185
186#ifdef __cplusplus
187}
188#endif
189
190// IPCore
191#undef __VSF_HAL_${FLASH_IP}_FLASH_CLASS_IMPLEMENT
192#undef __VSF_HAL_${FLASH_IP}_FLASH_CLASS_INHERIT__
193// IPCore end
194
195#endif // VSF_HAL_USE_FLASH
196#endif // __HAL_DRIVER_${SERIES/FLASH_IP}_FLASH_H__
197/* EOF */
vsf_flash_irq_mask_t
Definition flash.h:47
@ VSF_FLASH_IRQ_ERASE_MASK
Definition flash.h:49
@ VSF_FLASH_IRQ_READ_MASK
Definition flash.h:53
@ VSF_FLASH_IRQ_WRITE_ERROR_MASK
Definition flash.h:58
@ VSF_FLASH_IRQ_WRITE_MASK
Definition flash.h:51
@ VSF_FLASH_IRQ_ERASE_ERROR_MASK
Definition flash.h:56
@ VSF_FLASH_IRQ_READ_ERROR_MASK
Definition flash.h:60
void vsf_flash_isr_handler_t(void *target_ptr, vsf_flash_t *flash_ptr, vsf_flash_irq_mask_t mask)
Definition flash.h:85
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
struct vsf_flash_status_t vsf_flash_status_t
uint_fast32_t vsf_flash_size_t
Definition flash.h:80
Definition adc.h:92
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:263
vsf_flash_size_t max_size
Definition vsf_template_flash.h:270
uint8_t none_sector_aligned_read
Definition vsf_template_flash.h:276
vsf_flash_size_t write_sector_size
Definition vsf_template_flash.h:272
inherit(vsf_peripheral_capability_t) vsf_flash_irq_mask_t irq_mask
vsf_flash_size_t base_address
Definition vsf_template_flash.h:269
vsf_flash_size_t erase_sector_size
Definition vsf_template_flash.h:271
uint8_t none_sector_aligned_write
Definition vsf_template_flash.h:275
Definition vsf_template_flash.h:239
vsf_flash_isr_t isr
Interrupt configuration.
Definition vsf_template_flash.h:240
Definition vsf_template_flash.h:234
vsf_flash_isr_handler_t * handler_fn
Interrupt handler function.
Definition vsf_template_flash.h:235
vsf_arch_prio_t prio
Interrupt priority.
Definition vsf_template_flash.h:237
void * target_ptr
User target pointer.
Definition vsf_template_flash.h:236
Flash status structure that can be reimplemented in specific HAL drivers.
Definition vsf_template_flash.h:252
Definition vsf_template_flash.h:291
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
vsf_flash_irq_mask_t
Definition flash.h:120
void vsf_flash_isr_handler_t(void *target_ptr, vsf_flash_t *flash_ptr, vsf_flash_irq_mask_t mask)
Definition flash.h:136
vsf_flash_isr_t isr
Definition flash.h:114
class vsf_$ * reg
uint_fast32_t vsf_flash_size_t
Definition flash.h:131
vsf_flash_irq_mask_t
Predefined VSF Flash interrupts that can be reimplemented in specific HAL drivers.
Definition vsf_template_flash.h:198
Generated from commit: vsfteam/vsf@74aa6ce