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#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_${DMA_IP}_DMA_CLASS_IMPLEMENT)
47# define __VSF_CLASS_IMPLEMENT__
48#elif defined(__VSF_HAL_${DMA_IP}_DMA_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_${DMA_IP}_DMA_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
62 * while VSF_HW_DMA_CFG_MULTI_CLASS should be in dma.c.
63 */
64
65// IPCore
66#ifndef VSF_${DMA_IP}_DMA_CFG_MULTI_CLASS
67# define VSF_${DMA_IP}_DMA_CFG_MULTI_CLASS VSF_DMA_CFG_MULTI_CLASS
68#endif
69// IPCore end
70
71// HW
72/*\note hw DMA driver can reimplement following types:
73 * To enable reimplementation, please enable macro below:
74 * VSF_DMA_CFG_REIMPLEMENT_TYPE_MODE for vsf_dma_mode_t
75 * VSF_DMA_CFG_REIMPLEMENT_TYPE_STATUS for vsf_dma_status_t
76 * VSF_DMA_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_dma_irq_mask_t
77 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CTRL for vsf_dma_ctrl_t
78 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CFG for vsf_dma_cfg_t
79 * VSF_DMA_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_dma_capability_t
80 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
81 * *** DO NOT reimplement these in emulated drivers. ***
82 */
83
84#define VSF_DMA_CFG_REIMPLEMENT_TYPE_MODE ENABLED
85#define VSF_DMA_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
86#define VSF_DMA_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
87#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CTRL ENABLED
88#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CFG ENABLED
89#define VSF_DMA_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
90
91
92/*============================ MACROFIED FUNCTIONS ===========================*/
93/*============================ TYPES =========================================*/
94
95// IPCore
96vsf_class(vsf_${dma_ip}_dma_t) {
97#if VSF_${DMA_IP}_CFG_MULTI_CLASS == ENABLED
98 public_member(
99 vsf_dma_t vsf_dma;
100 )
101#endif
102
103/*\note You can add more member in vsf_${dma_ip}_dma_t instance.
104 * For members accessible from child, put in protected_member.
105 * Else, put in private_member.
106 */
107
108 protected_member(
109 vsf_${dma_ip}_dma_reg_t *reg;
112};
113// IPCore end
114
115
116// HW/IPCore, not for emulated drivers
117#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE == ENABLED
123
127
131
138
145
154
163
164 VSF_DMA_PRIOPIRY_LOW = (0x00 << 22),
166 VSF_DMA_PRIOPIRY_HIGH = (0x02 << 22),
169#endif
170
171#if VSF_DMA_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
172typedef enum vsf_dma_irq_mask_t {
173 VSF_DMA_IRQ_MASK_CPL = (0x1ul << 0),
177#endif
178
179#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG == ENABLED
180typedef struct vsf_dma_t vsf_dma_t;
181typedef void vsf_dma_isr_handler_t(void *target_ptr, vsf_dma_t *dma_ptr, int8_t channel, vsf_dma_irq_mask_t irq_mask);
182typedef struct vsf_dma_isr_t {
184 void *target_ptr;
186typedef struct vsf_dma_channel_cfg_t {
192#endif
193
194#if VSF_DMA_CFG_REIMPLEMENT_TYPE_STATUS == ENABLED
195typedef struct vsf_dma_channel_status_t {
196 union {
198 struct {
199 uint32_t is_busy : 1;
200 };
201 };
203#endif
204
205#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
206typedef struct vsf_dma_capability_t {
207#if VSF_DMA_CFG_INHERIT_HAL_CAPABILITY == ENABLED
209#endif
214#endif
215// HW/IPCore end
216
217/*============================ INCLUDES ======================================*/
218
219// IPCore
220/*\note Extern APIs for ip core diriver.
221 * There is no requirement about how APIs of IPCore drivers should be implemented.
222 * Just consider the simplicity for actual peripheral drivers.
223 */
224// IPCore end
225
226#ifdef __cplusplus
227}
228#endif
229
230// IPCore
231#undef __VSF_HAL_${DMA_IP}_DMA_CLASS_IMPLEMENT
232#undef __VSF_HAL_${DMA_IP}_DMA_CLASS_INHERIT__
233// IPCore end
234
235#endif // VSF_HAL_USE_DMA
236#endif // __HAL_DRIVER_${SERIES/DMA_IP}_DMA_H__
237/* EOF */
Definition adc.h:94
#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:351
uint8_t channel_count
Definition vsf_template_dma.h:358
uint32_t max_request_count
Definition vsf_template_dma.h:357
inherit(vsf_peripheral_capability_t) vsf_dma_irq_mask_t irq_mask
dma configuration
Definition vsf_template_dma.h:329
uint8_t src_idx
Index of the peripheral or memory corresponding to the source address of the DMA.
Definition vsf_template_dma.h:333
vsf_dma_channel_mode_t mode
Definition vsf_template_dma.h:330
uint8_t dst_idx
Index of the peripheral or memory corresponding to the destination address of the DMA.
Definition vsf_template_dma.h:335
vsf_dma_isr_t isr
Definition vsf_template_dma.h:331
Definition vsf_template_dma.h:340
Definition vsf_template_dma.h:323
vsf_dma_isr_handler_t * handler_fn
Definition vsf_template_dma.h:324
void * target_ptr
Definition vsf_template_dma.h:325
Definition vsf_template_dma.h:372
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
vsf_dma_channel_mode_t
Definition dma.h:118
@ VSF_DMA_DST_WIDTH_BYTES_32
Definition dma.h:144
@ VSF_DMA_SRC_BURST_LENGTH_64
Definition dma.h:152
@ VSF_DMA_DST_BURST_LENGTH_64
Definition dma.h:161
@ VSF_DMA_SRC_WIDTH_BYTES_8
Definition dma.h:135
@ VSF_DMA_SRC_WIDTH_BYTES_2
Definition dma.h:133
@ VSF_DMA_DST_WIDTH_BYTES_16
Definition dma.h:143
@ VSF_DMA_SRC_BURST_LENGTH_16
Definition dma.h:150
@ VSF_DMA_DST_BURST_LENGTH_128
Definition dma.h:162
@ VSF_DMA_DST_WIDTH_BYTE_1
Definition dma.h:139
@ VSF_DMA_SRC_WIDTH_BYTES_16
Definition dma.h:136
@ VSF_DMA_DST_ADDR_NO_CHANGE
Definition dma.h:130
@ VSF_DMA_DST_BURST_LENGTH_4
Definition dma.h:157
@ VSF_DMA_DST_BURST_LENGTH_1
Definition dma.h:155
@ VSF_DMA_SRC_ADDR_INCREMENT
Definition dma.h:124
@ VSF_DMA_MEMORY_TO_PERIPHERAL
Definition dma.h:120
@ VSF_DMA_DST_BURST_LENGTH_32
Definition dma.h:160
@ VSF_DMA_SRC_BURST_LENGTH_4
Definition dma.h:148
@ VSF_DMA_SRC_BURST_LENGTH_128
Definition dma.h:153
@ VSF_DMA_PRIOPIRY_VERY_HIGH
Definition dma.h:167
@ VSF_DMA_SRC_WIDTH_BYTE_1
Definition dma.h:132
@ VSF_DMA_MEMORY_TO_MEMORY
Definition dma.h:119
@ VSF_DMA_SRC_WIDTH_BYTES_4
Definition dma.h:134
@ VSF_DMA_DST_WIDTH_BYTES_8
Definition dma.h:142
@ VSF_DMA_SRC_BURST_LENGTH_1
Definition dma.h:146
@ VSF_DMA_PERIPHERA_TO_MEMORY
Definition dma.h:121
@ VSF_DMA_DST_WIDTH_BYTES_2
Definition dma.h:140
@ VSF_DMA_DST_WIDTH_BYTES_4
Definition dma.h:141
@ VSF_DMA_PRIOPIRY_LOW
Definition dma.h:164
@ VSF_DMA_SRC_BURST_LENGTH_2
Definition dma.h:147
@ VSF_DMA_SRC_ADDR_DECREMENT
Definition dma.h:125
@ VSF_DMA_DST_BURST_LENGTH_8
Definition dma.h:158
@ VSF_DMA_PERIPHERA_TO_PERIPHERAL
Definition dma.h:122
@ VSF_DMA_SRC_ADDR_NO_CHANGE
Definition dma.h:126
@ VSF_DMA_DST_BURST_LENGTH_16
Definition dma.h:159
@ VSF_DMA_SRC_BURST_LENGTH_8
Definition dma.h:149
@ VSF_DMA_DST_BURST_LENGTH_2
Definition dma.h:156
@ VSF_DMA_SRC_WIDTH_BYTES_32
Definition dma.h:137
@ VSF_DMA_SRC_BURST_LENGTH_32
Definition dma.h:151
@ VSF_DMA_PRIOPIRY_HIGH
Definition dma.h:166
@ VSF_DMA_PRIOPIRY_MEDIUM
Definition dma.h:165
@ VSF_DMA_DST_ADDR_DECREMENT
Definition dma.h:129
@ VSF_DMA_DST_ADDR_INCREMENT
Definition dma.h:128
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:181
vsf_dma_isr_t isr
Definition dma.h:111
class vsf_$ * reg
vsf_dma_irq_mask_t
Definition dma.h:172
@ VSF_DMA_IRQ_MASK_HALF_CPL
Definition dma.h:174
@ VSF_DMA_IRQ_MASK_CPL
Definition dma.h:173
@ VSF_DMA_IRQ_MASK_ERROR
Definition dma.h:175
vsf_dma_channel_mode_t
Definition vsf_template_dma.h:176
vsf_dma_irq_mask_t
Definition vsf_template_dma.h:304
Generated from commit: vsfteam/vsf@2b286be