MAX32665 SDK Documentation  0.2
Software Development Kit Overview and API Documentation
dma.h
1 
6 /* ****************************************************************************
7  * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
23  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * Except as contained in this notice, the name of Maxim Integrated
28  * Products, Inc. shall not be used except as stated in the Maxim Integrated
29  * Products, Inc. Branding Policy.
30  *
31  * The mere transfer of this software does not imply any licenses
32  * of trade secrets, proprietary technology, copyrights, patents,
33  * trademarks, maskwork rights, or any other form of intellectual
34  * property whatsoever. Maxim Integrated Products, Inc. retains all
35  * ownership rights.
36  *
37  * $Date: 2019-07-01 10:59:30 -0500 (Mon, 01 Jul 2019) $
38  * $Revision: 44381 $
39  *
40  *************************************************************************** */
41 
42 #ifndef _DMA_H_
43 #define _DMA_H_
44 
45 /* **** Includes **** */
46 #include "mxc_config.h"
47 #include "dma_regs.h"
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
59 /* **** Definitions **** */
60 
64 typedef enum {
70 
72 typedef enum {
117 } dma_reqsel_t;
118 
120 typedef enum {
126 
128 typedef enum {
137 } dma_timeout_t;
138 
140 typedef enum {
141  /* Using the '_V_' define instead of the '_S_' since these same values will be used to
142  specify the DSTWD also. The API functions will shift the value the correct amount
143  prior to writing the cfg register. */
147 } dma_width_t;
148 
150 #define DMA_FALSE 0
151 #define DMA_TRUE 1
153 /* **** Function Prototypes **** */
154 
160 int DMA_Init(void);
161 
162 
172 int DMA_AcquireChannel(void);
173 
182 int DMA_ReleaseChannel(int ch);
183 
205 int DMA_ConfigChannel(int ch,
206  dma_priority_t prio,
207  dma_reqsel_t reqsel, unsigned int reqwait_en,
208  dma_timeout_t tosel, dma_prescale_t pssel,
209  dma_width_t srcwd, unsigned int srcinc_en,
210  dma_width_t dstwd, unsigned int dstinc_en,
211  unsigned int burst_size, unsigned int chdis_inten,
212  unsigned int ctz_inten);
213 
229 int DMA_SetSrcDstCnt(int ch,
230  void *src_addr,
231  void *dst_addr,
232  unsigned int count);
233 
246 int DMA_SetReload(int ch,
247  void *src_addr_reload,
248  void *dst_addr_reload,
249  unsigned int count_reload);
250 
273 int DMA_SetCallback(int ch, void (*callback)(int, int));
274 
281 int DMA_EnableInterrupt(int ch);
282 
289 int DMA_DisableInterrupt(int ch);
290 
298 int DMA_GetFlags(int ch, unsigned int *fl);
299 
306 int DMA_ClearFlags(int ch);
307 
315 int DMA_Start(int ch);
316 
323 int DMA_Stop(int ch);
324 
333 
341 void DMA_Handler(int ch);
342 
344 #ifdef __cplusplus
345 }
346 #endif
347 
348 #endif /* _DMA_H_ */
I2C0 Receive DMA Request Selection.
Definition: dma.h:79
#define MXC_S_DMA_CFG_REQSEL_UART2RX
CFG_REQSEL_UART2RX Setting.
Definition: dma_regs.h:282
#define MXC_S_DMA_CFG_REQSEL_USBRXEP7
CFG_REQSEL_USBRXEP7 Setting.
Definition: dma_regs.h:300
Memory to Memory DMA Request Selection.
Definition: dma.h:73
#define MXC_S_DMA_CFG_REQSEL_USBTXEP5
CFG_REQSEL_USBTXEP5 Setting.
Definition: dma_regs.h:338
#define MXC_S_DMA_CFG_REQSEL_USBRXEP5
CFG_REQSEL_USBRXEP5 Setting.
Definition: dma_regs.h:296
SPI1 Receive DMA Request Selection.
Definition: dma.h:75
High Priority.
Definition: dma.h:65
#define MXC_S_DMA_CFG_REQSEL_SPI0TX
CFG_REQSEL_SPI0TX Setting.
Definition: dma_regs.h:310
#define MXC_V_DMA_CFG_SRCWD_WORD
CFG_SRCWD_WORD Value.
Definition: dma_regs.h:391
Prescaler disabled.
Definition: dma.h:121
#define MXC_S_DMA_CFG_REQSEL_SPI_MSS0TX
CFG_REQSEL_SPI_MSS0TX Setting.
Definition: dma_regs.h:328
USB Receive Endpoint 6 DMA Request Selection.
Definition: dma.h:90
#define MXC_S_DMA_CFG_REQSEL_MEMTOMEM
CFG_REQSEL_MEMTOMEM Setting.
Definition: dma_regs.h:264
#define MXC_S_DMA_CFG_PSSEL_DIS
CFG_PSSEL_DIS Setting.
Definition: dma_regs.h:377
USB Receive Endpoint 9 DMA Request Selection.
Definition: dma.h:93
int DMA_ReleaseChannel(int ch)
Release DMA channel.
SPI1 Transmit DMA Request Selection.
Definition: dma.h:97
UART 2 Transmit DMA Request Selection.
Definition: dma.h:103
int DMA_EnableInterrupt(int ch)
Enable channel interrupt.
Medium High Priority.
Definition: dma.h:66
USB TX Endpoint 2 DMA Request Selection.
Definition: dma.h:107
DMA timeout of 256 clocks.
Definition: dma.h:135
#define MXC_S_DMA_CFG_REQSEL_USBTXEP11
CFG_REQSEL_USBTXEP11 Setting.
Definition: dma_regs.h:350
int DMA_Stop(int ch)
Stop DMA transfer, irrespective of status (complete or in-progress)
#define MXC_S_DMA_CFG_TOSEL_TO4
CFG_TOSEL_TO4 Setting.
Definition: dma_regs.h:358
#define MXC_S_DMA_CFG_REQSEL_SPI_MSS0RX
CFG_REQSEL_SPI_MSS0RX Setting.
Definition: dma_regs.h:286
UART1 Receive DMA Request Selection.
Definition: dma.h:78
dma_reqsel_t
DMA request select.
Definition: dma.h:72
SPI3 Transmit DMA Request Selection.
Definition: dma.h:104
#define MXC_S_DMA_CFG_REQSEL_USBTXEP10
CFG_REQSEL_USBTXEP10 Setting.
Definition: dma_regs.h:348
#define MXC_S_DMA_CFG_REQSEL_I2C0RX
CFG_REQSEL_I2C0RX Setting.
Definition: dma_regs.h:276
#define MXC_S_DMA_CFG_REQSEL_SPI3TX
CFG_REQSEL_SPI3TX Setting.
Definition: dma_regs.h:326
Structure type to access the DMA Registers.
Definition: dma_regs.h:88
dma_prescale_t
Enumeration for the DMA prescaler.
Definition: dma.h:120
#define MXC_S_DMA_CFG_REQSEL_SPI0RX
CFG_REQSEL_SPI0RX Setting.
Definition: dma_regs.h:266
I2C1 Receive DMA Request Selection.
Definition: dma.h:80
#define MXC_S_DMA_CFG_REQSEL_UART0RX
CFG_REQSEL_UART0RX Setting.
Definition: dma_regs.h:272
#define MXC_S_DMA_CFG_REQSEL_USBRXEP2
CFG_REQSEL_USBRXEP2 Setting.
Definition: dma_regs.h:290
UART0 Transmit DMA Request Selection.
Definition: dma.h:99
SPI0 Transmit DMA Request Selection.
Definition: dma.h:96
#define MXC_S_DMA_CFG_REQSEL_SPI1RX
CFG_REQSEL_SPI1RX Setting.
Definition: dma_regs.h:268
SPI3 Receive DMA Request Selection.
Definition: dma.h:83
USB Receive Endpoint 11 DMA Request Selection.
Definition: dma.h:95
#define MXC_S_DMA_CFG_TOSEL_TO32
CFG_TOSEL_TO32 Setting.
Definition: dma_regs.h:364
int DMA_AcquireChannel(void)
Request DMA channel.
USB TX Endpoint 4 DMA Request Selection.
Definition: dma.h:109
#define MXC_S_DMA_CFG_PRI_HIGH
CFG_PRI_HIGH Setting.
Definition: dma_regs.h:253
DMA transfer in 16-bit half-words.
Definition: dma.h:145
#define MXC_S_DMA_CFG_REQSEL_I2C1RX
CFG_REQSEL_I2C1RX Setting.
Definition: dma_regs.h:278
USB Receive Endpoint 8 DMA Request Selection.
Definition: dma.h:92
#define MXC_S_DMA_CFG_PSSEL_DIV64K
CFG_PSSEL_DIV64K Setting.
Definition: dma_regs.h:381
USB TX Endpoint 7 DMA Request Selection.
Definition: dma.h:112
dma_priority_t
Enumeration for the DMA Channel's priority level.
Definition: dma.h:64
#define MXC_S_DMA_CFG_REQSEL_USBTXEP1
CFG_REQSEL_USBTXEP1 Setting.
Definition: dma_regs.h:330
#define MXC_S_DMA_CFG_REQSEL_USBTXEP7
CFG_REQSEL_USBTXEP7 Setting.
Definition: dma_regs.h:342
USB TX Endpoint 10 DMA Request Selection.
Definition: dma.h:115
I2C1 Transmit DMA Request Selection.
Definition: dma.h:102
USB TX Endpoint 11 DMA Request Selection.
Definition: dma.h:116
USB TX Endpoint 1 DMA Request Selection.
Definition: dma.h:106
#define MXC_S_DMA_CFG_REQSEL_UART0TX
CFG_REQSEL_UART0TX Setting.
Definition: dma_regs.h:316
DMA timeout of 64 clocks.
Definition: dma.h:133
#define MXC_S_DMA_CFG_PSSEL_DIV16M
CFG_PSSEL_DIV16M Setting.
Definition: dma_regs.h:383
#define MXC_S_DMA_CFG_REQSEL_USBRXEP3
CFG_REQSEL_USBRXEP3 Setting.
Definition: dma_regs.h:292
DMA transfer in 32-bit words.
Definition: dma.h:146
#define MXC_S_DMA_CFG_REQSEL_SPI1TX
CFG_REQSEL_SPI1TX Setting.
Definition: dma_regs.h:312
dma_width_t
DMA transfer data width.
Definition: dma.h:140
USB Receive Endpoint 1 DMA Request Selection.
Definition: dma.h:85
#define MXC_S_DMA_CFG_REQSEL_SPI2RX
CFG_REQSEL_SPI2RX Setting.
Definition: dma_regs.h:270
#define MXC_S_DMA_CFG_REQSEL_UART1TX
CFG_REQSEL_UART1TX Setting.
Definition: dma_regs.h:318
USB Receive Endpoint 5 DMA Request Selection.
Definition: dma.h:89
#define MXC_S_DMA_CFG_TOSEL_TO16
CFG_TOSEL_TO16 Setting.
Definition: dma_regs.h:362
#define MXC_S_DMA_CFG_REQSEL_UART1RX
CFG_REQSEL_UART1RX Setting.
Definition: dma_regs.h:274
DMA timeout of 128 clocks.
Definition: dma.h:134
#define MXC_S_DMA_CFG_REQSEL_USBTXEP6
CFG_REQSEL_USBTXEP6 Setting.
Definition: dma_regs.h:340
#define MXC_S_DMA_CFG_REQSEL_USBTXEP9
CFG_REQSEL_USBTXEP9 Setting.
Definition: dma_regs.h:346
int DMA_GetFlags(int ch, unsigned int *fl)
Read channel interrupt flags.
Divide by 65,536.
Definition: dma.h:123
UART0 Receive DMA Request Selection.
Definition: dma.h:77
int DMA_DisableInterrupt(int ch)
Disable channel interrupt.
Divide by 256.
Definition: dma.h:122
USB TX Endpoint 9 DMA Request Selection.
Definition: dma.h:114
DMA timeout of 512 clocks.
Definition: dma.h:136
SPI2 Receive DMA Request Selection.
Definition: dma.h:76
#define MXC_S_DMA_CFG_TOSEL_TO8
CFG_TOSEL_TO8 Setting.
Definition: dma_regs.h:360
USB Receive Endpoint 4 DMA Request Selection.
Definition: dma.h:88
#define MXC_V_DMA_CFG_SRCWD_BYTE
CFG_SRCWD_BYTE Value.
Definition: dma_regs.h:387
DMA timeout of 8 clocks.
Definition: dma.h:130
#define MXC_S_DMA_CFG_REQSEL_USBTXEP4
CFG_REQSEL_USBTXEP4 Setting.
Definition: dma_regs.h:336
USB TX Endpoint 5 DMA Request Selection.
Definition: dma.h:110
mxc_dma_ch_regs_t * DMA_GetCHRegs(int ch)
Get a pointer to the DMA channel registers.
#define MXC_S_DMA_CFG_TOSEL_TO512
CFG_TOSEL_TO512 Setting.
Definition: dma_regs.h:372
#define MXC_S_DMA_CFG_PSSEL_DIV256
CFG_PSSEL_DIV256 Setting.
Definition: dma_regs.h:379
I2S Transmit DMA Request Selection.
Definition: dma.h:105
DMA timeout of 16 clocks.
Definition: dma.h:131
int DMA_SetSrcDstCnt(int ch, void *src_addr, void *dst_addr, unsigned int count)
Set channel source, destination, and count for transfer.
Low Priority.
Definition: dma.h:68
DMA transfer in bytes.
Definition: dma.h:144
UART1 Transmit DMA Request Selection.
Definition: dma.h:100
USB TX Endpoint 6 DMA Request Selection.
Definition: dma.h:111
#define MXC_S_DMA_CFG_REQSEL_UART2TX
CFG_REQSEL_UART2TX Setting.
Definition: dma_regs.h:324
#define MXC_S_DMA_CFG_TOSEL_TO128
CFG_TOSEL_TO128 Setting.
Definition: dma_regs.h:368
#define MXC_S_DMA_CFG_REQSEL_I2C0TX
CFG_REQSEL_I2C0TX Setting.
Definition: dma_regs.h:320
#define MXC_S_DMA_CFG_PRI_MEDLOW
CFG_PRI_MEDLOW Setting.
Definition: dma_regs.h:257
dma_timeout_t
Enumeration for the DMA timeout value.
Definition: dma.h:128
USB TX Endpoint 3 DMA Request Selection.
Definition: dma.h:108
DMA timeout of 4 clocks.
Definition: dma.h:129
SPI2 Transmit DMA Request Selection.
Definition: dma.h:98
#define MXC_S_DMA_CFG_REQSEL_USBRXEP1
CFG_REQSEL_USBRXEP1 Setting.
Definition: dma_regs.h:288
USB TX Endpoint 8 DMA Request Selection.
Definition: dma.h:113
Medium Low Priority.
Definition: dma.h:67
#define MXC_S_DMA_CFG_REQSEL_I2C1TX
CFG_REQSEL_I2C1TX Setting.
Definition: dma_regs.h:322
#define MXC_S_DMA_CFG_REQSEL_USBRXEP11
CFG_REQSEL_USBRXEP11 Setting.
Definition: dma_regs.h:308
I2S Receive DMA Request Selection.
Definition: dma.h:84
#define MXC_S_DMA_CFG_REQSEL_SPI3RX
CFG_REQSEL_SPI3RX Setting.
Definition: dma_regs.h:284
I2C0 Transmit DMA Request Selection.
Definition: dma.h:101
DMA timeout of 32 clocks.
Definition: dma.h:132
#define MXC_V_DMA_CFG_SRCWD_HALFWORD
CFG_SRCWD_HALFWORD Value.
Definition: dma_regs.h:389
USB Receive Endpoint 2 DMA Request Selection.
Definition: dma.h:86
#define MXC_S_DMA_CFG_REQSEL_USBTXEP8
CFG_REQSEL_USBTXEP8 Setting.
Definition: dma_regs.h:344
#define MXC_S_DMA_CFG_REQSEL_USBRXEP8
CFG_REQSEL_USBRXEP8 Setting.
Definition: dma_regs.h:302
#define MXC_S_DMA_CFG_TOSEL_TO256
CFG_TOSEL_TO256 Setting.
Definition: dma_regs.h:370
#define MXC_S_DMA_CFG_PRI_LOW
CFG_PRI_LOW Setting.
Definition: dma_regs.h:259
#define MXC_S_DMA_CFG_REQSEL_USBRXEP9
CFG_REQSEL_USBRXEP9 Setting.
Definition: dma_regs.h:304
int DMA_SetReload(int ch, void *src_addr_reload, void *dst_addr_reload, unsigned int count_reload)
Set channel reload values.
void DMA_Handler(int ch)
Interrupt handler function.
Divide by 16,777,216.
Definition: dma.h:124
UART2 Receive DMA Request Selection.
Definition: dma.h:82
ADC DMA Request Selection.
Definition: dma.h:81
int DMA_Start(int ch)
Start transfer.
#define MXC_S_DMA_CFG_REQSEL_USBTXEP2
CFG_REQSEL_USBTXEP2 Setting.
Definition: dma_regs.h:332
int DMA_Init(void)
Initialize DMA resources.
#define MXC_S_DMA_CFG_REQSEL_SPI2TX
CFG_REQSEL_SPI2TX Setting.
Definition: dma_regs.h:314
int DMA_SetCallback(int ch, void(*callback)(int, int))
Set channel interrupt callback.
#define MXC_S_DMA_CFG_TOSEL_TO64
CFG_TOSEL_TO64 Setting.
Definition: dma_regs.h:366
USB Receive Endpoint 7 DMA Request Selection.
Definition: dma.h:91
#define MXC_S_DMA_CFG_REQSEL_USBRXEP10
CFG_REQSEL_USBRXEP10 Setting.
Definition: dma_regs.h:306
#define MXC_S_DMA_CFG_REQSEL_USBTXEP3
CFG_REQSEL_USBTXEP3 Setting.
Definition: dma_regs.h:334
#define MXC_S_DMA_CFG_REQSEL_USBRXEP4
CFG_REQSEL_USBRXEP4 Setting.
Definition: dma_regs.h:294
#define MXC_S_DMA_CFG_REQSEL_USBRXEP6
CFG_REQSEL_USBRXEP6 Setting.
Definition: dma_regs.h:298
int DMA_ClearFlags(int ch)
Clear channel interrupt flags.
USB Receive Endpoint 10 DMA Request Selection.
Definition: dma.h:94
SPI0 Receive DMA Request Selection.
Definition: dma.h:74
USB Receive Endpoint 3 DMA Request Selection.
Definition: dma.h:87
int DMA_ConfigChannel(int ch, dma_priority_t prio, dma_reqsel_t reqsel, unsigned int reqwait_en, dma_timeout_t tosel, dma_prescale_t pssel, dma_width_t srcwd, unsigned int srcinc_en, dma_width_t dstwd, unsigned int dstinc_en, unsigned int burst_size, unsigned int chdis_inten, unsigned int ctz_inten)
Configure the DMA channel.
#define MXC_S_DMA_CFG_REQSEL_ADC
CFG_REQSEL_ADC Setting.
Definition: dma_regs.h:280
#define MXC_S_DMA_CFG_PRI_MEDHIGH
CFG_PRI_MEDHIGH Setting.
Definition: dma_regs.h:255