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#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_${DAC_IP}_DAC_CLASS_IMPLEMENT)
47# define __VSF_CLASS_IMPLEMENT__
48#elif defined(__VSF_HAL_${DAC_IP}_DAC_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_${DAC_IP}_DAC_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
62 * while VSF_HW_DAC_CFG_MULTI_CLASS should be in dac.c.
63 */
64
65// IPCore
66#ifndef VSF_${DAC_IP}_DAC_CFG_MULTI_CLASS
67# define VSF_${DAC_IP}_DAC_CFG_MULTI_CLASS VSF_DAC_CFG_MULTI_CLASS
68#endif
69// IPCore end
70
71// HW
72/*\note hw DAC driver can reimplement following types:
73 * To enable reimplementation, please enable macro below:
74 * VSF_DAC_CFG_REIMPLEMENT_TYPE_STATUS for vsf_dac_status_t
75 * VSF_DAC_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_dac_irq_mask_t
76 * VSF_DAC_CFG_REIMPLEMENT_TYPE_CFG for vsf_dac_cfg_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_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 };
128#endif
129
130#if VSF_DAC_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
131typedef struct vsf_dac_t vsf_dac_t;
132typedef void vsf_dac_isr_handler_t(void *target_ptr, vsf_dac_t *dac_ptr, vsf_dac_irq_mask_t irq_mask);
133typedef struct vsf_dac_isr_t {
135 void *target_ptr;
138typedef struct vsf_dac_cfg_t {
141#endif
142
143#if VSF_DAC_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
144typedef struct vsf_dac_capability_t {
145#if VSF_DAC_CFG_INHERIT_HAL_CAPABILITY == ENABLED
147#endif
153#endif
154// HW/IPCore end
155
156/*============================ INCLUDES ======================================*/
157
158// IPCore
159/*\note Extern APIs for ip core diriver.
160 * There is no requirement about how APIs of IPCore drivers should be implemented.
161 * Just consider the simplicity for actual peripheral drivers.
162 */
163// IPCore end
164
165#ifdef __cplusplus
166}
167#endif
168
169// IPCore
170#undef __VSF_HAL_${DAC_IP}_DAC_CLASS_IMPLEMENT
171#undef __VSF_HAL_${DAC_IP}_DAC_CLASS_INHERIT__
172// IPCore end
173
174#endif // VSF_HAL_USE_DAC
175#endif // __HAL_DRIVER_${SERIES/DAC_IP}_DAC_H__
176/* EOF */
Definition adc.h:94
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:132
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:293
uint8_t min_resolution_bits
Minimum resolution bits.
Definition vsf_template_dac.h:299
inherit(vsf_peripheral_capability_t) vsf_dac_irq_mask_t irq_mask
uint8_t channel_count
Number of channels.
Definition vsf_template_dac.h:300
uint8_t max_resolution_bits
Maximum resolution bits.
Definition vsf_template_dac.h:298
DAC configuration structure.
Definition vsf_template_dac.h:262
vsf_dac_isr_t isr
Interrupt configuration.
Definition vsf_template_dac.h:263
DAC interrupt configuration structure.
Definition vsf_template_dac.h:249
vsf_dac_isr_handler_t * handler_fn
Interrupt handler.
Definition vsf_template_dac.h:250
void * target_ptr
User target pointer.
Definition vsf_template_dac.h:251
vsf_arch_prio_t prio
Interrupt priority.
Definition vsf_template_dac.h:252
DAC status structure that can be reimplemented in specific HAL drivers.
Definition vsf_template_dac.h:275
Definition vsf_template_dac.h:314
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:198
Generated from commit: vsfteam/vsf@2b286be