VSF Documented
dma.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/DMA_IP}_DMA_H__
19#define __HAL_DRIVER_${SERIES/DMA_IP}_DMA_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_DMA == 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_${DMA_IP}_DMA_CLASS_IMPLEMENT)
45# define __VSF_CLASS_IMPLEMENT__
46#elif defined(__VSF_HAL_${DMA_IP}_DMA_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_${DMA_IP}_DMA_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
60 * while VSF_HW_DMA_CFG_MULTI_CLASS should be in dma.c.
61 */
62
63// IPCore
64#ifndef VSF_${DMA_IP}_DMA_CFG_MULTI_CLASS
65# define VSF_${DMA_IP}_DMA_CFG_MULTI_CLASS VSF_DMA_CFG_MULTI_CLASS
66#endif
67// IPCore end
68
69// HW
70/*\note hw DMA driver can reimplement following types:
71 * To enable reimplementation, please enable macro below:
72 * VSF_DMA_CFG_REIMPLEMENT_TYPE_MODE for vsf_dma_mode_t
73 * VSF_DMA_CFG_REIMPLEMENT_TYPE_STATUS for vsf_dma_status_t
74 * VSF_DMA_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_dma_irq_mask_t
75 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CTRL for vsf_dma_ctrl_t
76 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CFG for vsf_dma_cfg_t
77 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_dma_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_DMA_CFG_REIMPLEMENT_TYPE_MODE ENABLED
83#define VSF_DMA_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
84#define VSF_DMA_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
85#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CTRL ENABLED
86#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CFG ENABLED
87#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
88
89
90/*============================ MACROFIED FUNCTIONS ===========================*/
91/*============================ TYPES =========================================*/
92
93// IPCore
94vsf_class(vsf_${dma_ip}_dma_t) {
95#if VSF_${DMA_IP}_CFG_MULTI_CLASS == ENABLED
96 public_member(
97 vsf_dma_t vsf_dma;
98 )
99#endif
100
101/*\note You can add more member in vsf_${dma_ip}_dma_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_${dma_ip}_dma_reg_t *reg;
110};
111// IPCore end
112
113
114// HW/IPCore, not for emulated drivers
115#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE == ENABLED
121
125
129
136
143
152
161
162 VSF_DMA_PRIOPIRY_LOW = (0x00 << 22),
164 VSF_DMA_PRIOPIRY_HIGH = (0x02 << 22),
167#endif
168
169#if VSF_DMA_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
170typedef enum vsf_dma_irq_mask_t {
171 VSF_DMA_IRQ_MASK_CPL = (0x1ul << 0),
175#endif
176
177#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG == ENABLED
178typedef struct vsf_dma_t vsf_dma_t;
179typedef void vsf_dma_isr_handler_t(void *target_ptr, vsf_dma_t *dma_ptr, int8_t channel, vsf_dma_irq_mask_t irq_mask);
180typedef struct vsf_dma_isr_t {
182 void *target_ptr;
184typedef struct vsf_dma_channel_cfg_t {
190#endif
191
192#if VSF_DMA_CFG_REIMPLEMENT_TYPE_STATUS == ENABLED
193typedef struct vsf_dma_channel_status_t {
194 union {
196 struct {
197 uint32_t is_busy : 1;
198 };
199 };
201#endif
202
203#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
204typedef struct vsf_dma_capability_t {
205#if VSF_DMA_CFG_INHERIT_HAL_CAPABILITY == ENABLED
207#endif
212#endif
213// HW/IPCore end
214
215/*============================ INCLUDES ======================================*/
216
217// IPCore
218/*\note Extern APIs for ip core diriver.
219 * There is no requirement about how APIs of IPCore drivers should be implemented.
220 * Just consider the simplicity for actual peripheral drivers.
221 */
222// IPCore end
223
224#ifdef __cplusplus
225}
226#endif
227
228// IPCore
229#undef __VSF_HAL_${DMA_IP}_DMA_CLASS_IMPLEMENT
230#undef __VSF_HAL_${DMA_IP}_DMA_CLASS_INHERIT__
231// IPCore end
232
233#endif // VSF_HAL_USE_DMA
234#endif // __HAL_DRIVER_${SERIES/DMA_IP}_DMA_H__
235/* EOF */
Definition adc.h:92
#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
signed char int8_t
Definition stdint.h:4
Definition vsf_template_dma.h:480
uint8_t channel_count
Definition vsf_template_dma.h:487
uint32_t max_request_count
Definition vsf_template_dma.h:486
inherit(vsf_peripheral_capability_t) vsf_dma_irq_mask_t irq_mask
dma configuration
Definition vsf_template_dma.h:435
uint8_t src_idx
Index of the peripheral or memory corresponding to the source address of the DMA.
Definition vsf_template_dma.h:439
vsf_dma_channel_mode_t mode
Definition vsf_template_dma.h:436
uint8_t dst_idx
Index of the peripheral or memory corresponding to the destination address of the DMA.
Definition vsf_template_dma.h:441
vsf_dma_isr_t isr
Definition vsf_template_dma.h:437
Definition vsf_template_dma.h:469
Definition vsf_template_dma.h:429
vsf_dma_isr_handler_t * handler_fn
Definition vsf_template_dma.h:430
void * target_ptr
Definition vsf_template_dma.h:431
Definition vsf_template_dma.h:501
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
vsf_dma_channel_mode_t
Definition dma.h:116
@ VSF_DMA_DST_WIDTH_BYTES_32
Definition dma.h:142
@ VSF_DMA_SRC_BURST_LENGTH_64
Definition dma.h:150
@ VSF_DMA_DST_BURST_LENGTH_64
Definition dma.h:159
@ VSF_DMA_SRC_WIDTH_BYTES_8
Definition dma.h:133
@ VSF_DMA_SRC_WIDTH_BYTES_2
Definition dma.h:131
@ VSF_DMA_DST_WIDTH_BYTES_16
Definition dma.h:141
@ VSF_DMA_SRC_BURST_LENGTH_16
Definition dma.h:148
@ VSF_DMA_DST_BURST_LENGTH_128
Definition dma.h:160
@ VSF_DMA_DST_WIDTH_BYTE_1
Definition dma.h:137
@ VSF_DMA_SRC_WIDTH_BYTES_16
Definition dma.h:134
@ VSF_DMA_DST_ADDR_NO_CHANGE
Definition dma.h:128
@ VSF_DMA_DST_BURST_LENGTH_4
Definition dma.h:155
@ VSF_DMA_DST_BURST_LENGTH_1
Definition dma.h:153
@ VSF_DMA_SRC_ADDR_INCREMENT
Definition dma.h:122
@ VSF_DMA_MEMORY_TO_PERIPHERAL
Definition dma.h:118
@ VSF_DMA_DST_BURST_LENGTH_32
Definition dma.h:158
@ VSF_DMA_SRC_BURST_LENGTH_4
Definition dma.h:146
@ VSF_DMA_SRC_BURST_LENGTH_128
Definition dma.h:151
@ VSF_DMA_PRIOPIRY_VERY_HIGH
Definition dma.h:165
@ VSF_DMA_SRC_WIDTH_BYTE_1
Definition dma.h:130
@ VSF_DMA_MEMORY_TO_MEMORY
Definition dma.h:117
@ VSF_DMA_SRC_WIDTH_BYTES_4
Definition dma.h:132
@ VSF_DMA_DST_WIDTH_BYTES_8
Definition dma.h:140
@ VSF_DMA_SRC_BURST_LENGTH_1
Definition dma.h:144
@ VSF_DMA_PERIPHERA_TO_MEMORY
Definition dma.h:119
@ VSF_DMA_DST_WIDTH_BYTES_2
Definition dma.h:138
@ VSF_DMA_DST_WIDTH_BYTES_4
Definition dma.h:139
@ VSF_DMA_PRIOPIRY_LOW
Definition dma.h:162
@ VSF_DMA_SRC_BURST_LENGTH_2
Definition dma.h:145
@ VSF_DMA_SRC_ADDR_DECREMENT
Definition dma.h:123
@ VSF_DMA_DST_BURST_LENGTH_8
Definition dma.h:156
@ VSF_DMA_PERIPHERA_TO_PERIPHERAL
Definition dma.h:120
@ VSF_DMA_SRC_ADDR_NO_CHANGE
Definition dma.h:124
@ VSF_DMA_DST_BURST_LENGTH_16
Definition dma.h:157
@ VSF_DMA_SRC_BURST_LENGTH_8
Definition dma.h:147
@ VSF_DMA_DST_BURST_LENGTH_2
Definition dma.h:154
@ VSF_DMA_SRC_WIDTH_BYTES_32
Definition dma.h:135
@ VSF_DMA_SRC_BURST_LENGTH_32
Definition dma.h:149
@ VSF_DMA_PRIOPIRY_HIGH
Definition dma.h:164
@ VSF_DMA_PRIOPIRY_MEDIUM
Definition dma.h:163
@ VSF_DMA_DST_ADDR_DECREMENT
Definition dma.h:127
@ VSF_DMA_DST_ADDR_INCREMENT
Definition dma.h:126
void vsf_dma_isr_handler_t(void *target_ptr, vsf_dma_t *dma_ptr, int8_t channel, vsf_dma_irq_mask_t irq_mask)
Definition dma.h:179
vsf_dma_isr_t isr
Definition dma.h:109
class vsf_$ * reg
vsf_dma_irq_mask_t
Definition dma.h:170
@ VSF_DMA_IRQ_MASK_HALF_CPL
Definition dma.h:172
@ VSF_DMA_IRQ_MASK_CPL
Definition dma.h:171
@ VSF_DMA_IRQ_MASK_ERROR
Definition dma.h:173
vsf_dma_channel_mode_t
Definition vsf_template_dma.h:249
vsf_dma_irq_mask_t
Definition vsf_template_dma.h:376
Generated from commit: vsfteam/vsf@74aa6ce