1 /***************************************************************************//**
2 * \file cy_dmac.h
3 * \version 1.20
4 *
5 * \brief
6 * The header file of the DMAC driver.
7 *
8 ********************************************************************************
9 * \copyright
10 * Copyright 2018-2020 Cypress Semiconductor Corporation
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *******************************************************************************/
25
26 /**
27 * \addtogroup group_dmac
28 * \{
29 * Configures the DMA Controller block, channels and descriptors.
30 *
31 * The functions and other declarations used in this driver are in cy_dmac.h.
32 * You can include cy_pdl.h to get access to all functions
33 * and declarations in the PDL.
34 *
35 * The DMA Controller channel can be used in any project to transfer data
36 * without CPU intervention basing on a hardware trigger signal from another component.
37 *
38 * The DMA Controller block has a set of registers, a base hardware address,
39 * and supports multiple channels. Many API functions for the DMAC driver require
40 * a base hardware address and channel number.
41 * Ensure that you use the correct hardware address for the DMA Controller block in use.
42 *
43 * Features:
44 * * Multiple channels (device specific).
45 * * Four priority levels for each channel.
46 * * Descriptor chaining.
47 * * Configurable data transfer width/masking: byte, half-word (2-byte), and word (4-byte).
48 * * Configurable source and destination addresses.
49 * * Single transfer, 1D, 2D, memory copy and scatter transfer descriptor types are supported.
50 * * Configurable input/output triggers and interrupts.
51 *
52 * \section group_dmac_configuration Configuration Considerations
53 *
54 * To set up a DMAC driver, initialize a descriptor,
55 * initialize and enable a channel, and enable the DMAC block.
56 *
57 * To set up a descriptor, provide the configuration parameters for the
58 * descriptor in the \ref cy_stc_dmac_descriptor_config_t structure. Then call the
59 * \ref Cy_DMAC_Descriptor_Init function to initialize the descriptor in SRAM. You can
60 * modify the source and destination addresses dynamically by calling
61 * \ref Cy_DMAC_Descriptor_SetSrcAddress and \ref Cy_DMAC_Descriptor_SetDstAddress.
62 *
63 * To set up a DMAC channel, provide a filled \ref cy_stc_dmac_channel_config_t
64 * structure. Call the \ref Cy_DMAC_Channel_Init function, specifying the channel
65 * number. Use \ref Cy_DMAC_Channel_Enable to enable the configured DMAC channel.
66 *
67 * Call \ref Cy_DMAC_Channel_Enable for each DMAC channel in use.
68 *
69 * When configured, another peripheral typically triggers the DMAC channel. The trigger is
70 * connected to the DMAC channel using the trigger multiplexer. The trigger multiplexer
71 * driver has a software trigger you can use in firmware to trigger the DMAC channel. See the
72 * <a href="group__group__trigmux.html">Trigger Multiplexer</a> documentation.
73 *
74 * The following is a simplified structure of the DMAC driver API interdependencies
75 * in a typical user application:
76 * \image html dmac.png
77 *
78 * <B>NOTE:</B> Even if a DMAC channel is enabled, it is not operational until
79 * the DMAC block is enabled using function \ref Cy_DMAC_Enable.\n
80 * <B>NOTE:</B> If the DMAC descriptor is configured to generate an interrupt,
81 * the interrupt must be enabled using the \ref Cy_DMAC_Channel_SetInterruptMask
82 * function for each DMAC channel.
83 *
84 * For example:
85 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Enable
86 *
87 * \section group_dmac_more_information More Information.
88 * See the DMAC chapter of the device technical reference manual (TRM).
89 *
90 * \section group_dmac_changelog Changelog
91 *
92 * <table class="doxtable">
93 * <tr><th>Version</th><th>Changes</th><th>Reason for Change</th></tr>
94 * <tr>
95 * <td>1.20</td>
96 * <td>Fixed MISRA 2012 violations.</td>
97 * <td>MISRA 2012 compliance.</td>
98 * </tr>
99 * <tr>
100 * <td>1.10.1</td>
101 * <td>Minor documentation updates.</td>
102 * <td>Documentation enhancement.</td>
103 * </tr>
104 * <tr>
105 * <td>1.10</td>
106 * <td>The \ref Cy_DMAC_Channel_ClearInterrupt is changed.</td>
107 * <td>Minor defect fixing.</td>
108 * </tr>
109 * <tr>
110 * <td>1.0</td>
111 * <td>The initial version.</td>
112 * <td></td>
113 * </tr>
114 * </table>
115 *
116 * \defgroup group_dmac_macros Macros
117 * \defgroup group_dmac_macros_interrupt_masks Interrupt Masks
118 * \defgroup group_dmac_functions Functions
119 * \{
120 * \defgroup group_dmac_block_functions Block Functions
121 * \defgroup group_dmac_channel_functions Channel Functions
122 * \defgroup group_dmac_descriptor_functions Descriptor Functions
123 * \}
124 * \defgroup group_dmac_data_structures Data Structures
125 * \defgroup group_dmac_enums Enumerated Types
126 */
127
128 #if !defined (CY_DMAC_H)
129 #define CY_DMAC_H
130
131 #include "cy_device.h"
132
133 #if defined (CY_IP_M4CPUSS_DMAC) || defined (CY_IP_MXAHBDMAC)
134
135 #include "cy_syslib.h"
136 #include <stdint.h>
137 #include <stdbool.h>
138 #include <stddef.h>
139
140 #if defined(__cplusplus)
141 extern "C" {
142 #endif
143
144 CY_MISRA_DEVIATE_BLOCK_START('MISRA C-2012 Rule 10.8', 13, \
145 'Value extracted from _VAL2FLD macro will not exceed enum range.');
146
147 /******************************************************************************
148 * Macro definitions *
149 ******************************************************************************/
150
151 /**
152 * \addtogroup group_dmac_macros
153 * \{
154 */
155
156 /** The driver major version */
157 #define CY_DMAC_DRV_VERSION_MAJOR 1
158
159 /** The driver minor version */
160 #define CY_DMAC_DRV_VERSION_MINOR 20
161
162 /** The DMAC driver identifier */
163 #define CY_DMAC_ID (CY_PDL_DRV_ID(0x3FU))
164
165 /** The minimum X/Y Count API parameters */
166 #define CY_DMAC_LOOP_COUNT_MIN (1UL)
167 /** The maximum X/Y Count API parameters */
168 #define CY_DMAC_LOOP_COUNT_MAX (65536UL)
169 /** The maximum X Count API parameter for scatter transfer */
170 #define CY_DMAC_SCATTER_COUNT_MAX (32768UL)
171
172 /** The minimum X/Y Increment API parameters */
173 #define CY_DMAC_LOOP_INCREMENT_MIN (-32768L)
174 /** The maximum X/Y Increment API parameters */
175 #define CY_DMAC_LOOP_INCREMENT_MAX (32767L)
176
177 /**
178 * \addtogroup group_dmac_macros_interrupt_masks Interrupt Masks
179 * \{
180 */
181
182 /** Bit 0: Completion of data transfer(s) as specified by the descriptor's interruptType setting. */
183 #define CY_DMAC_INTR_COMPLETION (DMAC_CH_V2_INTR_COMPLETION_Msk)
184 /** Bit 1: Bus error for a load from the source. */
185 #define CY_DMAC_INTR_SRC_BUS_ERROR (DMAC_CH_V2_INTR_SRC_BUS_ERROR_Msk)
186 /** Bit 2: Bus error for a store to the destination. */
187 #define CY_DMAC_INTR_DST_BUS_ERROR (DMAC_CH_V2_INTR_DST_BUS_ERROR_Msk)
188 /** Bit 3: Misalignment of the source address. */
189 #define CY_DMAC_INTR_SRC_MISAL (DMAC_CH_V2_INTR_SRC_MISAL_Msk)
190 /** Bit 4: Misalignment of the destination address. */
191 #define CY_DMAC_INTR_DST_MISAL (DMAC_CH_V2_INTR_DST_MISAL_Msk)
192 /** Bit 5: The channel is enabled and the current descriptor pointer is "0". */
193 #define CY_DMAC_INTR_CURR_PTR_NULL (DMAC_CH_V2_INTR_CURR_PTR_NULL_Msk)
194 /** Bit 6: The channel is disabled and the data transfer engine is busy. */
195 #define CY_DMAC_INTR_ACTIVE_CH_DISABLED (DMAC_CH_V2_INTR_ACTIVE_CH_DISABLED_Msk)
196 /** Bit 7: Bus error for a load of the descriptor. */
197 #define CY_DMAC_INTR_DESCR_BUS_ERROR (DMAC_CH_V2_INTR_DESCR_BUS_ERROR_Msk)
198
199 /** \} group_dmac_macros_interrupt_masks */
200
201 /** \} group_dmac_macros */
202
203
204 /**
205 * \addtogroup group_dmac_enums
206 * \{
207 */
208
209 /** Contains the options for the descriptor type */
210 typedef enum
211 {
212 CY_DMAC_SINGLE_TRANSFER = 0U, /**< Single transfer. */
213 CY_DMAC_1D_TRANSFER = 1U, /**< 1D transfer. */
214 CY_DMAC_2D_TRANSFER = 2U, /**< 2D transfer. */
215 CY_DMAC_MEMORY_COPY = 3U, /**< Memory copy. */
216 CY_DMAC_SCATTER_TRANSFER = 4U /**< Scatter transfer. */
217 } cy_en_dmac_descriptor_type_t;
218
219 /** Contains the options for the interrupt, trig-in and trig-out type parameters of the descriptor */
220 typedef enum
221 {
222 CY_DMAC_1ELEMENT = 0U, /**< One element transfer. */
223 CY_DMAC_X_LOOP = 1U, /**< One X loop transfer. */
224 CY_DMAC_DESCR = 2U, /**< One descriptor transfer. */
225 CY_DMAC_DESCR_CHAIN = 3U /**< Entire descriptor chain transfer. */
226 } cy_en_dmac_trigger_type_t;
227
228 /** Contains the options for the data size */
229 typedef enum
230 {
231 CY_DMAC_BYTE = 0U, /**< One byte. */
232 CY_DMAC_HALFWORD = 1U, /**< Half word (two bytes). */
233 CY_DMAC_WORD = 2U /**< Full word (four bytes). */
234 } cy_en_dmac_data_size_t;
235
236 /** Contains the options for descriptor retriggering */
237 typedef enum
238 {
239 CY_DMAC_RETRIG_IM = 0U, /**< Retrigger immediately. */
240 CY_DMAC_RETRIG_4CYC = 1U, /**< Retrigger after 4 Clk_Slow cycles. */
241 CY_DMAC_RETRIG_16CYC = 2U, /**< Retrigger after 16 Clk_Slow cycles. */
242 CY_DMAC_WAIT_FOR_REACT = 3U /**< Wait for trigger reactivation. */
243 } cy_en_dmac_retrigger_t;
244
245 /** Contains the options for the transfer size */
246 typedef enum
247 {
248 CY_DMAC_TRANSFER_SIZE_DATA = 0U, /**< As specified by dataSize. */
249 CY_DMAC_TRANSFER_SIZE_WORD = 1U, /**< A full word (four bytes). */
250 } cy_en_dmac_transfer_size_t;
251
252 /** Contains the options for the state of the channel when the descriptor is completed */
253 typedef enum
254 {
255 CY_DMAC_CHANNEL_ENABLED = 0U, /**< Channel stays enabled. */
256 CY_DMAC_CHANNEL_DISABLED = 1U /**< Channel is disabled. */
257 } cy_en_dmac_channel_state_t;
258
259 /** Contains the return values of the DMAC driver */
260 typedef enum
261 {
262 CY_DMAC_SUCCESS = 0x0UL, /**< Success. */
263 CY_DMAC_BAD_PARAM = CY_DMAC_ID | CY_PDL_STATUS_ERROR | 0x1UL /**< The input parameters passed to the DMAC API are not valid. */
264 } cy_en_dmac_status_t;
265
266 /** \} group_dmac_enums */
267
268 /** \cond Macros for the conditions used by CY_ASSERT calls */
269
270 #define CY_DMAC_IS_LOOP_COUNT_VALID(count) (((count) >= CY_DMAC_LOOP_COUNT_MIN) && ((count) <= CY_DMAC_LOOP_COUNT_MAX))
271 #define CY_DMAC_IS_SCATTER_COUNT_VALID(count) (((count) >= CY_DMAC_LOOP_COUNT_MIN) && ((count) <= CY_DMAC_SCATTER_COUNT_MAX))
272 #define CY_DMAC_IS_LOOP_INCR_VALID(incr) (((incr) >= CY_DMAC_LOOP_INCREMENT_MIN) && ((incr) <= CY_DMAC_LOOP_INCREMENT_MAX))
273 #define CY_DMAC_IS_PRIORITY_VALID(prio) ((prio) <= 3UL)
274
275 #define CY_DMAC_INTR_MASK (CY_DMAC_INTR_COMPLETION | \
276 CY_DMAC_INTR_SRC_BUS_ERROR | \
277 CY_DMAC_INTR_DST_BUS_ERROR | \
278 CY_DMAC_INTR_SRC_MISAL | \
279 CY_DMAC_INTR_DST_MISAL | \
280 CY_DMAC_INTR_CURR_PTR_NULL | \
281 CY_DMAC_INTR_ACTIVE_CH_DISABLED | \
282 CY_DMAC_INTR_DESCR_BUS_ERROR)
283
284 #define CY_DMAC_IS_INTR_MASK_VALID(intr) (0UL == ((intr) & ((uint32_t) ~CY_DMAC_INTR_MASK)))
285
286 #define CY_DMAC_IS_RETRIGGER_VALID(retrigger) ((CY_DMAC_RETRIG_IM == (retrigger)) || \
287 (CY_DMAC_RETRIG_4CYC == (retrigger)) || \
288 (CY_DMAC_RETRIG_16CYC == (retrigger)) || \
289 (CY_DMAC_WAIT_FOR_REACT == (retrigger)))
290
291 #define CY_DMAC_IS_TRIG_TYPE_VALID(trigType) ((CY_DMAC_1ELEMENT == (trigType)) || \
292 (CY_DMAC_X_LOOP == (trigType)) || \
293 (CY_DMAC_DESCR == (trigType)) || \
294 (CY_DMAC_DESCR_CHAIN == (trigType)))
295
296 #define CY_DMAC_IS_XFER_SIZE_VALID(xferSize) ((CY_DMAC_TRANSFER_SIZE_DATA == (xferSize)) || \
297 (CY_DMAC_TRANSFER_SIZE_WORD == (xferSize)))
298
299 #define CY_DMAC_IS_CHANNEL_STATE_VALID(state) ((CY_DMAC_CHANNEL_ENABLED == (state)) || \
300 (CY_DMAC_CHANNEL_DISABLED == (state)))
301
302 #define CY_DMAC_IS_DATA_SIZE_VALID(dataSize) ((CY_DMAC_BYTE == (dataSize)) || \
303 (CY_DMAC_HALFWORD == (dataSize)) || \
304 (CY_DMAC_WORD == (dataSize)))
305
306 #define CY_DMAC_IS_TYPE_VALID(descrType) ((CY_DMAC_SINGLE_TRANSFER == (descrType)) || \
307 (CY_DMAC_1D_TRANSFER == (descrType)) || \
308 (CY_DMAC_2D_TRANSFER == (descrType)) || \
309 (CY_DMAC_MEMORY_COPY == (descrType)) || \
310 (CY_DMAC_SCATTER_TRANSFER == (descrType)))
311
312 #define CY_DMAC_IS_CH_NR_VALID(chNr) (CY_DMAC_CH_NR > (chNr))
313
314 /** \endcond */
315
316
317 /**
318 * \addtogroup group_dmac_data_structures
319 * \{
320 */
321
322
323 /**
324 * DMAC descriptor structure type. It is a user-declared structure
325 * allocated in RAM. The DMAC HW requires a pointer to this structure to work with it.
326 *
327 * For advanced users: the descriptor can be allocated even in flash, however the user
328 * have to predefine all the structure items with constants manually,
329 * because the descriptor "Set" API functions (including \ref Cy_DMAC_Descriptor_Init())
330 * don't work with read-only descriptors.
331 */
332 typedef struct
333 {
334 uint32_t ctl; /*!< 0x00000000 Descriptor control */
335 uint32_t src; /*!< 0x00000004 Descriptor source */
336 uint32_t dst; /*!< 0x00000008 Descriptor destination */
337 uint32_t xSize; /*!< 0x0000000C Descriptor X loop size */
338 uint32_t xIncr; /*!< 0x00000010 Descriptor X loop increment */
339 uint32_t ySize; /*!< 0x00000014 Descriptor Y loop size */
340 uint32_t yIncr; /*!< 0x00000010 Descriptor Y loop increment */
341 uint32_t nextPtr; /*!< 0x00000014 Descriptor next pointer */
342 } cy_stc_dmac_descriptor_t;
343
344 /** \cond The next type-specific descriptor types are ONLY for internal API implementation. */
345
346 typedef cy_stc_dmac_descriptor_t cy_stc_dmac_dscr_2d_t;
347
348 typedef struct
349 {
350 uint32_t ctl;
351 uint32_t src;
352 uint32_t dst;
353 uint32_t nextPtr;
354 } cy_stc_dmac_dscr_single_t;
355
356 typedef struct
357 {
358 uint32_t ctl;
359 uint32_t src;
360 uint32_t xSize;
361 uint32_t nextPtr;
362 } cy_stc_dmac_dscr_scatter_t;
363
364 typedef struct
365 {
366 uint32_t ctl;
367 uint32_t src;
368 uint32_t dst;
369 uint32_t xSize;
370 uint32_t nextPtr;
371 } cy_stc_dmac_dscr_memcpy_t;
372
373 typedef struct
374 {
375 uint32_t ctl;
376 uint32_t src;
377 uint32_t dst;
378 uint32_t xSize;
379 uint32_t xIncr;
380 uint32_t nextPtr;
381 } cy_stc_dmac_dscr_1d_t;
382
383 /** \endcond */
384
385
386 /**
387 * This structure is a configuration structure pre-initialized by user
388 * and passed as a parameter to the \ref Cy_DMAC_Descriptor_Init().
389 * It can be allocated in RAM/flash (on user's choice).
390 * In case of flash allocation there is a possibility to reinitialize the descriptor in runtime.
391 * This structure has all the parameters of the descriptor as separate parameters.
392 * Most of these parameters are represented in the \ref cy_stc_dmac_descriptor_t structure as bit fields.
393 */
394 typedef struct
395 {
396 cy_en_dmac_retrigger_t retrigger; /**< Specifies whether the DMA controller should wait for the input trigger to be deactivated. */
397 cy_en_dmac_trigger_type_t interruptType; /**< Sets the event that triggers an interrupt. See \ref cy_en_dmac_trigger_type_t. */
398 cy_en_dmac_trigger_type_t triggerOutType; /**< Sets the event that triggers an output. See \ref cy_en_dmac_trigger_type_t. */
399 cy_en_dmac_channel_state_t channelState; /**< Specifies whether the channel is enabled or disabled on completion of descriptor see \ref cy_en_dmac_channel_state_t. */
400 cy_en_dmac_trigger_type_t triggerInType; /**< Sets what type of transfer is triggered. See \ref cy_en_dmac_trigger_type_t. */
401 bool dataPrefetch; /**< Source data transfers are initiated as soon as the channel is enabled, the current descriptor pointer is NOT "0"
402 * and there is space available in the channel's data FIFO.
403 */
404 cy_en_dmac_data_size_t dataSize; /**< The size of the data bus for transfer. See \ref cy_en_dmac_data_size_t.
405 * For memory copy and scatter descriptors this setting will be ignored.
406 */
407 cy_en_dmac_transfer_size_t srcTransferSize; /**< The source transfer size.
408 * For memory copy and scatter descriptors this setting will be ignored.
409 */
410 cy_en_dmac_transfer_size_t dstTransferSize; /**< The destination transfer size.
411 * For memory copy and scatter descriptors this setting will be ignored.
412 */
413 cy_en_dmac_descriptor_type_t descriptorType; /**< The type of the descriptor. See \ref cy_en_dmac_descriptor_type_t. */
414 void * srcAddress; /**< The source address of the transfer. */
415 void * dstAddress; /**< The destination address of the transfer. */
416 int32_t srcXincrement; /**< The address increment of the source after each X-loop transfer. Valid range is -32768...32767. */
417 int32_t dstXincrement; /**< The address increment of the destination after each X-loop transfer. Valid range is -32768...32767. */
418 uint32_t xCount; /**< The number of transfers in an X-loop. Valid range (for all descriptors except scatter transfer) is 1...65536.
419 * For memory copy descriptors, the X count is a nubmer of bytes (not a data transfer size).
420 * For scatter descriptors, the X count is a nubmer of [address, data] pairs (two words each). Valid range is 1...32768.
421 */
422 int32_t srcYincrement; /**< The address increment of the source after each Y-loop transfer. Valid range is -32768...32767. */
423 int32_t dstYincrement; /**< The address increment of the destination after each Y-loop transfer. Valid range is -32768...32767. */
424 uint32_t yCount; /**< The number of X-loops in the Y-loop. Valid range is 1...65536. */
425 cy_stc_dmac_descriptor_t * nextDescriptor; /**< The next descriptor to chain after completion. A NULL value will signify no chaining. */
426 } cy_stc_dmac_descriptor_config_t;
427
428 /** This structure holds the initialization values for the DMAC channel */
429 typedef struct
430 {
431 cy_stc_dmac_descriptor_t * descriptor; /**< The DMAC descriptor associated with the channel being initialized. */
432 uint32_t priority; /**< This parameter specifies the channel's priority. */
433 bool enable; /**< This parameter specifies if the channel is enabled after initializing. */
434 bool bufferable; /**< This parameter specifies whether a write transaction can complete.
435 * without waiting for the destination to accept the write transaction data.
436 */
437 } cy_stc_dmac_channel_config_t;
438
439 /** \} group_dmac_data_structures */
440
441
442 /**
443 * \addtogroup group_dmac_functions
444 * \{
445 */
446
447 __STATIC_INLINE void Cy_DMAC_Enable (DMAC_Type * base);
448 __STATIC_INLINE void Cy_DMAC_Disable (DMAC_Type * base);
449 __STATIC_INLINE uint32_t Cy_DMAC_GetActiveChannel (DMAC_Type const * base);
450
451
452 /**
453 * \addtogroup group_dmac_channel_functions
454 * \{
455 */
456 cy_en_dmac_status_t Cy_DMAC_Channel_Init (DMAC_Type * base, uint32_t channel, cy_stc_dmac_channel_config_t const * config);
457 void Cy_DMAC_Channel_DeInit (DMAC_Type * base, uint32_t channel);
458 __STATIC_INLINE void Cy_DMAC_Channel_SetDescriptor (DMAC_Type * base, uint32_t channel, cy_stc_dmac_descriptor_t const * descriptor);
459 __STATIC_INLINE void Cy_DMAC_Channel_Enable (DMAC_Type * base, uint32_t channel);
460 __STATIC_INLINE void Cy_DMAC_Channel_Disable (DMAC_Type * base, uint32_t channel);
461 __STATIC_INLINE void Cy_DMAC_Channel_SetPriority (DMAC_Type * base, uint32_t channel, uint32_t priority);
462 __STATIC_INLINE uint32_t Cy_DMAC_Channel_GetPriority (DMAC_Type const * base, uint32_t channel);
463 __STATIC_INLINE void * Cy_DMAC_Channel_GetCurrentSrcAddress (DMAC_Type const * base, uint32_t channel);
464 __STATIC_INLINE void * Cy_DMAC_Channel_GetCurrentDstAddress (DMAC_Type const * base, uint32_t channel);
465 __STATIC_INLINE uint32_t Cy_DMAC_Channel_GetCurrentXloopIndex (DMAC_Type const * base, uint32_t channel);
466 __STATIC_INLINE uint32_t Cy_DMAC_Channel_GetCurrentYloopIndex (DMAC_Type const * base, uint32_t channel);
467 __STATIC_INLINE cy_stc_dmac_descriptor_t *
468 Cy_DMAC_Channel_GetCurrentDescriptor (DMAC_Type const * base, uint32_t channel);
469 __STATIC_INLINE uint32_t Cy_DMAC_Channel_GetInterruptStatus (DMAC_Type const * base, uint32_t channel);
470 __STATIC_INLINE void Cy_DMAC_Channel_ClearInterrupt (DMAC_Type * base, uint32_t channel, uint32_t interrupt);
471 __STATIC_INLINE void Cy_DMAC_Channel_SetInterrupt (DMAC_Type * base, uint32_t channel, uint32_t interrupt);
472 __STATIC_INLINE uint32_t Cy_DMAC_Channel_GetInterruptMask (DMAC_Type const * base, uint32_t channel);
473 __STATIC_INLINE void Cy_DMAC_Channel_SetInterruptMask (DMAC_Type * base, uint32_t channel, uint32_t interrupt);
474 __STATIC_INLINE uint32_t Cy_DMAC_Channel_GetInterruptStatusMasked(DMAC_Type const * base, uint32_t channel);
475
476 /** \} group_dmac_channel_functions */
477
478
479 /**
480 * \addtogroup group_dmac_descriptor_functions
481 * \{
482 */
483
484 cy_en_dmac_status_t Cy_DMAC_Descriptor_Init (cy_stc_dmac_descriptor_t * descriptor, cy_stc_dmac_descriptor_config_t const * config);
485 void Cy_DMAC_Descriptor_DeInit(cy_stc_dmac_descriptor_t * descriptor);
486
487 void Cy_DMAC_Descriptor_SetNextDescriptor (cy_stc_dmac_descriptor_t * descriptor, cy_stc_dmac_descriptor_t const * nextDescriptor);
488 void Cy_DMAC_Descriptor_SetDescriptorType (cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_descriptor_type_t descriptorType);
489 __STATIC_INLINE void Cy_DMAC_Descriptor_SetSrcAddress (cy_stc_dmac_descriptor_t * descriptor, void const * srcAddress);
490 __STATIC_INLINE void Cy_DMAC_Descriptor_SetDstAddress (cy_stc_dmac_descriptor_t * descriptor, void const * dstAddress);
491 void Cy_DMAC_Descriptor_SetXloopDataCount (cy_stc_dmac_descriptor_t * descriptor, uint32_t xCount);
492 __STATIC_INLINE void Cy_DMAC_Descriptor_SetYloopDataCount (cy_stc_dmac_descriptor_t * descriptor, uint32_t yCount);
493 __STATIC_INLINE void Cy_DMAC_Descriptor_SetXloopSrcIncrement(cy_stc_dmac_descriptor_t * descriptor, int32_t srcXincrement);
494 __STATIC_INLINE void Cy_DMAC_Descriptor_SetXloopDstIncrement(cy_stc_dmac_descriptor_t * descriptor, int32_t dstXincrement);
495 __STATIC_INLINE void Cy_DMAC_Descriptor_SetYloopSrcIncrement(cy_stc_dmac_descriptor_t * descriptor, int32_t srcYincrement);
496 __STATIC_INLINE void Cy_DMAC_Descriptor_SetYloopDstIncrement(cy_stc_dmac_descriptor_t * descriptor, int32_t dstYincrement);
497 __STATIC_INLINE void Cy_DMAC_Descriptor_SetInterruptType (cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_trigger_type_t interruptType);
498 __STATIC_INLINE void Cy_DMAC_Descriptor_SetTriggerInType (cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_trigger_type_t triggerInType);
499 __STATIC_INLINE void Cy_DMAC_Descriptor_SetTriggerOutType (cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_trigger_type_t triggerOutType);
500 __STATIC_INLINE void Cy_DMAC_Descriptor_SetDataSize (cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_data_size_t dataSize);
501 __STATIC_INLINE void Cy_DMAC_Descriptor_SetSrcTransferSize (cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_transfer_size_t srcTransferSize);
502 __STATIC_INLINE void Cy_DMAC_Descriptor_SetDstTransferSize (cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_transfer_size_t dstTransferSize);
503 __STATIC_INLINE void Cy_DMAC_Descriptor_SetRetrigger (cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_retrigger_t retrigger);
504 __STATIC_INLINE void Cy_DMAC_Descriptor_SetChannelState (cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_channel_state_t channelState);
505
506 cy_stc_dmac_descriptor_t * Cy_DMAC_Descriptor_GetNextDescriptor (cy_stc_dmac_descriptor_t const * descriptor);
507 __STATIC_INLINE cy_en_dmac_descriptor_type_t Cy_DMAC_Descriptor_GetDescriptorType (cy_stc_dmac_descriptor_t const * descriptor);
508 __STATIC_INLINE void * Cy_DMAC_Descriptor_GetSrcAddress (cy_stc_dmac_descriptor_t const * descriptor);
509 __STATIC_INLINE void * Cy_DMAC_Descriptor_GetDstAddress (cy_stc_dmac_descriptor_t const * descriptor);
510 uint32_t Cy_DMAC_Descriptor_GetXloopDataCount (cy_stc_dmac_descriptor_t const * descriptor);
511 __STATIC_INLINE uint32_t Cy_DMAC_Descriptor_GetYloopDataCount (cy_stc_dmac_descriptor_t const * descriptor);
512 __STATIC_INLINE int32_t Cy_DMAC_Descriptor_GetXloopSrcIncrement(cy_stc_dmac_descriptor_t const * descriptor);
513 __STATIC_INLINE int32_t Cy_DMAC_Descriptor_GetXloopDstIncrement(cy_stc_dmac_descriptor_t const * descriptor);
514 __STATIC_INLINE int32_t Cy_DMAC_Descriptor_GetYloopSrcIncrement(cy_stc_dmac_descriptor_t const * descriptor);
515 __STATIC_INLINE int32_t Cy_DMAC_Descriptor_GetYloopDstIncrement(cy_stc_dmac_descriptor_t const * descriptor);
516 __STATIC_INLINE cy_en_dmac_trigger_type_t Cy_DMAC_Descriptor_GetInterruptType (cy_stc_dmac_descriptor_t const * descriptor);
517 __STATIC_INLINE cy_en_dmac_trigger_type_t Cy_DMAC_Descriptor_GetTriggerInType (cy_stc_dmac_descriptor_t const * descriptor);
518 __STATIC_INLINE cy_en_dmac_trigger_type_t Cy_DMAC_Descriptor_GetTriggerOutType (cy_stc_dmac_descriptor_t const * descriptor);
519 __STATIC_INLINE cy_en_dmac_data_size_t Cy_DMAC_Descriptor_GetDataSize (cy_stc_dmac_descriptor_t const * descriptor);
520 __STATIC_INLINE cy_en_dmac_transfer_size_t Cy_DMAC_Descriptor_GetSrcTransferSize (cy_stc_dmac_descriptor_t const * descriptor);
521 __STATIC_INLINE cy_en_dmac_transfer_size_t Cy_DMAC_Descriptor_GetDstTransferSize (cy_stc_dmac_descriptor_t const * descriptor);
522 __STATIC_INLINE cy_en_dmac_retrigger_t Cy_DMAC_Descriptor_GetRetrigger (cy_stc_dmac_descriptor_t const * descriptor);
523 __STATIC_INLINE cy_en_dmac_channel_state_t Cy_DMAC_Descriptor_GetChannelState (cy_stc_dmac_descriptor_t const * descriptor);
524
525 /** \} group_dmac_descriptor_functions */
526
527
528 /***************************************
529 * In-line Function Implementation
530 ***************************************/
531
532
533 /**
534 * \addtogroup group_dmac_block_functions
535 * \{
536 */
537
538
539 /*******************************************************************************
540 * Function Name: Cy_DMAC_Enable
541 ****************************************************************************//**
542 *
543 * Enables the DMACblock.
544 *
545 * \param base
546 * The pointer to the hardware DMAC block.
547 *
548 * \funcusage
549 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Enable
550 *
551 *******************************************************************************/
Cy_DMAC_Enable(DMAC_Type * base)552 __STATIC_INLINE void Cy_DMAC_Enable(DMAC_Type * base)
553 {
554 DMAC_CTL(base) |= DMAC_V2_CTL_ENABLED_Msk;
555 }
556
557
558 /*******************************************************************************
559 * Function Name: Cy_DMAC_Disable
560 ****************************************************************************//**
561 *
562 * Disables the DMACblock.
563 *
564 * \param base
565 * The pointer to the hardware DMAC block.
566 *
567 * \funcusage
568 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Disable
569 *
570 *******************************************************************************/
Cy_DMAC_Disable(DMAC_Type * base)571 __STATIC_INLINE void Cy_DMAC_Disable(DMAC_Type * base)
572 {
573 DMAC_CTL(base) &= (uint32_t) ~DMAC_V2_CTL_ENABLED_Msk;
574 }
575
576
577 /*******************************************************************************
578 * Function Name: Cy_DMAC_GetActiveChannel
579 ****************************************************************************//**
580 *
581 * Returns the status of the active/pending channels of the DMACblock.
582 *
583 * \param base
584 * The pointer to the hardware DMAC block.
585 *
586 * \return
587 * Returns a bit-field with all of the currently active/pending channels in the
588 * DMAC block.
589 *
590 * \funcusage
591 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Disable
592 *
593 *******************************************************************************/
Cy_DMAC_GetActiveChannel(DMAC_Type const * base)594 __STATIC_INLINE uint32_t Cy_DMAC_GetActiveChannel(DMAC_Type const * base)
595 {
596 return(_FLD2VAL(DMAC_V2_ACTIVE_ACTIVE, DMAC_ACTIVE(base)));
597 }
598
599 /** \} group_dmac_block_functions */
600
601
602 /**
603 * \addtogroup group_dmac_descriptor_functions
604 * \{
605 */
606
607
608 /*******************************************************************************
609 * Function Name: Cy_DMAC_Descriptor_SetSrcAddress
610 ****************************************************************************//**
611 *
612 * Sets the source address parameter for the specified descriptor.
613 *
614 * \param descriptor
615 * The descriptor structure instance.
616 *
617 * \param srcAddress
618 * The source address value for the descriptor.
619 *
620 * \funcusage
621 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
622 *
623 *******************************************************************************/
Cy_DMAC_Descriptor_SetSrcAddress(cy_stc_dmac_descriptor_t * descriptor,void const * srcAddress)624 __STATIC_INLINE void Cy_DMAC_Descriptor_SetSrcAddress(cy_stc_dmac_descriptor_t * descriptor, void const * srcAddress)
625 {
626 descriptor->src = (uint32_t) srcAddress;
627 }
628
629
630 /*******************************************************************************
631 * Function Name: Cy_DMAC_Descriptor_GetSrcAddress
632 ****************************************************************************//**
633 *
634 * Returns the source address of the specified descriptor.
635 *
636 * \param descriptor
637 * The descriptor structure instance.
638 *
639 * \return
640 * The source address value of the descriptor.
641 *
642 * \funcusage
643 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
644 *
645 *******************************************************************************/
Cy_DMAC_Descriptor_GetSrcAddress(cy_stc_dmac_descriptor_t const * descriptor)646 __STATIC_INLINE void * Cy_DMAC_Descriptor_GetSrcAddress(cy_stc_dmac_descriptor_t const * descriptor)
647 {
648 return ((void *) descriptor->src);
649 }
650
651
652 /*******************************************************************************
653 * Function Name: Cy_DMAC_Descriptor_SetDstAddress
654 ****************************************************************************//**
655 *
656 * Sets the destination address parameter for the specified descriptor.
657 *
658 * \param descriptor
659 * The descriptor structure instance.
660 *
661 * \param dstAddress
662 * The destination address value for the descriptor.
663 *
664 * \funcusage
665 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
666 *
667 *******************************************************************************/
Cy_DMAC_Descriptor_SetDstAddress(cy_stc_dmac_descriptor_t * descriptor,void const * dstAddress)668 __STATIC_INLINE void Cy_DMAC_Descriptor_SetDstAddress(cy_stc_dmac_descriptor_t * descriptor, void const * dstAddress)
669 {
670 CY_ASSERT_L1(CY_DMAC_SCATTER_TRANSFER != Cy_DMAC_Descriptor_GetDescriptorType(descriptor));
671
672 descriptor->dst = (uint32_t) dstAddress;
673 }
674
675
676 /*******************************************************************************
677 * Function Name: Cy_DMAC_Descriptor_GetDstAddress
678 ****************************************************************************//**
679 *
680 * Returns the destination address of the specified descriptor.
681 *
682 * \param descriptor
683 * The descriptor structure instance.
684 *
685 * \return
686 * The destination address value of the descriptor.
687 *
688 * \funcusage
689 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
690 *
691 *******************************************************************************/
Cy_DMAC_Descriptor_GetDstAddress(cy_stc_dmac_descriptor_t const * descriptor)692 __STATIC_INLINE void * Cy_DMAC_Descriptor_GetDstAddress(cy_stc_dmac_descriptor_t const * descriptor)
693 {
694 CY_ASSERT_L1(CY_DMAC_SCATTER_TRANSFER != Cy_DMAC_Descriptor_GetDescriptorType(descriptor));
695
696 return ((void *) descriptor->dst);
697 }
698
699
700 /*******************************************************************************
701 * Function Name: Cy_DMAC_Descriptor_SetInterruptType
702 ****************************************************************************//**
703 *
704 * Sets the interrupt type parameter for the specified descriptor.
705 *
706 * \param descriptor
707 * The descriptor structure instance.
708 *
709 * \param interruptType
710 * The interrupt type set for the descriptor. \ref cy_en_dmac_trigger_type_t
711 *
712 * \funcusage
713 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
714 *
715 *******************************************************************************/
Cy_DMAC_Descriptor_SetInterruptType(cy_stc_dmac_descriptor_t * descriptor,cy_en_dmac_trigger_type_t interruptType)716 __STATIC_INLINE void Cy_DMAC_Descriptor_SetInterruptType(cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_trigger_type_t interruptType)
717 {
718 CY_ASSERT_L3(CY_DMAC_IS_TRIG_TYPE_VALID(interruptType));
719
720 CY_REG32_CLR_SET(descriptor->ctl, DMAC_CH_V2_DESCR_CTL_INTR_TYPE, interruptType);
721 }
722
723
724 /*******************************************************************************
725 * Function Name: Cy_DMAC_Descriptor_GetInterruptType
726 ****************************************************************************//**
727 *
728 * Returns the Interrupt-Type of the specified descriptor.
729 *
730 * \param descriptor
731 * The descriptor structure instance.
732 *
733 * \return
734 * The Interrupt-Type \ref cy_en_dmac_trigger_type_t.
735 *
736 * \funcusage
737 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
738 *
739 *******************************************************************************/
Cy_DMAC_Descriptor_GetInterruptType(cy_stc_dmac_descriptor_t const * descriptor)740 __STATIC_INLINE cy_en_dmac_trigger_type_t Cy_DMAC_Descriptor_GetInterruptType(cy_stc_dmac_descriptor_t const * descriptor)
741 {
742 return((cy_en_dmac_trigger_type_t) _FLD2VAL(DMAC_CH_V2_DESCR_CTL_INTR_TYPE, descriptor->ctl));
743 }
744
745
746 /*******************************************************************************
747 * Function Name: Cy_DMAC_Descriptor_SetTriggerInType
748 ****************************************************************************//**
749 *
750 * Sets the Trigger In Type parameter for the specified descriptor.
751 *
752 * \param descriptor
753 * The descriptor structure instance.
754 *
755 * \param triggerInType
756 * The Trigger In Type parameter \ref cy_en_dmac_trigger_type_t
757 *
758 * \funcusage
759 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
760 *
761 *******************************************************************************/
Cy_DMAC_Descriptor_SetTriggerInType(cy_stc_dmac_descriptor_t * descriptor,cy_en_dmac_trigger_type_t triggerInType)762 __STATIC_INLINE void Cy_DMAC_Descriptor_SetTriggerInType(cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_trigger_type_t triggerInType)
763 {
764 CY_ASSERT_L3(CY_DMAC_IS_TRIG_TYPE_VALID(triggerInType));
765
766 CY_REG32_CLR_SET(descriptor->ctl, DMAC_CH_V2_DESCR_CTL_TR_IN_TYPE, triggerInType);
767 }
768
769
770 /*******************************************************************************
771 * Function Name: Cy_DMAC_Descriptor_GetTriggerInType
772 ****************************************************************************//**
773 *
774 * Returns the Trigger In Type of the specified descriptor.
775 *
776 * \param descriptor
777 * The descriptor structure instance.
778 *
779 * \return
780 * The Trigger In Type \ref cy_en_dmac_trigger_type_t
781 *
782 * \funcusage
783 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
784 *
785 *******************************************************************************/
Cy_DMAC_Descriptor_GetTriggerInType(cy_stc_dmac_descriptor_t const * descriptor)786 __STATIC_INLINE cy_en_dmac_trigger_type_t Cy_DMAC_Descriptor_GetTriggerInType(cy_stc_dmac_descriptor_t const * descriptor)
787 {
788 return((cy_en_dmac_trigger_type_t) _FLD2VAL(DMAC_CH_V2_DESCR_CTL_TR_IN_TYPE, descriptor->ctl));
789 }
790
791
792 /*******************************************************************************
793 * Function Name: Cy_DMAC_Descriptor_SetTriggerOutType
794 ****************************************************************************//**
795 *
796 * Sets the Trigger Out Type parameter for the specified descriptor.
797 *
798 * \param descriptor
799 * The descriptor structure instance.
800 *
801 * \param triggerOutType
802 * The Trigger Out Type set for the descriptor. \ref cy_en_dmac_trigger_type_t
803 *
804 * \funcusage
805 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
806 *
807 *******************************************************************************/
Cy_DMAC_Descriptor_SetTriggerOutType(cy_stc_dmac_descriptor_t * descriptor,cy_en_dmac_trigger_type_t triggerOutType)808 __STATIC_INLINE void Cy_DMAC_Descriptor_SetTriggerOutType(cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_trigger_type_t triggerOutType)
809 {
810 CY_ASSERT_L3(CY_DMAC_IS_TRIG_TYPE_VALID(triggerOutType));
811
812 CY_REG32_CLR_SET(descriptor->ctl, DMAC_CH_V2_DESCR_CTL_TR_OUT_TYPE, triggerOutType);
813 }
814
815
816 /*******************************************************************************
817 * Function Name: Cy_DMAC_Descriptor_GetTriggerOutType
818 ****************************************************************************//**
819 *
820 * Returns the Trigger Out Type of the specified descriptor.
821 *
822 * \param descriptor
823 * The descriptor structure instance.
824 *
825 * \return
826 * The Trigger Out Type parameter \ref cy_en_dmac_trigger_type_t.
827 *
828 * \funcusage
829 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
830 *
831 *******************************************************************************/
Cy_DMAC_Descriptor_GetTriggerOutType(cy_stc_dmac_descriptor_t const * descriptor)832 __STATIC_INLINE cy_en_dmac_trigger_type_t Cy_DMAC_Descriptor_GetTriggerOutType(cy_stc_dmac_descriptor_t const * descriptor)
833 {
834 return((cy_en_dmac_trigger_type_t) _FLD2VAL(DMAC_CH_V2_DESCR_CTL_TR_OUT_TYPE, descriptor->ctl));
835 }
836
837
838 /*******************************************************************************
839 * Function Name: Cy_DMAC_Descriptor_SetDataSize
840 ****************************************************************************//**
841 *
842 * Sets the Data Element Size parameter for the specified descriptor.
843 *
844 * \param descriptor
845 * The descriptor structure instance.
846 *
847 * \param dataSize
848 * The Data Element Size \ref cy_en_dmac_data_size_t
849 *
850 * \funcusage
851 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
852 *
853 *******************************************************************************/
Cy_DMAC_Descriptor_SetDataSize(cy_stc_dmac_descriptor_t * descriptor,cy_en_dmac_data_size_t dataSize)854 __STATIC_INLINE void Cy_DMAC_Descriptor_SetDataSize(cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_data_size_t dataSize)
855 {
856 CY_ASSERT_L3(CY_DMAC_IS_DATA_SIZE_VALID(dataSize));
857
858 CY_REG32_CLR_SET(descriptor->ctl, DMAC_CH_V2_DESCR_CTL_DATA_SIZE, dataSize);
859 }
860
861
862 /*******************************************************************************
863 * Function Name: Cy_DMAC_Descriptor_GetDataSize
864 ****************************************************************************//**
865 *
866 * Returns the Data Element Size of the specified descriptor.
867 *
868 * \param descriptor
869 * The descriptor structure instance.
870 *
871 * \return
872 * The Data Element Size \ref cy_en_dmac_data_size_t.
873 *
874 * \funcusage
875 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
876 *
877 *******************************************************************************/
Cy_DMAC_Descriptor_GetDataSize(cy_stc_dmac_descriptor_t const * descriptor)878 __STATIC_INLINE cy_en_dmac_data_size_t Cy_DMAC_Descriptor_GetDataSize(cy_stc_dmac_descriptor_t const * descriptor)
879 {
880 return((cy_en_dmac_data_size_t) _FLD2VAL(DMAC_CH_V2_DESCR_CTL_DATA_SIZE, descriptor->ctl));
881 }
882
883
884 /*******************************************************************************
885 * Function Name: Cy_DMAC_Descriptor_SetSrcTransferSize
886 ****************************************************************************//**
887 *
888 * Sets the Source Transfer Size parameter for the specified descriptor.
889 *
890 * \param descriptor
891 * The descriptor structure instance.
892 *
893 * \param srcTransferSize
894 * The Source Transfer Size \ref cy_en_dmac_transfer_size_t.
895 *
896 * \funcusage
897 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
898 *******************************************************************************/
Cy_DMAC_Descriptor_SetSrcTransferSize(cy_stc_dmac_descriptor_t * descriptor,cy_en_dmac_transfer_size_t srcTransferSize)899 __STATIC_INLINE void Cy_DMAC_Descriptor_SetSrcTransferSize(cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_transfer_size_t srcTransferSize)
900 {
901 CY_ASSERT_L3(CY_DMAC_IS_XFER_SIZE_VALID(srcTransferSize));
902
903 CY_REG32_CLR_SET(descriptor->ctl, DMAC_CH_V2_DESCR_CTL_SRC_TRANSFER_SIZE, srcTransferSize);
904 }
905
906
907 /*******************************************************************************
908 * Function Name: Cy_DMAC_Descriptor_GetSrcTransferSize
909 ****************************************************************************//**
910 *
911 * Returns the Source Transfer Size of the specified descriptor.
912 *
913 * \param descriptor
914 * The descriptor structure instance.
915 *
916 * \return
917 * The Source Transfer Size \ref cy_en_dmac_transfer_size_t.
918 *
919 * \funcusage
920 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
921 *
922 *******************************************************************************/
Cy_DMAC_Descriptor_GetSrcTransferSize(cy_stc_dmac_descriptor_t const * descriptor)923 __STATIC_INLINE cy_en_dmac_transfer_size_t Cy_DMAC_Descriptor_GetSrcTransferSize(cy_stc_dmac_descriptor_t const * descriptor)
924 {
925 return((cy_en_dmac_transfer_size_t) _FLD2VAL(DMAC_CH_V2_DESCR_CTL_SRC_TRANSFER_SIZE, descriptor->ctl));
926 }
927
928
929 /*******************************************************************************
930 * Function Name: Cy_DMAC_Descriptor_SetDstTransferSize
931 ****************************************************************************//**
932 *
933 * Sets the Destination Transfer Size parameter for the specified descriptor.
934 *
935 * \param descriptor
936 * The descriptor structure instance.
937 *
938 * \param dstTransferSize
939 * The Destination Transfer Size \ref cy_en_dmac_transfer_size_t.
940 *
941 * \funcusage
942 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
943 *
944 *******************************************************************************/
Cy_DMAC_Descriptor_SetDstTransferSize(cy_stc_dmac_descriptor_t * descriptor,cy_en_dmac_transfer_size_t dstTransferSize)945 __STATIC_INLINE void Cy_DMAC_Descriptor_SetDstTransferSize(cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_transfer_size_t dstTransferSize)
946 {
947 CY_ASSERT_L3(CY_DMAC_IS_XFER_SIZE_VALID(dstTransferSize));
948
949 CY_REG32_CLR_SET(descriptor->ctl, DMAC_CH_V2_DESCR_CTL_DST_TRANSFER_SIZE, dstTransferSize);
950 }
951
952
953 /*******************************************************************************
954 * Function Name: Cy_DMAC_Descriptor_GetDstTransferSize
955 ****************************************************************************//**
956 *
957 * Returns the Destination Transfer Size of the specified descriptor.
958 *
959 * \param descriptor
960 * The descriptor structure instance.
961 *
962 * \return
963 * The Destination Transfer Size \ref cy_en_dmac_transfer_size_t
964 *
965 * \funcusage
966 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
967 *
968 *******************************************************************************/
Cy_DMAC_Descriptor_GetDstTransferSize(cy_stc_dmac_descriptor_t const * descriptor)969 __STATIC_INLINE cy_en_dmac_transfer_size_t Cy_DMAC_Descriptor_GetDstTransferSize(cy_stc_dmac_descriptor_t const * descriptor)
970 {
971 return((cy_en_dmac_transfer_size_t) _FLD2VAL(DMAC_CH_V2_DESCR_CTL_DST_TRANSFER_SIZE, descriptor->ctl));
972 }
973
974
975 /*******************************************************************************
976 * Function Name: Cy_DMAC_Descriptor_SetRetrigger
977 ****************************************************************************//**
978 *
979 * Sets the retrigger value which specifies whether the controller should
980 * wait for the input trigger to be deactivated.
981 *
982 * \param descriptor
983 * The descriptor structure instance.
984 *
985 * \param retrigger
986 * The \ref cy_en_dmac_retrigger_t parameter specifies whether the controller
987 * should wait for the input trigger to be deactivated.
988 *
989 * \funcusage
990 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
991 *
992 *******************************************************************************/
Cy_DMAC_Descriptor_SetRetrigger(cy_stc_dmac_descriptor_t * descriptor,cy_en_dmac_retrigger_t retrigger)993 __STATIC_INLINE void Cy_DMAC_Descriptor_SetRetrigger(cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_retrigger_t retrigger)
994 {
995 CY_ASSERT_L3(CY_DMAC_IS_RETRIGGER_VALID(retrigger));
996
997 CY_REG32_CLR_SET(descriptor->ctl, DMAC_CH_V2_DESCR_CTL_WAIT_FOR_DEACT, retrigger);
998 }
999
1000
1001 /*******************************************************************************
1002 * Function Name: Cy_DMAC_Descriptor_GetRetrigger
1003 ****************************************************************************//**
1004 *
1005 * Returns a value which specifies whether the controller should
1006 * wait for the input trigger to be deactivated.
1007 *
1008 * \param descriptor
1009 * The descriptor structure instance.
1010 *
1011 * \return
1012 * The Retrigger setting \ref cy_en_dmac_retrigger_t.
1013 *
1014 * \funcusage
1015 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
1016 *
1017 *******************************************************************************/
Cy_DMAC_Descriptor_GetRetrigger(cy_stc_dmac_descriptor_t const * descriptor)1018 __STATIC_INLINE cy_en_dmac_retrigger_t Cy_DMAC_Descriptor_GetRetrigger(cy_stc_dmac_descriptor_t const * descriptor)
1019 {
1020 return((cy_en_dmac_retrigger_t) _FLD2VAL(DMAC_CH_V2_DESCR_CTL_WAIT_FOR_DEACT, descriptor->ctl));
1021 }
1022
1023
1024 /*******************************************************************************
1025 * Function Name: Cy_DMAC_Descriptor_GetDescriptorType
1026 ****************************************************************************//**
1027 *
1028 * Returns the descriptor's type of the specified descriptor.
1029 *
1030 * \param descriptor
1031 * The descriptor structure instance.
1032 *
1033 * \return
1034 * The descriptor type \ref cy_en_dmac_descriptor_type_t
1035 *
1036 * \funcusage
1037 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
1038 *
1039 *******************************************************************************/
Cy_DMAC_Descriptor_GetDescriptorType(cy_stc_dmac_descriptor_t const * descriptor)1040 __STATIC_INLINE cy_en_dmac_descriptor_type_t Cy_DMAC_Descriptor_GetDescriptorType(cy_stc_dmac_descriptor_t const * descriptor)
1041 {
1042 return((cy_en_dmac_descriptor_type_t) _FLD2VAL(DMAC_CH_V2_DESCR_CTL_DESCR_TYPE, descriptor->ctl));
1043 }
1044
1045
1046 /*******************************************************************************
1047 * Function Name: Cy_DMAC_Descriptor_SetChannelState
1048 ****************************************************************************//**
1049 *
1050 * Sets the channel state on completion of the specified descriptor.
1051 *
1052 * \param descriptor
1053 * The descriptor structure instance.
1054 *
1055 * \param channelState
1056 * The channel state \ref cy_en_dmac_channel_state_t.
1057 *
1058 * \funcusage
1059 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
1060 *
1061 *******************************************************************************/
Cy_DMAC_Descriptor_SetChannelState(cy_stc_dmac_descriptor_t * descriptor,cy_en_dmac_channel_state_t channelState)1062 __STATIC_INLINE void Cy_DMAC_Descriptor_SetChannelState(cy_stc_dmac_descriptor_t * descriptor, cy_en_dmac_channel_state_t channelState)
1063 {
1064 CY_ASSERT_L3(CY_DMAC_IS_CHANNEL_STATE_VALID(channelState));
1065
1066 CY_REG32_CLR_SET(descriptor->ctl, DMAC_CH_V2_DESCR_CTL_CH_DISABLE, channelState);
1067 }
1068
1069
1070 /*******************************************************************************
1071 * Function Name: Cy_DMAC_Descriptor_GetChannelState
1072 ****************************************************************************//**
1073 *
1074 * Returns the channel state on completion of the specified descriptor.
1075 *
1076 * \param descriptor
1077 * The descriptor structure instance.
1078 *
1079 * \return
1080 * The Channel State setting \ref cy_en_dmac_channel_state_t
1081 *
1082 * \funcusage
1083 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
1084 *
1085 *******************************************************************************/
Cy_DMAC_Descriptor_GetChannelState(cy_stc_dmac_descriptor_t const * descriptor)1086 __STATIC_INLINE cy_en_dmac_channel_state_t Cy_DMAC_Descriptor_GetChannelState(cy_stc_dmac_descriptor_t const * descriptor)
1087 {
1088 return((cy_en_dmac_channel_state_t) _FLD2VAL(DMAC_CH_V2_DESCR_CTL_CH_DISABLE, descriptor->ctl));
1089 }
1090
1091
1092 /*******************************************************************************
1093 * Function Name: Cy_DMAC_Descriptor_SetXloopSrcIncrement
1094 ****************************************************************************//**
1095 *
1096 * Sets the source increment parameter for the X loop of the specified
1097 * descriptor (for 1D or 2D descriptors only).
1098 *
1099 * \param descriptor
1100 * The descriptor structure instance.
1101 *
1102 * \param srcXincrement
1103 * The value of the source increment. The valid range is -32768 ... 32767.
1104 *
1105 * \funcusage
1106 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
1107 *
1108 *******************************************************************************/
Cy_DMAC_Descriptor_SetXloopSrcIncrement(cy_stc_dmac_descriptor_t * descriptor,int32_t srcXincrement)1109 __STATIC_INLINE void Cy_DMAC_Descriptor_SetXloopSrcIncrement(cy_stc_dmac_descriptor_t * descriptor, int32_t srcXincrement)
1110 {
1111 CY_ASSERT_L1(CY_DMAC_SINGLE_TRANSFER != Cy_DMAC_Descriptor_GetDescriptorType(descriptor));
1112 CY_ASSERT_L2(CY_DMAC_IS_LOOP_INCR_VALID(srcXincrement));
1113
1114 CY_REG32_CLR_SET(descriptor->xIncr, DMAC_CH_V2_DESCR_X_INCR_SRC_X, srcXincrement);
1115 }
1116
1117
1118 /*******************************************************************************
1119 * Function Name: Cy_DMAC_Descriptor_GetXloopSrcIncrement
1120 ****************************************************************************//**
1121 *
1122 * Returns the source increment parameter for the X loop of the specified
1123 * descriptor (for 1D or 2D descriptors only).
1124 *
1125 * \param descriptor
1126 * The descriptor structure instance.
1127 *
1128 * \return
1129 * The value of the source increment. The range is -32768 ... 32767.
1130 *
1131 * \funcusage
1132 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
1133 *
1134 *******************************************************************************/
Cy_DMAC_Descriptor_GetXloopSrcIncrement(cy_stc_dmac_descriptor_t const * descriptor)1135 __STATIC_INLINE int32_t Cy_DMAC_Descriptor_GetXloopSrcIncrement(cy_stc_dmac_descriptor_t const * descriptor)
1136 {
1137 CY_ASSERT_L1(CY_DMAC_SINGLE_TRANSFER != Cy_DMAC_Descriptor_GetDescriptorType(descriptor));
1138
1139 return ((int32_t) _FLD2VAL(DMAC_CH_V2_DESCR_X_INCR_SRC_X, descriptor->xIncr));
1140 }
1141
1142
1143 /*******************************************************************************
1144 * Function Name: Cy_DMAC_Descriptor_SetXloopDstIncrement
1145 ****************************************************************************//**
1146 *
1147 * Sets the destination increment parameter for the X loop for the specified
1148 * descriptor (for 1D or 2D descriptors only).
1149 *
1150 * \param descriptor
1151 * The descriptor structure instance.
1152 *
1153 * \param dstXincrement
1154 * The value of the destination increment. The valid range is -32768 ... 32767.
1155 *
1156 * \funcusage
1157 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
1158 *
1159 *******************************************************************************/
Cy_DMAC_Descriptor_SetXloopDstIncrement(cy_stc_dmac_descriptor_t * descriptor,int32_t dstXincrement)1160 __STATIC_INLINE void Cy_DMAC_Descriptor_SetXloopDstIncrement(cy_stc_dmac_descriptor_t * descriptor, int32_t dstXincrement)
1161 {
1162 CY_ASSERT_L1(CY_DMAC_SINGLE_TRANSFER != Cy_DMAC_Descriptor_GetDescriptorType(descriptor));
1163 CY_ASSERT_L2(CY_DMAC_IS_LOOP_INCR_VALID(dstXincrement));
1164
1165 CY_REG32_CLR_SET(descriptor->xIncr, DMAC_CH_V2_DESCR_X_INCR_DST_X, dstXincrement);
1166 }
1167
1168
1169 /*******************************************************************************
1170 * Function Name: Cy_DMAC_Descriptor_GetXloopDstIncrement
1171 ****************************************************************************//**
1172 *
1173 * Returns the destination increment parameter for the X loop of the specified
1174 * descriptor (for 1D or 2D descriptors only).
1175 *
1176 * \param descriptor
1177 * The descriptor structure instance.
1178 *
1179 * \return
1180 * The value of the destination increment. The range is -32768 ... 32767.
1181 *
1182 * \funcusage
1183 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
1184 *
1185 *******************************************************************************/
Cy_DMAC_Descriptor_GetXloopDstIncrement(cy_stc_dmac_descriptor_t const * descriptor)1186 __STATIC_INLINE int32_t Cy_DMAC_Descriptor_GetXloopDstIncrement(cy_stc_dmac_descriptor_t const * descriptor)
1187 {
1188 CY_ASSERT_L1(CY_DMAC_SINGLE_TRANSFER != Cy_DMAC_Descriptor_GetDescriptorType(descriptor));
1189
1190 return ((int32_t) _FLD2VAL(DMAC_CH_V2_DESCR_X_INCR_DST_X, descriptor->xIncr));
1191 }
1192
1193
1194 /*******************************************************************************
1195 * Function Name: Cy_DMAC_Descriptor_SetYloopDataCount
1196 ****************************************************************************//**
1197 *
1198 * Sets the number of data elements for the Y loop of the specified descriptor
1199 * (for 2D descriptors only).
1200 *
1201 * \param descriptor
1202 * The descriptor structure instance.
1203 *
1204 * \param yCount
1205 * The number of X loops to execute in the Y loop. The valid range is 1 ... 65536.
1206 *
1207 * \funcusage
1208 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
1209 *
1210 *******************************************************************************/
Cy_DMAC_Descriptor_SetYloopDataCount(cy_stc_dmac_descriptor_t * descriptor,uint32_t yCount)1211 __STATIC_INLINE void Cy_DMAC_Descriptor_SetYloopDataCount(cy_stc_dmac_descriptor_t * descriptor, uint32_t yCount)
1212 {
1213 CY_ASSERT_L1(CY_DMAC_2D_TRANSFER == Cy_DMAC_Descriptor_GetDescriptorType(descriptor));
1214 CY_ASSERT_L2(CY_DMAC_IS_LOOP_COUNT_VALID(yCount));
1215 /* Convert the data count from the user's range (1-65536) into the machine range (0-65535). */
1216 CY_REG32_CLR_SET(descriptor->ySize, DMAC_CH_V2_DESCR_Y_SIZE_Y_COUNT, yCount - 1UL);
1217 }
1218
1219
1220 /*******************************************************************************
1221 * Function Name: Cy_DMAC_Descriptor_GetYloopDataCount
1222 ****************************************************************************//**
1223 *
1224 * Returns the number of X loops to execute in the Y loop of the specified
1225 * descriptor (for 2D descriptors only).
1226 *
1227 * \param descriptor
1228 * The descriptor structure instance.
1229 *
1230 * \return
1231 * The number of X loops to execute in the Y loop. The range is 1 ... 65536.
1232 *
1233 * \funcusage
1234 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
1235 *
1236 *******************************************************************************/
Cy_DMAC_Descriptor_GetYloopDataCount(cy_stc_dmac_descriptor_t const * descriptor)1237 __STATIC_INLINE uint32_t Cy_DMAC_Descriptor_GetYloopDataCount(cy_stc_dmac_descriptor_t const * descriptor)
1238 {
1239 CY_ASSERT_L1(CY_DMAC_2D_TRANSFER == Cy_DMAC_Descriptor_GetDescriptorType(descriptor));
1240 /* Convert the data count from the machine range (0-65535) into the user's range (1-65536). */
1241 return (_FLD2VAL(DMAC_CH_V2_DESCR_Y_SIZE_Y_COUNT, descriptor->ySize) + 1UL);
1242 }
1243
1244
1245 /*******************************************************************************
1246 * Function Name: Cy_DMAC_Descriptor_SetYloopSrcIncrement
1247 ****************************************************************************//**
1248 *
1249 * Sets the source increment parameter for the Y loop for the specified
1250 * descriptor (for 2D descriptors only).
1251 *
1252 * \param descriptor
1253 * The descriptor structure instance.
1254 *
1255 * \param srcYincrement
1256 * The value of the source increment. The valid range is -32768 ... 32767.
1257 *
1258 * \funcusage
1259 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
1260 *
1261 *******************************************************************************/
Cy_DMAC_Descriptor_SetYloopSrcIncrement(cy_stc_dmac_descriptor_t * descriptor,int32_t srcYincrement)1262 __STATIC_INLINE void Cy_DMAC_Descriptor_SetYloopSrcIncrement(cy_stc_dmac_descriptor_t * descriptor, int32_t srcYincrement)
1263 {
1264 CY_ASSERT_L1(CY_DMAC_2D_TRANSFER == Cy_DMAC_Descriptor_GetDescriptorType(descriptor));
1265 CY_ASSERT_L2(CY_DMAC_IS_LOOP_INCR_VALID(srcYincrement));
1266
1267 CY_REG32_CLR_SET(descriptor->yIncr, DMAC_CH_V2_DESCR_Y_INCR_SRC_Y, srcYincrement);
1268 }
1269
1270
1271 /*******************************************************************************
1272 * Function Name: Cy_DMAC_Descriptor_GetYloopSrcIncrement
1273 ****************************************************************************//**
1274 *
1275 * Returns the source increment parameter for the Y loop of the specified
1276 * descriptor (for 2D descriptors only).
1277 *
1278 * \param descriptor
1279 * The descriptor structure instance.
1280 *
1281 * \return
1282 * The value of source increment. The range is -32768 ... 32767.
1283 *
1284 * \funcusage
1285 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
1286 *
1287 *******************************************************************************/
Cy_DMAC_Descriptor_GetYloopSrcIncrement(cy_stc_dmac_descriptor_t const * descriptor)1288 __STATIC_INLINE int32_t Cy_DMAC_Descriptor_GetYloopSrcIncrement(cy_stc_dmac_descriptor_t const * descriptor)
1289 {
1290 CY_ASSERT_L1(CY_DMAC_2D_TRANSFER == Cy_DMAC_Descriptor_GetDescriptorType(descriptor));
1291
1292 return ((int32_t) _FLD2VAL(DMAC_CH_V2_DESCR_Y_INCR_SRC_Y, descriptor->yIncr));
1293 }
1294
1295
1296 /*******************************************************************************
1297 * Function Name: Cy_DMAC_Descriptor_SetYloopDstIncrement
1298 ****************************************************************************//**
1299 *
1300 * Sets the destination increment parameter for the Y loop of the specified
1301 * descriptor (for 2D descriptors only).
1302 *
1303 * \param descriptor
1304 * The descriptor structure instance.
1305 *
1306 * \param dstYincrement
1307 * The value of the destination increment. The valid range is -32768 ... 32767.
1308 *
1309 * \funcusage
1310 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_SetterFunctions
1311 *
1312 *******************************************************************************/
Cy_DMAC_Descriptor_SetYloopDstIncrement(cy_stc_dmac_descriptor_t * descriptor,int32_t dstYincrement)1313 __STATIC_INLINE void Cy_DMAC_Descriptor_SetYloopDstIncrement(cy_stc_dmac_descriptor_t * descriptor, int32_t dstYincrement)
1314 {
1315 CY_ASSERT_L1(CY_DMAC_2D_TRANSFER == Cy_DMAC_Descriptor_GetDescriptorType(descriptor));
1316 CY_ASSERT_L2(CY_DMAC_IS_LOOP_INCR_VALID(dstYincrement));
1317
1318 CY_REG32_CLR_SET(descriptor->yIncr, DMAC_CH_V2_DESCR_Y_INCR_DST_Y, dstYincrement);
1319 }
1320
1321
1322 /*******************************************************************************
1323 * Function Name: Cy_DMAC_Descriptor_GetYloopDstIncrement
1324 ****************************************************************************//**
1325 *
1326 * Returns the destination increment parameter for the Y loop of the specified
1327 * descriptor (for 2D descriptors only).
1328 *
1329 * \param descriptor
1330 * The descriptor structure instance.
1331 *
1332 * \return
1333 * The value of the destination increment. The range is -32768 ... 32767.
1334 *
1335 * \funcusage
1336 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_GetterFunctions
1337 *
1338 *******************************************************************************/
Cy_DMAC_Descriptor_GetYloopDstIncrement(cy_stc_dmac_descriptor_t const * descriptor)1339 __STATIC_INLINE int32_t Cy_DMAC_Descriptor_GetYloopDstIncrement(cy_stc_dmac_descriptor_t const * descriptor)
1340 {
1341 CY_ASSERT_L1(CY_DMAC_2D_TRANSFER == Cy_DMAC_Descriptor_GetDescriptorType(descriptor));
1342
1343 return ((int32_t) _FLD2VAL(DMAC_CH_V2_DESCR_Y_INCR_DST_Y, descriptor->yIncr));
1344 }
1345
1346 /** \} group_dmac_descriptor_functions */
1347
1348
1349 /**
1350 * \addtogroup group_dmac_channel_functions
1351 * \{
1352 */
1353
1354
1355 /*******************************************************************************
1356 * Function Name: Cy_DMAC_Channel_SetDescriptor
1357 ****************************************************************************//**
1358 *
1359 * Sets a descriptor as current for the specified DMACchannel.
1360 *
1361 * \param base
1362 * The pointer to the hardware DMAC block.
1363 *
1364 * \param channel
1365 * The channel number.
1366 *
1367 * \param descriptor
1368 * This is the descriptor to be associated with the channel.
1369 *
1370 * \funcusage
1371 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Enable
1372 *
1373 *******************************************************************************/
Cy_DMAC_Channel_SetDescriptor(DMAC_Type * base,uint32_t channel,cy_stc_dmac_descriptor_t const * descriptor)1374 __STATIC_INLINE void Cy_DMAC_Channel_SetDescriptor(DMAC_Type * base, uint32_t channel, cy_stc_dmac_descriptor_t const * descriptor)
1375 {
1376 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1377
1378 DMAC_CH_CURR(base, channel) = (uint32_t)descriptor;
1379 }
1380
1381
1382 /*******************************************************************************
1383 * Function Name: Cy_DMAC_Channel_Enable
1384 ****************************************************************************//**
1385 *
1386 * Enables a DMAC channel.
1387 *
1388 * \param base
1389 * The pointer to the hardware DMAC block.
1390 *
1391 * \param channel
1392 * The channel number.
1393 *
1394 * \funcusage
1395 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Enable
1396 *
1397 *******************************************************************************/
Cy_DMAC_Channel_Enable(DMAC_Type * base,uint32_t channel)1398 __STATIC_INLINE void Cy_DMAC_Channel_Enable(DMAC_Type * base, uint32_t channel)
1399 {
1400 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1401
1402 DMAC_CH_CTL(base, channel) |= DMAC_CH_V2_CTL_ENABLED_Msk;
1403 }
1404
1405
1406 /*******************************************************************************
1407 * Function Name: Cy_DMAC_Channel_Disable
1408 ****************************************************************************//**
1409 *
1410 * Disables a DMACchannel.
1411 *
1412 * \param base
1413 * The pointer to the hardware DMAC block.
1414 *
1415 * \param channel
1416 * The channel number.
1417 *
1418 * \funcusage
1419 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Disable
1420 *
1421 *******************************************************************************/
Cy_DMAC_Channel_Disable(DMAC_Type * base,uint32_t channel)1422 __STATIC_INLINE void Cy_DMAC_Channel_Disable(DMAC_Type * base, uint32_t channel)
1423 {
1424 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1425
1426 DMAC_CH_CTL(base, channel) &= (uint32_t) ~DMAC_CH_V2_CTL_ENABLED_Msk;
1427 }
1428
1429
1430 /*******************************************************************************
1431 * Function Name: Cy_DMAC_Channel_SetPriority
1432 ****************************************************************************//**
1433 *
1434 * The function is used to set a priority for the DMAC channel.
1435 *
1436 * \param base
1437 * The pointer to the hardware DMAC block.
1438 *
1439 * \param channel
1440 * The channel number.
1441 *
1442 * \param priority
1443 * The priority to be set for the DMAC channel. The allowed values are 0,1,2,3.
1444 *
1445 * \funcusage
1446 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Enable
1447 *
1448 *******************************************************************************/
Cy_DMAC_Channel_SetPriority(DMAC_Type * base,uint32_t channel,uint32_t priority)1449 __STATIC_INLINE void Cy_DMAC_Channel_SetPriority(DMAC_Type * base, uint32_t channel, uint32_t priority)
1450 {
1451 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1452 CY_ASSERT_L2(CY_DMAC_IS_PRIORITY_VALID(priority));
1453
1454 CY_REG32_CLR_SET(DMAC_CH_CTL(base, channel), DMAC_CH_V2_CTL_PRIO, priority);
1455 }
1456
1457
1458 /*******************************************************************************
1459 * Function Name: Cy_DMAC_Channel_GetPriority
1460 ****************************************************************************//**
1461 *
1462 * Returns the priority of the DMAC channel.
1463 *
1464 * \param base
1465 * The pointer to the hardware DMAC block.
1466 *
1467 * \param channel
1468 * The channel number.
1469 *
1470 * \return
1471 * The priority of the channel.
1472 *
1473 * \funcusage
1474 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Disable
1475 *
1476 *******************************************************************************/
Cy_DMAC_Channel_GetPriority(DMAC_Type const * base,uint32_t channel)1477 __STATIC_INLINE uint32_t Cy_DMAC_Channel_GetPriority(DMAC_Type const * base, uint32_t channel)
1478 {
1479 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1480
1481 return ((uint32_t) _FLD2VAL(DMAC_CH_V2_CTL_PRIO, DMAC_CH_CTL(base, channel)));
1482 }
1483
1484
1485 /*******************************************************************************
1486 * Function Name: Cy_DMAC_Channel_GetCurrentSrcAddress
1487 ****************************************************************************//**
1488 *
1489 * Returns the source address being used for the current transfer.
1490 *
1491 * \param base
1492 * The pointer to the hardware DMAC block.
1493 *
1494 * \param channel
1495 * The channel number.
1496 *
1497 * \return
1498 * Returns the pointer to the source of transfer.
1499 *
1500 * \funcusage
1501 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Channel_GetCurrentSrcAddress
1502 *
1503 *******************************************************************************/
Cy_DMAC_Channel_GetCurrentSrcAddress(DMAC_Type const * base,uint32_t channel)1504 __STATIC_INLINE void * Cy_DMAC_Channel_GetCurrentSrcAddress(DMAC_Type const * base, uint32_t channel)
1505 {
1506 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1507
1508 return ((void *)(DMAC_CH_DESCR_SRC(base, channel)));
1509 }
1510
1511
1512 /*******************************************************************************
1513 * Function Name: Cy_DMAC_Channel_GetCurrentDstAddress
1514 ****************************************************************************//**
1515 *
1516 * Returns the destination address being used for the current transfer.
1517 *
1518 * \param base
1519 * The pointer to the hardware DMAC block.
1520 *
1521 * \param channel
1522 * The channel number.
1523 *
1524 * \return
1525 * Returns the pointer to the destination of transfer.
1526 *
1527 * \funcusage
1528 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Channel_GetCurrentSrcAddress
1529 *
1530 *******************************************************************************/
Cy_DMAC_Channel_GetCurrentDstAddress(DMAC_Type const * base,uint32_t channel)1531 __STATIC_INLINE void * Cy_DMAC_Channel_GetCurrentDstAddress(DMAC_Type const * base, uint32_t channel)
1532 {
1533 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1534
1535 return ((void *)(DMAC_CH_DESCR_DST(base, channel)));
1536 }
1537
1538
1539 /*******************************************************************************
1540 * Function Name: Cy_DMAC_Channel_GetCurrentXloopIndex
1541 ****************************************************************************//**
1542 *
1543 * Returns the current transfer X-loop index.
1544 *
1545 * \param base
1546 * The pointer to the hardware DMAC block.
1547 *
1548 * \param channel
1549 * The channel number.
1550 *
1551 * \return
1552 * Returns the current transfer X-loop index.
1553 *
1554 * \funcusage
1555 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Channel_GetCurrentloopIndex
1556 *
1557 *******************************************************************************/
Cy_DMAC_Channel_GetCurrentXloopIndex(DMAC_Type const * base,uint32_t channel)1558 __STATIC_INLINE uint32_t Cy_DMAC_Channel_GetCurrentXloopIndex(DMAC_Type const * base, uint32_t channel)
1559 {
1560 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1561
1562 return (_FLD2VAL(DMAC_CH_V2_IDX_X, DMAC_CH_IDX(base, channel)));
1563 }
1564
1565
1566 /*******************************************************************************
1567 * Function Name: Cy_DMAC_Channel_GetCurrentYloopIndex
1568 ****************************************************************************//**
1569 *
1570 * Returns the current transfer X-loop index.
1571 *
1572 * \param base
1573 * The pointer to the hardware DMAC block.
1574 *
1575 * \param channel
1576 * The channel number.
1577 *
1578 * \return
1579 * Returns the current transfer X-loop index.
1580 *
1581 * \funcusage
1582 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Channel_GetCurrentloopIndex
1583 *
1584 *******************************************************************************/
Cy_DMAC_Channel_GetCurrentYloopIndex(DMAC_Type const * base,uint32_t channel)1585 __STATIC_INLINE uint32_t Cy_DMAC_Channel_GetCurrentYloopIndex(DMAC_Type const * base, uint32_t channel)
1586 {
1587 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1588
1589 return (_FLD2VAL(DMAC_CH_V2_IDX_Y, DMAC_CH_IDX(base, channel)));
1590 }
1591
1592
1593 /*******************************************************************************
1594 * Function Name: Cy_DMAC_Channel_GetCurrentDescriptor
1595 ****************************************************************************//**
1596 *
1597 * Returns the descriptor that is active in the channel.
1598 *
1599 * \param base
1600 * The pointer to the hardware DMAC block.
1601 *
1602 * \param channel
1603 * The channel number.
1604 *
1605 * \return
1606 * The pointer to the descriptor associated with the channel.
1607 *
1608 * \funcusage
1609 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_Descriptor_Deinit
1610 *
1611 *******************************************************************************/
Cy_DMAC_Channel_GetCurrentDescriptor(DMAC_Type const * base,uint32_t channel)1612 __STATIC_INLINE cy_stc_dmac_descriptor_t * Cy_DMAC_Channel_GetCurrentDescriptor(DMAC_Type const * base, uint32_t channel)
1613 {
1614 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1615
1616 return ((cy_stc_dmac_descriptor_t*)(DMAC_CH_CURR(base, channel)));
1617 }
1618
1619
1620 /*******************************************************************************
1621 * Function Name: Cy_DMAC_Channel_GetInterruptStatus
1622 ****************************************************************************//**
1623 *
1624 * Returns the interrupt status of the specified channel.
1625 *
1626 * \param base
1627 * The pointer to the hardware DMAC block.
1628 *
1629 * \param channel
1630 * The channel number.
1631 *
1632 * \return
1633 * The interrupt status, see \ref group_dmac_macros_interrupt_masks.
1634 *
1635 * \funcusage
1636 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_GetInterruptStatus
1637 *
1638 *******************************************************************************/
Cy_DMAC_Channel_GetInterruptStatus(DMAC_Type const * base,uint32_t channel)1639 __STATIC_INLINE uint32_t Cy_DMAC_Channel_GetInterruptStatus(DMAC_Type const * base, uint32_t channel)
1640 {
1641 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1642
1643 return (DMAC_CH_INTR(base, channel));
1644 }
1645
1646
1647 /*******************************************************************************
1648 * Function Name: Cy_DMAC_Channel_ClearInterrupt
1649 ****************************************************************************//**
1650 *
1651 * Clears the interrupt status of the specified channel.
1652 *
1653 * \param base
1654 * The pointer to the hardware DMAC block.
1655 *
1656 * \param channel
1657 * The channel number.
1658 *
1659 * \param interrupt
1660 * The interrupt mask, see \ref group_dmac_macros_interrupt_masks.
1661 *
1662 * \funcusage
1663 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_ClearInterrupt
1664 *
1665 *******************************************************************************/
Cy_DMAC_Channel_ClearInterrupt(DMAC_Type * base,uint32_t channel,uint32_t interrupt)1666 __STATIC_INLINE void Cy_DMAC_Channel_ClearInterrupt(DMAC_Type * base, uint32_t channel, uint32_t interrupt)
1667 {
1668 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1669 CY_ASSERT_L2(CY_DMAC_IS_INTR_MASK_VALID(interrupt));
1670
1671 DMAC_CH_INTR(base, channel) = interrupt;
1672 (void) DMAC_CH_INTR(base, channel);
1673 }
1674
1675
1676 /*******************************************************************************
1677 * Function Name: Cy_DMAC_Channel_SetInterrupt
1678 ****************************************************************************//**
1679 *
1680 * Sets the interrupt for the specified channel.
1681 *
1682 * \param base
1683 * The pointer to the hardware DMAC block.
1684 *
1685 * \param channel
1686 * The channel number.
1687 *
1688 * \param interrupt
1689 * The interrupt mask. See \ref group_dmac_macros_interrupt_masks.
1690 *
1691 * \funcusage
1692 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_SetInterruptMask
1693 *
1694 *******************************************************************************/
Cy_DMAC_Channel_SetInterrupt(DMAC_Type * base,uint32_t channel,uint32_t interrupt)1695 __STATIC_INLINE void Cy_DMAC_Channel_SetInterrupt(DMAC_Type * base, uint32_t channel, uint32_t interrupt)
1696 {
1697 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1698 CY_ASSERT_L2(CY_DMAC_IS_INTR_MASK_VALID(interrupt));
1699
1700 DMAC_CH_INTR_SET(base, channel) = interrupt;
1701 }
1702
1703
1704 /*******************************************************************************
1705 * Function Name: Cy_DMAC_Channel_GetInterruptMask
1706 ****************************************************************************//**
1707 *
1708 * Returns the interrupt mask value of the specified channel.
1709 *
1710 * \param base
1711 * The pointer to the hardware DMAC block.
1712 *
1713 * \param channel
1714 * The channel number.
1715 *
1716 * \return
1717 * The interrupt mask value. See \ref group_dmac_macros_interrupt_masks.
1718 *
1719 * \funcusage
1720 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_SetInterruptMask
1721 *
1722 *******************************************************************************/
Cy_DMAC_Channel_GetInterruptMask(DMAC_Type const * base,uint32_t channel)1723 __STATIC_INLINE uint32_t Cy_DMAC_Channel_GetInterruptMask(DMAC_Type const * base, uint32_t channel)
1724 {
1725 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1726
1727 return (DMAC_CH_INTR_MASK(base, channel));
1728 }
1729
1730
1731 /*******************************************************************************
1732 * Function Name: Cy_DMAC_Channel_SetInterruptMask
1733 ****************************************************************************//**
1734 *
1735 * Sets an interrupt mask value for the specified channel.
1736 *
1737 * \param base
1738 * The pointer to the hardware DMAC block.
1739 *
1740 * \param channel
1741 * The channel number.
1742 *
1743 * \param interrupt
1744 * The interrupt mask, see \ref group_dmac_macros_interrupt_masks.
1745 *
1746 * \funcusage
1747 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_SetInterruptMask
1748 *
1749 *******************************************************************************/
Cy_DMAC_Channel_SetInterruptMask(DMAC_Type * base,uint32_t channel,uint32_t interrupt)1750 __STATIC_INLINE void Cy_DMAC_Channel_SetInterruptMask(DMAC_Type * base, uint32_t channel, uint32_t interrupt)
1751 {
1752 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1753 CY_ASSERT_L2(CY_DMAC_IS_INTR_MASK_VALID(interrupt));
1754 DMAC_CH_INTR_MASK(base, channel) = interrupt;
1755 }
1756
1757
1758 /*******************************************************************************
1759 * Function Name: Cy_DMAC_Channel_GetInterruptStatusMasked
1760 ****************************************************************************//**
1761 *
1762 * Returns the logical AND of the corresponding INTR and INTR_MASK fields
1763 * in a single-load operation.
1764 *
1765 * \param base
1766 * The pointer to the hardware DMAC block.
1767 *
1768 * \param channel
1769 * The channel number.
1770 *
1771 * \return
1772 * The masked interrupt status. See \ref group_dmac_macros_interrupt_masks.
1773 *
1774 * \funcusage
1775 * \snippet dmac/snippet/main.c snippet_Cy_DMAC_ClearInterrupt
1776 *
1777 *******************************************************************************/
Cy_DMAC_Channel_GetInterruptStatusMasked(DMAC_Type const * base,uint32_t channel)1778 __STATIC_INLINE uint32_t Cy_DMAC_Channel_GetInterruptStatusMasked(DMAC_Type const * base, uint32_t channel)
1779 {
1780 CY_ASSERT_L1(CY_DMAC_IS_CH_NR_VALID(channel));
1781
1782 return (DMAC_CH_INTR_MASKED(base, channel));
1783 }
1784
1785 /** \} group_dmac_channel_functions */
1786
1787 /** \} group_dmac_functions */
1788
1789 CY_MISRA_BLOCK_END('MISRA C-2012 Rule 10.8');
1790
1791 #if defined(__cplusplus)
1792 }
1793 #endif
1794
1795 #endif /* CY_IP_M4CPUSS_DMAC, CY_IP_MXAHBDMAC */
1796
1797 #endif /* !defined (CY_DMAC_H) */
1798
1799 /** \} group_dmac */
1800
1801
1802 /* [] END OF FILE */
1803