no-OS
no_os_dma.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef _NO_OS_DMA_H_
41 #define _NO_OS_DMA_H_
42 
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <stdint.h>
46 
47 #include "no_os_list.h"
48 #include "no_os_irq.h"
49 #include "no_os_mutex.h"
50 
59 };
60 
68  void *extra;
69 };
70 
72 
79  uint8_t *src;
81  uint8_t *dst;
83  uint32_t length;
86 
89  struct no_os_dma_xfer_desc *,
90  void *);
97  uint32_t irq_priority;
98 
104 
106  void *extra;
107 };
108 
113 struct no_os_dma_ch {
115  uint32_t id;
117  bool free;
121  uint32_t irq_num;
124  void *extra;
125 
127  void *mutex;
128 
133  bool sync_lock;
134 };
135 
142  uint32_t id;
144  uint32_t num_ch;
157  void *extra;
159  uint32_t ref;
161  void *mutex;
162 
168  void (*sg_handler)(void *);
169 };
170 
177  uint32_t id;
179  uint32_t num_ch;
183  void *extra;
184 
189  void (*sg_handler)(void *);
194  void *ctx;
195 };
196 
198 int no_os_dma_init(struct no_os_dma_desc **,
199  struct no_os_dma_init_param *);
200 
202 int no_os_dma_remove(struct no_os_dma_desc *);
203 
206  struct no_os_dma_xfer_desc *,
207  uint32_t,
208  struct no_os_dma_ch *);
209 
211 int no_os_dma_chan_lock(struct no_os_dma_ch *);
212 
214 int no_os_dma_chan_unlock(struct no_os_dma_ch *);
215 
217 int no_os_dma_xfer_start(struct no_os_dma_desc *, struct no_os_dma_ch *);
218 
223 int no_os_dma_xfer_abort(struct no_os_dma_desc *, struct no_os_dma_ch *);
224 
229 bool no_os_dma_is_completed(struct no_os_dma_desc *, struct no_os_dma_ch *);
230 
232 bool no_os_dma_in_progress(struct no_os_dma_desc *, struct no_os_dma_ch *);
233 
235 int no_os_dma_acquire_channel(struct no_os_dma_desc *, struct no_os_dma_ch **);
236 
239 
247  int (*dma_init)(struct no_os_dma_desc **, struct no_os_dma_init_param *);
249  int (*dma_remove)(struct no_os_dma_desc *desc);
251  int (*dma_acquire_ch)(struct no_os_dma_desc *, uint32_t *);
252  int (*dma_release_ch)(struct no_os_dma_desc *, uint32_t);
254  int (*dma_config_xfer)(struct no_os_dma_ch *,
255  struct no_os_dma_xfer_desc *);
257  int (*dma_xfer_start)(struct no_os_dma_desc *, struct no_os_dma_ch *);
259  int (*dma_xfer_abort)(struct no_os_dma_desc *, struct no_os_dma_ch *);
267 };
268 
269 #endif
no_os_dma_xfer_desc::irq_priority
uint32_t irq_priority
Definition: no_os_dma.h:97
no_os_list_desc
Structure storing the list and function wrapper for usual list types.
Definition: no_os_list.h:234
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:320
no_os_dma_desc::sg_handler
void(* sg_handler)(void *)
Definition: no_os_dma.h:168
no_os_dma_default_handler_data
IRQ parameter for the default inter transfer handler.
Definition: no_os_dma.h:65
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:185
no_os_dma_ch::irq_ctx
struct no_os_dma_default_handler_data irq_ctx
Definition: no_os_dma.h:123
no_os_dma_platform_ops::dma_acquire_ch
int(* dma_acquire_ch)(struct no_os_dma_desc *, uint32_t *)
Definition: no_os_dma.h:251
no_os_dma_init_param::extra
void * extra
Definition: no_os_dma.h:183
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:257
no_os_dma_init_param
Initialization parameter for the DMA controller.
Definition: no_os_dma.h:175
no_os_dma_ch::id
uint32_t id
Definition: no_os_dma.h:115
no_os_irq.h
Header file of IRQ interface.
no_os_dma_desc::id
uint32_t id
Definition: no_os_dma.h:142
no_os_dma_default_handler_data::extra
void * extra
Definition: no_os_dma.h:68
no_os_dma_ch::irq_num
uint32_t irq_num
Definition: no_os_dma.h:121
DEV_TO_MEM
@ DEV_TO_MEM
Definition: no_os_dma.h:58
no_os_dma_desc::extra
void * extra
Definition: no_os_dma.h:157
no_os_dma_init_param::platform_ops
struct no_os_dma_platform_ops * platform_ops
Definition: no_os_dma.h:181
no_os_irq_peripheral
no_os_irq_peripheral
Definition: no_os_irq.h:90
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:437
no_os_dma_platform_ops::dma_remove
int(* dma_remove)(struct no_os_dma_desc *desc)
Definition: no_os_dma.h:249
bool
bool
Definition: common.h:54
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:243
no_os_dma_init_param::num_ch
uint32_t num_ch
Definition: no_os_dma.h:179
no_os_dma_init_param::id
uint32_t id
Definition: no_os_dma.h:177
no_os_dma_default_handler_data::channel
struct no_os_dma_ch * channel
Definition: no_os_dma.h:67
no_os_dma_desc::mutex
void * mutex
Definition: no_os_dma.h:161
no_os_mutex.h
no_os_dma_ch
Describes the state of a DMA channel.
Definition: no_os_dma.h:113
no_os_dma_platform_ops
Definition: no_os_dma.h:245
no_os_dma_init_param::ctx
void * ctx
Definition: no_os_dma.h:194
no_os_dma_xfer_desc::dst
uint8_t * dst
Definition: no_os_dma.h:81
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:259
MEM_TO_MEM
@ MEM_TO_MEM
Definition: no_os_dma.h:56
no_os_dma_desc::platform_ops
struct no_os_dma_platform_ops * platform_ops
Definition: no_os_dma.h:148
no_os_dma_default_handler_data::desc
struct no_os_dma_desc * desc
Definition: no_os_dma.h:66
no_os_dma_xfer_desc
It's used to setup a generic DMA transfer.
Definition: no_os_dma.h:77
no_os_dma_xfer_desc::xfer_complete_ctx
void * xfer_complete_ctx
Definition: no_os_dma.h:95
no_os_dma_desc::ref
uint32_t ref
Definition: no_os_dma.h:159
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:88
no_os_dma_desc::irq_ctrl
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: no_os_dma.h:155
no_os_dma_desc::num_ch
uint32_t num_ch
Definition: no_os_dma.h:144
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:247
no_os_dma_ch::free
bool free
Definition: no_os_dma.h:117
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:96
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:359
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:254
no_os_dma_xfer_desc::xfer_type
enum no_os_dma_xfer_type xfer_type
Definition: no_os_dma.h:85
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:149
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:217
no_os_list.h
List library header.
no_os_dma_xfer_desc::src
uint8_t * src
Definition: no_os_dma.h:79
no_os_dma_ch::extra
void * extra
Definition: no_os_dma.h:124
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:387
no_os_dma_platform_ops::dma_release_ch
int(* dma_release_ch)(struct no_os_dma_desc *, uint32_t)
Definition: no_os_dma.h:252
no_os_dma_init_param::sg_handler
void(* sg_handler)(void *)
Definition: no_os_dma.h:189
MEM_TO_DEV
@ MEM_TO_DEV
Definition: no_os_dma.h:57
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:420
no_os_dma_desc::channels
struct no_os_dma_ch * channels
Definition: no_os_dma.h:146
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:266
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:339
no_os_dma_xfer_desc::extra
void * extra
Definition: no_os_dma.h:106
no_os_dma_ch::mutex
void * mutex
Definition: no_os_dma.h:127
no_os_dma_xfer_type
no_os_dma_xfer_type
Supported transfer directions.
Definition: no_os_dma.h:55
no_os_irq_ctrl_desc
Definition: no_os_irq.h:129
no_os_dma_ch::sync_lock
bool sync_lock
Definition: no_os_dma.h:133
no_os_dma_xfer_desc::length
uint32_t length
Definition: no_os_dma.h:83
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:261
no_os_dma_ch::sg_list
struct no_os_list_desc * sg_list
Definition: no_os_dma.h:119
no_os_dma_xfer_desc::periph
enum no_os_irq_peripheral periph
Definition: no_os_dma.h:103
no_os_dma_desc
Describes the state of the DMA controller.
Definition: no_os_dma.h:140