no-OS
no_os_dma.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef _NO_OS_DMA_H_
35 #define _NO_OS_DMA_H_
36 
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <stdint.h>
40 
41 #include "no_os_list.h"
42 #include "no_os_irq.h"
43 #include "no_os_mutex.h"
44 
53 };
54 
62  void *extra;
63 };
64 
66 
73  uint8_t *src;
75  uint8_t *dst;
77  uint32_t length;
80 
83  struct no_os_dma_xfer_desc *,
84  void *);
91  uint32_t irq_priority;
92 
98 
100  void *extra;
101 };
102 
107 struct no_os_dma_ch {
109  uint32_t id;
111  bool free;
115  uint32_t irq_num;
120  void *extra;
121 
123  void *mutex;
124 
129  bool sync_lock;
130 };
131 
138  uint32_t id;
140  uint32_t num_ch;
153  void *extra;
155  uint32_t ref;
157  void *mutex;
158 
164  void (*sg_handler)(void *);
165 };
166 
173  uint32_t id;
175  uint32_t num_ch;
179  void *extra;
180 
185  void (*sg_handler)(void *);
190  void *ctx;
191 };
192 
194 int no_os_dma_init(struct no_os_dma_desc **,
195  struct no_os_dma_init_param *);
196 
198 int no_os_dma_remove(struct no_os_dma_desc *);
199 
202  struct no_os_dma_xfer_desc *,
203  uint32_t,
204  struct no_os_dma_ch *);
205 
207 int no_os_dma_chan_lock(struct no_os_dma_ch *);
208 
210 int no_os_dma_chan_unlock(struct no_os_dma_ch *);
211 
213 int no_os_dma_xfer_start(struct no_os_dma_desc *, struct no_os_dma_ch *);
214 
219 int no_os_dma_xfer_abort(struct no_os_dma_desc *, struct no_os_dma_ch *);
220 
225 bool no_os_dma_is_completed(struct no_os_dma_desc *, struct no_os_dma_ch *);
226 
228 bool no_os_dma_in_progress(struct no_os_dma_desc *, struct no_os_dma_ch *);
229 
231 int no_os_dma_acquire_channel(struct no_os_dma_desc *, struct no_os_dma_ch **);
232 
235 
243  int (*dma_init)(struct no_os_dma_desc **, struct no_os_dma_init_param *);
245  int (*dma_remove)(struct no_os_dma_desc *desc);
247  int (*dma_acquire_ch)(struct no_os_dma_desc *, uint32_t *);
248  int (*dma_release_ch)(struct no_os_dma_desc *, uint32_t);
250  int (*dma_config_xfer)(struct no_os_dma_ch *,
251  struct no_os_dma_xfer_desc *);
253  int (*dma_xfer_start)(struct no_os_dma_desc *, struct no_os_dma_ch *);
255  int (*dma_xfer_abort)(struct no_os_dma_desc *, struct no_os_dma_ch *);
263 };
264 
265 #endif
no_os_dma_xfer_desc::irq_priority
uint32_t irq_priority
Definition: no_os_dma.h:91
no_os_list_desc
Structure storing the list and function wrapper for usual list types.
Definition: no_os_list.h:228
no_os_dma_chan_lock
int no_os_dma_chan_lock(struct no_os_dma_ch *)
Lock a DMA channel, so it won't be acquired even if it's free.
Definition: no_os_dma.c:317
no_os_dma_desc::sg_handler
void(* sg_handler)(void *)
Definition: no_os_dma.h:164
no_os_dma_default_handler_data
IRQ parameter for the default inter transfer handler.
Definition: no_os_dma.h:59
no_os_dma_acquire_channel
int no_os_dma_acquire_channel(struct no_os_dma_desc *, struct no_os_dma_ch **)
Get a free DMA channel.
Definition: no_os_dma.c:184
no_os_dma_ch::irq_ctx
struct no_os_dma_default_handler_data irq_ctx
Definition: no_os_dma.h:119
no_os_dma_platform_ops::dma_acquire_ch
int(* dma_acquire_ch)(struct no_os_dma_desc *, uint32_t *)
Definition: no_os_dma.h:247
no_os_dma_init_param::extra
void * extra
Definition: no_os_dma.h:179
no_os_dma_platform_ops::dma_xfer_start
int(* dma_xfer_start)(struct no_os_dma_desc *, struct no_os_dma_ch *)
Definition: no_os_dma.h:253
no_os_callback_desc
Structure describing a callback to be registered.
Definition: no_os_irq.h:142
no_os_dma_init_param
Initialization parameter for the DMA controller.
Definition: no_os_dma.h:171
no_os_dma_ch::id
uint32_t id
Definition: no_os_dma.h:109
no_os_irq.h
Header file of IRQ interface.
no_os_dma_desc::id
uint32_t id
Definition: no_os_dma.h:138
no_os_dma_default_handler_data::extra
void * extra
Definition: no_os_dma.h:62
no_os_dma_ch::irq_num
uint32_t irq_num
Definition: no_os_dma.h:115
DEV_TO_MEM
@ DEV_TO_MEM
Definition: no_os_dma.h:52
no_os_dma_desc::extra
void * extra
Definition: no_os_dma.h:153
no_os_dma_init_param::platform_ops
struct no_os_dma_platform_ops * platform_ops
Definition: no_os_dma.h:177
no_os_irq_peripheral
no_os_irq_peripheral
Definition: no_os_irq.h:84
no_os_dma_in_progress
bool no_os_dma_in_progress(struct no_os_dma_desc *, struct no_os_dma_ch *)
Whether or not there is a transfer in progress on a specific channel.
Definition: no_os_dma.c:434
no_os_dma_platform_ops::dma_remove
int(* dma_remove)(struct no_os_dma_desc *desc)
Definition: no_os_dma.h:245
bool
bool
Definition: common.h:48
no_os_dma_config_xfer
int no_os_dma_config_xfer(struct no_os_dma_desc *, struct no_os_dma_xfer_desc *, uint32_t, struct no_os_dma_ch *)
Acquire a channel and configure the list of transfers.
Definition: no_os_dma.c:242
no_os_dma_init_param::num_ch
uint32_t num_ch
Definition: no_os_dma.h:175
no_os_dma_init_param::id
uint32_t id
Definition: no_os_dma.h:173
no_os_dma_default_handler_data::channel
struct no_os_dma_ch * channel
Definition: no_os_dma.h:61
no_os_dma_desc::mutex
void * mutex
Definition: no_os_dma.h:157
no_os_mutex.h
no_os_dma_ch
Describes the state of a DMA channel.
Definition: no_os_dma.h:107
no_os_dma_platform_ops
Definition: no_os_dma.h:241
no_os_dma_init_param::ctx
void * ctx
Definition: no_os_dma.h:190
no_os_dma_xfer_desc::dst
uint8_t * dst
Definition: no_os_dma.h:75
no_os_dma_platform_ops::dma_xfer_abort
int(* dma_xfer_abort)(struct no_os_dma_desc *, struct no_os_dma_ch *)
Definition: no_os_dma.h:255
MEM_TO_MEM
@ MEM_TO_MEM
Definition: no_os_dma.h:50
no_os_dma_desc::platform_ops
struct no_os_dma_platform_ops * platform_ops
Definition: no_os_dma.h:144
no_os_dma_default_handler_data::desc
struct no_os_dma_desc * desc
Definition: no_os_dma.h:60
no_os_dma_xfer_desc
It's used to setup a generic DMA transfer.
Definition: no_os_dma.h:71
no_os_dma_xfer_desc::xfer_complete_ctx
void * xfer_complete_ctx
Definition: no_os_dma.h:89
no_os_dma_desc::ref
uint32_t ref
Definition: no_os_dma.h:155
no_os_dma_xfer_desc::xfer_complete_cb
void(* xfer_complete_cb)(struct no_os_dma_xfer_desc *, struct no_os_dma_xfer_desc *, void *)
Definition: no_os_dma.h:82
no_os_dma_desc::irq_ctrl
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: no_os_dma.h:151
no_os_dma_desc::num_ch
uint32_t num_ch
Definition: no_os_dma.h:140
no_os_dma_platform_ops::dma_init
int(* dma_init)(struct no_os_dma_desc **, struct no_os_dma_init_param *)
Definition: no_os_dma.h:243
no_os_dma_ch::free
bool free
Definition: no_os_dma.h:111
no_os_dma_init
int no_os_dma_init(struct no_os_dma_desc **, struct no_os_dma_init_param *)
Initialize the DMA controller.
Definition: no_os_dma.c:90
no_os_dma_xfer_start
int no_os_dma_xfer_start(struct no_os_dma_desc *, struct no_os_dma_ch *)
Acquire a channel and configure the list of transfers.
Definition: no_os_dma.c:356
no_os_dma_platform_ops::dma_config_xfer
int(* dma_config_xfer)(struct no_os_dma_ch *, struct no_os_dma_xfer_desc *)
Definition: no_os_dma.h:250
no_os_dma_xfer_desc::xfer_type
enum no_os_dma_xfer_type xfer_type
Definition: no_os_dma.h:79
no_os_dma_remove
int no_os_dma_remove(struct no_os_dma_desc *)
Remove resources allocated for the DMA controller.
Definition: no_os_dma.c:143
no_os_dma_release_channel
int no_os_dma_release_channel(struct no_os_dma_desc *, struct no_os_dma_ch *)
Free DMA channel.
Definition: no_os_dma.c:216
no_os_list.h
List library header.
no_os_dma_xfer_desc::src
uint8_t * src
Definition: no_os_dma.h:73
no_os_dma_ch::extra
void * extra
Definition: no_os_dma.h:120
no_os_dma_xfer_abort
int no_os_dma_xfer_abort(struct no_os_dma_desc *, struct no_os_dma_ch *)
Abort the ongoing and any other future transfers scheduled for a channel.
Definition: no_os_dma.c:384
no_os_dma_platform_ops::dma_release_ch
int(* dma_release_ch)(struct no_os_dma_desc *, uint32_t)
Definition: no_os_dma.h:248
no_os_dma_init_param::sg_handler
void(* sg_handler)(void *)
Definition: no_os_dma.h:185
MEM_TO_DEV
@ MEM_TO_DEV
Definition: no_os_dma.h:51
no_os_dma_is_completed
bool no_os_dma_is_completed(struct no_os_dma_desc *, struct no_os_dma_ch *)
Get the state of a DMA channel (free or not).
Definition: no_os_dma.c:417
no_os_dma_desc::channels
struct no_os_dma_ch * channels
Definition: no_os_dma.h:142
no_os_dma_platform_ops::dma_ch_in_progress
bool(* dma_ch_in_progress)(struct no_os_dma_desc *, struct no_os_dma_ch *)
Definition: no_os_dma.h:262
no_os_dma_chan_unlock
int no_os_dma_chan_unlock(struct no_os_dma_ch *)
Unlock a DMA channel, marking it available for acquisition.
Definition: no_os_dma.c:336
no_os_dma_xfer_desc::extra
void * extra
Definition: no_os_dma.h:100
no_os_dma_ch::cb_desc
struct no_os_callback_desc cb_desc
Definition: no_os_dma.h:117
no_os_dma_ch::mutex
void * mutex
Definition: no_os_dma.h:123
no_os_dma_xfer_type
no_os_dma_xfer_type
Supported transfer directions.
Definition: no_os_dma.h:49
no_os_irq_ctrl_desc
Definition: no_os_irq.h:123
no_os_dma_ch::sync_lock
bool sync_lock
Definition: no_os_dma.h:129
no_os_dma_xfer_desc::length
uint32_t length
Definition: no_os_dma.h:77
no_os_dma_platform_ops::dma_ch_is_completed
bool(* dma_ch_is_completed)(struct no_os_dma_desc *, struct no_os_dma_ch *)
Definition: no_os_dma.h:257
no_os_dma_ch::sg_list
struct no_os_list_desc * sg_list
Definition: no_os_dma.h:113
no_os_dma_xfer_desc::periph
enum no_os_irq_peripheral periph
Definition: no_os_dma.h:97
no_os_dma_desc
Describes the state of the DMA controller.
Definition: no_os_dma.h:136