VSF Documented
vsf_template_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 __VSF_TEMPLATE_DMA_H__
19#define __VSF_TEMPLATE_DMA_H__
20
21/*============================ INCLUDES ======================================*/
22
24#include "hal/arch/vsf_arch.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*============================ MACROS ========================================*/
31
39#ifndef VSF_DMA_CFG_MULTI_CLASS
40# define VSF_DMA_CFG_MULTI_CLASS ENABLED
41#endif
42
52#ifndef VSF_DMA_CFG_PREFIX
53# if VSF_DMA_CFG_MULTI_CLASS == ENABLED
54# define VSF_DMA_CFG_PREFIX vsf
55# elif defined(VSF_HW_DMA_COUNT) && (VSF_HW_DMA_COUNT != 0)
56# define VSF_DMA_CFG_PREFIX vsf_hw
57# else
58# define VSF_DMA_CFG_PREFIX vsf
59# endif
60#endif
61
71#ifndef VSF_DMA_CFG_FUNCTION_RENAME
72# define VSF_DMA_CFG_FUNCTION_RENAME ENABLED
73#endif
74
82#ifndef VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE
83# define VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE DISABLED
84#endif
85
93#ifndef VSF_DMA_CFG_REIMPLEMENT_TYPE_IRQ_MASK
94# define VSF_DMA_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED
95#endif
96
104#ifndef VSF_DMA_CFG_REIMPLEMENT_TYPE_ADDR
105# define VSF_DMA_CFG_REIMPLEMENT_TYPE_ADDR DISABLED
106#endif
107
115#ifndef VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_HINT
116# define VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_HINT DISABLED
117#endif
118
130#ifndef VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG
131# define VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG DISABLED
132#endif
133
141#ifndef VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_SG_CFG
142# define VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_SG_CFG \
143 DISABLED
144#endif
145
155#ifndef VSF_DMA_CFG_REIMPLEMENT_TYPE_CFG
156# define VSF_DMA_CFG_REIMPLEMENT_TYPE_CFG DISABLED
157#endif
158
165#ifndef VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_STATUS
166# define VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_STATUS DISABLED
167#endif
168
178#ifndef VSF_DMA_CFG_REIMPLEMENT_TYPE_CAPABILITY
179# define VSF_DMA_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
180#endif
181
189#ifndef VSF_DMA_CFG_INHERIT_HAL_CAPABILITY
190# define VSF_DMA_CFG_INHERIT_HAL_CAPABILITY ENABLED
191#endif
192
228#ifndef VSF_DMA_CHANNEL_SG_ARRAY
229# define VSF_DMA_CHANNEL_SG_ARRAY(__NAME, __COUNT, ...) \
230 vsf_dma_channel_sg_desc_t __NAME[__COUNT] = { \
231 __VA_ARGS__ \
232 };
233#endif
234
249#ifndef VSF_DMA_CHANNEL_SG_ITEM
250# define VSF_DMA_CHANNEL_SG_ITEM(__MODE, __SRC_ADDR, __DST_ADDR, __CNT, ...) \
251 { \
252 .mode = __MODE, \
253 .src_address = __SRC_ADDR, \
254 .dst_address = __DST_ADDR, \
255 .count = __CNT, \
256 __VA_ARGS__ \
257 }
258#endif
259
260/*============================ MACROFIED FUNCTIONS ===========================*/
261
271#define VSF_DMA_APIS(__prefix_name) \
272 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, dma, init, VSF_MCONNECT(__prefix_name, _t) *dma_ptr, vsf_dma_cfg_t *cfg_ptr) \
273 __VSF_HAL_TEMPLATE_API(__prefix_name, void, dma, fini, VSF_MCONNECT(__prefix_name, _t) *dma_ptr) \
274 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, dma, get_configuration, VSF_MCONNECT(__prefix_name, _t) *dma_ptr, vsf_dma_cfg_t *cfg_ptr) \
275 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_dma_capability_t, dma, capability, VSF_MCONNECT(__prefix_name, _t) *dma_ptr) \
276 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, dma, channel_acquire, VSF_MCONNECT(__prefix_name, _t) *dma_ptr, vsf_dma_channel_hint_t *channel_hint_ptr) \
277 __VSF_HAL_TEMPLATE_API(__prefix_name, void, dma, channel_release, VSF_MCONNECT(__prefix_name, _t) *dma_ptr, uint8_t channel) \
278 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, dma, channel_config, VSF_MCONNECT(__prefix_name, _t) *dma_ptr, uint8_t channel, vsf_dma_channel_cfg_t *cfg_ptr) \
279 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, dma, channel_get_configuration, VSF_MCONNECT(__prefix_name, _t) *dma_ptr, uint8_t channel, vsf_dma_channel_cfg_t *cfg_ptr) \
280 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, dma, channel_start, VSF_MCONNECT(__prefix_name, _t) *dma_ptr, uint8_t channel, vsf_dma_addr_t src_address, vsf_dma_addr_t dst_address, uint32_t count) \
281 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, dma, channel_cancel, VSF_MCONNECT(__prefix_name, _t) *dma_ptr, uint8_t channel) \
282 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, dma, channel_sg_config_desc, VSF_MCONNECT(__prefix_name, _t) *dma_ptr, uint8_t channel, vsf_dma_isr_t isr, vsf_dma_channel_sg_desc_t *scatter_gather_cfg, uint32_t sg_count) \
283 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, dma, channel_sg_start, VSF_MCONNECT(__prefix_name, _t) *dma_ptr, uint8_t channel) \
284 __VSF_HAL_TEMPLATE_API(__prefix_name, uint32_t, dma, channel_get_transferred_count, VSF_MCONNECT(__prefix_name, _t) *dma_ptr, uint8_t channel) \
285 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_dma_channel_status_t, dma, channel_status, VSF_MCONNECT(__prefix_name, _t) *dma_ptr, uint8_t channel)
286
287/*============================ TYPES =========================================*/
288
298#if VSF_DMA_CFG_REIMPLEMENT_TYPE_ADDR == DISABLED
300#endif
301
302#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE == DISABLED
308
312
316
323
330
339
348
349 //prio
350 VSF_DMA_PRIORITY_LOW = (0x00 << 22),
352 VSF_DMA_PRIORITY_HIGH = (0x02 << 22),
354
356#endif
357
358enum {
364
369
374
382
390
400
410
416
426
427};
428
429#if VSF_DMA_CFG_REIMPLEMENT_TYPE_IRQ_MASK == DISABLED
430typedef enum vsf_dma_irq_mask_t {
431 VSF_DMA_IRQ_MASK_CPL = (0x1ul << 0),
435#endif
436
437enum {
442};
443
444
445#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
458typedef struct vsf_dma_cfg_t {
461#endif
462
463#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_HINT == DISABLED
475typedef struct vsf_dma_channel_hint_t {
521#endif
522
523#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG == DISABLED
524typedef struct vsf_dma_t vsf_dma_t;
525
526typedef void vsf_dma_isr_handler_t(void *target_ptr, vsf_dma_t *dma_ptr, int8_t channel, vsf_dma_irq_mask_t irq_mask);
527
528typedef struct vsf_dma_isr_t {
530 void *target_ptr;
532
534
545typedef struct vsf_dma_channel_cfg_t {
607#endif
608
609/*============================ INITIALIZATION MACROS =========================*/
610
611// Helper macro for optional argument with default value
612#ifndef __VSF_DMA_GET_ARG_OR_DEFAULT
613# define __VSF_DMA_GET_ARG_OR_DEFAULT(__DEFAULT, __ARG, ...) (__ARG)
614#endif
615
663#ifndef VSF_DMA_CHANNEL_HINT_INIT
664# define VSF_DMA_CHANNEL_HINT_INIT(__CHANNEL, __REQUEST_LINE, ...) \
665 { \
666 .channel = (__CHANNEL), \
667 .request_line = (__REQUEST_LINE), \
668 .prio = __VSF_DMA_GET_ARG_OR_DEFAULT(,##__VA_ARGS__, vsf_arch_prio_invalid, vsf_arch_prio_invalid), \
669 }
670#endif
671
697#ifndef VSF_DMA_CHANNEL_CFG_INIT
698# define VSF_DMA_CHANNEL_CFG_INIT(__MODE, __ISR, __IRQ_MASK, __SRC_REQ_IDX, __DST_REQ_IDX, ...) \
699 { \
700 .mode = (__MODE), \
701 .isr = (__ISR), \
702 .irq_mask = (__IRQ_MASK), \
703 .prio = __VSF_DMA_GET_ARG_OR_DEFAULT(,##__VA_ARGS__, vsf_arch_prio_invalid, vsf_arch_prio_invalid), \
704 .src_request_idx = (__SRC_REQ_IDX), \
705 .dst_request_idx = (__DST_REQ_IDX), \
706 }
707#endif
708
709#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_SG_CFG == DISABLED
723typedef struct vsf_dma_channel_sg_desc_t {
735#endif
736
737#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CHANNEL_STATUS == DISABLED
738typedef struct vsf_dma_channel_status_t {
739 union {
741 struct {
742 uint32_t is_busy : 1;
743 };
744 };
746#endif
747
748#if VSF_DMA_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
760typedef struct vsf_dma_capability_t {
761#if VSF_DMA_CFG_INHERIT_HAL_CAPABILITY == ENABLED
763#endif
764
766
768
778
796
799
802#endif
803
804typedef struct vsf_dma_op_t {
806#undef __VSF_HAL_TEMPLATE_API
807#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
809
810 VSF_DMA_APIS(vsf_dma)
812
813#if VSF_DMA_CFG_MULTI_CLASS == ENABLED
814struct vsf_dma_t {
816};
817#endif
818
819/*============================ PROTOTYPES ====================================*/
820
840extern vsf_err_t vsf_dma_init(vsf_dma_t *dma_ptr, vsf_dma_cfg_t *cfg_ptr);
841
853extern void vsf_dma_fini(vsf_dma_t *dma_ptr);
854
869
882
900extern vsf_err_t vsf_dma_channel_acquire(vsf_dma_t *dma_ptr, vsf_dma_channel_hint_t *channel_hint_ptr);
901
915extern void vsf_dma_channel_release(vsf_dma_t *dma_ptr, uint8_t channel);
916
974
991
1028extern vsf_err_t vsf_dma_channel_start(vsf_dma_t *dma_ptr, uint8_t channel, vsf_dma_addr_t src_address, vsf_dma_addr_t dst_address, uint32_t count);
1029
1043extern vsf_err_t vsf_dma_channel_cancel(vsf_dma_t *dma_ptr, uint8_t channel);
1044
1090 vsf_dma_channel_sg_desc_t *sg_desc_ptr, uint32_t sg_count);
1091
1126extern vsf_err_t vsf_dma_channel_sg_start(vsf_dma_t *dma_ptr, uint8_t channel);
1127
1171
1186
1188// \~english
1189// @brief Acquire a DMA channel from all available DMA instances
1190// @param[in,out] channel_hint_ptr: a pointer to DMA channel hint. User should provide appropriate hint information based on actual requirements. If the actually allocated channel or other configuration differs from user's expectation, the function may modify channel_hint_ptr to notify the user of the actual allocation. The allocated channel number will be stored in channel_hint_ptr->channel.
1191// @return vsf_dma_t *: pointer to the DMA instance that successfully allocated the channel, or NULL if allocation failed
1192// @note Prerequisites: All DMA instances must be homogeneous (isomorphic). Peripherals can acquire channels from any DMA instance, and channels acquired from any DMA instance can be assigned to any peripheral. This function iterates through all available DMA instances and attempts to acquire a channel from each one. It returns the first DMA instance that successfully allocates a channel.
1193// @note The VSF_PREFIX prefix of this can be replaced with the actual prefix, e.g. vsf_hw
1194//
1195// \~chinese
1196// @brief 从所有可用的 DMA 实例中获取一个 DMA 通道
1197// @param[in,out] channel_hint_ptr: 指向 DMA 通道提示的指针。用户应根据实际情况提供合适的提示信息。如果实际分配的通道或其他配置与用户预期不一致,函数可能会修改 channel_hint_ptr 来通知用户实际分配的结果。分配的通道号将存储在 channel_hint_ptr->channel 中。
1198// @return vsf_dma_t *: 成功分配通道的 DMA 实例指针,如果分配失败则返回 NULL
1199// @note 前提条件:所有 DMA 实例必须是同构的(功能相同)。外设可以从任意一个 DMA 实例申请通道,并且从任意一个 DMA 实例获取的通道都可以分配给任意一个外设使用。此函数遍历所有可用的 DMA 实例,并尝试从每个实例中获取通道。它返回第一个成功分配通道的 DMA 实例。
1200// @note VSF_PREFIX 前缀可以替换成实际的前缀,例如 vsf_hw
1201// */
1202//extern vsf_dma_t * VSF_PREFIX_dma_channel_acquire_from_all(vsf_dma_channel_hint_t *channel_hint_ptr);
1203//
1204
1205/*============================ MACROFIED FUNCTIONS ===========================*/
1206
1208#if VSF_DMA_CFG_FUNCTION_RENAME == ENABLED
1209# define __vsf_dma_t VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_t)
1210# define vsf_dma_init(__DMA, ...) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_init)((__vsf_dma_t *)(__DMA), ##__VA_ARGS__)
1211# define vsf_dma_fini(__DMA) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_fini)((__vsf_dma_t *)(__DMA))
1212# define vsf_dma_get_configuration(__DMA, ...) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_get_configuration)((__vsf_dma_t *)(__DMA), ##__VA_ARGS__)
1213# define vsf_dma_capability(__DMA) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_capability)((__vsf_dma_t *)(__DMA))
1214# define vsf_dma_channel_acquire(__DMA, ...) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_channel_acquire)((__vsf_dma_t *)(__DMA), ##__VA_ARGS__)
1215# define vsf_dma_channel_release(__DMA, ...) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_channel_release)((__vsf_dma_t *)(__DMA), ##__VA_ARGS__)
1216# define vsf_dma_channel_config(__DMA, ...) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_channel_config)((__vsf_dma_t *)(__DMA), ##__VA_ARGS__)
1217# define vsf_dma_channel_get_configuration(__DMA, ...) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_channel_get_configuration)((__vsf_dma_t *)(__DMA), ##__VA_ARGS__)
1218# define vsf_dma_channel_start(__DMA, ...) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_channel_start)((__vsf_dma_t *)(__DMA), ##__VA_ARGS__)
1219# define vsf_dma_channel_sg_config_desc(__DMA, ...) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_channel_sg_config_desc)((__vsf_dma_t *)(__DMA), ##__VA_ARGS__)
1220# define vsf_dma_channel_sg_start(__DMA, ...) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_channel_sg_start)((__vsf_dma_t *)(__DMA), ##__VA_ARGS__)
1221# define vsf_dma_channel_cancel(__DMA, ...) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_channel_cancel)((__vsf_dma_t *)(__DMA), ##__VA_ARGS__)
1222# define vsf_dma_channel_get_transferred_count(__DMA, ...) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_channel_get_transferred_count)((__vsf_dma_t *)(__DMA), ##__VA_ARGS__)
1223# define vsf_dma_channel_status(__DMA, ...) VSF_MCONNECT(VSF_DMA_CFG_PREFIX, _dma_channel_status)((__vsf_dma_t *)(__DMA), ##__VA_ARGS__)
1224#endif
1226
1227#ifdef __cplusplus
1228}
1229#endif
1230
1231#endif /*__VSF_TEMPLATE_DMA_H__*/
vsf_err_t
Definition __type.h:42
vsf_dma_channel_mode_t
Definition dma.h:86
vsf_dma_irq_mask_t
Definition dma.h:160
uintptr_t vsf_dma_addr_t
Definition dma.h:82
vsf_arch_prio_t
Definition cortex_a_generic.h:88
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:229
uint8_t addr_alignment
Address alignment requirement in bytes (1 means no alignment required)
Definition dma.h:238
vsf_dma_channel_mode_t supported_modes
Definition dma.h:236
uint8_t channel_count
Number of DMA channels.
Definition dma.h:234
uint8_t support_scatter_gather
Support scatter-gather transfer.
Definition dma.h:239
uint8_t irq_count
Definition dma.h:235
uint32_t max_transfer_count
Maximum number of data items per transfer (0 means no limit)
Definition dma.h:237
inherit(vsf_peripheral_capability_t) vsf_dma_irq_mask_t irq_mask
Supported interrupt mask bits.
Configuration structure for DMA.
Definition dma.h:223
vsf_arch_prio_t prio
Default interrupt priority for DMA channels.
Definition dma.h:224
dma configuration
Definition dma.h:185
uint8_t dst_request_idx
Definition dma.h:191
vsf_dma_channel_mode_t mode
Definition dma.h:186
vsf_dma_irq_mask_t irq_mask
Definition dma.h:188
uint8_t src_request_idx
Definition dma.h:190
vsf_dma_isr_t isr
Definition dma.h:187
vsf_arch_prio_t prio
Definition dma.h:189
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
vsf_arch_prio_t prio
Definition dma.h:174
DMA scatter-gather descriptor structure.
Definition dma.h:213
uint32_t count
Definition dma.h:217
vsf_dma_addr_t src_address
Source address.
Definition dma.h:215
vsf_dma_addr_t next
Definition dma.h:218
vsf_dma_channel_mode_t mode
DMA channel mode.
Definition dma.h:214
vsf_dma_addr_t dst_address
Destination address.
Definition dma.h:216
Definition dma.h:202
Definition dma.h:181
vsf_dma_isr_handler_t * handler_fn
Definition dma.h:182
void * target_ptr
Definition dma.h:183
Definition vsf_template_dma.h:804
Definition vsf_template_dma.h:814
const vsf_dma_op_t * op
Definition vsf_template_dma.h:815
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
vsf_adc_isr_t isr
Definition adc.h:111
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:200
vsf_dma_irq_mask_t
Definition dma.h:181
vsf_dma_channel_mode_t
Definition vsf_template_dma.h:303
@ VSF_DMA_PRIORITY_MEDIUM
Definition vsf_template_dma.h:351
@ VSF_DMA_DST_WIDTH_BYTES_32
Definition vsf_template_dma.h:329
@ VSF_DMA_SRC_BURST_LENGTH_64
Definition vsf_template_dma.h:337
@ VSF_DMA_DST_BURST_LENGTH_64
Definition vsf_template_dma.h:346
@ VSF_DMA_SRC_WIDTH_BYTES_8
Definition vsf_template_dma.h:320
@ VSF_DMA_SRC_WIDTH_BYTES_2
Definition vsf_template_dma.h:318
@ VSF_DMA_DST_WIDTH_BYTES_16
Definition vsf_template_dma.h:328
@ VSF_DMA_SRC_BURST_LENGTH_16
Definition vsf_template_dma.h:335
@ VSF_DMA_DST_BURST_LENGTH_128
Definition vsf_template_dma.h:347
@ VSF_DMA_DST_WIDTH_BYTE_1
Definition vsf_template_dma.h:324
@ VSF_DMA_PRIORITY_HIGH
Definition vsf_template_dma.h:352
@ VSF_DMA_SRC_WIDTH_BYTES_16
Definition vsf_template_dma.h:321
@ VSF_DMA_DST_ADDR_NO_CHANGE
Definition vsf_template_dma.h:315
@ VSF_DMA_DST_BURST_LENGTH_4
Definition vsf_template_dma.h:342
@ VSF_DMA_DST_BURST_LENGTH_1
Definition vsf_template_dma.h:340
@ VSF_DMA_SRC_ADDR_INCREMENT
Definition vsf_template_dma.h:309
@ VSF_DMA_MEMORY_TO_PERIPHERAL
Definition vsf_template_dma.h:305
@ VSF_DMA_DST_BURST_LENGTH_32
Definition vsf_template_dma.h:345
@ VSF_DMA_SRC_BURST_LENGTH_4
Definition vsf_template_dma.h:333
@ VSF_DMA_SRC_BURST_LENGTH_128
Definition vsf_template_dma.h:338
@ VSF_DMA_SRC_WIDTH_BYTE_1
Definition vsf_template_dma.h:317
@ VSF_DMA_MEMORY_TO_MEMORY
Definition vsf_template_dma.h:304
@ VSF_DMA_PRIORITY_LOW
Definition vsf_template_dma.h:350
@ VSF_DMA_SRC_WIDTH_BYTES_4
Definition vsf_template_dma.h:319
@ VSF_DMA_DST_WIDTH_BYTES_8
Definition vsf_template_dma.h:327
@ VSF_DMA_SRC_BURST_LENGTH_1
Definition vsf_template_dma.h:331
@ VSF_DMA_DST_WIDTH_BYTES_2
Definition vsf_template_dma.h:325
@ VSF_DMA_DST_WIDTH_BYTES_4
Definition vsf_template_dma.h:326
@ VSF_DMA_SRC_BURST_LENGTH_2
Definition vsf_template_dma.h:332
@ VSF_DMA_SRC_ADDR_DECREMENT
Definition vsf_template_dma.h:310
@ VSF_DMA_DST_BURST_LENGTH_8
Definition vsf_template_dma.h:343
@ VSF_DMA_SRC_ADDR_NO_CHANGE
Definition vsf_template_dma.h:311
@ VSF_DMA_DST_BURST_LENGTH_16
Definition vsf_template_dma.h:344
@ VSF_DMA_SRC_BURST_LENGTH_8
Definition vsf_template_dma.h:334
@ VSF_DMA_DST_BURST_LENGTH_2
Definition vsf_template_dma.h:341
@ VSF_DMA_SRC_WIDTH_BYTES_32
Definition vsf_template_dma.h:322
@ VSF_DMA_PRIORITY_VERY_HIGH
Definition vsf_template_dma.h:353
@ VSF_DMA_SRC_BURST_LENGTH_32
Definition vsf_template_dma.h:336
@ VSF_DMA_DST_ADDR_DECREMENT
Definition vsf_template_dma.h:314
@ VSF_DMA_PERIPHERAL_TO_PERIPHERAL
Definition vsf_template_dma.h:307
@ VSF_DMA_PERIPHERAL_TO_MEMORY
Definition vsf_template_dma.h:306
@ VSF_DMA_DST_ADDR_INCREMENT
Definition vsf_template_dma.h:313
struct vsf_dma_isr_t vsf_dma_isr_t
vsf_err_t vsf_dma_channel_start(vsf_dma_t *dma_ptr, uint8_t channel, vsf_dma_addr_t src_address, vsf_dma_addr_t dst_address, uint32_t count)
Start a DMA channel transfer.
Definition dma_common.c:115
vsf_err_t vsf_dma_channel_sg_start(vsf_dma_t *dma_ptr, uint8_t channel)
Start a DMA scatter-gather transfer.
Definition dma_common.c:138
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 vsf_template_dma.h:526
struct vsf_dma_capability_t vsf_dma_capability_t
DMA capability structure that can be reimplemented in specific HAL drivers.
@ VSF_DMA_IRQ_COUNT
Definition vsf_template_dma.h:438
@ VSF_DMA_IRQ_ALL_BITS_MASK
Definition vsf_template_dma.h:439
struct vsf_dma_channel_status_t vsf_dma_channel_status_t
vsf_err_t vsf_dma_channel_acquire(vsf_dma_t *dma_ptr, vsf_dma_channel_hint_t *channel_hint_ptr)
DMA acquire a new channel.
Definition dma_common.c:75
vsf_err_t vsf_dma_get_configuration(vsf_dma_t *dma_ptr, vsf_dma_cfg_t *cfg_ptr)
Get the current configuration of DMA instance.
Definition dma_common.c:56
vsf_err_t vsf_dma_channel_get_configuration(vsf_dma_t *dma_ptr, uint8_t channel, vsf_dma_channel_cfg_t *cfg_ptr)
Get the current configuration of a DMA channel.
Definition dma_common.c:104
void vsf_dma_channel_release(vsf_dma_t *dma_ptr, uint8_t channel)
Release a DMA channel.
Definition dma_common.c:85
struct vsf_dma_channel_sg_desc_t vsf_dma_channel_sg_desc_t
DMA scatter-gather descriptor structure.
@ VSF_DMA_PRIORITY_MASK
Definition vsf_template_dma.h:412
@ VSF_DMA_DST_WIDTH_MASK
Definition vsf_template_dma.h:384
@ VSF_DMA_SRC_WIDTH_MASK
Definition vsf_template_dma.h:376
@ VSF_DMA_MODE_ALL_BITS_MASK
Definition vsf_template_dma.h:418
@ VSF_DMA_DST_ADDR_MASK
Definition vsf_template_dma.h:371
@ VSF_DMA_SRC_BURST_MASK
Definition vsf_template_dma.h:392
@ VSF_DMA_DST_ADDR_COUNT
Definition vsf_template_dma.h:370
@ VSF_DMA_DIRECTION_COUNT
Definition vsf_template_dma.h:359
@ VSF_DMA_PRIORITY_COUNT
Definition vsf_template_dma.h:411
@ VSF_DMA_DST_BURST_COUNT
Definition vsf_template_dma.h:401
@ VSF_DMA_SRC_BURST_COUNT
Definition vsf_template_dma.h:391
@ VSF_DMA_SRC_ADDR_COUNT
Definition vsf_template_dma.h:365
@ VSF_DMA_SRC_ADDR_MASK
Definition vsf_template_dma.h:366
@ VSF_DMA_DST_WIDTH_COUNT
Definition vsf_template_dma.h:383
@ VSF_DMA_DIRECTION_MASK
Definition vsf_template_dma.h:360
@ VSF_DMA_SRC_WIDTH_COUNT
Definition vsf_template_dma.h:375
@ VSF_DMA_MODE_MASK_COUNT
Definition vsf_template_dma.h:417
@ VSF_DMA_DST_BURST_MASK
Definition vsf_template_dma.h:402
vsf_err_t vsf_dma_init(vsf_dma_t *dma_ptr, vsf_dma_cfg_t *cfg_ptr)
Initialize a DMA instance.
Definition dma_common.c:38
vsf_err_t vsf_dma_channel_sg_config_desc(vsf_dma_t *dma_ptr, uint8_t channel, vsf_dma_isr_t isr, vsf_dma_channel_sg_desc_t *sg_desc_ptr, uint32_t sg_count)
Configure a DMA channel for scatter-gather transfer.
Definition dma_common.c:127
vsf_err_t vsf_dma_channel_cancel(vsf_dma_t *dma_ptr, uint8_t channel)
Cancel the transmission of a specific DMA channel.
Definition dma_common.c:147
void vsf_dma_fini(vsf_dma_t *dma_ptr)
Finalize a DMA instance.
Definition dma_common.c:47
vsf_err_t vsf_dma_channel_config(vsf_dma_t *dma_ptr, uint8_t channel, vsf_dma_channel_cfg_t *cfg_ptr)
Configure a DMA channel.
Definition dma_common.c:94
vsf_dma_irq_mask_t
Definition vsf_template_dma.h:430
@ VSF_DMA_IRQ_MASK_HALF_CPL
Definition vsf_template_dma.h:432
@ VSF_DMA_IRQ_MASK_CPL
Definition vsf_template_dma.h:431
@ VSF_DMA_IRQ_MASK_ERROR
Definition vsf_template_dma.h:433
uintptr_t vsf_dma_addr_t
DMA address type, used for source address, destination address and scatter-gather descriptor address.
Definition vsf_template_dma.h:299
vsf_dma_channel_status_t vsf_dma_channel_status(vsf_dma_t *dma_ptr, uint8_t channel)
Get status of a DMA channel.
Definition dma_common.c:165
struct vsf_dma_channel_cfg_t vsf_dma_channel_cfg_t
dma configuration
vsf_dma_capability_t vsf_dma_capability(vsf_dma_t *dma_ptr)
Get the capabilities of DMA instance.
Definition dma_common.c:66
struct vsf_dma_channel_hint_t vsf_dma_channel_hint_t
DMA channel hint structure for channel allocation.
uint32_t vsf_dma_channel_get_transferred_count(vsf_dma_t *dma_ptr, uint8_t channel)
Get the count of data items transferred for a specific DMA channel.
Definition dma_common.c:156
struct vsf_dma_cfg_t vsf_dma_cfg_t
Configuration structure for DMA.
#define VSF_DMA_APIS(__prefix_name)
DMA API template, used to generate DMA type, specific prefix function declarations,...
Definition vsf_template_dma.h:271
Generated from commit: vsfteam/vsf@3f77d3b