VSF Documented
adc.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/ADC_IP}_ADC_H__
19#define __HAL_DRIVER_${SERIES/ADC_IP}_ADC_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_ADC == 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_${ADC_IP}_ADC_CLASS_IMPLEMENT)
45# define __VSF_CLASS_IMPLEMENT__
46#elif defined(__VSF_HAL_${ADC_IP}_ADC_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_${ADC_IP}_ADC_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
60 * while VSF_HW_ADC_CFG_MULTI_CLASS should be in adc.c.
61 */
62
63// IPCore
64#ifndef VSF_${ADC_IP}_ADC_CFG_MULTI_CLASS
65# define VSF_${ADC_IP}_ADC_CFG_MULTI_CLASS VSF_ADC_CFG_MULTI_CLASS
66#endif
67// IPCore end
68
69// HW
70/*\note hw ADC driver can reimplement following types:
71 * To enable reimplementation, please enable macro below:
72 * VSF_ADC_CFG_REIMPLEMENT_TYPE_MODE for vsf_adc_mode_t
73 * VSF_ADC_CFG_REIMPLEMENT_TYPE_STATUS for vsf_adc_status_t
74 * VSF_ADC_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_adc_irq_mask_t
75 * VSF_ADC_CFG_REIMPLEMENT_TYPE_CFG for vsf_adc_cfg_t
76 * VSF_ADC_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_adc_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_ADC_CFG_REIMPLEMENT_TYPE_MODE ENABLED
82#define VSF_ADC_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
83#define VSF_ADC_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
84#define VSF_ADC_CFG_REIMPLEMENT_TYPE_CFG ENABLED
85#define VSF_ADC_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
86// HW end
87
88/*============================ MACROFIED FUNCTIONS ===========================*/
89/*============================ TYPES =========================================*/
90
91// IPCore
92vsf_class(vsf_${adc_ip}_adc_t) {
93#if VSF_${ADC_IP}_CFG_MULTI_CLASS == ENABLED
94 public_member(
95 vsf_adc_t vsf_adc;
96 )
97#endif
98
99/*\note You can add more member in vsf_${adc_ip}_adc_t instance.
100 * For members accessible from child, put in protected_member.
101 * Else, put in private_member.
102 */
103
104 protected_member(
105 vsf_${adc_ip}_adc_reg_t *reg;
108};
109// IPCore end
110
111// HW/IPCore, not for emulated drivers
112
113#if VSF_ADC_CFG_REIMPLEMENT_TYPE_MODE == ENABLED
114typedef enum vsf_adc_mode_t {
127#endif
128
129#if VSF_ADC_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
130typedef enum vsf_adc_irq_mask_t {
131 VSF_ADC_IRQ_MASK_CPL = (0x1ul << 0),
133#endif
134
135#if VSF_ADC_CFG_REIMPLEMENT_TYPE_STATUS == ENABLED
136typedef struct vsf_adc_status_t {
137 union {
139 struct {
140 uint32_t is_busy : 1;
141 };
143 };
145#endif
146
147#if VSF_ADC_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
148typedef struct vsf_adc_t vsf_adc_t;
149typedef void vsf_adc_isr_handler_t(void *target_ptr,
150 vsf_adc_t *adc_ptr,
152typedef struct vsf_adc_isr_t {
154 void *target_ptr;
157typedef struct vsf_adc_cfg_t {
162#endif
163
164#if VSF_ADC_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
165typedef struct vsf_adc_capability_t {
166#if VSF_ADC_CFG_INHERIT_HAL_CAPABILITY == ENABLED
168#endif
173#endif
174// HW/IPCore end
175
176/*============================ INCLUDES ======================================*/
177
178// IPCore
179/*\note Extern APIs for ip core diriver.
180 * There is no requirement about how APIs of IPCore drivers should be implemented.
181 * Just consider the simplicity for actual peripheral drivers.
182 */
183// IPCore end
184
185#ifdef __cplusplus
186}
187#endif
188
189// IPCore
190#undef __VSF_HAL_${ADC_IP}_ADC_CLASS_IMPLEMENT
191#undef __VSF_HAL_${ADC_IP}_ADC_CLASS_INHERIT__
192// IPCore end
193
194#endif // VSF_HAL_USE_ADC
195#endif // __HAL_DRIVER_${SERIES/ADC_IP}_ADC_H__
196/* EOF */
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 char uint8_t
Definition stdint.h:5
Predefined VSF ADC capability that can be reimplemented in specific HAL drivers.
Definition vsf_template_adc.h:689
inherit(vsf_peripheral_capability_t) vsf_adc_irq_mask_t irq_mask
uint8_t max_data_bits
Definition vsf_template_adc.h:695
uint8_t channel_count
Definition vsf_template_adc.h:696
Configuration structure for ADC.
Definition vsf_template_adc.h:639
vsf_adc_isr_t isr
Interrupt service routine configuration.
Definition vsf_template_adc.h:641
uint32_t clock_hz
Clock frequency in Hertz.
Definition vsf_template_adc.h:642
vsf_adc_mode_t mode
ADC working mode.
Definition vsf_template_adc.h:640
adc isr for api
Definition vsf_template_adc.h:626
vsf_arch_prio_t prio
Definition vsf_template_adc.h:629
void * target_ptr
Definition vsf_template_adc.h:628
vsf_adc_isr_handler_t * handler_fn
Definition vsf_template_adc.h:627
Predefined VSF ADC status that can be reimplemented in specific HAL drivers.
Definition vsf_template_adc.h:661
uint32_t value
Definition vsf_template_adc.h:667
Definition vsf_template_adc.h:710
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
void vsf_adc_isr_handler_t(void *target_ptr, vsf_adc_t *adc_ptr, vsf_adc_irq_mask_t irq_mask)
Definition adc.h:149
vsf_adc_irq_mask_t
Definition adc.h:130
@ VSF_ADC_IRQ_MASK_CPL
Definition adc.h:131
vsf_adc_mode_t
Definition adc.h:114
@ VSF_ADC_EXTERN_TRIGGER_2
Definition adc.h:125
@ VSF_ADC_DATA_ALIGN_LEFT
Definition adc.h:120
@ VSF_ADC_REF_VDD_1_2
Definition adc.h:116
@ VSF_ADC_DATA_ALIGN_RIGHT
Definition adc.h:119
@ VSF_ADC_REF_VDD_1_4
Definition adc.h:118
@ VSF_ADC_EXTERN_TRIGGER_1
Definition adc.h:124
@ VSF_ADC_REF_VDD_1_3
Definition adc.h:117
@ VSF_ADC_EXTERN_TRIGGER_0
Definition adc.h:123
@ VSF_ADC_SCAN_CONV_SINGLE_MODE
Definition adc.h:121
@ VSF_ADC_SCAN_CONV_SEQUENCE_MODE
Definition adc.h:122
@ VSF_ADC_REF_VDD_1
Definition adc.h:115
class vsf_$ * reg
vsf_adc_isr_t isr
Definition adc.h:107
vsf_adc_irq_mask_t
Predefined VSF ADC interrupt that can be reimplemented in specific HAL drivers.
Definition vsf_template_adc.h:594
vsf_adc_mode_t
Predefined VSF ADC modes that can be reimplemented in specific HAL drivers.
Definition vsf_template_adc.h:262
Generated from commit: vsfteam/vsf@74aa6ce