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#include "../../__device.h"
35
36/*\note Refer to template/README.md for usage cases.
37 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
38 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
39 * For emulated drivers, **** No reimplementation ****.
40 */
41
42/*\note Includes CAN ONLY be put here. */
43/*\note If current header is for a peripheral driver(hw driver), and inherit from an IPCore driver, include IPCore header here. */
44
45// IPCore
46#if defined(__VSF_HAL_${ADC_IP}_ADC_CLASS_IMPLEMENT)
47# define __VSF_CLASS_IMPLEMENT__
48#elif defined(__VSF_HAL_${ADC_IP}_ADC_CLASS_INHERIT__)
49# define __VSF_CLASS_INHERIT__
50#endif
51
52#include "utilities/ooc_class.h"
53// IPCore end
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59/*============================ MACROS ========================================*/
60
61/*\note VSF_${ADC_IP}_ADC_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
62 * while VSF_HW_ADC_CFG_MULTI_CLASS should be in adc.c.
63 */
64
65// IPCore
66#ifndef VSF_${ADC_IP}_ADC_CFG_MULTI_CLASS
67# define VSF_${ADC_IP}_ADC_CFG_MULTI_CLASS VSF_ADC_CFG_MULTI_CLASS
68#endif
69// IPCore end
70
71// HW
72/*\note hw ADC driver can reimplement following types:
73 * To enable reimplementation, please enable macro below:
74 * VSF_ADC_CFG_REIMPLEMENT_TYPE_MODE for vsf_adc_mode_t
75 * VSF_ADC_CFG_REIMPLEMENT_TYPE_STATUS for vsf_adc_status_t
76 * VSF_ADC_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_adc_irq_mask_t
77 * VSF_ADC_CFG_REIMPLEMENT_TYPE_CFG for vsf_adc_cfg_t
78 * VSF_ADC_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_adc_capability_t
79 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
80 * *** DO NOT reimplement these in emulated drivers. ***
81 */
82
83#define VSF_ADC_CFG_REIMPLEMENT_TYPE_MODE ENABLED
84#define VSF_ADC_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
85#define VSF_ADC_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
86#define VSF_ADC_CFG_REIMPLEMENT_TYPE_CFG ENABLED
87#define VSF_ADC_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
88// HW end
89
90/*============================ MACROFIED FUNCTIONS ===========================*/
91/*============================ TYPES =========================================*/
92
93// IPCore
94vsf_class(vsf_${adc_ip}_adc_t) {
95#if VSF_${ADC_IP}_CFG_MULTI_CLASS == ENABLED
96 public_member(
97 vsf_adc_t vsf_adc;
98 )
99#endif
100
101/*\note You can add more member in vsf_${adc_ip}_adc_t instance.
102 * For members accessible from child, put in protected_member.
103 * Else, put in private_member.
104 */
105
106 protected_member(
107 vsf_${adc_ip}_adc_reg_t *reg;
110};
111// IPCore end
112
113// HW/IPCore, not for emulated drivers
114
115#if VSF_ADC_CFG_REIMPLEMENT_TYPE_MODE == ENABLED
116typedef enum vsf_adc_mode_t {
129#endif
130
131#if VSF_ADC_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
132typedef enum vsf_adc_irq_mask_t {
133 VSF_ADC_IRQ_MASK_CPL = (0x1ul << 0),
135#endif
136
137#if VSF_ADC_CFG_REIMPLEMENT_TYPE_STATUS == ENABLED
138typedef struct vsf_adc_status_t {
139 union {
141 struct {
142 uint32_t is_busy : 1;
143 };
145 };
147#endif
148
149#if VSF_ADC_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
150typedef struct vsf_adc_t vsf_adc_t;
151typedef void vsf_adc_isr_handler_t(void *target_ptr,
152 vsf_adc_t *adc_ptr,
154typedef struct vsf_adc_isr_t {
156 void *target_ptr;
159typedef struct vsf_adc_cfg_t {
164#endif
165
166#if VSF_ADC_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
167typedef struct vsf_adc_capability_t {
168#if VSF_ADC_CFG_INHERIT_HAL_CAPABILITY == ENABLED
170#endif
175#endif
176// HW/IPCore end
177
178/*============================ INCLUDES ======================================*/
179
180// IPCore
181/*\note Extern APIs for ip core diriver.
182 * There is no requirement about how APIs of IPCore drivers should be implemented.
183 * Just consider the simplicity for actual peripheral drivers.
184 */
185// IPCore end
186
187#ifdef __cplusplus
188}
189#endif
190
191// IPCore
192#undef __VSF_HAL_${ADC_IP}_ADC_CLASS_IMPLEMENT
193#undef __VSF_HAL_${ADC_IP}_ADC_CLASS_INHERIT__
194// IPCore end
195
196#endif // VSF_HAL_USE_ADC
197#endif // __HAL_DRIVER_${SERIES/ADC_IP}_ADC_H__
198/* EOF */
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 char uint8_t
Definition stdint.h:5
Predefined VSF ADC capability that can be reimplemented in specific HAL drivers.
Definition vsf_template_adc.h:688
inherit(vsf_peripheral_capability_t) vsf_adc_irq_mask_t irq_mask
uint8_t max_data_bits
Definition vsf_template_adc.h:694
uint8_t channel_count
Definition vsf_template_adc.h:695
Configuration structure for ADC.
Definition vsf_template_adc.h:638
vsf_adc_isr_t isr
Interrupt service routine configuration.
Definition vsf_template_adc.h:640
uint32_t clock_hz
Clock frequency in Hertz.
Definition vsf_template_adc.h:641
vsf_adc_mode_t mode
ADC working mode.
Definition vsf_template_adc.h:639
adc isr for api
Definition vsf_template_adc.h:625
vsf_arch_prio_t prio
Definition vsf_template_adc.h:628
void * target_ptr
Definition vsf_template_adc.h:627
vsf_adc_isr_handler_t * handler_fn
Definition vsf_template_adc.h:626
Predefined VSF ADC status that can be reimplemented in specific HAL drivers.
Definition vsf_template_adc.h:660
uint32_t value
Definition vsf_template_adc.h:666
Definition vsf_template_adc.h:709
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:151
vsf_adc_irq_mask_t
Definition adc.h:132
@ VSF_ADC_IRQ_MASK_CPL
Definition adc.h:133
vsf_adc_mode_t
Definition adc.h:116
@ VSF_ADC_EXTERN_TRIGGER_2
Definition adc.h:127
@ VSF_ADC_DATA_ALIGN_LEFT
Definition adc.h:122
@ VSF_ADC_REF_VDD_1_2
Definition adc.h:118
@ VSF_ADC_DATA_ALIGN_RIGHT
Definition adc.h:121
@ VSF_ADC_REF_VDD_1_4
Definition adc.h:120
@ VSF_ADC_EXTERN_TRIGGER_1
Definition adc.h:126
@ VSF_ADC_REF_VDD_1_3
Definition adc.h:119
@ VSF_ADC_EXTERN_TRIGGER_0
Definition adc.h:125
@ VSF_ADC_SCAN_CONV_SINGLE_MODE
Definition adc.h:123
@ VSF_ADC_SCAN_CONV_SEQUENCE_MODE
Definition adc.h:124
@ VSF_ADC_REF_VDD_1
Definition adc.h:117
class vsf_$ * reg
vsf_adc_isr_t isr
Definition adc.h:109
vsf_adc_irq_mask_t
Predefined VSF ADC interrupt that can be reimplemented in specific HAL drivers.
Definition vsf_template_adc.h:593
vsf_adc_mode_t
Predefined VSF ADC modes that can be reimplemented in specific HAL drivers.
Definition vsf_template_adc.h:261
Generated from commit: vsfteam/vsf@2b286be