18#ifndef __VSF_TEMPLATE_FLASH_H__
19#define __VSF_TEMPLATE_FLASH_H__
34#ifndef VSF_FLASH_CFG_MULTI_CLASS
35# define VSF_FLASH_CFG_MULTI_CLASS ENABLED
38#if defined(VSF_HW_FLASH_COUNT) && !defined(VSF_HW_FLASH_MASK)
39# define VSF_HW_FLASH_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_FLASH_COUNT)
42#if defined(VSF_HW_FLASH_MASK) && !defined(VSF_HW_FLASH_COUNT)
43# define VSF_HW_FLASH_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_FLASH_MASK)
47#ifndef VSF_FLASH_CFG_PREFIX
48# if VSF_FLASH_CFG_MULTI_CLASS == ENABLED
49# define VSF_FLASH_CFG_PREFIX vsf
50# elif defined(VSF_HW_FLASH_COUNT) && (VSF_HW_FLASH_COUNT != 0)
51# define VSF_FLASH_CFG_PREFIX vsf_hw
53# define VSF_FLASH_CFG_PREFIX vsf
57#ifndef VSF_FLASH_CFG_FUNCTION_RENAME
58# define VSF_FLASH_CFG_FUNCTION_RENAME ENABLED
61#ifndef VSF_FLASH_CFG_REIMPLEMENT_TYPE_IRQ_MASK
62# define VSF_FLASH_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED
65#ifndef VSF_FLASH_CFG_REIMPLEMENT_TYPE_FLASH_SIZE
66# define VSF_FLASH_CFG_REIMPLEMENT_TYPE_FLASH_SIZE DISABLED
69#ifndef VSF_FLASH_CFG_REIMPLEMENT_TYPE_STATUS
70# define VSF_FLASH_CFG_REIMPLEMENT_TYPE_STATUS DISABLED
76#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
77# define VSF_FLASH_CFG_REIMPLEMENT_TYPE_CFG DISABLED
83#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
84# define VSF_FLASH_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
87#ifndef VSF_FLASH_CFG_INHERT_HAL_CAPABILITY
88# define VSF_FLASH_CFG_INHERT_HAL_CAPABILITY ENABLED
93#define VSF_FLASH_APIS(__prefix_name) \
94 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, flash, init, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr, vsf_flash_cfg_t *cfg_ptr) \
95 __VSF_HAL_TEMPLATE_API(__prefix_name, void, flash, fini, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptrr) \
96 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, flash, enable, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr) \
97 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, flash, disable, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr) \
98 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_flash_status_t, flash, status, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr) \
99 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_flash_capability_t, flash, capability, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr) \
100 __VSF_HAL_TEMPLATE_API(__prefix_name, void, flash, irq_enable, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr, vsf_flash_irq_mask_t irq_mask) \
101 __VSF_HAL_TEMPLATE_API(__prefix_name, void, flash, irq_disable, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr, vsf_flash_irq_mask_t irq_mask) \
102 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, flash, erase_one_sector, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr, vsf_flash_size_t offset_of_bytes) \
103 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, flash, erase_multi_sector, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr, vsf_flash_size_t offset_of_bytes, vsf_flash_size_t size_of_bytes) \
104 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, flash, erase_all, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr) \
105 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, flash, write_one_sector, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr, vsf_flash_size_t offset_of_bytes, uint8_t* buffer, vsf_flash_size_t size_of_bytes) \
106 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, flash, write_multi_sector, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr, vsf_flash_size_t offset_of_bytes, uint8_t* buffer, vsf_flash_size_t size_of_bytes) \
107 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, flash, read_one_sector, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr, vsf_flash_size_t offset_of_bytes, uint8_t* buffer, vsf_flash_size_t size_of_bytes) \
108 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, flash, read_multi_sector, VSF_MCONNECT(__prefix_name, _flash_t) *flash_ptr, vsf_flash_size_t offset_of_bytes, uint8_t* buffer, vsf_flash_size_t size_of_bytes)
112#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_IRQ_MASK == DISABLED
134#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_FLASH_SIZE == DISABLED
138#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
152#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_STATUS == DISABLED
163#if VSF_FLASH_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
165#if VSF_FLASH_CFG_INHERT_HAL_CAPABILITY == ENABLED
183#undef __VSF_HAL_TEMPLATE_API
184#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
189#if VSF_FLASH_CFG_MULTI_CLASS == ENABLED
467#if VSF_FLASH_CFG_FUNCTION_RENAME == ENABLED
468# define __vsf_flash_t VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_t)
469# define vsf_flash_init(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_init) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
470# define vsf_flash_fini(__FLASH) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_fini) ((__vsf_flash_t *)(__FLASH))
471# define vsf_flash_enable(__FLASH) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_enable) ((__vsf_flash_t *)(__FLASH))
472# define vsf_flash_disable(__FLASH) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_disable) ((__vsf_flash_t *)(__FLASH))
473# define vsf_flash_capability(__FLASH) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_capability) ((__vsf_flash_t *)(__FLASH))
474# define vsf_flash_status(__FLASH) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_status) ((__vsf_flash_t *)(__FLASH))
475# define vsf_flash_irq_enable(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_irq_enable) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
476# define vsf_flash_irq_disable(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_irq_disable) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
477# define vsf_flash_erase_one_sector(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_erase_one_sector) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
478# define vsf_flash_erase_multi_sector(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_erase_multi_sector) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
479# define vsf_flash_erase(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_erase_multi_sector) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
480# define vsf_flash_erase_all(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_erase_all) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
481# define vsf_flash_write_one_sector(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_write_one_sector) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
482# define vsf_flash_write_multi_sector(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_write_multi_sector) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
483# define vsf_flash_write(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_write_multi_sector) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
484# define vsf_flash_read_one_sector(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_read_one_sector) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
485# define vsf_flash_read_multi_sector(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_read_multi_sector) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
486# define vsf_flash_read(__FLASH, ...) VSF_MCONNECT(VSF_FLASH_CFG_PREFIX, _flash_read_multi_sector) ((__vsf_flash_t *)(__FLASH), ##__VA_ARGS__)
vsf_err_t
Definition __type.h:42
vsf_arch_prio_t
Definition cortex_a_generic.h:88
unsigned int uint32_t
Definition lvgl.h:43
unsigned char uint8_t
Definition lvgl.h:40
const i_spi_t vsf_spi_irq_mask_t irq_mask
Definition spi_interface.h:38
unsigned int uint_fast32_t
Definition stdint.h:27
Definition vsf_template_flash.h:164
vsf_flash_size_t max_size
Definition vsf_template_flash.h:171
uint8_t none_sector_aligned_read
Definition vsf_template_flash.h:177
vsf_flash_size_t write_sector_size
Definition vsf_template_flash.h:173
inherit(vsf_peripheral_capability_t) vsf_flash_irq_mask_t irq_mask
vsf_flash_size_t base_address
Definition vsf_template_flash.h:170
vsf_flash_size_t erase_sector_size
Definition vsf_template_flash.h:172
uint8_t none_sector_aligned_write
Definition vsf_template_flash.h:176
Definition vsf_template_flash.h:147
vsf_flash_isr_t isr
Definition vsf_template_flash.h:148
Definition vsf_template_flash.h:142
void * target_ptr
Definition vsf_template_flash.h:144
vsf_arch_prio_t prio
Definition vsf_template_flash.h:145
vsf_flash_isr_handler_t * handler_fn
Definition vsf_template_flash.h:143
Definition vsf_template_flash.h:182
Definition vsf_template_flash.h:153
Definition vsf_template_flash.h:190
const vsf_flash_op_t * op
Definition vsf_template_flash.h:191
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
fsm_rt_t
Definition vsf_fsm.h:315
#define vsf_flash_status(__FLASH)
Definition vsf_template_flash.h:474
#define VSF_FLASH_APIS(__prefix_name)
Definition vsf_template_flash.h:93
#define vsf_flash_erase_one_sector(__FLASH,...)
Definition vsf_template_flash.h:477
vsf_flash_irq_mask_t
Definition vsf_template_flash.h:113
@ VSF_FLASH_IRQ_ERASE_MASK
Definition vsf_template_flash.h:114
@ VSF_FLASH_IRQ_READ_MASK
Definition vsf_template_flash.h:116
@ VSF_FLASH_IRQ_WRITE_ERROR_MASK
Definition vsf_template_flash.h:119
@ VSF_FLASH_IRQ_WRITE_MASK
Definition vsf_template_flash.h:115
@ VSF_FLASH_IRQ_ERASE_ERROR_MASK
Definition vsf_template_flash.h:118
@ VSF_FLASH_IRQ_READ_ERROR_MASK
Definition vsf_template_flash.h:120
#define vsf_flash_capability(__FLASH)
Definition vsf_template_flash.h:473
void vsf_flash_isr_handler_t(void *target_ptr, vsf_flash_t *flash_ptr, vsf_flash_irq_mask_t mask)
Definition vsf_template_flash.h:140
#define vsf_flash_init(__FLASH,...)
Definition vsf_template_flash.h:469
#define vsf_flash_erase_multi_sector(__FLASH,...)
Definition vsf_template_flash.h:478
#define vsf_flash_irq_enable(__FLASH,...)
Definition vsf_template_flash.h:475
#define vsf_flash_erase_all(__FLASH,...)
Definition vsf_template_flash.h:480
#define vsf_flash_fini(__FLASH)
Definition vsf_template_flash.h:470
@ VSF_FLASH_IRQ_COUNT
Definition vsf_template_flash.h:125
@ VSF_FLASH_IRQ_ALL_BITS_MASK
Definition vsf_template_flash.h:126
#define vsf_flash_irq_disable(__FLASH,...)
Definition vsf_template_flash.h:476
#define vsf_flash_read_multi_sector(__FLASH,...)
Definition vsf_template_flash.h:485
#define vsf_flash_disable(__FLASH)
Definition vsf_template_flash.h:472
#define vsf_flash_read_one_sector(__FLASH,...)
Definition vsf_template_flash.h:484
#define vsf_flash_write_one_sector(__FLASH,...)
Definition vsf_template_flash.h:481
uint_fast32_t vsf_flash_size_t
Definition vsf_template_flash.h:135
#define vsf_flash_enable(__FLASH)
Definition vsf_template_flash.h:471
#define vsf_flash_write_multi_sector(__FLASH,...)
Definition vsf_template_flash.h:482