mikroSDK Reference Manual
drv_dma.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2024 MikroElektronika d.o.o.
4 ** Contact: https://www.mikroe.com/contact
5 **
6 ** This file is part of the mikroSDK package
7 **
8 ** Commercial License Usage
9 **
10 ** Licensees holding valid commercial NECTO compilers AI licenses may use this
11 ** file in accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The MikroElektronika Company.
14 ** For licensing terms and conditions see
15 ** https://www.mikroe.com/legal/software-license-agreement.
16 ** For further information use the contact form at
17 ** https://www.mikroe.com/contact.
18 **
19 **
20 ** GNU Lesser General Public License Usage
21 **
22 ** Alternatively, this file may be used for
23 ** non-commercial projects under the terms of the GNU Lesser
24 ** General Public License version 3 as published by the Free Software
25 ** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
26 **
27 ** The above copyright notice and this permission notice shall be
28 ** included in all copies or substantial portions of the Software.
29 **
30 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31 ** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
32 ** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
35 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36 ** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 **
38 ****************************************************************************/
44 #ifndef _DRV_DMA_H_
45 #define _DRV_DMA_H_
46 
47 #ifdef __cplusplus
48 extern "C"{
49 #endif
50 
51 #include "drv_name.h"
52 #include "hal_dma.h"
53 
57 typedef enum
58 {
60  DMA_ERROR = (-1)
61 } dma_err_t;
62 
66 typedef enum
67 {
70 } dma_state_t;
71 
75 typedef enum
76 {
81 
85 typedef enum
86 {
94 
98 typedef enum
99 {
107 
111 typedef enum
112 {
117 } dma_mode_t;
118 
122 typedef enum
123 {
131 
135 typedef enum
136 {
146 
153 typedef uint8_t dma_channel_t[ DMA_NUM_OF_MODULES ][ DMA_NUM_OF_STREAMS_FAMILY ][ DMA_NUM_OF_CHANNELS_FAMILY ];
154 
176 typedef struct
177 {
178  uint8_t module;
179  uint8_t stream;
180  uint8_t channel;
181  dma_direction_t direction;
185  dma_mode_t mode;
187  bool src_inc;
188  dma_data_align_t data_align_source;
190  dma_burst_size_t burst_size_source;
195  bool dst_inc;
196  dma_data_align_t data_align_destination;
198  dma_burst_size_t burst_size_destination;
203  dma_priority_t priority;
205  uint32_t addr_src;
206  uint32_t addr_dst;
207  size_t transfer_length;
208 } dma_config_t;
209 
229 typedef struct
230 {
231  handle_t handle;
232  dma_config_t config;
233  uint8_t module;
234  uint8_t stream;
235  uint8_t channel;
236  dma_state_t allocated;
237  bool initialized;
238 } dma_t;
239 
328 void dma_configure_default( dma_config_t *config );
329 
373 err_t dma_open( dma_t *obj, dma_config_t *config );
374 
401 void dma_get_channels( dma_channel_t *channels );
402 
440 err_t dma_set_mode( dma_t *obj, dma_mode_t mode );
441 
479 err_t dma_set_direction( dma_t *obj, dma_direction_t direction );
480 
518 err_t dma_set_priority( dma_t *obj, dma_priority_t priority );
519 
577 err_t dma_set_transfer_config( dma_t *obj, uint32_t addr_src, uint32_t addr_dst, size_t transfer_size, dma_source_memory_region_t src_mem_type );
578 
643 
712 
783 
820 err_t dma_close( dma_t *obj );
821  // drvdmagroup // drvgroup // pergroup
825 
826 #ifdef __cplusplus
827 }
828 #endif
829 
830 #endif // _DRV_DMA_H_
831 // ------------------------------------------------------------------------- END
dma_mode_t
dma_mode_t
Definition: drv_dma.h:110
drv_name.h
Pin and port name type definitions.
dma_set_mode
err_t dma_set_mode(dma_t *obj, dma_mode_t mode)
Set the DMA mode.
DMA_MODE_DEFAULT
Definition: drv_dma.h:115
DMA_SOURCE_MEMORY_REGION_RAM
Definition: drv_dma.h:76
DMA_DATA_ALIGN_BYTES_2
Definition: drv_dma.h:100
dma_channel_t
uint8_t dma_channel_t[DMA_NUM_OF_MODULES][DMA_NUM_OF_STREAMS_FAMILY][DMA_NUM_OF_CHANNELS_FAMILY]
Definition: drv_dma.h:152
DMA_BURST_SIZE_INCREMENT_16
Definition: drv_dma.h:140
dma_set_direction
err_t dma_set_direction(dma_t *obj, dma_direction_t direction)
Set the DMA direction.
dma_priority_t
dma_priority_t
Definition: drv_dma.h:121
dma_transfer_start
err_t dma_transfer_start(dma_t *obj)
Initializes the DMA transfer.
dma_set_priority
err_t dma_set_priority(dma_t *obj, dma_priority_t priority)
Set the DMA priority.
dma_direction_t
dma_direction_t
Definition: drv_dma.h:84
DMA_BURST_SIZE_INCREMENT_2
Definition: drv_dma.h:137
DMA_DIRECTION_PERIPH_TO_PERIPH
Definition: drv_dma.h:89
DMA_DIRECTION_MEMORY_TO_PERIPH
Definition: drv_dma.h:87
dma_get_channels
void dma_get_channels(dma_channel_t *channels)
Get DMA modules/streams/channels.
DMA_DIRECTION_PERIPH_TO_MEMORY
Definition: drv_dma.h:88
DMA_SUCCESS
Definition: drv_dma.h:58
DMA_PRIORITY_LOW
Definition: drv_dma.h:123
dma_config_t
DMA Configuration Structure prototype.
Definition: drv_dma.h:175
dma_set_transfer_config
err_t dma_set_transfer_config(dma_t *obj, uint32_t addr_src, uint32_t addr_dst, size_t transfer_size, dma_source_memory_region_t src_mem_type)
Configure the DMA transfer.
dma_configure_default
void dma_configure_default(dma_config_t *config)
Configure DMA Driver configuration structure.
dma_state_t
dma_state_t
Definition: drv_dma.h:65
dma_close
err_t dma_close(dma_t *obj)
Close DMA Driver object.
dma_transfer_abort
err_t dma_transfer_abort(dma_t *obj)
Aborts a DMA transfer.
DMA_DATA_ALIGN_DEFAULT
Definition: drv_dma.h:104
DMA_SOURCE_MEMORY_REGION_PFM
Definition: drv_dma.h:77
DMA_STATE_FREE
Definition: drv_dma.h:67
DMA_BURST_SIZE_INCREMENT_DEFAULT
Definition: drv_dma.h:143
dma_err_t
dma_err_t
Definition: drv_dma.h:56
DMA_PRIORITY_VERY_HIGH
Definition: drv_dma.h:126
DMA_PRIORITY_DEFAULT
Definition: drv_dma.h:128
DMA_DIRECTION_MEMORY_TO_MEMORY
Definition: drv_dma.h:86
DMA_PRIORITY_HIGH
Definition: drv_dma.h:125
DMA_DATA_ALIGN_BYTES_3
Definition: drv_dma.h:101
DMA_DATA_ALIGN_BYTES_1
Definition: drv_dma.h:99
DMA_MODE_CIRCULAR
Definition: drv_dma.h:113
dma_open
err_t dma_open(dma_t *obj, dma_config_t *config)
Open the DMA Driver object.
dma_source_memory_region_t
dma_source_memory_region_t
Definition: drv_dma.h:74
DMA_DIRECTION_DEFAULT
Definition: drv_dma.h:91
DMA_BURST_SIZE_INCREMENT_4
Definition: drv_dma.h:138
dma_t
DMA Handle prototype.
Definition: drv_dma.h:228
DMA_MODE_NORMAL
Definition: drv_dma.h:112
DMA_BURST_SIZE_INCREMENT_32
Definition: drv_dma.h:141
dma_burst_size_t
dma_burst_size_t
Definition: drv_dma.h:134
err_t
int32_t err_t
Definition: hal_target.h:63
DMA_BURST_SIZE_INCREMENT_8
Definition: drv_dma.h:139
DMA_DATA_ALIGN_BYTES_4
Definition: drv_dma.h:102
dma_data_align_t
dma_data_align_t
Definition: drv_dma.h:97
DMA_STATE_ALLOCATED
Definition: drv_dma.h:68
dma_transfer_stop
err_t dma_transfer_stop(dma_t *obj)
Stops the DMA transfer.
DMA_BURST_SIZE_INCREMENT_1
Definition: drv_dma.h:136
DMA_ERROR
Definition: drv_dma.h:59
DMA_PRIORITY_MEDIUM
Definition: drv_dma.h:124
DMA_SOURCE_MEMORY_REGION_DEEPROM
Definition: drv_dma.h:78