VSF Documented
dac.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/DAC_IP}_DAC_H__
19#define __HAL_DRIVER_${SERIES/DAC_IP}_DAC_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_DAC == 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_${DAC_IP}_DAC_CLASS_IMPLEMENT)
45# define __VSF_CLASS_IMPLEMENT__
46#elif defined(__VSF_HAL_${DAC_IP}_DAC_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_${DAC_IP}_DAC_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
60 * while VSF_HW_DAC_CFG_MULTI_CLASS should be in dac.c.
61 */
62
63// IPCore
64#ifndef VSF_${DAC_IP}_DAC_CFG_MULTI_CLASS
65# define VSF_${DAC_IP}_DAC_CFG_MULTI_CLASS VSF_DAC_CFG_MULTI_CLASS
66#endif
67// IPCore end
68
69// HW
70/*\note hw DAC driver can reimplement following types:
71 * To enable reimplementation, please enable macro below:
72 * VSF_DAC_CFG_REIMPLEMENT_TYPE_STATUS for vsf_dac_status_t
73 * VSF_DAC_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_dac_irq_mask_t
74 * VSF_DAC_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG for vsf_dac_channel_cfg_t
75 * VSF_DAC_CFG_REIMPLEMENT_TYPE_CFG for vsf_dac_cfg_t
76 * VSF_DAC_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_dac_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_DAC_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
82#define VSF_DAC_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
83#define VSF_DAC_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG ENABLED
84#define VSF_DAC_CFG_REIMPLEMENT_TYPE_CFG ENABLED
85#define VSF_DAC_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
86// HW end
87
88/*============================ MACROFIED FUNCTIONS ===========================*/
89/*============================ TYPES =========================================*/
90
91// IPCore
92vsf_class(vsf_${dac_ip}_dac_t) {
93#if VSF_${DAC_IP}_CFG_MULTI_CLASS == ENABLED
94 public_member(
95 vsf_dac_t vsf_dac;
96 )
97#endif
98
99/*\note You can add more member in vsf_${dac_ip}_dac_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_${dac_ip}_dac_reg_t *reg;
108};
109// IPCore end
110
111// HW/IPCore, not for emulated drivers
112#if VSF_DAC_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
113typedef enum vsf_dac_irq_mask_t {
114 VSF_DAC_IRQ_MASK_IDLE = (0x01ul << 0),
115 VSF_DAC_IRQ_MASK_CPL = (0x1ul << 0),
117#endif
118
119#if VSF_DAC_CFG_REIMPLEMENT_TYPE_STATUS == ENABLED
120typedef struct vsf_dac_status_t {
121 union {
123 struct {
124 uint32_t is_busy : 1;
125 };
126 };
127
128 // more vendor specified status can be added here
130#endif
131
132#if VSF_DAC_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG == ENABLED
133typedef struct vsf_dac_channel_cfg_t {
136 // more vendor specified channel cfg can be added here
138#endif
139
140#if VSF_DAC_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
141typedef struct vsf_dac_t vsf_dac_t;
142typedef void vsf_dac_isr_handler_t(void *target_ptr, vsf_dac_t *dac_ptr, vsf_dac_irq_mask_t irq_mask);
143typedef struct vsf_dac_isr_t {
145 void *target_ptr;
148typedef struct vsf_dac_cfg_t {
151#endif
152
153#if VSF_DAC_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
154typedef struct vsf_dac_capability_t {
155#if VSF_DAC_CFG_INHERIT_HAL_CAPABILITY == ENABLED
157#endif
163#endif
164// HW/IPCore end
165
166/*============================ INCLUDES ======================================*/
167
168// IPCore
169/*\note Extern APIs for ip core diriver.
170 * There is no requirement about how APIs of IPCore drivers should be implemented.
171 * Just consider the simplicity for actual peripheral drivers.
172 */
173// IPCore end
174
175#ifdef __cplusplus
176}
177#endif
178
179// IPCore
180#undef __VSF_HAL_${DAC_IP}_DAC_CLASS_IMPLEMENT
181#undef __VSF_HAL_${DAC_IP}_DAC_CLASS_INHERIT__
182// IPCore end
183
184#endif // VSF_HAL_USE_DAC
185#endif // __HAL_DRIVER_${SERIES/DAC_IP}_DAC_H__
186/* EOF */
Definition adc.h:96
vsf_arch_prio_t
Definition cortex_a_generic.h:88
vsf_dac_isr_t isr
Definition dac.h:107
void vsf_dac_isr_handler_t(void *target_ptr, vsf_dac_t *dac_ptr, vsf_dac_irq_mask_t irq_mask)
Definition dac.h:142
vsf_dac_irq_mask_t
Definition dac.h:113
@ VSF_DAC_IRQ_MASK_IDLE
Definition dac.h:114
@ VSF_DAC_IRQ_MASK_CPL
Definition dac.h:115
class vsf_$ * reg
#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
DAC capability structure that can be reimplemented in specific HAL drivers.
Definition vsf_template_dac.h:306
uint8_t min_resolution_bits
Minimum resolution bits.
Definition vsf_template_dac.h:312
inherit(vsf_peripheral_capability_t) vsf_dac_irq_mask_t irq_mask
uint8_t channel_count
Number of channels.
Definition vsf_template_dac.h:313
uint8_t max_resolution_bits
Maximum resolution bits.
Definition vsf_template_dac.h:311
DAC configuration structure.
Definition vsf_template_dac.h:275
vsf_dac_isr_t isr
Interrupt configuration.
Definition vsf_template_dac.h:276
dac channel configuration
Definition vsf_template_dac.h:231
uint8_t channel
Channel index.
Definition vsf_template_dac.h:232
uint8_t resolution
Channel resolution.
Definition vsf_template_dac.h:233
DAC interrupt configuration structure.
Definition vsf_template_dac.h:262
vsf_dac_isr_handler_t * handler_fn
Interrupt handler.
Definition vsf_template_dac.h:263
void * target_ptr
User target pointer.
Definition vsf_template_dac.h:264
vsf_arch_prio_t prio
Interrupt priority.
Definition vsf_template_dac.h:265
DAC status structure that can be reimplemented in specific HAL drivers.
Definition vsf_template_dac.h:288
Definition vsf_template_dac.h:327
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
vsf_dac_irq_mask_t
Predefined VSF DAC interrupts that can be reimplemented in specific HAL drivers. Even if the hardware...
Definition vsf_template_dac.h:211
Generated from commit: vsfteam/vsf@f33b89f