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_ADDR for vsf_dma_addr_t
73 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE for vsf_dma_channel_mode_t
74 * VSF_DMA_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_dma_irq_mask_t
75 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_HINT for vsf_dma_channel_hint_t
76 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG for vsf_dma_channel_cfg_t
77 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_SG_CFG for vsf_dma_channel_sg_cfg_t
78 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_STATUS for vsf_dma_channel_status_t
79 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CFG for vsf_dma_cfg_t
80 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_dma_capability_t
81 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
82 * *** DO NOT reimplement these in emulated drivers. ***
83 */
84
85// vsf_dma_addr_t: must be enabled if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_SG_CFG is enabled
86#define VSF_DMA_CFG_REIMPLEMENT_TYPE_ADDR ENABLED
87#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE ENABLED
88#define VSF_DMA_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
89#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_HINT ENABLED
90#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG ENABLED
91#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_SG_CFG ENABLED
92#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_STATUS ENABLED
93#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CFG ENABLED
94#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
95
96
97/*============================ MACROFIED FUNCTIONS ===========================*/
98/*============================ TYPES =========================================*/
99
100// IPCore
101vsf_class(vsf_${dma_ip}_dma_t) {
102#if VSF_${DMA_IP}_CFG_MULTI_CLASS == ENABLED
103 public_member(
104 vsf_dma_t vsf_dma;
105 )
106#endif
107
108/*\note You can add more member in vsf_${dma_ip}_dma_t instance.
109 * For members accessible from child, put in protected_member.
110 * Else, put in private_member.
111 */
112
113 protected_member(
114 vsf_${dma_ip}_dma_reg_t *reg;
117};
118// IPCore end
119
120
121// HW/IPCore, not for emulated drivers
122#if VSF_DMA_CFG_REIMPLEMENT_TYPE_ADDR == ENABLED
124#endif
125
126#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE == ENABLED
132
136
140
147
154
163
172
173 VSF_DMA_PRIORITY_LOW = (0x00 << 22),
175 VSF_DMA_PRIORITY_HIGH = (0x02 << 22),
178#endif
179
180#if VSF_DMA_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
181typedef enum vsf_dma_irq_mask_t {
182 VSF_DMA_IRQ_MASK_CPL = (0x1ul << 0),
186#endif
187
188#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_HINT == ENABLED
189typedef struct vsf_dma_channel_hint_t {
192
193 // more vendor specified channel hint can be added here
195#endif
196
197#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG == ENABLED
198typedef struct vsf_dma_t vsf_dma_t;
199typedef void vsf_dma_isr_handler_t(void *target_ptr, vsf_dma_t *dma_ptr, int8_t channel, vsf_dma_irq_mask_t irq_mask);
200typedef struct vsf_dma_isr_t {
202 void *target_ptr;
204typedef struct vsf_dma_channel_cfg_t {
212#endif
213
214#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_STATUS == ENABLED
215typedef struct vsf_dma_channel_status_t {
216 union {
218 struct {
219 uint32_t is_busy : 1;
220 };
221 };
222
223 // more vendor specified status can be added here
225#endif
226
227#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_SG_CFG == ENABLED
228typedef struct vsf_dma_channel_sg_desc_t {
234
235 // more vendor specified channel sg desc can be added here
237#endif
238
239#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
240typedef struct vsf_dma_cfg_t {
242
243 // more vendor specified cfg can be added here
245#endif
246
247#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
248typedef struct vsf_dma_capability_t {
249#if VSF_DMA_CFG_INHERIT_HAL_CAPABILITY == ENABLED
251#endif
260#endif
261// HW/IPCore end
262
263/*============================ INCLUDES ======================================*/
264
265// IPCore
266/*\note Extern APIs for ip core diriver.
267 * There is no requirement about how APIs of IPCore drivers should be implemented.
268 * Just consider the simplicity for actual peripheral drivers.
269 */
270// IPCore end
271
272#ifdef __cplusplus
273}
274#endif
275
276// IPCore
277#undef __VSF_HAL_${DMA_IP}_DMA_CLASS_IMPLEMENT
278#undef __VSF_HAL_${DMA_IP}_DMA_CLASS_INHERIT__
279// IPCore end
280
281#endif // VSF_HAL_USE_DMA
282#endif // __HAL_DRIVER_${SERIES/DMA_IP}_DMA_H__
283/* EOF */
vsf_dma_channel_mode_t
Definition dma.h:86
@ VSF_DMA_PRIORITY_MEDIUM
Definition dma.h:113
@ VSF_DMA_DST_WIDTH_BYTES_32
Definition dma.h:137
@ VSF_DMA_SRC_BURST_LENGTH_64
Definition dma.h:145
@ VSF_DMA_DST_BURST_LENGTH_64
Definition dma.h:154
@ VSF_DMA_SRC_WIDTH_BYTES_8
Definition dma.h:131
@ VSF_DMA_SRC_WIDTH_BYTES_2
Definition dma.h:100
@ VSF_DMA_DST_WIDTH_BYTES_16
Definition dma.h:136
@ VSF_DMA_SRC_BURST_LENGTH_16
Definition dma.h:143
@ VSF_DMA_DST_BURST_LENGTH_128
Definition dma.h:155
@ VSF_DMA_DST_WIDTH_BYTE_1
Definition dma.h:107
@ VSF_DMA_PRIORITY_HIGH
Definition dma.h:114
@ VSF_DMA_SRC_WIDTH_BYTES_16
Definition dma.h:132
@ VSF_DMA_DST_ADDR_NO_CHANGE
Definition dma.h:105
@ VSF_DMA_DST_BURST_LENGTH_4
Definition dma.h:150
@ VSF_DMA_DST_BURST_LENGTH_1
Definition dma.h:148
@ VSF_DMA_SRC_ADDR_INCREMENT
Definition dma.h:96
@ VSF_DMA_MEMORY_TO_PERIPHERAL
Definition dma.h:89
@ VSF_DMA_DST_BURST_LENGTH_32
Definition dma.h:153
@ VSF_DMA_SRC_BURST_LENGTH_4
Definition dma.h:141
@ VSF_DMA_SRC_BURST_LENGTH_128
Definition dma.h:146
@ VSF_DMA_SRC_WIDTH_BYTE_1
Definition dma.h:99
@ VSF_DMA_MEMORY_TO_MEMORY
Definition dma.h:88
@ VSF_DMA_PRIORITY_LOW
Definition dma.h:112
@ VSF_DMA_SRC_WIDTH_BYTES_4
Definition dma.h:101
@ VSF_DMA_DST_WIDTH_BYTES_8
Definition dma.h:135
@ VSF_DMA_SRC_BURST_LENGTH_1
Definition dma.h:139
@ VSF_DMA_DST_WIDTH_BYTES_2
Definition dma.h:108
@ VSF_DMA_DST_WIDTH_BYTES_4
Definition dma.h:109
@ VSF_DMA_SRC_BURST_LENGTH_2
Definition dma.h:140
@ VSF_DMA_SRC_ADDR_DECREMENT
Definition dma.h:128
@ VSF_DMA_DST_BURST_LENGTH_8
Definition dma.h:151
@ VSF_DMA_SRC_ADDR_NO_CHANGE
Definition dma.h:97
@ VSF_DMA_DST_BURST_LENGTH_16
Definition dma.h:152
@ VSF_DMA_SRC_BURST_LENGTH_8
Definition dma.h:142
@ VSF_DMA_DST_BURST_LENGTH_2
Definition dma.h:149
@ VSF_DMA_SRC_WIDTH_BYTES_32
Definition dma.h:133
@ VSF_DMA_PRIORITY_VERY_HIGH
Definition dma.h:115
@ VSF_DMA_SRC_BURST_LENGTH_32
Definition dma.h:144
@ VSF_DMA_DST_ADDR_DECREMENT
Definition dma.h:129
@ VSF_DMA_PERIPHERAL_TO_PERIPHERAL
Definition dma.h:127
@ VSF_DMA_PERIPHERAL_TO_MEMORY
Definition dma.h:90
@ VSF_DMA_DST_ADDR_INCREMENT
Definition dma.h:104
struct vsf_dma_isr_t vsf_dma_isr_t
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
struct vsf_dma_capability_t vsf_dma_capability_t
struct vsf_dma_channel_status_t vsf_dma_channel_status_t
struct vsf_dma_channel_sg_desc_t vsf_dma_channel_sg_desc_t
vsf_dma_irq_mask_t
Definition dma.h:160
@ VSF_DMA_IRQ_MASK_HALF_CPL
Definition dma.h:164
@ VSF_DMA_IRQ_MASK_CPL
Definition dma.h:162
@ VSF_DMA_IRQ_MASK_ERROR
Definition dma.h:166
uintptr_t vsf_dma_addr_t
Definition dma.h:82
struct vsf_dma_channel_cfg_t vsf_dma_channel_cfg_t
struct vsf_dma_channel_hint_t vsf_dma_channel_hint_t
struct vsf_dma_cfg_t vsf_dma_cfg_t
Definition adc.h:96
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
uint32_t uintptr_t
Definition stdint.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
DMA capability structure that can be reimplemented in specific HAL drivers.
Definition dma.h:228
uint8_t addr_alignment
Address alignment requirement in bytes (1 means no alignment required)
Definition dma.h:237
vsf_dma_channel_mode_t supported_modes
Definition dma.h:235
uint8_t channel_count
Number of DMA channels.
Definition dma.h:233
uint8_t support_scatter_gather
Support scatter-gather transfer.
Definition dma.h:238
uint8_t irq_count
Definition dma.h:234
uint32_t max_transfer_count
Maximum number of data items per transfer (0 means no limit)
Definition dma.h:236
inherit(vsf_peripheral_capability_t) vsf_dma_irq_mask_t irq_mask
Configuration structure for DMA.
Definition dma.h:222
vsf_arch_prio_t prio
Definition dma.h:223
dma configuration
Definition dma.h:184
uint8_t dst_request_idx
Definition dma.h:190
vsf_dma_channel_mode_t mode
Definition dma.h:185
vsf_dma_irq_mask_t irq_mask
Definition dma.h:187
uint8_t src_request_idx
Definition dma.h:189
vsf_dma_isr_t isr
Definition dma.h:186
vsf_arch_prio_t prio
Definition dma.h:188
DMA channel hint structure for channel allocation.
Definition dma.h:171
int8_t channel
Definition dma.h:172
uint8_t request_line
Definition dma.h:173
DMA scatter-gather descriptor structure.
Definition dma.h:212
uint32_t count
Definition dma.h:216
vsf_dma_addr_t src_address
Source address.
Definition dma.h:214
vsf_dma_addr_t next
Definition dma.h:217
vsf_dma_channel_mode_t mode
DMA channel mode.
Definition dma.h:213
vsf_dma_addr_t dst_address
Destination address.
Definition dma.h:215
Definition dma.h:201
Definition dma.h:180
vsf_dma_isr_handler_t * handler_fn
Definition dma.h:181
void * target_ptr
Definition dma.h:182
Definition vsf_template_dma.h:647
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
vsf_dma_channel_mode_t
Definition dma.h:127
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:199
vsf_dma_isr_t isr
Definition dma.h:116
class vsf_$ * reg
vsf_dma_irq_mask_t
Definition dma.h:181
Generated from commit: vsfteam/vsf@f33b89f