18#ifndef __VSF_TEMPLATE_ADC_H__
19#define __VSF_TEMPLATE_ADC_H__
33#ifndef VSF_ADC_CFG_MULTI_CLASS
34# define VSF_ADC_CFG_MULTI_CLASS ENABLED
37#if defined(VSF_HW_ADC_COUNT) && !defined(VSF_HW_ADC_MASK)
38# define VSF_HW_ADC_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_ADC_COUNT)
41#if defined(VSF_HW_ADC_MASK) && !defined(VSF_HW_ADC_COUNT)
42# define VSF_HW_ADC_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_ADC_MASK)
46#ifndef VSF_ADC_CFG_PREFIX
47# if VSF_ADC_CFG_MULTI_CLASS == ENABLED
48# define VSF_ADC_CFG_PREFIX vsf
49# elif defined(VSF_HW_ADC_COUNT) && (VSF_HW_ADC_COUNT != 0)
50# define VSF_ADC_CFG_PREFIX vsf_hw
52# define VSF_ADC_CFG_PREFIX vsf
56#ifndef VSF_ADC_CFG_FUNCTION_RENAME
57# define VSF_ADC_CFG_FUNCTION_RENAME ENABLED
60#ifndef VSF_ADC_CFG_REIMPLEMENT_TYPE_MODE
61# define VSF_ADC_CFG_REIMPLEMENT_TYPE_MODE DISABLED
64#ifndef VSF_ADC_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE
65# define VSF_ADC_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE DISABLED
68#ifndef VSF_ADC_CFG_REIMPLEMENT_TYPE_IRQ_MASK
69# define VSF_ADC_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED
75#if VSF_ADC_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG == DISABLED
76# define VSF_ADC_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG DISABLED
82#if VSF_ADC_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
83# define VSF_ADC_CFG_REIMPLEMENT_TYPE_CFG DISABLED
89#if VSF_ADC_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
90# define VSF_ADC_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
93#ifndef VSF_ADC_CFG_INHERT_HAL_CAPABILITY
94# define VSF_ADC_CFG_INHERT_HAL_CAPABILITY ENABLED
99#define VSF_ADC_APIS(__PREFIX_NAME) \
100 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_err_t, adc, init, VSF_MCONNECT(__PREFIX_NAME, _adc_t) *adc_ptr, vsf_adc_cfg_t *cfg_ptr) \
101 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, void, adc, fini, VSF_MCONNECT(__PREFIX_NAME, _adc_t) *adc_ptr) \
102 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, fsm_rt_t, adc, enable, VSF_MCONNECT(__PREFIX_NAME, _adc_t) *adc_ptr) \
103 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, fsm_rt_t, adc, disable, VSF_MCONNECT(__PREFIX_NAME, _adc_t) *adc_ptr) \
104 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_adc_status_t, adc, status, VSF_MCONNECT(__PREFIX_NAME, _adc_t) *adc_ptr) \
105 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_adc_capability_t, adc, capability, VSF_MCONNECT(__PREFIX_NAME, _adc_t) *adc_ptr) \
106 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, void, adc, irq_enable, VSF_MCONNECT(__PREFIX_NAME, _adc_t) *adc_ptr, vsf_adc_irq_mask_t irq_mask) \
107 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, void, adc, irq_disable, VSF_MCONNECT(__PREFIX_NAME, _adc_t) *adc_ptr, vsf_adc_irq_mask_t irq_mask) \
108 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_err_t, adc, channel_request_once, VSF_MCONNECT(__PREFIX_NAME, _adc_t) *adc_ptr, vsf_adc_channel_cfg_t *channel_cfg, void *buffer_ptr) \
109 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_err_t, adc, channel_config, VSF_MCONNECT(__PREFIX_NAME, _adc_t) *adc_ptr, vsf_adc_channel_cfg_t *channel_cfgs_ptr, uint32_t channel_cfgs_cnt) \
110 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_err_t, adc, channel_request, VSF_MCONNECT(__PREFIX_NAME, _adc_t) *adc_ptr, void *buffer_ptr, uint_fast32_t count)
114#if VSF_ADC_CFG_REIMPLEMENT_TYPE_MODE == DISABLED
161#if VSF_ADC_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE == DISABLED
198#if VSF_ADC_CFG_REIMPLEMENT_TYPE_IRQ_MASK == DISABLED
210#if VSF_ADC_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG == DISABLED
218#if VSF_ADC_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
236#if VSF_ADC_CFG_REIMPLEMENT_TYPE_STATUS == DISABLED
247#if VSF_ADC_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
249#if VSF_ADC_CFG_INHERT_HAL_CAPABILITY == ENABLED
260#undef __VSF_HAL_TEMPLATE_API
261#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
266#if VSF_ADC_CFG_MULTI_CLASS == ENABLED
458#if VSF_ADC_CFG_FUNCTION_RENAME == ENABLED
459# define __vsf_adc_t VSF_MCONNECT(VSF_ADC_CFG_PREFIX, _adc_t)
460# define vsf_adc_init(__ADC, ...) VSF_MCONNECT(VSF_ADC_CFG_PREFIX, _adc_init) ((__vsf_adc_t *)(__ADC), ##__VA_ARGS__)
461# define vsf_adc_fini(__ADC) VSF_MCONNECT(VSF_ADC_CFG_PREFIX, _adc_fini) ((__vsf_adc_t *)(__ADC))
462# define vsf_adc_enable(__ADC) VSF_MCONNECT(VSF_ADC_CFG_PREFIX, _adc_enable) ((__vsf_adc_t *)(__ADC))
463# define vsf_adc_disable(__ADC) VSF_MCONNECT(VSF_ADC_CFG_PREFIX, _adc_disable) ((__vsf_adc_t *)(__ADC))
464# define vsf_adc_status(__ADC) VSF_MCONNECT(VSF_ADC_CFG_PREFIX, _adc_status) ((__vsf_adc_t *)(__ADC))
465# define vsf_adc_capability(__ADC) VSF_MCONNECT(VSF_ADC_CFG_PREFIX, _adc_capability) ((__vsf_adc_t *)(__ADC))
466# define vsf_adc_irq_enable(__ADC, ...) VSF_MCONNECT(VSF_ADC_CFG_PREFIX, _adc_irq_enable) ((__vsf_adc_t *)(__ADC), ##__VA_ARGS__)
467# define vsf_adc_irq_disable(__ADC, ...) VSF_MCONNECT(VSF_ADC_CFG_PREFIX, _adc_irq_disable) ((__vsf_adc_t *)(__ADC), ##__VA_ARGS__)
468# define vsf_adc_channel_request_once(__ADC, ...) VSF_MCONNECT(VSF_ADC_CFG_PREFIX, _adc_channel_request_once) ((__vsf_adc_t *)(__ADC), ##__VA_ARGS__)
469# define vsf_adc_channel_config(__ADC, ...) VSF_MCONNECT(VSF_ADC_CFG_PREFIX, _adc_channel_config) ((__vsf_adc_t *)(__ADC), ##__VA_ARGS__)
470# define vsf_adc_channel_request(__ADC, ...) VSF_MCONNECT(VSF_ADC_CFG_PREFIX, _adc_channel_request) ((__vsf_adc_t *)(__ADC), ##__VA_ARGS__)
vsf_err_t
Definition __type.h:42
vsf_arch_prio_t
Definition cortex_a_generic.h:88
unsigned short uint16_t
Definition lvgl.h:41
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_adc.h:248
inherit(vsf_peripheral_capability_t) vsf_adc_irq_mask_t irq_mask
uint8_t max_data_bits
Definition vsf_template_adc.h:254
uint8_t channel_count
Definition vsf_template_adc.h:255
adc configuration
Definition vsf_template_adc.h:229
vsf_adc_isr_t isr
Definition vsf_template_adc.h:231
uint32_t clock_hz
Definition vsf_template_adc.h:232
vsf_adc_mode_t mode
Definition vsf_template_adc.h:230
adc channel configuration
Definition vsf_template_adc.h:211
vsf_adc_channel_mode_t mode
Definition vsf_template_adc.h:212
uint16_t sample_cycles
Definition vsf_template_adc.h:213
uint8_t channel
Definition vsf_template_adc.h:214
Definition vsf_template_adc.h:223
vsf_arch_prio_t prio
Definition vsf_template_adc.h:226
vsf_adc_isr_handler_t * handler_fn
Definition vsf_template_adc.h:224
void * target_ptr
Definition vsf_template_adc.h:225
Definition vsf_template_adc.h:259
Definition vsf_template_adc.h:237
Definition vsf_template_adc.h:267
const vsf_adc_op_t * op
Definition vsf_template_adc.h:268
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
fsm_rt_t
Definition vsf_fsm.h:315
void vsf_adc_isr_handler_t(void *target_ptr, vsf_adc_t *adc_ptr, vsf_adc_irq_mask_t irq_mask)
Definition vsf_template_adc.h:220
@ VSF_ADC_CHANNEL_GAIN_MASK
Definition vsf_template_adc.h:179
@ VSF_ADC_CHANNEL_MODE_ALL_BITS_MASK
Definition vsf_template_adc.h:193
@ VSF_ADC_CHANNEL_MODE_MASK_COUNT
Definition vsf_template_adc.h:192
@ VSF_ADC_CHANNEL_REF_VDD_MASK
Definition vsf_template_adc.h:187
@ VSF_ADC_CHANNEL_GAIN_COUNT
Definition vsf_template_adc.h:178
@ VSF_ADC_CHANNEL_REF_VDD_COUNT
Definition vsf_template_adc.h:186
#define vsf_adc_channel_request(__ADC,...)
Definition vsf_template_adc.h:470
#define vsf_adc_enable(__ADC)
Definition vsf_template_adc.h:462
#define vsf_adc_init(__ADC,...)
Definition vsf_template_adc.h:460
#define vsf_adc_irq_enable(__ADC,...)
Definition vsf_template_adc.h:466
vsf_adc_irq_mask_t
Definition vsf_template_adc.h:199
@ VSF_ADC_IRQ_MASK_CPL
Definition vsf_template_adc.h:200
vsf_adc_channel_mode_t
Definition vsf_template_adc.h:162
@ VSF_ADC_CHANNEL_REF_VDD_1_3
Definition vsf_template_adc.h:172
@ VSF_ADC_CHANNEL_REF_VDD_1_2
Definition vsf_template_adc.h:171
@ VSF_ADC_CHANNEL_REF_VDD_1
Definition vsf_template_adc.h:170
@ VSF_ADC_CHANNEL_GAIN_1_4
Definition vsf_template_adc.h:165
@ VSF_ADC_CHANNEL_GAIN_1_5
Definition vsf_template_adc.h:164
@ VSF_ADC_CHANNEL_GAIN_1_2
Definition vsf_template_adc.h:167
@ VSF_ADC_CHANNEL_GAIN_1
Definition vsf_template_adc.h:168
@ VSF_ADC_CHANNEL_REF_VDD_1_4
Definition vsf_template_adc.h:173
@ VSF_ADC_CHANNEL_GAIN_1_3
Definition vsf_template_adc.h:166
@ VSF_ADC_CHANNEL_GAIN_1_6
Definition vsf_template_adc.h:163
@ VSF_ADC_MODE_ALL_BITS_MASK
Definition vsf_template_adc.h:155
@ VSF_ADC_EXTERN_TRIGGER_COUNT
Definition vsf_template_adc.h:149
@ VSF_ADC_MODE_MASK_COUNT
Definition vsf_template_adc.h:154
@ VSF_ADC_REF_VDD_MASK
Definition vsf_template_adc.h:136
@ VSF_ADC_REF_VDD_COUNT
Definition vsf_template_adc.h:135
@ VSF_ADC_DATA_ALIGN_MASK
Definition vsf_template_adc.h:142
@ VSF_ADC_DATA_ALIGN_COUNT
Definition vsf_template_adc.h:141
@ VSF_ADC_SCAN_CONV_MASK
Definition vsf_template_adc.h:146
@ VSF_ADC_EXTERN_TRIGGER_MASK
Definition vsf_template_adc.h:150
@ VSF_ADC_SCAN_CONV_COUNT
Definition vsf_template_adc.h:145
vsf_adc_mode_t
Definition vsf_template_adc.h:115
@ VSF_ADC_EXTERN_TRIGGER_2
Definition vsf_template_adc.h:130
@ VSF_ADC_DATA_ALIGN_LEFT
ADC data alignment to left.
Definition vsf_template_adc.h:122
@ VSF_ADC_REF_VDD_1_2
Definition vsf_template_adc.h:117
@ VSF_ADC_DATA_ALIGN_RIGHT
ADC data alignment to right.
Definition vsf_template_adc.h:121
@ VSF_ADC_REF_VDD_1_4
Definition vsf_template_adc.h:119
@ VSF_ADC_EXTERN_TRIGGER_1
Definition vsf_template_adc.h:129
@ VSF_ADC_REF_VDD_1_3
Definition vsf_template_adc.h:118
@ VSF_ADC_EXTERN_TRIGGER_0
Selects the external event used to trigger the conversion.
Definition vsf_template_adc.h:128
@ VSF_ADC_SCAN_CONV_SINGLE_MODE
Conversion is performed in single mode.
Definition vsf_template_adc.h:124
@ VSF_ADC_SCAN_CONV_SEQUENCE_MODE
Conversions are performed in sequence mode.
Definition vsf_template_adc.h:125
@ VSF_ADC_REF_VDD_1
Definition vsf_template_adc.h:116
#define vsf_adc_channel_request_once(__ADC,...)
Definition vsf_template_adc.h:468
#define vsf_adc_status(__ADC)
Definition vsf_template_adc.h:464
#define vsf_adc_fini(__ADC)
Definition vsf_template_adc.h:461
@ VSF_ADC_IRQ_COUNT
Definition vsf_template_adc.h:205
@ VSF_ADC_IRQ_ALL_BITS_MASK
Definition vsf_template_adc.h:206
#define vsf_adc_capability(__ADC)
Definition vsf_template_adc.h:465
#define vsf_adc_irq_disable(__ADC,...)
Definition vsf_template_adc.h:467
#define vsf_adc_disable(__ADC)
Definition vsf_template_adc.h:463
#define VSF_ADC_APIS(__PREFIX_NAME)
Definition vsf_template_adc.h:99
#define vsf_adc_channel_config(__ADC,...)
Definition vsf_template_adc.h:469