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_CTRL for vsf_dac_ctrl_t
77 * VSF_DAC_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_dac_capability_t
78 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
79 * *** DO NOT reimplement these in emulated drivers. ***
80 */
81
82#define VSF_DAC_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
83#define VSF_DAC_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
84#define VSF_DAC_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG ENABLED
85#define VSF_DAC_CFG_REIMPLEMENT_TYPE_CFG ENABLED
86#define VSF_DAC_CFG_REIMPLEMENT_TYPE_CTRL ENABLED
87#define VSF_DAC_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
88// HW end
89
90/*============================ MACROFIED FUNCTIONS ===========================*/
91/*============================ TYPES =========================================*/
92
93// IPCore
94vsf_class(vsf_${dac_ip}_dac_t) {
95#if VSF_${DAC_IP}_CFG_MULTI_CLASS == ENABLED
96 public_member(
97 vsf_dac_t vsf_dac;
98 )
99#endif
100
101/*\note You can add more member in vsf_${dac_ip}_dac_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_${dac_ip}_dac_reg_t *reg;
110};
111// IPCore end
112
113// HW/IPCore, not for emulated drivers
114#if VSF_DAC_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
115typedef enum vsf_dac_irq_mask_t {
116 VSF_DAC_IRQ_MASK_IDLE = (0x01ul << 0),
117 VSF_DAC_IRQ_MASK_CPL = (0x01ul << 1),
119#endif
120
121#if VSF_DAC_CFG_REIMPLEMENT_TYPE_STATUS == ENABLED
122typedef struct vsf_dac_status_t {
123 union {
125 struct {
126 uint32_t is_busy : 1;
127 };
128 };
129
130 // more vendor specified status can be added here
132#endif
133
134#if VSF_DAC_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG == ENABLED
135typedef struct vsf_dac_channel_cfg_t {
138 // more vendor specified channel cfg can be added here
140#endif
141
142#if VSF_DAC_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
143typedef struct vsf_dac_t vsf_dac_t;
144typedef void vsf_dac_isr_handler_t(void *target_ptr, vsf_dac_t *dac_ptr, vsf_dac_irq_mask_t irq_mask);
145typedef struct vsf_dac_isr_t {
147 void *target_ptr;
150typedef struct vsf_dac_cfg_t {
153#endif
154
155#if VSF_DAC_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
156typedef struct vsf_dac_capability_t {
157#if VSF_DAC_CFG_INHERIT_HAL_CAPABILITY == ENABLED
159#endif
165#endif
166
167#if VSF_DAC_CFG_REIMPLEMENT_TYPE_CTRL == ENABLED
168typedef enum vsf_dac_ctrl_t {
171#endif
172// HW/IPCore end
173
174/*============================ INCLUDES ======================================*/
175
176// IPCore
177/*\note Extern APIs for ip core diriver.
178 * There is no requirement about how APIs of IPCore drivers should be implemented.
179 * Just consider the simplicity for actual peripheral drivers.
180 */
181// IPCore end
182
183#ifdef __cplusplus
184}
185#endif
186
187// IPCore
188#undef __VSF_HAL_${DAC_IP}_DAC_CLASS_IMPLEMENT
189#undef __VSF_HAL_${DAC_IP}_DAC_CLASS_INHERIT__
190// IPCore end
191
192#endif // VSF_HAL_USE_DAC
193#endif // __HAL_DRIVER_${SERIES/DAC_IP}_DAC_H__
194/* EOF */
Definition adc.h:98
vsf_arch_prio_t
Definition cortex_a_generic.h:88
vsf_dac_isr_t isr
Definition dac.h:109
void vsf_dac_isr_handler_t(void *target_ptr, vsf_dac_t *dac_ptr, vsf_dac_irq_mask_t irq_mask)
Definition dac.h:144
vsf_dac_irq_mask_t
Definition dac.h:115
@ VSF_DAC_IRQ_MASK_IDLE
Definition dac.h:116
@ VSF_DAC_IRQ_MASK_CPL
Definition dac.h:117
vsf_dac_ctrl_t
Definition dac.h:168
@ __VSF_DAC_CTRL_DUMMY
Definition dac.h:169
class vsf_$ * reg
#define vsf_class(__name)
Definition ooc_class.h:52
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:322
uint8_t min_resolution_bits
Minimum resolution bits.
Definition vsf_template_dac.h:328
inherit(vsf_peripheral_capability_t) vsf_dac_irq_mask_t irq_mask
uint8_t channel_count
Number of channels.
Definition vsf_template_dac.h:329
uint8_t max_resolution_bits
Maximum resolution bits.
Definition vsf_template_dac.h:327
DAC configuration structure.
Definition vsf_template_dac.h:291
vsf_dac_isr_t isr
Interrupt configuration.
Definition vsf_template_dac.h:292
dac channel configuration
Definition vsf_template_dac.h:247
uint8_t channel
Channel index.
Definition vsf_template_dac.h:248
uint8_t resolution
Channel resolution.
Definition vsf_template_dac.h:249
DAC interrupt configuration structure.
Definition vsf_template_dac.h:278
vsf_dac_isr_handler_t * handler_fn
Interrupt handler.
Definition vsf_template_dac.h:279
void * target_ptr
User target pointer.
Definition vsf_template_dac.h:280
vsf_arch_prio_t prio
Interrupt priority.
Definition vsf_template_dac.h:281
DAC status structure that can be reimplemented in specific HAL drivers.
Definition vsf_template_dac.h:304
Definition vsf_template_dac.h:374
Definition vsf_template_hal_driver.h:204
Definition vsf_template_hal_driver.h:197
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:227
vsf_dac_ctrl_t
DAC control commands for hardware-specific operations.
Definition vsf_template_dac.h:342
Generated from commit: vsfteam/vsf@b2e9e8a