1 /***************************************************************************//**
2 * \file cy_dma.h
3 * \version 2.70
4 *
5 * \brief
6 * The header file of the DMA driver.
7 *
8 ********************************************************************************
9 * \copyright
10 * Copyright 2016-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_dma
28 * \{
29 * Configures a DMA channel and its descriptor(s).
30 *
31 * The functions and other declarations used in this driver are in cy_dma.h.
32 * You can include cy_pdl.h to get access to all functions
33 * and declarations in the PDL.
34 *
35 * The DMA 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 * A device may support more than one DMA hardware block. Each block has a set of
39 * registers, a base hardware address, and supports multiple channels.
40 * Many API functions for the DMA driver require a base hardware address and
41 * channel number. Ensure that you use the correct hardware address for the DMA block in use.
42 *
43 * Features:
44 * * Multiple DW blocks (device specific)
45 * * Multiple channels per each DW block (device specific)
46 * * Four priority levels for each channel
47 * * Byte, half-word (2-byte), and word (4-byte) transfers
48 * * Configurable source and destination addresses
49 * * CRC calculation support (only for CPUSS_ver2)
50 *
51 * \section group_dma_configuration Configuration Considerations
52 *
53 * To set up a DMA driver, initialize a descriptor,
54 * initialize and enable a channel, and enable the DMA block.
55 *
56 * To set up a descriptor, provide the configuration parameters for the
57 * descriptor in the \ref cy_stc_dma_descriptor_config_t structure. Then call the
58 * \ref Cy_DMA_Descriptor_Init function to initialize the descriptor in SRAM. You can
59 * modify the source and destination addresses dynamically by calling
60 * \ref Cy_DMA_Descriptor_SetSrcAddress and \ref Cy_DMA_Descriptor_SetDstAddress.
61 *
62 * To set up a DMA channel, provide a filled \ref cy_stc_dma_channel_config_t
63 * structure. Call the \ref Cy_DMA_Channel_Init function, specifying the channel
64 * number. Use \ref Cy_DMA_Channel_Enable to enable the configured DMA channel.
65 *
66 * Call \ref Cy_DMA_Channel_Enable for each DMA channel in use.
67 *
68 * When configured, another peripheral typically triggers the DMA. The trigger is
69 * connected to the DMA using the trigger multiplexer. The trigger multiplexer
70 * driver has a software trigger you can use in firmware to trigger the DMA. See the
71 * <a href="group__group__trigmux.html">Trigger Multiplexer</a> documentation.
72 *
73 * The following is a simplified structure of the DMA driver API interdependencies
74 * in a typical user application:
75 * \image html dma.png
76 *
77 * <B>NOTE:</B> DMA will read descriptors from SRAM memory. To run DMA on devices with Core CM7,
78 * D cache needs to be cleaned before DMA transfer and should be invalidated after DMA transfer. \n
79 * <B>NOTE:</B> Even if a DMA channel is enabled, it is not operational until
80 * the DMA block is enabled using function \ref Cy_DMA_Enable.\n
81 * <B>NOTE:</B> If the DMA descriptor is configured to generate an interrupt,
82 * the interrupt must be enabled using the \ref Cy_DMA_Channel_SetInterruptMask
83 * function for each DMA channel.
84 *
85 * For example:
86 * \snippet dma/snippet/main.c snippet_Cy_DMA_Enable
87 *
88 * CM7 cores in CAT1C devices support Data Cache. Data Cache line is 32 bytes.
89 * User needs to make sure that the source and destination buffer pointers and the config structure pointers passed
90 * to the following functions points to 32 byte aligned data.
91 * Cy_DMA_Channel_SetDescriptor, Cy_DMA_Descriptor_SetNextDescriptor, Cy_DMA_Descriptor_SetSrcAddress, Cy_DMA_Descriptor_SetDstAddress.
92 * User can use CY_ALIGN(32) macro for 32 byte alignment.
93 * User needs to clean the following data elements from the cache and invalidate before accessing them.
94 * source and destination buffers and descriptor structure.
95 * * \snippet dma/snippet/main.c snippet_Cy_DMA_Cache_usage
96 *
97 * \section group_dma_more_information More Information.
98 * See: the DMA chapter of the device technical reference manual (TRM);
99 *      the DMA Component datasheet;
100 *      CE219940 - PSoC 6 MCU Multiple DMA Concatenation.
101 *
102 * \section group_dma_changelog Changelog
103 *
104 * <table class="doxtable">
105 *   <tr><th>Version</th><th>Changes</th><th>Reason for Change</th></tr>
106 *   <tr>
107 *     <td>2.70</td>
108 *     <td>Updated \ref Cy_DMA_Descriptor_SetNextDescriptor and \ref Cy_DMA_Descriptor_GetNextDescriptor.</td>
109 *     <td>Coverity bug fixes.</td>
110 *   </tr>
111 *   <tr>
112 *     <td>2.60</td>
113 *     <td>Fixed MISRA 2012 violations and minor documentation update.</td>
114 *     <td>MISRA 2012 compliance.</td>
115 *   </tr>
116 *   <tr>
117 *     <td>2.50</td>
118 *     <td>Fixed MISRA 2012 violations.</td>
119 *     <td>MISRA 2012 compliance.</td>
120 *   </tr>
121 *   <tr>
122 *     <td>2.40.1</td>
123 *     <td>Minor documentation updates.</td>
124 *     <td>Update to configure DMA on core CM7.</td>
125 *   </tr>
126 *   <tr>
127 *     <td>2.40</td>
128 *     <td>Minor Bug fixes.</td>
129 *     <td>Check for valid parameters.</td>
130 *   </tr>
131 *   <tr>
132 *     <td>2.30</td>
133 *     <td>Fixed MISRA 2012 violations.</td>
134 *     <td>MISRA 2012 compliance.</td>
135 *   </tr>
136 *   <tr>
137 *     <td>2.20.1</td>
138 *     <td>Minor documentation updates.</td>
139 *     <td>Documentation enhancement.</td>
140 *   </tr>
141 *   <tr>
142 *     <td>2.20</td>
143 *     <td>The channel number validation method is updated.</td>
144 *     <td>New devices support.</td>
145 *   </tr>
146 *   <tr>
147 *     <td rowspan="3">2.10</td>
148 *     <td>Flattened the organization of the driver source code into the single source directory and the single include directory.</td>
149 *     <td>Driver library directory-structure simplification.</td>
150 *   </tr>
151 *   <tr>
152 *     <td>Added CRC mode and the CRC descriptor support. \n Added the \ref Cy_DMA_Crc_Init function.</td>
153 *     <td>New devices support.</td>
154 *   </tr>
155 *   <tr>
156 *     <td>Added register access layer. Use register access macros instead
157 *         of direct register access using dereferenced pointers.</td>
158 *     <td>Makes register access device-independent, so that the PDL does
159 *         not need to be recompiled for each supported part number.</td>
160 *   </tr>
161 *   <tr>
162 *     <td>2.0.1</td>
163 *     <td>Changed CY_DMA_BWC macro values from Boolean to numeric</td>
164 *     <td>Improvements made based on usability feedback</td>
165 *   </tr>
166 *   <tr>
167 *     <td>2.0</td>
168 *     <td> * All the API is refactored to be consistent within itself and with the
169 *            rest of the PDL content.
170 *          * The descriptor API is updated as follows:
171 *            The \ref Cy_DMA_Descriptor_Init function sets a full bunch of descriptor
172 *            settings, and the rest of the descriptor API is a get/set interface
173 *            to each of the descriptor settings.
174 *          * There is a group of macros to support the backward compatibility with most
175 *            of the driver version 1.0 API. But, you should use
176 *            the new v2.0 interface in new designs (do not just copy-paste from old
177 *            projects). To enable the backward compatibility support, the CY_DMA_BWC
178 *            definition should be changed to "1".</td>
179 *     <td></td>
180 *   </tr>
181 *   <tr>
182 *     <td>1.0</td>
183 *     <td>Initial version</td>
184 *     <td></td>
185 *   </tr>
186 * </table>
187 *
188 
189 * \defgroup group_dma_macros Macros
190 * \defgroup group_dma_functions Functions
191 * \{
192 * \defgroup group_dma_block_functions Block Functions
193 * \defgroup group_dma_channel_functions Channel Functions
194 * \defgroup group_dma_descriptor_functions Descriptor Functions
195 * \}
196 * \defgroup group_dma_data_structures Data Structures
197 * \defgroup group_dma_enums Enumerated Types
198 */
199 
200 #if !defined (CY_DMA_H)
201 #define CY_DMA_H
202 
203 #include "cy_device.h"
204 
205 #if defined (CY_IP_M4CPUSS_DMA) || defined (CY_IP_MXDW) || defined (CY_IP_M7CPUSS_DMA)
206 
207 #include "cy_syslib.h"
208 #include <stdint.h>
209 #include <stdbool.h>
210 #include <stddef.h>
211 
212 #if defined(__cplusplus)
213 extern "C" {
214 #endif
215 
216 CY_MISRA_DEVIATE_BLOCK_START('MISRA C-2012 Rule 10.8', 15, \
217 'Value extracted from _VAL2FLD macro will not exceed enum range.')
218 
219 /******************************************************************************
220  * Macro definitions                                                          *
221  ******************************************************************************/
222 
223 /**
224 * \addtogroup group_dma_macros
225 * \{
226 */
227 
228 /** The driver major version */
229 #define CY_DMA_DRV_VERSION_MAJOR       2
230 
231 /** The driver minor version */
232 #define CY_DMA_DRV_VERSION_MINOR       70
233 
234 /** The DMA driver identifier */
235 #define CY_DMA_ID                      (CY_PDL_DRV_ID(0x13U))
236 
237 /** The DMA channel interrupt mask */
238 #define CY_DMA_INTR_MASK               (0x01UL)
239 
240 /** The minimum X/Y Count API parameters */
241 #define CY_DMA_LOOP_COUNT_MIN          (1UL)
242 /** The maximum X/Y Count API parameters */
243 #define CY_DMA_LOOP_COUNT_MAX          (256UL)
244 
245 /** The minimum X/Y Increment API parameters */
246 #define CY_DMA_LOOP_INCREMENT_MIN      (-2048L)
247 /** The maximum X/Y Increment API parameters */
248 #define CY_DMA_LOOP_INCREMENT_MAX      (2047L)
249 
250 /** The backward compatibility flag. Enables a group of macros which provide
251 * the backward compatibility with most of the DMA driver version 1.0 interface. */
252 #ifndef CY_DMA_BWC
253     #define CY_DMA_BWC                 (0U) /* Disabled by default */
254 #endif
255 
256 /** \} group_dma_macros */
257 
258 /**
259 * \addtogroup group_dma_enums
260 * \{
261 */
262 
263 /** Contains the possible interrupt cause values */
264 typedef enum
265 {
266     CY_DMA_INTR_CAUSE_NO_INTR            = 0U, /**< No interrupt.                       */
267     CY_DMA_INTR_CAUSE_COMPLETION         = 1U, /**< Completion.                         */
268     CY_DMA_INTR_CAUSE_SRC_BUS_ERROR      = 2U, /**< Source bus error.                   */
269     CY_DMA_INTR_CAUSE_DST_BUS_ERROR      = 3U, /**< Destination bus error.              */
270     CY_DMA_INTR_CAUSE_SRC_MISAL          = 4U, /**< Source address is not aligned.       */
271     CY_DMA_INTR_CAUSE_DST_MISAL          = 5U, /**< Destination address is not aligned. */
272     CY_DMA_INTR_CAUSE_CURR_PTR_NULL      = 6U, /**< Current descriptor pointer is NULL. */
273     CY_DMA_INTR_CAUSE_ACTIVE_CH_DISABLED = 7U, /**< Active channel is disabled.         */
274     CY_DMA_INTR_CAUSE_DESCR_BUS_ERROR    = 8U  /**< Descriptor bus error.               */
275 } cy_en_dma_intr_cause_t;
276 
277 /** Contains the options for the descriptor type */
278 typedef enum
279 {
280     CY_DMA_SINGLE_TRANSFER = 0UL,          /**< Single transfer. */
281     CY_DMA_1D_TRANSFER     = 1UL,          /**< 1D transfer.     */
282     CY_DMA_2D_TRANSFER     = 2UL,          /**< 2D transfer.     */
283     CY_DMA_CRC_TRANSFER    = 3UL,          /**< CRC transfer. Supported by the CPUSS_ver2 only. */
284 } cy_en_dma_descriptor_type_t;
285 
286 /** Contains the options for the interrupt, trig-in and trig-out type parameters of the descriptor */
287 typedef enum
288 {
289     CY_DMA_1ELEMENT    = 0UL,              /**< One element transfer.             */
290     CY_DMA_X_LOOP      = 1UL,              /**< One X loop transfer.              */
291     CY_DMA_DESCR       = 2UL,              /**< One descriptor transfer.          */
292     CY_DMA_DESCR_CHAIN = 3UL               /**< Entire descriptor chain transfer. */
293 } cy_en_dma_trigger_type_t;
294 
295 /** Contains the options for the data size */
296 typedef enum
297 {
298     CY_DMA_BYTE     = 0UL,                 /**< One byte.               */
299     CY_DMA_HALFWORD = 1UL,                 /**< Half word (two bytes).  */
300     CY_DMA_WORD     = 2UL                  /**< Full word (four bytes). */
301 } cy_en_dma_data_size_t;
302 
303 /** Contains the options for descriptor retriggering */
304 typedef enum
305 {
306     CY_DMA_RETRIG_IM      = 0UL,           /**< Retrigger immediately.              */
307     CY_DMA_RETRIG_4CYC    = 1UL,           /**< Retrigger after 4 Clk_Slow cycles.  */
308     CY_DMA_RETRIG_16CYC   = 2UL,           /**< Retrigger after 16 Clk_Slow cycles. */
309     CY_DMA_WAIT_FOR_REACT = 3UL            /**< Wait for trigger reactivation.      */
310 } cy_en_dma_retrigger_t;
311 
312 /** Contains the options for the transfer size */
313 typedef enum
314 {
315     CY_DMA_TRANSFER_SIZE_DATA = 0UL,       /**< As specified by dataSize. */
316     CY_DMA_TRANSFER_SIZE_WORD = 1UL,       /**< A full word (four bytes). */
317 } cy_en_dma_transfer_size_t;
318 
319 /** Contains the options for the state of the channel when the descriptor is completed   */
320 typedef enum
321 {
322     CY_DMA_CHANNEL_ENABLED  = 0UL,         /**< Channel stays enabled. */
323     CY_DMA_CHANNEL_DISABLED = 1UL          /**< Channel is disabled.   */
324 } cy_en_dma_channel_state_t;
325 
326 /** Contains the return values of the DMA driver */
327 typedef enum
328 {
329     CY_DMA_SUCCESS   = 0x00UL, /**< Success. */
330     CY_DMA_BAD_PARAM = CY_DMA_ID | CY_PDL_STATUS_ERROR | 0x01UL /**< The input parameters passed to the DMA API are not valid. */
331 } cy_en_dma_status_t;
332 
333 /** \} group_dma_enums */
334 
335 
336 /** \cond Internal */
337 
338 /* Macros for the conditions used by CY_ASSERT calls */
339 #define CY_DMA_IS_LOOP_COUNT_VALID(count)      (((count) >= CY_DMA_LOOP_COUNT_MIN) && ((count) <= CY_DMA_LOOP_COUNT_MAX))
340 #define CY_DMA_IS_LOOP_INCR_VALID(incr)        (((incr) >= CY_DMA_LOOP_INCREMENT_MIN) && ((incr) <= CY_DMA_LOOP_INCREMENT_MAX))
341 #define CY_DMA_IS_PRIORITY_VALID(prio)         ((prio) <= 3UL)
342 #define CY_DMA_IS_INTR_MASK_VALID(intr)        (0UL == ((intr) & ((uint32_t) ~CY_DMA_INTR_MASK)))
343 
344 #define CY_DMA_IS_RETRIG_VALID(retrig)         ((CY_DMA_RETRIG_IM      == (retrig)) || \
345                                                 (CY_DMA_RETRIG_4CYC    == (retrig)) || \
346                                                 (CY_DMA_RETRIG_16CYC   == (retrig)) || \
347                                                 (CY_DMA_WAIT_FOR_REACT == (retrig)))
348 
349 #define CY_DMA_IS_TRIG_TYPE_VALID(trigType)    ((CY_DMA_1ELEMENT    == (trigType)) || \
350                                                 (CY_DMA_X_LOOP      == (trigType)) || \
351                                                 (CY_DMA_DESCR       == (trigType)) || \
352                                                 (CY_DMA_DESCR_CHAIN == (trigType)))
353 
354 #define CY_DMA_IS_XFER_SIZE_VALID(xferSize)    ((CY_DMA_TRANSFER_SIZE_DATA == (xferSize)) || \
355                                                 (CY_DMA_TRANSFER_SIZE_WORD == (xferSize)))
356 
357 #define CY_DMA_IS_CHANNEL_STATE_VALID(state)   ((CY_DMA_CHANNEL_ENABLED  == (state)) || \
358                                                 (CY_DMA_CHANNEL_DISABLED == (state)))
359 
360 #define CY_DMA_IS_DATA_SIZE_VALID(dataSize)    ((CY_DMA_BYTE     == (dataSize)) || \
361                                                 (CY_DMA_HALFWORD == (dataSize)) || \
362                                                 (CY_DMA_WORD     == (dataSize)))
363 
364 #define CY_DMA_IS_TYPE_VALID(descrType)        ((CY_DMA_SINGLE_TRANSFER == (descrType)) || \
365                                                 (CY_DMA_1D_TRANSFER     == (descrType)) || \
366                                                 (CY_DMA_2D_TRANSFER     == (descrType)) || \
367                                                 (CY_DMA_CRC_TRANSFER    == (descrType)))
368 
369 #define CY_DMA_IS_CH_NR_VALID(base, chNr)      ((CY_DW0_BASE == (base)) ? ((chNr) < CY_DW0_CH_NR) : \
370                                                                           ((chNr) < CY_DW1_CH_NR))
371 
372 /* The descriptor structure bit field definitions */
373 #define CY_DMA_CTL_RETRIG_Pos      (0UL)
374 #define CY_DMA_CTL_RETRIG_Msk      ((uint32_t)0x3UL << CY_DMA_CTL_RETRIG_Pos)
375 #define CY_DMA_CTL_INTR_TYPE_Pos   (2UL)
376 #define CY_DMA_CTL_INTR_TYPE_Msk   ((uint32_t)0x3UL << CY_DMA_CTL_INTR_TYPE_Pos)
377 #define CY_DMA_CTL_TR_OUT_TYPE_Pos (4UL)
378 #define CY_DMA_CTL_TR_OUT_TYPE_Msk ((uint32_t)0x3UL << CY_DMA_CTL_TR_OUT_TYPE_Pos)
379 #define CY_DMA_CTL_TR_IN_TYPE_Pos  (6UL)
380 #define CY_DMA_CTL_TR_IN_TYPE_Msk  ((uint32_t)0x3UL << CY_DMA_CTL_TR_IN_TYPE_Pos)
381 #define CY_DMA_CTL_CH_DISABLE_Pos  (24UL)
382 #define CY_DMA_CTL_CH_DISABLE_Msk  ((uint32_t)0x1UL << CY_DMA_CTL_CH_DISABLE_Pos)
383 #define CY_DMA_CTL_SRC_SIZE_Pos    (26UL)
384 #define CY_DMA_CTL_SRC_SIZE_Msk    ((uint32_t)0x1UL << CY_DMA_CTL_SRC_SIZE_Pos)
385 #define CY_DMA_CTL_DST_SIZE_Pos    (27UL)
386 #define CY_DMA_CTL_DST_SIZE_Msk    ((uint32_t)0x1UL << CY_DMA_CTL_DST_SIZE_Pos)
387 #define CY_DMA_CTL_DATA_SIZE_Pos   (28UL)
388 #define CY_DMA_CTL_DATA_SIZE_Msk   ((uint32_t)0x3UL << CY_DMA_CTL_DATA_SIZE_Pos)
389 #define CY_DMA_CTL_TYPE_Pos        (30UL)
390 #define CY_DMA_CTL_TYPE_Msk        ((uint32_t)0x3UL << CY_DMA_CTL_TYPE_Pos)
391 
392 #define CY_DMA_CTL_SRC_INCR_Pos    (0UL)
393 #define CY_DMA_CTL_SRC_INCR_Msk    ((uint32_t)0xFFFUL << CY_DMA_CTL_SRC_INCR_Pos)
394 #define CY_DMA_CTL_DST_INCR_Pos    (12UL)
395 #define CY_DMA_CTL_DST_INCR_Msk    ((uint32_t)0xFFFUL << CY_DMA_CTL_DST_INCR_Pos)
396 #define CY_DMA_CTL_COUNT_Pos       (24UL)
397 #define CY_DMA_CTL_COUNT_Msk       ((uint32_t)0xFFUL << CY_DMA_CTL_COUNT_Pos)
398 
399 /** \endcond */
400 
401 
402 /**
403 * \addtogroup group_dma_data_structures
404 * \{
405 */
406 
407 /**
408 * DMA descriptor structure type. It is a user/component-declared structure
409 * allocated in RAM. The DMA HW requires a pointer to this structure to work with it.
410 *
411 * For advanced users: the descriptor can be allocated even in flash, then the user
412 * manually predefines all the structure items with constants. This is
413 * because most of the driver's API (especially functions modifying
414 * descriptors, including \ref Cy_DMA_Descriptor_Init()) can't work with
415 * read-only descriptors.
416 */
417 typedef struct
418 {
419     uint32_t ctl;                    /*!< 0x00000000 Descriptor control */
420     uint32_t src;                    /*!< 0x00000004 Descriptor source */
421     uint32_t dst;                    /*!< 0x00000008 Descriptor destination */
422     uint32_t xCtl;                   /*!< 0x0000000C Descriptor X loop control */
423     uint32_t yCtl;                   /*!< 0x00000010 Descriptor Y loop control */
424     uint32_t nextPtr;                /*!< 0x00000014 Descriptor next pointer */
425 } cy_stc_dma_descriptor_t;
426 
427 /**
428 * This structure is a configuration structure pre-initialized by the user and
429 * passed as a parameter to the \ref Cy_DMA_Descriptor_Init().
430 * It can be allocated in RAM/flash (the user's choice).
431 * In case of flash allocation, there is a possibility to reinitialize the descriptor in runtime.
432 * This structure has all the parameters of the descriptor as separate parameters.
433 * Most of these parameters are represented in the \ref cy_stc_dma_descriptor_t structure as bitfields.
434 */
435 typedef struct
436 {
437     cy_en_dma_retrigger_t       retrigger;       /**< Specifies whether the DW controller should wait for the input trigger to be deactivated. */
438     cy_en_dma_trigger_type_t    interruptType;   /**< Sets the event that triggers an interrupt. See \ref cy_en_dma_trigger_type_t. */
439     cy_en_dma_trigger_type_t    triggerOutType;  /**< Sets the event that triggers an output. See \ref cy_en_dma_trigger_type_t. */
440     cy_en_dma_channel_state_t   channelState;    /**< Specifies whether the channel is enabled or disabled on completion of descriptor. See \ref cy_en_dma_channel_state_t. */
441     cy_en_dma_trigger_type_t    triggerInType;   /**< Sets what type of transfer is triggered. See \ref cy_en_dma_trigger_type_t. */
442     cy_en_dma_data_size_t       dataSize;        /**< The size of the data bus for transfer. See \ref cy_en_dma_data_size_t. */
443     cy_en_dma_transfer_size_t   srcTransferSize; /**< The source transfer size. */
444     cy_en_dma_transfer_size_t   dstTransferSize; /**< The destination transfer size. */
445     cy_en_dma_descriptor_type_t descriptorType;  /**< The type of the descriptor. See \ref cy_en_dma_descriptor_type_t. */
446     void *                      srcAddress;      /**< The source address of the transfer. */
447     void *                      dstAddress;      /**< The destination address of the transfer.
448                                                    *  For CPUSS_ver2 only: for CRC transfer, the CRC result without post-processing
449                                                    *  (reversing and/or XORing, if used) is placed into the dstAddress.
450                                                    */
451     int32_t                     srcXincrement;   /**< The address increment of the source after each X-loop transfer. Valid range is -2048 ... 2047. */
452     int32_t                     dstXincrement;   /**< The address increment of the destination after each X-loop transfer. Valid range is -2048 ... 2047. */
453     uint32_t                    xCount;          /**< The number of transfers in an X-loop. Valid range is 1 ... 256. */
454     int32_t                     srcYincrement;   /**< The address increment of the source after each Y-loop transfer. Valid range is -2048 ... 2047. */
455     int32_t                     dstYincrement;   /**< The address increment of the destination after each Y-loop transfer. Valid range is -2048 ... 2047. */
456     uint32_t                    yCount;          /**< The number of X-loops in the Y-loop. Valid range is 1 ... 256. */
457     cy_stc_dma_descriptor_t *   nextDescriptor;  /**< The next descriptor to chain after completion. A NULL value will signify no chaining. */
458 } cy_stc_dma_descriptor_config_t;
459 
460 /** This structure holds the initialization values for the DMA channel */
461 typedef struct
462 {
463     cy_stc_dma_descriptor_t * descriptor;      /**< The DMA descriptor associated with the channel being initialized.           */
464     bool     preemptable;                      /**< Specifies whether the channel is preemptable by another higher-priority channel. */
465     uint32_t priority;                         /**< This parameter specifies the channel's priority.                            */
466     bool     enable;                           /**< This parameter specifies whether the channel is enabled after initializing.      */
467     bool     bufferable;                       /**< This parameter specifies whether a write transaction can complete.
468                                                     without waiting for the destination to accept the write transaction data.  */
469 } cy_stc_dma_channel_config_t;
470 
471 
472 /** This structure holds the initialization values for the CRC feature, only for CPUSS_ver2 */
473 typedef struct
474 {
475     bool     dataReverse;     /**< Specifies the bit order in which a data byte is processed (reversal is performed after XORing):
476                                * 'false': Most significant bit (bit 1) first.
477                                * 'true': Least significant bit (bit 0) first.
478                                */
479     uint32_t dataXor;         /**< Specifies a byte mask with which each data byte is XORed. The XOR is performed before data reversal. */
480     bool     reminderReverse; /**< Specifies whether the remainder is bit reversed (reversal is performed after XORing).
481                                *   Note: this parameter doesn't affect the CRC value stored into the dstAddress.
482                                *   The reversed value remains in the CRC_REM_RESULT register.
483                                */
484     uint32_t reminderXor;     /**< Specifies a mask with which the remainder is XORed. The XOR is performed before remainder reversal.
485                                *   Note: this parameter doesn't affect the CRC value stored into the dstAddress.
486                                *   The XORed value remains in the CRC_REM_RESULT register.
487                                */
488     uint32_t polynomial;      /**< CRC polynomial. The polynomial is represented WITHOUT the high order bit (this bit is always assumed '1').
489                                * The polynomial should be aligned/shifted such that the more significant bits (bit 31 and down) contain the polynomial
490                                * and the less significant bits (bit 0 and up) contain padding '0's. Some frequently used polynomials:
491                                * - CRC32: POLYNOMIAL is 0x04c11db7 (x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1).
492                                * - CRC16: POLYNOMIAL is 0x80050000 (x^16 + x^15 + x^2 + 1, shifted by 16 bit positions).
493                                * - CRC16 CCITT: POLYNOMIAL is 0x10210000 (x^16 + x^12 + x^5 + 1, shifted by 16 bit positions).
494                                */
495     uint32_t lfsrInitVal;     /**< The initial value of the Linear Feedback Shift Register */
496 } cy_stc_dma_crc_config_t;
497 
498 /** \} group_dma_data_structures */
499 
500 
501 /**
502 * \addtogroup group_dma_functions
503 * \{
504 */
505 
506 
507 /**
508 * \addtogroup group_dma_block_functions
509 * \{
510 */
511 
512 
513 __STATIC_INLINE void     Cy_DMA_Enable             (DW_Type * base);
514 __STATIC_INLINE void     Cy_DMA_Disable            (DW_Type * base);
515 __STATIC_INLINE uint32_t Cy_DMA_GetActiveChannel   (DW_Type const * base);
516 __STATIC_INLINE void *   Cy_DMA_GetActiveSrcAddress(DW_Type const * base);
517 __STATIC_INLINE void *   Cy_DMA_GetActiveDstAddress(DW_Type const * base);
518       cy_en_dma_status_t Cy_DMA_Crc_Init           (DW_Type * base, cy_stc_dma_crc_config_t const * crcConfig);
519 
520 /** \} group_dma_block_functions */
521 
522 
523 /**
524 * \addtogroup group_dma_channel_functions
525 * \{
526 */
527       cy_en_dma_status_t Cy_DMA_Channel_Init                    (DW_Type       * base, uint32_t channel, cy_stc_dma_channel_config_t const * channelConfig);
528                 void     Cy_DMA_Channel_DeInit                  (DW_Type       * base, uint32_t channel);
529 __STATIC_INLINE void     Cy_DMA_Channel_SetDescriptor           (DW_Type       * base, uint32_t channel, cy_stc_dma_descriptor_t const * descriptor);
530 __STATIC_INLINE void     Cy_DMA_Channel_Enable                  (DW_Type       * base, uint32_t channel);
531 __STATIC_INLINE void     Cy_DMA_Channel_Disable                 (DW_Type       * base, uint32_t channel);
532 __STATIC_INLINE void     Cy_DMA_Channel_SetPriority             (DW_Type       * base, uint32_t channel, uint32_t priority);
533 __STATIC_INLINE uint32_t Cy_DMA_Channel_GetPriority             (DW_Type const * base, uint32_t channel);
534 __STATIC_INLINE
535   cy_en_dma_intr_cause_t Cy_DMA_Channel_GetStatus               (DW_Type const * base, uint32_t channel);
536 __STATIC_INLINE
537 cy_stc_dma_descriptor_t * Cy_DMA_Channel_GetCurrentDescriptor   (DW_Type const * base, uint32_t channel);
538 
539 __STATIC_INLINE uint32_t Cy_DMA_Channel_GetInterruptStatus      (DW_Type const * base, uint32_t channel);
540 __STATIC_INLINE void     Cy_DMA_Channel_ClearInterrupt          (DW_Type       * base, uint32_t channel);
541 __STATIC_INLINE void     Cy_DMA_Channel_SetInterrupt            (DW_Type       * base, uint32_t channel);
542 __STATIC_INLINE uint32_t Cy_DMA_Channel_GetInterruptMask        (DW_Type const * base, uint32_t channel);
543 __STATIC_INLINE void     Cy_DMA_Channel_SetInterruptMask        (DW_Type       * base, uint32_t channel, uint32_t interrupt);
544 __STATIC_INLINE uint32_t Cy_DMA_Channel_GetInterruptStatusMasked(DW_Type const * base, uint32_t channel);
545 
546 /** \} group_dma_channel_functions */
547 
548 
549 /**
550 * \addtogroup group_dma_descriptor_functions
551 * \{
552 */
553 
554   cy_en_dma_status_t Cy_DMA_Descriptor_Init  (cy_stc_dma_descriptor_t * descriptor, cy_stc_dma_descriptor_config_t const * config);
555                 void Cy_DMA_Descriptor_DeInit(cy_stc_dma_descriptor_t * descriptor);
556 
557                 void Cy_DMA_Descriptor_SetNextDescriptor   (cy_stc_dma_descriptor_t * descriptor, cy_stc_dma_descriptor_t const * nextDescriptor);
558                 void Cy_DMA_Descriptor_SetDescriptorType   (cy_stc_dma_descriptor_t * descriptor, cy_en_dma_descriptor_type_t descriptorType);
559 __STATIC_INLINE void Cy_DMA_Descriptor_SetSrcAddress       (cy_stc_dma_descriptor_t * descriptor, void const * srcAddress);
560 __STATIC_INLINE void Cy_DMA_Descriptor_SetDstAddress       (cy_stc_dma_descriptor_t * descriptor, void const * dstAddress);
561 __STATIC_INLINE void Cy_DMA_Descriptor_SetXloopDataCount   (cy_stc_dma_descriptor_t * descriptor, uint32_t xCount);
562 __STATIC_INLINE void Cy_DMA_Descriptor_SetYloopDataCount   (cy_stc_dma_descriptor_t * descriptor, uint32_t yCount);
563 __STATIC_INLINE void Cy_DMA_Descriptor_SetXloopSrcIncrement(cy_stc_dma_descriptor_t * descriptor, int32_t srcXincrement);
564 __STATIC_INLINE void Cy_DMA_Descriptor_SetXloopDstIncrement(cy_stc_dma_descriptor_t * descriptor, int32_t dstXincrement);
565 __STATIC_INLINE void Cy_DMA_Descriptor_SetYloopSrcIncrement(cy_stc_dma_descriptor_t * descriptor, int32_t srcYincrement);
566 __STATIC_INLINE void Cy_DMA_Descriptor_SetYloopDstIncrement(cy_stc_dma_descriptor_t * descriptor, int32_t dstYincrement);
567 __STATIC_INLINE void Cy_DMA_Descriptor_SetInterruptType    (cy_stc_dma_descriptor_t * descriptor, cy_en_dma_trigger_type_t interruptType);
568 __STATIC_INLINE void Cy_DMA_Descriptor_SetTriggerInType    (cy_stc_dma_descriptor_t * descriptor, cy_en_dma_trigger_type_t triggerInType);
569 __STATIC_INLINE void Cy_DMA_Descriptor_SetTriggerOutType   (cy_stc_dma_descriptor_t * descriptor, cy_en_dma_trigger_type_t triggerOutType);
570 __STATIC_INLINE void Cy_DMA_Descriptor_SetDataSize         (cy_stc_dma_descriptor_t * descriptor, cy_en_dma_data_size_t dataSize);
571 __STATIC_INLINE void Cy_DMA_Descriptor_SetSrcTransferSize  (cy_stc_dma_descriptor_t * descriptor, cy_en_dma_transfer_size_t srcTransferSize);
572 __STATIC_INLINE void Cy_DMA_Descriptor_SetDstTransferSize  (cy_stc_dma_descriptor_t * descriptor, cy_en_dma_transfer_size_t dstTransferSize);
573 __STATIC_INLINE void Cy_DMA_Descriptor_SetRetrigger        (cy_stc_dma_descriptor_t * descriptor, cy_en_dma_retrigger_t retrigger);
574 __STATIC_INLINE void Cy_DMA_Descriptor_SetChannelState     (cy_stc_dma_descriptor_t * descriptor, cy_en_dma_channel_state_t channelState);
575 
576                 cy_stc_dma_descriptor_t *   Cy_DMA_Descriptor_GetNextDescriptor   (cy_stc_dma_descriptor_t const * descriptor);
577 __STATIC_INLINE cy_en_dma_descriptor_type_t Cy_DMA_Descriptor_GetDescriptorType   (cy_stc_dma_descriptor_t const * descriptor);
578 __STATIC_INLINE void *                      Cy_DMA_Descriptor_GetSrcAddress       (cy_stc_dma_descriptor_t const * descriptor);
579 __STATIC_INLINE void *                      Cy_DMA_Descriptor_GetDstAddress       (cy_stc_dma_descriptor_t const * descriptor);
580 __STATIC_INLINE uint32_t                    Cy_DMA_Descriptor_GetXloopDataCount   (cy_stc_dma_descriptor_t const * descriptor);
581 __STATIC_INLINE uint32_t                    Cy_DMA_Descriptor_GetYloopDataCount   (cy_stc_dma_descriptor_t const * descriptor);
582 __STATIC_INLINE int32_t                     Cy_DMA_Descriptor_GetXloopSrcIncrement(cy_stc_dma_descriptor_t const * descriptor);
583 __STATIC_INLINE int32_t                     Cy_DMA_Descriptor_GetXloopDstIncrement(cy_stc_dma_descriptor_t const * descriptor);
584 __STATIC_INLINE int32_t                     Cy_DMA_Descriptor_GetYloopSrcIncrement(cy_stc_dma_descriptor_t const * descriptor);
585 __STATIC_INLINE int32_t                     Cy_DMA_Descriptor_GetYloopDstIncrement(cy_stc_dma_descriptor_t const * descriptor);
586 __STATIC_INLINE cy_en_dma_trigger_type_t    Cy_DMA_Descriptor_GetInterruptType    (cy_stc_dma_descriptor_t const * descriptor);
587 __STATIC_INLINE cy_en_dma_trigger_type_t    Cy_DMA_Descriptor_GetTriggerInType    (cy_stc_dma_descriptor_t const * descriptor);
588 __STATIC_INLINE cy_en_dma_trigger_type_t    Cy_DMA_Descriptor_GetTriggerOutType   (cy_stc_dma_descriptor_t const * descriptor);
589 __STATIC_INLINE cy_en_dma_data_size_t       Cy_DMA_Descriptor_GetDataSize         (cy_stc_dma_descriptor_t const * descriptor);
590 __STATIC_INLINE cy_en_dma_transfer_size_t   Cy_DMA_Descriptor_GetSrcTransferSize  (cy_stc_dma_descriptor_t const * descriptor);
591 __STATIC_INLINE cy_en_dma_transfer_size_t   Cy_DMA_Descriptor_GetDstTransferSize  (cy_stc_dma_descriptor_t const * descriptor);
592 __STATIC_INLINE cy_en_dma_retrigger_t       Cy_DMA_Descriptor_GetRetrigger        (cy_stc_dma_descriptor_t const * descriptor);
593 __STATIC_INLINE cy_en_dma_channel_state_t   Cy_DMA_Descriptor_GetChannelState     (cy_stc_dma_descriptor_t const * descriptor);
594 
595 /** \} group_dma_descriptor_functions */
596 
597 
598 
599 /***************************************
600 *    In-line Function Implementation
601 ***************************************/
602 
603 
604 /**
605 * \addtogroup group_dma_block_functions
606 * \{
607 */
608 
609 
610 /*******************************************************************************
611 * Function Name: Cy_DMA_Enable
612 ****************************************************************************//**
613 *
614 * Enables the DMA block.
615 *
616 * \param base
617 * The pointer to the hardware DMA block.
618 *
619 * \funcusage
620 * \snippet dma/snippet/main.c snippet_Cy_DMA_Enable
621 *
622 *******************************************************************************/
Cy_DMA_Enable(DW_Type * base)623 __STATIC_INLINE void Cy_DMA_Enable(DW_Type * base)
624 {
625     DW_CTL(base) |= DW_CTL_ENABLED_Msk;
626 }
627 
628 
629 /*******************************************************************************
630 * Function Name: Cy_DMA_Disable
631 ****************************************************************************//**
632 *
633 * Disables the DMA block.
634 *
635 * \param base
636 * The pointer to the hardware DMA block.
637 *
638 * \funcusage
639 * \snippet dma/snippet/main.c snippet_Cy_DMA_Disable
640 *
641 *******************************************************************************/
Cy_DMA_Disable(DW_Type * base)642 __STATIC_INLINE void Cy_DMA_Disable(DW_Type * base)
643 {
644     DW_CTL(base) &= (uint32_t) ~DW_CTL_ENABLED_Msk;
645 }
646 
647 
648 /*******************************************************************************
649 * Function Name: Cy_DMA_GetActiveChannel
650 ****************************************************************************//**
651 *
652 * Returns the status of the active/pending channels.
653 * the DMA block.
654 *
655 * \param base
656 * The pointer to the hardware DMA block.
657 *
658 * \return
659 * Returns a bit-field with all of the currently active/pending channels in the
660 * DMA block.
661 *
662 * \funcusage
663 * \snippet dma/snippet/main.c snippet_Cy_DMA_Disable
664 *
665 *******************************************************************************/
Cy_DMA_GetActiveChannel(DW_Type const * base)666 __STATIC_INLINE uint32_t Cy_DMA_GetActiveChannel(DW_Type const * base)
667 {
668     return(_FLD2VAL(CY_DW_STATUS_CH_IDX, DW_STATUS(base)));
669 }
670 
671 
672 /*******************************************************************************
673 * Function Name: Cy_DMA_GetActiveSrcAddress
674 ****************************************************************************//**
675 *
676 * Returns the source address being used for the current transfer.
677 *
678 * \param base
679 * The pointer to the hardware DMA block.
680 *
681 * \return
682 * Returns the pointer to the source of transfer.
683 *
684 * \funcusage
685 * \snippet dma/snippet/main.c snippet_Cy_DMA_GetActiveSrcAddress
686 *
687 *******************************************************************************/
Cy_DMA_GetActiveSrcAddress(DW_Type const * base)688 __STATIC_INLINE void * Cy_DMA_GetActiveSrcAddress(DW_Type const * base)
689 {
690     return ((void *) DW_DESCR_SRC(base));
691 }
692 
693 
694 /*******************************************************************************
695 * Function Name: Cy_DMA_GetActiveDstAddress
696 ****************************************************************************//**
697 *
698 * Returns the destination address being used for the current transfer.
699 *
700 * \param base
701 * The pointer to the hardware DMA block.
702 *
703 * \return
704 * Returns the pointer to the destination of transfer.
705 *
706 * \funcusage
707 * \snippet dma/snippet/main.c snippet_Cy_DMA_GetActiveSrcAddress
708 *
709 *******************************************************************************/
Cy_DMA_GetActiveDstAddress(DW_Type const * base)710 __STATIC_INLINE void * Cy_DMA_GetActiveDstAddress(DW_Type const * base)
711 {
712     return ((void *) DW_DESCR_DST(base));
713 }
714 
715 /** \} group_dma_block_functions */
716 
717 /**
718 * \addtogroup group_dma_descriptor_functions
719 * \{
720 */
721 
722 
723 /*******************************************************************************
724 * Function Name: Cy_DMA_Descriptor_SetSrcAddress
725 ****************************************************************************//**
726 *
727 * Sets the source address for the specified descriptor.
728 *
729 * \param descriptor
730 * The descriptor structure instance declared by the user/component.
731 *
732 * \param srcAddress
733 * The source address value for the descriptor.
734 * For CAT1C devices this data pointer needs to point to 32 byte aligned data.
735 *
736 * \funcusage
737 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
738 *
739 *******************************************************************************/
Cy_DMA_Descriptor_SetSrcAddress(cy_stc_dma_descriptor_t * descriptor,void const * srcAddress)740 __STATIC_INLINE void Cy_DMA_Descriptor_SetSrcAddress(cy_stc_dma_descriptor_t * descriptor, void const * srcAddress)
741 {
742     descriptor->src = (uint32_t) srcAddress;
743 }
744 
745 
746 /*******************************************************************************
747 * Function Name: Cy_DMA_Descriptor_GetSrcAddress
748 ****************************************************************************//**
749 *
750 * Returns the source address parameter of the specified descriptor.
751 *
752 * \param descriptor
753 * The descriptor structure instance declared by the user/component.
754 *
755 * \return
756 * The source address value of the descriptor.
757 *
758 * \funcusage
759 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
760 *
761 *******************************************************************************/
Cy_DMA_Descriptor_GetSrcAddress(cy_stc_dma_descriptor_t const * descriptor)762 __STATIC_INLINE void * Cy_DMA_Descriptor_GetSrcAddress(cy_stc_dma_descriptor_t const * descriptor)
763 {
764     return ((void *) descriptor->src);
765 }
766 
767 
768 /*******************************************************************************
769 * Function Name: Cy_DMA_Descriptor_SetDstAddress
770 ****************************************************************************//**
771 *
772 * Sets the destination address for the specified descriptor.
773 *
774 * \param descriptor
775 * The descriptor structure instance declared by the user/component.
776 *
777 * \param dstAddress
778 * The destination address value for the descriptor.
779 * For CAT1C devices this data pointer needs to point to 32 byte aligned data.
780 *
781 * \funcusage
782 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
783 *
784 *******************************************************************************/
Cy_DMA_Descriptor_SetDstAddress(cy_stc_dma_descriptor_t * descriptor,void const * dstAddress)785 __STATIC_INLINE void Cy_DMA_Descriptor_SetDstAddress(cy_stc_dma_descriptor_t * descriptor, void const * dstAddress)
786 {
787     descriptor->dst = (uint32_t) dstAddress;
788 }
789 
790 
791 /*******************************************************************************
792 * Function Name: Cy_DMA_Descriptor_GetDstAddress
793 ****************************************************************************//**
794 *
795 * Returns the destination address parameter of the specified descriptor.
796 *
797 * \param descriptor
798 * The descriptor structure instance declared by the user/component.
799 *
800 * \return
801 * The destination address value of the descriptor.
802 *
803 * \funcusage
804 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
805 *
806 *******************************************************************************/
Cy_DMA_Descriptor_GetDstAddress(cy_stc_dma_descriptor_t const * descriptor)807 __STATIC_INLINE void * Cy_DMA_Descriptor_GetDstAddress(cy_stc_dma_descriptor_t const * descriptor)
808 {
809     return ((void *) descriptor->dst);
810 }
811 
812 
813 /*******************************************************************************
814 * Function Name: Cy_DMA_Descriptor_SetInterruptType
815 ****************************************************************************//**
816 *
817 * Sets the interrupt type for the specified descriptor.
818 *
819 * \param descriptor
820 * The descriptor structure instance declared by the user/component.
821 *
822 * \param interruptType
823 * The interrupt type set for the descriptor. \ref cy_en_dma_trigger_type_t
824 *
825 * \funcusage
826 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
827 *
828 *******************************************************************************/
Cy_DMA_Descriptor_SetInterruptType(cy_stc_dma_descriptor_t * descriptor,cy_en_dma_trigger_type_t interruptType)829 __STATIC_INLINE void Cy_DMA_Descriptor_SetInterruptType(cy_stc_dma_descriptor_t * descriptor, cy_en_dma_trigger_type_t interruptType)
830 {
831     CY_ASSERT_L3(CY_DMA_IS_TRIG_TYPE_VALID(interruptType));
832 
833     CY_REG32_CLR_SET(descriptor->ctl, CY_DMA_CTL_INTR_TYPE, interruptType);
834 }
835 
836 
837 /*******************************************************************************
838 * Function Name: Cy_DMA_Descriptor_GetInterruptType
839 ****************************************************************************//**
840 *
841 * Returns the Interrupt-Type of the specified descriptor.
842 *
843 * \param descriptor
844 * The descriptor structure instance declared by the user/component.
845 *
846 * \return
847 * The Interrupt-Type \ref cy_en_dma_trigger_type_t.
848 *
849 * \funcusage
850 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
851 *
852 *******************************************************************************/
Cy_DMA_Descriptor_GetInterruptType(cy_stc_dma_descriptor_t const * descriptor)853 __STATIC_INLINE cy_en_dma_trigger_type_t Cy_DMA_Descriptor_GetInterruptType(cy_stc_dma_descriptor_t const * descriptor)
854 {
855     return((cy_en_dma_trigger_type_t) _FLD2VAL(CY_DMA_CTL_INTR_TYPE, descriptor->ctl));
856 }
857 
858 
859 /*******************************************************************************
860 * Function Name: Cy_DMA_Descriptor_SetTriggerInType
861 ****************************************************************************//**
862 *
863 * Sets the Trigger-In-Type for the specified descriptor.
864 *
865 * \param descriptor
866 * The descriptor structure instance declared by the user/component.
867 *
868 * \param triggerInType
869 * The Trigger In Type parameter \ref cy_en_dma_trigger_type_t
870 *
871 * \funcusage
872 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
873 *
874 *******************************************************************************/
Cy_DMA_Descriptor_SetTriggerInType(cy_stc_dma_descriptor_t * descriptor,cy_en_dma_trigger_type_t triggerInType)875 __STATIC_INLINE void Cy_DMA_Descriptor_SetTriggerInType(cy_stc_dma_descriptor_t * descriptor, cy_en_dma_trigger_type_t triggerInType)
876 {
877     CY_ASSERT_L3(CY_DMA_IS_TRIG_TYPE_VALID(triggerInType));
878 
879     CY_REG32_CLR_SET(descriptor->ctl, CY_DMA_CTL_TR_IN_TYPE, triggerInType);
880 }
881 
882 
883 /*******************************************************************************
884 * Function Name: Cy_DMA_Descriptor_GetTriggerInType
885 ****************************************************************************//**
886 *
887 * Returns the Trigger-In-Type parameter of the specified descriptor.
888 *
889 * \param descriptor
890 * The descriptor structure instance declared by the user/component.
891 *
892 * \return
893 * The Trigger-In-Type \ref cy_en_dma_trigger_type_t
894 *
895 * \funcusage
896 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
897 *
898 *******************************************************************************/
Cy_DMA_Descriptor_GetTriggerInType(cy_stc_dma_descriptor_t const * descriptor)899 __STATIC_INLINE cy_en_dma_trigger_type_t Cy_DMA_Descriptor_GetTriggerInType(cy_stc_dma_descriptor_t const * descriptor)
900 {
901     return((cy_en_dma_trigger_type_t) _FLD2VAL(CY_DMA_CTL_TR_IN_TYPE, descriptor->ctl));
902 }
903 
904 
905 /*******************************************************************************
906 * Function Name: Cy_DMA_Descriptor_SetTriggerOutType
907 ****************************************************************************//**
908 *
909 * Sets the Trigger-Out-Type for the specified descriptor.
910 *
911 * \param descriptor
912 * The descriptor structure instance declared by the user/component.
913 *
914 * \param triggerOutType
915 * The Trigger-Out-Type set for the descriptor. \ref cy_en_dma_trigger_type_t
916 *
917 * \funcusage
918 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
919 *
920 *******************************************************************************/
Cy_DMA_Descriptor_SetTriggerOutType(cy_stc_dma_descriptor_t * descriptor,cy_en_dma_trigger_type_t triggerOutType)921 __STATIC_INLINE void Cy_DMA_Descriptor_SetTriggerOutType(cy_stc_dma_descriptor_t * descriptor, cy_en_dma_trigger_type_t triggerOutType)
922 {
923     CY_ASSERT_L3(CY_DMA_IS_TRIG_TYPE_VALID(triggerOutType));
924 
925     CY_REG32_CLR_SET(descriptor->ctl, CY_DMA_CTL_TR_OUT_TYPE, triggerOutType);
926 }
927 
928 
929 /*******************************************************************************
930 * Function Name: Cy_DMA_Descriptor_GetTriggerOutType
931 ****************************************************************************//**
932 *
933 * Returns the Trigger-Out-Type parameter of the specified descriptor.
934 *
935 * \param descriptor
936 * The descriptor structure instance declared by the user/component.
937 *
938 * \return
939 * The Trigger-Out-Type parameter \ref cy_en_dma_trigger_type_t.
940 *
941 * \funcusage
942 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
943 *
944 *******************************************************************************/
Cy_DMA_Descriptor_GetTriggerOutType(cy_stc_dma_descriptor_t const * descriptor)945 __STATIC_INLINE cy_en_dma_trigger_type_t Cy_DMA_Descriptor_GetTriggerOutType(cy_stc_dma_descriptor_t const * descriptor)
946 {
947     return((cy_en_dma_trigger_type_t) _FLD2VAL(CY_DMA_CTL_TR_OUT_TYPE, descriptor->ctl));
948 }
949 
950 
951 /*******************************************************************************
952 * Function Name: Cy_DMA_Descriptor_SetDataSize
953 ****************************************************************************//**
954 *
955 * Sets the Data Element Size for the specified descriptor.
956 *
957 * \param descriptor
958 * The descriptor structure instance declared by the user/component.
959 *
960 * \param dataSize
961 * The Data Element Size \ref cy_en_dma_data_size_t
962 *
963 * \funcusage
964 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
965 *
966 *******************************************************************************/
Cy_DMA_Descriptor_SetDataSize(cy_stc_dma_descriptor_t * descriptor,cy_en_dma_data_size_t dataSize)967 __STATIC_INLINE void Cy_DMA_Descriptor_SetDataSize(cy_stc_dma_descriptor_t * descriptor, cy_en_dma_data_size_t dataSize)
968 {
969     CY_ASSERT_L3(CY_DMA_IS_DATA_SIZE_VALID(dataSize));
970 
971     CY_REG32_CLR_SET(descriptor->ctl, CY_DMA_CTL_DATA_SIZE, dataSize);
972 }
973 
974 
975 /*******************************************************************************
976 * Function Name: Cy_DMA_Descriptor_GetDataSize
977 ****************************************************************************//**
978 *
979 * Returns the Data Element Size parameter of the specified descriptor.
980 *
981 * \param descriptor
982 * The descriptor structure instance declared by the user/component.
983 *
984 * \return
985 * The Data Element Size \ref cy_en_dma_data_size_t.
986 *
987 * \funcusage
988 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
989 *
990 *******************************************************************************/
Cy_DMA_Descriptor_GetDataSize(cy_stc_dma_descriptor_t const * descriptor)991 __STATIC_INLINE cy_en_dma_data_size_t Cy_DMA_Descriptor_GetDataSize(cy_stc_dma_descriptor_t const * descriptor)
992 {
993     return((cy_en_dma_data_size_t) _FLD2VAL(CY_DMA_CTL_DATA_SIZE, descriptor->ctl));
994 }
995 
996 
997 /*******************************************************************************
998 * Function Name: Cy_DMA_Descriptor_SetSrcTransferSize
999 ****************************************************************************//**
1000 *
1001 * Sets the Source Transfer Size for the specified descriptor.
1002 *
1003 * \param descriptor
1004 * The descriptor structure instance declared by the user/component.
1005 *
1006 * \param srcTransferSize
1007 * The Source Transfer Size \ref cy_en_dma_transfer_size_t.
1008 *
1009 * \funcusage
1010 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
1011 *
1012 *******************************************************************************/
Cy_DMA_Descriptor_SetSrcTransferSize(cy_stc_dma_descriptor_t * descriptor,cy_en_dma_transfer_size_t srcTransferSize)1013 __STATIC_INLINE void Cy_DMA_Descriptor_SetSrcTransferSize(cy_stc_dma_descriptor_t * descriptor, cy_en_dma_transfer_size_t srcTransferSize)
1014 {
1015     CY_ASSERT_L3(CY_DMA_IS_XFER_SIZE_VALID(srcTransferSize));
1016 
1017     CY_REG32_CLR_SET(descriptor->ctl, CY_DMA_CTL_SRC_SIZE, srcTransferSize);
1018 }
1019 
1020 
1021 /*******************************************************************************
1022 * Function Name: Cy_DMA_Descriptor_GetSrcTransferSize
1023 ****************************************************************************//**
1024 *
1025 * Returns the Source Transfer Size parameter of the specified descriptor.
1026 *
1027 * \param descriptor
1028 * The descriptor structure instance declared by the user/component.
1029 *
1030 * \return
1031 * The Source Transfer Size \ref cy_en_dma_transfer_size_t.
1032 *
1033 * \funcusage
1034 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
1035 *
1036 *******************************************************************************/
Cy_DMA_Descriptor_GetSrcTransferSize(cy_stc_dma_descriptor_t const * descriptor)1037 __STATIC_INLINE cy_en_dma_transfer_size_t Cy_DMA_Descriptor_GetSrcTransferSize(cy_stc_dma_descriptor_t const * descriptor)
1038 {
1039     return((cy_en_dma_transfer_size_t) _FLD2VAL(CY_DMA_CTL_SRC_SIZE, descriptor->ctl));
1040 }
1041 
1042 
1043 /*******************************************************************************
1044 * Function Name: Cy_DMA_Descriptor_SetDstTransferSize
1045 ****************************************************************************//**
1046 *
1047 * Sets the Destination Transfer Size for the specified descriptor.
1048 *
1049 * \param descriptor
1050 * The descriptor structure instance declared by the user/component.
1051 *
1052 * \param dstTransferSize
1053 * The Destination Transfer Size \ref cy_en_dma_transfer_size_t.
1054 *
1055 * \funcusage
1056 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
1057 *
1058 *******************************************************************************/
Cy_DMA_Descriptor_SetDstTransferSize(cy_stc_dma_descriptor_t * descriptor,cy_en_dma_transfer_size_t dstTransferSize)1059 __STATIC_INLINE void Cy_DMA_Descriptor_SetDstTransferSize(cy_stc_dma_descriptor_t * descriptor, cy_en_dma_transfer_size_t dstTransferSize)
1060 {
1061     CY_ASSERT_L3(CY_DMA_IS_XFER_SIZE_VALID(dstTransferSize));
1062 
1063     CY_REG32_CLR_SET(descriptor->ctl, CY_DMA_CTL_DST_SIZE, dstTransferSize);
1064 }
1065 
1066 
1067 /*******************************************************************************
1068 * Function Name: Cy_DMA_Descriptor_GetDstTransferSize
1069 ****************************************************************************//**
1070 *
1071 * Returns the Destination Transfer Size parameter of the specified descriptor.
1072 *
1073 * \param descriptor
1074 * The descriptor structure instance declared by the user/component.
1075 *
1076 * \return
1077 * The Destination Transfer Size \ref cy_en_dma_transfer_size_t.
1078 *
1079 * \funcusage
1080 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
1081 *
1082 *******************************************************************************/
Cy_DMA_Descriptor_GetDstTransferSize(cy_stc_dma_descriptor_t const * descriptor)1083 __STATIC_INLINE cy_en_dma_transfer_size_t Cy_DMA_Descriptor_GetDstTransferSize(cy_stc_dma_descriptor_t const * descriptor)
1084 {
1085     return((cy_en_dma_transfer_size_t) _FLD2VAL(CY_DMA_CTL_DST_SIZE, descriptor->ctl));
1086 }
1087 
1088 
1089 /*******************************************************************************
1090 * Function Name: Cy_DMA_Descriptor_SetRetrigger
1091 ****************************************************************************//**
1092 *
1093 * Sets the retrigger value that specifies whether the controller should
1094 * wait for the input trigger to be deactivated.
1095 *
1096 * \param descriptor
1097 * The descriptor structure instance declared by the user/component.
1098 *
1099 * \param retrigger
1100 * The \ref cy_en_dma_retrigger_t parameter specifies whether the controller
1101 * should wait for the input trigger to be deactivated.
1102 *
1103 * \funcusage
1104 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
1105 *
1106 *******************************************************************************/
Cy_DMA_Descriptor_SetRetrigger(cy_stc_dma_descriptor_t * descriptor,cy_en_dma_retrigger_t retrigger)1107 __STATIC_INLINE void Cy_DMA_Descriptor_SetRetrigger(cy_stc_dma_descriptor_t * descriptor, cy_en_dma_retrigger_t retrigger)
1108 {
1109     CY_ASSERT_L3(CY_DMA_IS_RETRIG_VALID(retrigger));
1110 
1111     CY_REG32_CLR_SET(descriptor->ctl, CY_DMA_CTL_RETRIG, retrigger);
1112 }
1113 
1114 
1115 /*******************************************************************************
1116 * Function Name: Cy_DMA_Descriptor_GetRetrigger
1117 ****************************************************************************//**
1118 *
1119 * Returns a value that specifies whether the controller should
1120 * wait for the input trigger to be deactivated.
1121 *
1122 * \param descriptor
1123 * The descriptor structure instance declared by the user/component.
1124 *
1125 * \return
1126 * The Retrigger setting \ref cy_en_dma_retrigger_t.
1127 *
1128 * \funcusage
1129 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
1130 *
1131 *******************************************************************************/
Cy_DMA_Descriptor_GetRetrigger(cy_stc_dma_descriptor_t const * descriptor)1132 __STATIC_INLINE cy_en_dma_retrigger_t Cy_DMA_Descriptor_GetRetrigger(cy_stc_dma_descriptor_t const * descriptor)
1133 {
1134     return((cy_en_dma_retrigger_t) _FLD2VAL(CY_DMA_CTL_RETRIG, descriptor->ctl));
1135 }
1136 
1137 
1138 /*******************************************************************************
1139 * Function Name: Cy_DMA_Descriptor_GetDescriptorType
1140 ****************************************************************************//**
1141 *
1142 * Returns the descriptor's type of the specified descriptor.
1143 *
1144 * \param descriptor
1145 * The descriptor structure instance declared by the user/component.
1146 *
1147 * \return
1148 * The descriptor type \ref cy_en_dma_descriptor_type_t.
1149 *
1150 * \funcusage
1151 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
1152 *
1153 *******************************************************************************/
Cy_DMA_Descriptor_GetDescriptorType(cy_stc_dma_descriptor_t const * descriptor)1154 __STATIC_INLINE cy_en_dma_descriptor_type_t Cy_DMA_Descriptor_GetDescriptorType(cy_stc_dma_descriptor_t const * descriptor)
1155 {
1156     return((cy_en_dma_descriptor_type_t) _FLD2VAL(CY_DMA_CTL_TYPE, descriptor->ctl));
1157 }
1158 
1159 
1160 /*******************************************************************************
1161 * Function Name: Cy_DMA_Descriptor_SetChannelState
1162 ****************************************************************************//**
1163 *
1164 * Sets the channel state on completion of the specified descriptor.
1165 *
1166 * \param descriptor
1167 * The descriptor structure instance declared by the user/component.
1168 *
1169 * \param channelState
1170 * The channel state \ref cy_en_dma_channel_state_t.
1171 *
1172 * \funcusage
1173 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
1174 *
1175 *******************************************************************************/
Cy_DMA_Descriptor_SetChannelState(cy_stc_dma_descriptor_t * descriptor,cy_en_dma_channel_state_t channelState)1176 __STATIC_INLINE void Cy_DMA_Descriptor_SetChannelState(cy_stc_dma_descriptor_t * descriptor, cy_en_dma_channel_state_t channelState)
1177 {
1178     CY_ASSERT_L3(CY_DMA_IS_CHANNEL_STATE_VALID(channelState));
1179 
1180     CY_REG32_CLR_SET(descriptor->ctl, CY_DMA_CTL_CH_DISABLE, channelState);
1181 }
1182 
1183 
1184 /*******************************************************************************
1185 * Function Name: Cy_DMA_Descriptor_GetChannelState
1186 ****************************************************************************//**
1187 *
1188 * Returns the channel state on completion of the specified descriptor.
1189 *
1190 * \param descriptor
1191 * The descriptor structure instance declared by the user/component.
1192 *
1193 * \return
1194 * The Channel State setting \ref cy_en_dma_channel_state_t.
1195 *
1196 * \funcusage
1197 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
1198 *
1199 *******************************************************************************/
Cy_DMA_Descriptor_GetChannelState(cy_stc_dma_descriptor_t const * descriptor)1200 __STATIC_INLINE cy_en_dma_channel_state_t Cy_DMA_Descriptor_GetChannelState(cy_stc_dma_descriptor_t const * descriptor)
1201 {
1202     return((cy_en_dma_channel_state_t) _FLD2VAL(CY_DMA_CTL_CH_DISABLE, descriptor->ctl));
1203 }
1204 
1205 
1206 /*******************************************************************************
1207 * Function Name: Cy_DMA_Descriptor_SetXloopDataCount
1208 ****************************************************************************//**
1209 *
1210 * Sets the number of data elements to transfer in the X loop
1211 * for the specified descriptor (for 1D or 2D descriptors only).
1212 *
1213 * \param descriptor
1214 * The descriptor structure instance declared by the user/component.
1215 *
1216 * \param xCount
1217 * The number of data elements to transfer in the X loop. Valid range is 1 ... 256.
1218 *
1219 * \funcusage
1220 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
1221 *
1222 *******************************************************************************/
Cy_DMA_Descriptor_SetXloopDataCount(cy_stc_dma_descriptor_t * descriptor,uint32_t xCount)1223 __STATIC_INLINE void Cy_DMA_Descriptor_SetXloopDataCount(cy_stc_dma_descriptor_t * descriptor, uint32_t xCount)
1224 {
1225     CY_ASSERT_L1(CY_DMA_SINGLE_TRANSFER != Cy_DMA_Descriptor_GetDescriptorType(descriptor));
1226     CY_ASSERT_L2(CY_DMA_IS_LOOP_COUNT_VALID(xCount));
1227     /* Convert the data count from the user's range (1-256) into the machine range (0-255). */
1228     CY_REG32_CLR_SET(descriptor->xCtl, CY_DMA_CTL_COUNT, xCount - 1UL);
1229 }
1230 
1231 
1232 /*******************************************************************************
1233 * Function Name: Cy_DMA_Descriptor_GetXloopDataCount
1234 ****************************************************************************//**
1235 *
1236 * Returns the number of data elements for the X loop of the specified
1237 * descriptor (for 1D or 2D descriptors only).
1238 *
1239 * \param descriptor
1240 * The descriptor structure instance declared by the user/component.
1241 *
1242 * \return
1243 * The number of data elements to transfer in the X loop. The range is 1 ... 256.
1244 *
1245 * \funcusage
1246 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
1247 *
1248 *******************************************************************************/
Cy_DMA_Descriptor_GetXloopDataCount(cy_stc_dma_descriptor_t const * descriptor)1249 __STATIC_INLINE uint32_t Cy_DMA_Descriptor_GetXloopDataCount(cy_stc_dma_descriptor_t const * descriptor)
1250 {
1251     CY_ASSERT_L1(CY_DMA_SINGLE_TRANSFER != Cy_DMA_Descriptor_GetDescriptorType(descriptor));
1252     /* Convert the data count from the machine range (0-255) into the user's range (1-256). */
1253     return (_FLD2VAL(CY_DMA_CTL_COUNT, descriptor->xCtl) + 1UL);
1254 }
1255 
1256 
1257 /*******************************************************************************
1258 * Function Name: Cy_DMA_Descriptor_SetXloopSrcIncrement
1259 ****************************************************************************//**
1260 *
1261 * Sets the source increment parameter for the X loop of the specified
1262 * descriptor (for 1D or 2D descriptors only).
1263 *
1264 * \param descriptor
1265 * The descriptor structure instance declared by the user/component.
1266 *
1267 * \param srcXincrement
1268 * The value of the source increment. The valid range is -2048 ... 2047.
1269 *
1270 * \funcusage
1271 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
1272 *
1273 *******************************************************************************/
Cy_DMA_Descriptor_SetXloopSrcIncrement(cy_stc_dma_descriptor_t * descriptor,int32_t srcXincrement)1274 __STATIC_INLINE void Cy_DMA_Descriptor_SetXloopSrcIncrement(cy_stc_dma_descriptor_t * descriptor, int32_t srcXincrement)
1275 {
1276     CY_ASSERT_L1(CY_DMA_SINGLE_TRANSFER != Cy_DMA_Descriptor_GetDescriptorType(descriptor));
1277     CY_ASSERT_L2(CY_DMA_IS_LOOP_INCR_VALID(srcXincrement));
1278 
1279     CY_REG32_CLR_SET(descriptor->xCtl, CY_DMA_CTL_SRC_INCR, srcXincrement);
1280 }
1281 
1282 
1283 /*******************************************************************************
1284 * Function Name: Cy_DMA_Descriptor_GetXloopSrcIncrement
1285 ****************************************************************************//**
1286 *
1287 * Returns the source increment parameter for the X loop of the specified
1288 * descriptor (for 1D or 2D descriptors only).
1289 *
1290 * \param descriptor
1291 * The descriptor structure instance declared by the user/component.
1292 *
1293 * \return
1294 * The value of the source increment. The range is -2048 ... 2047.
1295 *
1296 * \funcusage
1297 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
1298 *
1299 *******************************************************************************/
Cy_DMA_Descriptor_GetXloopSrcIncrement(cy_stc_dma_descriptor_t const * descriptor)1300 __STATIC_INLINE int32_t Cy_DMA_Descriptor_GetXloopSrcIncrement(cy_stc_dma_descriptor_t const * descriptor)
1301 {
1302     CY_ASSERT_L1(CY_DMA_SINGLE_TRANSFER != Cy_DMA_Descriptor_GetDescriptorType(descriptor));
1303 
1304     return ((int32_t) _FLD2VAL(CY_DMA_CTL_SRC_INCR, descriptor->xCtl));
1305 }
1306 
1307 
1308 /*******************************************************************************
1309 * Function Name: Cy_DMA_Descriptor_SetXloopDstIncrement
1310 ****************************************************************************//**
1311 *
1312 * Sets the destination increment parameter for the X loop for the specified
1313 * descriptor (for 1D or 2D descriptors only).
1314 *
1315 * \param descriptor
1316 * The descriptor structure instance declared by the user/component.
1317 *
1318 * \param dstXincrement
1319 * The value of the destination increment. The valid range is -2048 ... 2047.
1320 *
1321 * \funcusage
1322 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
1323 *
1324 *******************************************************************************/
Cy_DMA_Descriptor_SetXloopDstIncrement(cy_stc_dma_descriptor_t * descriptor,int32_t dstXincrement)1325 __STATIC_INLINE void Cy_DMA_Descriptor_SetXloopDstIncrement(cy_stc_dma_descriptor_t * descriptor, int32_t dstXincrement)
1326 {
1327     CY_ASSERT_L1(CY_DMA_SINGLE_TRANSFER != Cy_DMA_Descriptor_GetDescriptorType(descriptor));
1328     CY_ASSERT_L2(CY_DMA_IS_LOOP_INCR_VALID(dstXincrement));
1329 
1330     CY_REG32_CLR_SET(descriptor->xCtl, CY_DMA_CTL_DST_INCR, dstXincrement);
1331 }
1332 
1333 
1334 /*******************************************************************************
1335 * Function Name: Cy_DMA_Descriptor_GetXloopDstIncrement
1336 ****************************************************************************//**
1337 *
1338 * Returns the destination increment parameter for the X loop of the specified
1339 * descriptor (for 1D or 2D descriptors only).
1340 *
1341 * \param descriptor
1342 * The descriptor structure instance declared by the user/component.
1343 *
1344 * \return
1345 * The value of the destination increment. The range is -2048 ... 2047.
1346 *
1347 * \funcusage
1348 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
1349 *
1350 *******************************************************************************/
Cy_DMA_Descriptor_GetXloopDstIncrement(cy_stc_dma_descriptor_t const * descriptor)1351 __STATIC_INLINE int32_t Cy_DMA_Descriptor_GetXloopDstIncrement(cy_stc_dma_descriptor_t const * descriptor)
1352 {
1353     CY_ASSERT_L1(CY_DMA_SINGLE_TRANSFER != Cy_DMA_Descriptor_GetDescriptorType(descriptor));
1354 
1355     return ((int32_t) _FLD2VAL(CY_DMA_CTL_DST_INCR, descriptor->xCtl));
1356 }
1357 
1358 
1359 /*******************************************************************************
1360 * Function Name: Cy_DMA_Descriptor_SetYloopDataCount
1361 ****************************************************************************//**
1362 *
1363 * Sets the number of data elements for the Y loop of the specified descriptor
1364 * (for 2D descriptors only).
1365 *
1366 * \param descriptor
1367 * The descriptor structure instance declared by the user/component.
1368 *
1369 * \param yCount
1370 * The number of X loops to execute in the Y loop. The valid range is 1 ... 256.
1371 *
1372 * \funcusage
1373 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
1374 *
1375 *******************************************************************************/
Cy_DMA_Descriptor_SetYloopDataCount(cy_stc_dma_descriptor_t * descriptor,uint32_t yCount)1376 __STATIC_INLINE void Cy_DMA_Descriptor_SetYloopDataCount(cy_stc_dma_descriptor_t * descriptor, uint32_t yCount)
1377 {
1378     CY_ASSERT_L1(CY_DMA_2D_TRANSFER == Cy_DMA_Descriptor_GetDescriptorType(descriptor));
1379     CY_ASSERT_L2(CY_DMA_IS_LOOP_COUNT_VALID(yCount));
1380     /* Convert the data count from the user's range (1-256) into the machine range (0-255). */
1381     CY_REG32_CLR_SET(descriptor->yCtl, CY_DMA_CTL_COUNT, yCount - 1UL);
1382 }
1383 
1384 
1385 /*******************************************************************************
1386 * Function Name: Cy_DMA_Descriptor_GetYloopDataCount
1387 ****************************************************************************//**
1388 *
1389 * Returns the number of X loops to execute in the Y loop of the specified
1390 * descriptor (for 2D descriptors only).
1391 *
1392 * \param descriptor
1393 * The descriptor structure instance declared by the user/component.
1394 *
1395 * \return
1396 * The number of X loops to execute in the Y loop. The range is 1 ... 256.
1397 *
1398 * \funcusage
1399 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
1400 *
1401 *******************************************************************************/
Cy_DMA_Descriptor_GetYloopDataCount(cy_stc_dma_descriptor_t const * descriptor)1402 __STATIC_INLINE uint32_t Cy_DMA_Descriptor_GetYloopDataCount(cy_stc_dma_descriptor_t const * descriptor)
1403 {
1404     CY_ASSERT_L1(CY_DMA_2D_TRANSFER == Cy_DMA_Descriptor_GetDescriptorType(descriptor));
1405     /* Convert the data count from the machine range (0-255) into the user's range (1-256). */
1406     return (_FLD2VAL(CY_DMA_CTL_COUNT, descriptor->yCtl) + 1UL);
1407 }
1408 
1409 
1410 /*******************************************************************************
1411 * Function Name: Cy_DMA_Descriptor_SetYloopSrcIncrement
1412 ****************************************************************************//**
1413 *
1414 * Sets the source increment parameter for the Y loop for the specified
1415 * descriptor (for 2D descriptors only).
1416 *
1417 * \param descriptor
1418 * The descriptor structure instance declared by the user/component.
1419 *
1420 * \param srcYincrement
1421 * The value of the source increment. The valid range is -2048 ... 2047.
1422 *
1423 * \funcusage
1424 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
1425 *
1426 *******************************************************************************/
Cy_DMA_Descriptor_SetYloopSrcIncrement(cy_stc_dma_descriptor_t * descriptor,int32_t srcYincrement)1427 __STATIC_INLINE void Cy_DMA_Descriptor_SetYloopSrcIncrement(cy_stc_dma_descriptor_t * descriptor, int32_t srcYincrement)
1428 {
1429     CY_ASSERT_L1(CY_DMA_2D_TRANSFER == Cy_DMA_Descriptor_GetDescriptorType(descriptor));
1430     CY_ASSERT_L2(CY_DMA_IS_LOOP_INCR_VALID(srcYincrement));
1431 
1432     CY_REG32_CLR_SET(descriptor->yCtl, CY_DMA_CTL_SRC_INCR, srcYincrement);
1433 }
1434 
1435 
1436 /*******************************************************************************
1437 * Function Name: Cy_DMA_Descriptor_GetYloopSrcIncrement
1438 ****************************************************************************//**
1439 *
1440 * Returns the source increment parameter for the outer Y of the specified
1441 * descriptor (for 2D descriptors only).
1442 *
1443 * \param descriptor
1444 * The descriptor structure instance declared by the user/component.
1445 *
1446 * \return
1447 * The value of the source increment. The range is -2048 ... 2047.
1448 *
1449 * \funcusage
1450 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
1451 *
1452 *******************************************************************************/
Cy_DMA_Descriptor_GetYloopSrcIncrement(cy_stc_dma_descriptor_t const * descriptor)1453 __STATIC_INLINE int32_t Cy_DMA_Descriptor_GetYloopSrcIncrement(cy_stc_dma_descriptor_t const * descriptor)
1454 {
1455     CY_ASSERT_L1(CY_DMA_2D_TRANSFER == Cy_DMA_Descriptor_GetDescriptorType(descriptor));
1456 
1457     return ((int32_t) _FLD2VAL(CY_DMA_CTL_SRC_INCR, descriptor->yCtl));
1458 }
1459 
1460 
1461 /*******************************************************************************
1462 * Function Name: Cy_DMA_Descriptor_SetYloopDstIncrement
1463 ****************************************************************************//**
1464 *
1465 * Sets the destination increment parameter for the Y loop of the specified
1466 * descriptor (for 2D descriptors only).
1467 *
1468 * \param descriptor
1469 * The descriptor structure instance declared by the user/component.
1470 *
1471 * \param dstYincrement
1472 * The value of the destination increment. The valid range is -2048 ... 2047.
1473 *
1474 * \funcusage
1475 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_SetterFunctions
1476 *
1477 *******************************************************************************/
Cy_DMA_Descriptor_SetYloopDstIncrement(cy_stc_dma_descriptor_t * descriptor,int32_t dstYincrement)1478 __STATIC_INLINE void Cy_DMA_Descriptor_SetYloopDstIncrement(cy_stc_dma_descriptor_t * descriptor, int32_t dstYincrement)
1479 {
1480     CY_ASSERT_L1(CY_DMA_2D_TRANSFER == Cy_DMA_Descriptor_GetDescriptorType(descriptor));
1481     CY_ASSERT_L2(CY_DMA_IS_LOOP_INCR_VALID(dstYincrement));
1482 
1483     CY_REG32_CLR_SET(descriptor->yCtl, CY_DMA_CTL_DST_INCR, dstYincrement);
1484 }
1485 
1486 
1487 /*******************************************************************************
1488 * Function Name: Cy_DMA_Descriptor_GetYloopDstIncrement
1489 ****************************************************************************//**
1490 *
1491 * Returns the destination increment parameter for the Y loop of the specified
1492 * descriptor (for 2D descriptors only).
1493 *
1494 * \param descriptor
1495 * The descriptor structure instance declared by the user/component.
1496 *
1497 * \return
1498 * The value of the destination increment. The range is -2048 ... 2047.
1499 *
1500 * \funcusage
1501 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_GetterFunctions
1502 *
1503 *******************************************************************************/
Cy_DMA_Descriptor_GetYloopDstIncrement(cy_stc_dma_descriptor_t const * descriptor)1504 __STATIC_INLINE int32_t Cy_DMA_Descriptor_GetYloopDstIncrement(cy_stc_dma_descriptor_t const * descriptor)
1505 {
1506     CY_ASSERT_L1(CY_DMA_2D_TRANSFER == Cy_DMA_Descriptor_GetDescriptorType(descriptor));
1507 
1508     return ((int32_t) _FLD2VAL(CY_DMA_CTL_DST_INCR, descriptor->yCtl));
1509 }
1510 
1511 
1512 /** \} group_dma_descriptor_functions */
1513 
1514 
1515 /**
1516 * \addtogroup group_dma_channel_functions
1517 * \{
1518 */
1519 
1520 
1521 /*******************************************************************************
1522 * Function Name: Cy_DMA_Channel_SetDescriptor
1523 ****************************************************************************//**
1524 *
1525 * Sets a descriptor as current for the specified DMA channel.
1526 *
1527 * \param base
1528 * The pointer to the hardware DMA block.
1529 *
1530 * \param channel
1531 * The channel number.
1532 *
1533 * \param descriptor
1534 * This is the descriptor to be associated with the channel.
1535 * For CAT1C devices this pointer needs to point to 32 byte aligned structure.
1536 *
1537 * \funcusage
1538 * \snippet dma/snippet/main.c snippet_Cy_DMA_Enable
1539 *
1540 *******************************************************************************/
Cy_DMA_Channel_SetDescriptor(DW_Type * base,uint32_t channel,cy_stc_dma_descriptor_t const * descriptor)1541 __STATIC_INLINE void Cy_DMA_Channel_SetDescriptor(DW_Type * base, uint32_t channel, cy_stc_dma_descriptor_t const * descriptor)
1542 {
1543     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1544 
1545     DW_CH_CURR_PTR(base, channel) = (uint32_t)descriptor;
1546     DW_CH_IDX(base, channel) &= (uint32_t) ~(DW_CH_STRUCT_CH_IDX_X_IDX_Msk | DW_CH_STRUCT_CH_IDX_Y_IDX_Msk);
1547 }
1548 
1549 
1550 /*******************************************************************************
1551 * Function Name: Cy_DMA_Channel_Enable
1552 ****************************************************************************//**
1553 *
1554 * The function is used to enable a DMA channel.
1555 *
1556 * \param base
1557 * The pointer to the hardware DMA block.
1558 *
1559 * \param channel
1560 * The  channel number.
1561 *
1562 * \funcusage
1563 * \snippet dma/snippet/main.c snippet_Cy_DMA_Enable
1564 *
1565 *******************************************************************************/
Cy_DMA_Channel_Enable(DW_Type * base,uint32_t channel)1566 __STATIC_INLINE void Cy_DMA_Channel_Enable(DW_Type * base, uint32_t channel)
1567 {
1568     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1569 
1570     DW_CH_CTL(base, channel) |= DW_CH_STRUCT_CH_CTL_ENABLED_Msk;
1571 }
1572 
1573 
1574 /*******************************************************************************
1575 * Function Name: Cy_DMA_Channel_Disable
1576 ****************************************************************************//**
1577 *
1578 * The function is used to disable a DMA channel.
1579 *
1580 * \param base
1581 * The pointer to the hardware DMA block.
1582 *
1583 * \param channel
1584 * The channel number.
1585 *
1586 * \funcusage
1587 * \snippet dma/snippet/main.c snippet_Cy_DMA_Disable
1588 *
1589 *******************************************************************************/
Cy_DMA_Channel_Disable(DW_Type * base,uint32_t channel)1590 __STATIC_INLINE void Cy_DMA_Channel_Disable(DW_Type * base, uint32_t channel)
1591 {
1592     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1593 
1594     DW_CH_CTL(base, channel) &= (uint32_t) ~DW_CH_STRUCT_CH_CTL_ENABLED_Msk;
1595 }
1596 
1597 
1598 /*******************************************************************************
1599 * Function Name: Cy_DMA_Channel_SetPriority
1600 ****************************************************************************//**
1601 *
1602 * The function is used to set a priority for the DMA channel.
1603 *
1604 * \param base
1605 * The pointer to the hardware DMA block.
1606 *
1607 * \param channel
1608 * The channel number.
1609 *
1610 * \param priority
1611 * The priority to be set for the DMA channel. The allowed values are 0,1,2,3.
1612 *
1613 * \funcusage
1614 * \snippet dma/snippet/main.c snippet_Cy_DMA_Enable
1615 *
1616 *******************************************************************************/
Cy_DMA_Channel_SetPriority(DW_Type * base,uint32_t channel,uint32_t priority)1617 __STATIC_INLINE void Cy_DMA_Channel_SetPriority(DW_Type * base, uint32_t channel, uint32_t priority)
1618 {
1619     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1620     CY_ASSERT_L2(CY_DMA_IS_PRIORITY_VALID(priority));
1621 
1622     CY_REG32_CLR_SET(DW_CH_CTL(base, channel), CY_DW_CH_CTL_PRIO, priority);
1623 }
1624 
1625 
1626 /*******************************************************************************
1627 * Function Name: Cy_DMA_Channel_GetPriority
1628 ****************************************************************************//**
1629 *
1630 * Returns the priority of the DMA channel.
1631 *
1632 * \param base
1633 * The pointer to the hardware DMA block.
1634 *
1635 * \param channel
1636 * The channel number.
1637 *
1638 * \return
1639 * The priority of the channel.
1640 *
1641 * \funcusage
1642 * \snippet dma/snippet/main.c snippet_Cy_DMA_Disable
1643 *
1644 *******************************************************************************/
Cy_DMA_Channel_GetPriority(DW_Type const * base,uint32_t channel)1645 __STATIC_INLINE uint32_t Cy_DMA_Channel_GetPriority(DW_Type const * base, uint32_t channel)
1646 {
1647     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1648 
1649     return ((uint32_t) _FLD2VAL(CY_DW_CH_CTL_PRIO, DW_CH_CTL(base, channel)));
1650 }
1651 
1652 
1653 /*******************************************************************************
1654 * Function Name: Cy_DMA_Channel_GetCurrentDescriptor
1655 ****************************************************************************//**
1656 *
1657 * Returns the descriptor that is active in the channel.
1658 *
1659 * \param base
1660 * The pointer to the hardware DMA block.
1661 *
1662 * \param channel
1663 * The channel number.
1664 *
1665 * \return
1666 * The pointer to the descriptor associated with the channel.
1667 *
1668 * \funcusage
1669 * \snippet dma/snippet/main.c snippet_Cy_DMA_Descriptor_Deinit
1670 *
1671 *******************************************************************************/
Cy_DMA_Channel_GetCurrentDescriptor(DW_Type const * base,uint32_t channel)1672 __STATIC_INLINE cy_stc_dma_descriptor_t * Cy_DMA_Channel_GetCurrentDescriptor(DW_Type const * base, uint32_t channel)
1673 {
1674     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1675 
1676     return ((cy_stc_dma_descriptor_t*)(DW_CH_CURR_PTR(base, channel)));
1677 }
1678 
1679 
1680 
1681 /*******************************************************************************
1682 * Function Name: Cy_DMA_Channel_GetInterruptStatus
1683 ****************************************************************************//**
1684 *
1685 * Returns the interrupt status of the specified channel.
1686 *
1687 * \param base
1688 * The pointer to the hardware DMA block.
1689 *
1690 * \param channel
1691 * The channel number.
1692 *
1693 * \return
1694 * The status of an interrupt for the specified channel.
1695 *
1696 * \funcusage
1697 * \snippet dma/snippet/main.c snippet_Cy_DMA_GetInterruptStatus
1698 *
1699 *******************************************************************************/
Cy_DMA_Channel_GetInterruptStatus(DW_Type const * base,uint32_t channel)1700 __STATIC_INLINE uint32_t Cy_DMA_Channel_GetInterruptStatus(DW_Type const * base, uint32_t channel)
1701 {
1702     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1703 
1704     return (DW_CH_INTR(base, channel));
1705 }
1706 
1707 
1708 /*******************************************************************************
1709 * Function Name: Cy_DMA_Channel_GetStatus
1710 ****************************************************************************//**
1711 *
1712 * Returns the interrupt reason of the specified channel.
1713 *
1714 * \param base
1715 * The pointer to the hardware DMA block.
1716 *
1717 * \param channel
1718 * The channel number.
1719 *
1720 * \return
1721 * The cause \ref cy_en_dma_intr_cause_t of the interrupt.
1722 *
1723 * \funcusage
1724 * \snippet dma/snippet/main.c snippet_Cy_DMA_ClearInterrupt
1725 *
1726 *******************************************************************************/
Cy_DMA_Channel_GetStatus(DW_Type const * base,uint32_t channel)1727 __STATIC_INLINE cy_en_dma_intr_cause_t Cy_DMA_Channel_GetStatus(DW_Type const * base, uint32_t channel)
1728 {
1729     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1730 
1731     return ((cy_en_dma_intr_cause_t) _FLD2VAL(DW_CH_STRUCT_CH_STATUS_INTR_CAUSE, DW_CH_STATUS(base, channel)));
1732 }
1733 
1734 
1735 /*******************************************************************************
1736 * Function Name: Cy_DMA_Channel_ClearInterrupt
1737 ****************************************************************************//**
1738 *
1739 * Clears the interrupt status of the specified channel.
1740 *
1741 * \param base
1742 * The pointer to the hardware DMA block.
1743 *
1744 * \param channel
1745 * The channel number.
1746 *
1747 * \funcusage
1748 * \snippet dma/snippet/main.c snippet_Cy_DMA_ClearInterrupt
1749 *
1750 *******************************************************************************/
Cy_DMA_Channel_ClearInterrupt(DW_Type * base,uint32_t channel)1751 __STATIC_INLINE void Cy_DMA_Channel_ClearInterrupt(DW_Type * base, uint32_t channel)
1752 {
1753     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1754 
1755     DW_CH_INTR(base, channel) = CY_DMA_INTR_MASK;
1756     /* This dummy reading is necessary here. It provides a guarantee that interrupt is cleared at returning from this function. */
1757     (void) DW_CH_INTR(base, channel);
1758 }
1759 
1760 
1761 /*******************************************************************************
1762 * Function Name: Cy_DMA_Channel_SetInterrupt
1763 ****************************************************************************//**
1764 *
1765 * Sets the interrupt for the specified channel.
1766 *
1767 * \param base
1768 * The pointer to the hardware DMA block.
1769 *
1770 * \param channel
1771 * The channel number.
1772 *
1773 * \funcusage
1774 * \snippet dma/snippet/main.c snippet_Cy_DMA_SetInterruptMask
1775 *
1776 *******************************************************************************/
Cy_DMA_Channel_SetInterrupt(DW_Type * base,uint32_t channel)1777 __STATIC_INLINE void Cy_DMA_Channel_SetInterrupt(DW_Type * base, uint32_t channel)
1778 {
1779     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1780 
1781     DW_CH_INTR_SET(base, channel) = CY_DMA_INTR_MASK;
1782 }
1783 
1784 
1785 /*******************************************************************************
1786 * Function Name: Cy_DMA_Channel_GetInterruptMask
1787 ****************************************************************************//**
1788 *
1789 * Returns the interrupt mask value of the specified channel.
1790 *
1791 * \param base
1792 * The pointer to the hardware DMA block.
1793 *
1794 * \param channel
1795 * The channel number.
1796 *
1797 * \return
1798 * The interrupt mask value.
1799 *
1800 * \funcusage
1801 * \snippet dma/snippet/main.c snippet_Cy_DMA_SetInterruptMask
1802 *
1803 *******************************************************************************/
Cy_DMA_Channel_GetInterruptMask(DW_Type const * base,uint32_t channel)1804 __STATIC_INLINE uint32_t Cy_DMA_Channel_GetInterruptMask(DW_Type const * base, uint32_t channel)
1805 {
1806     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1807 
1808     return (DW_CH_INTR_MASK(base, channel));
1809 }
1810 
1811 
1812 /*******************************************************************************
1813 * Function Name: Cy_DMA_Channel_SetInterruptMask
1814 ****************************************************************************//**
1815 *
1816 * Sets an interrupt mask value for the specified channel.
1817 *
1818 * \param base
1819 * The pointer to the hardware DMA block.
1820 *
1821 * \param channel
1822 * The channel number.
1823 *
1824 * \param interrupt
1825 * The interrupt mask:
1826 * CY_DMA_INTR_MASK to enable the interrupt or 0UL to disable the interrupt.
1827 *
1828 * \funcusage
1829 * \snippet dma/snippet/main.c snippet_Cy_DMA_SetInterruptMask
1830 *
1831 *******************************************************************************/
Cy_DMA_Channel_SetInterruptMask(DW_Type * base,uint32_t channel,uint32_t interrupt)1832 __STATIC_INLINE void Cy_DMA_Channel_SetInterruptMask(DW_Type * base, uint32_t channel, uint32_t interrupt)
1833 {
1834     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1835     CY_ASSERT_L2(CY_DMA_IS_INTR_MASK_VALID(interrupt));
1836     DW_CH_INTR_MASK(base, channel) = interrupt;
1837 }
1838 
1839 
1840 /*******************************************************************************
1841 * Function Name: Cy_DMA_Channel_GetInterruptStatusMasked
1842 ****************************************************************************//**
1843 *
1844 * Returns the logical AND of the corresponding INTR and INTR_MASK fields
1845 * in a single-load operation.
1846 *
1847 * \param base
1848 * The pointer to the hardware DMA block.
1849 *
1850 * \param channel
1851 * The channel number.
1852 *
1853 * \funcusage
1854 * \snippet dma/snippet/main.c snippet_Cy_DMA_ClearInterrupt
1855 *
1856 *******************************************************************************/
Cy_DMA_Channel_GetInterruptStatusMasked(DW_Type const * base,uint32_t channel)1857 __STATIC_INLINE uint32_t Cy_DMA_Channel_GetInterruptStatusMasked(DW_Type const * base, uint32_t channel)
1858 {
1859     CY_ASSERT_L1(CY_DMA_IS_CH_NR_VALID(base, channel));
1860 
1861     return (DW_CH_INTR_MASKED(base, channel));
1862 }
1863 
1864 
1865 /** \} group_dma_channel_functions */
1866 
1867 /** \} group_dma_functions */
1868 
1869 
1870 /** \cond The definitions to support the backward compatibility, do not use them in new designs */
1871 
1872 #if(0U != CY_DMA_BWC)
1873 
1874     /* Type definitions */
1875     #define cy_stc_dma_chnl_config_t        cy_stc_dma_channel_config_t
1876     #define cy_stc_dma_descr_t              cy_stc_dma_descriptor_t
1877     #define cy_stc_dma_descr_config_t       cy_stc_dma_descriptor_config_t
1878     #define cy_en_dma_trig_type_t           cy_en_dma_trigger_type_t
1879 
1880     /* Structure items */
1881     #define DMA_Descriptor                  descriptor
1882     #define deact                           retrigger
1883     #define intrType                        interruptType
1884     #define chStateAtCmplt                  channelState
1885     #define srcTxfrSize                     srcTransferSize
1886     #define destTxfrSize                    dstTransferSize
1887     #define trigoutType                     triggerOutType
1888     #define triginType                      triggerInType
1889     #define descrType                       descriptorType
1890     #define srcAddr                         srcAddress
1891     #define destAddr                        dstAddress
1892     #define srcXincr                        srcXincrement
1893     #define srcYincr                        srcYincrement
1894     #define destXincr                       dstXincrement
1895     #define destYincr                       dstYincrement
1896     #define descrNext                       nextDescriptor
1897 
1898     /* Constants */
1899     #define CY_DMA_CH_DISABLED              (CY_DMA_CHANNEL_DISABLED)
1900     #define CY_DMA_CH_ENABLED               (CY_DMA_CHANNEL_ENABLED)
1901 
1902     #define CY_DMA_TXFR_SIZE_DATA_SIZE      (CY_DMA_TRANSFER_SIZE_DATA)
1903     #define CY_DMA_TXFR_SIZE_WORD           (CY_DMA_TRANSFER_SIZE_WORD)
1904 
1905     #define CY_DMA_INTR_1ELEMENT_CMPLT      (CY_DMA_1ELEMENT)
1906     #define CY_DMA_INTR_X_LOOP_CMPLT        (CY_DMA_X_LOOP)
1907     #define CY_DMA_INTR_DESCR_CMPLT         (CY_DMA_DESCR)
1908     #define CY_DMA_INTR_DESCRCHAIN_CMPLT    (CY_DMA_DESCR_CHAIN)
1909 
1910     #define CY_DMA_TRIGOUT_1ELEMENT_CMPLT   (CY_DMA_1ELEMENT)
1911     #define CY_DMA_TRIGOUT_X_LOOP_CMPLT     (CY_DMA_X_LOOP)
1912     #define CY_DMA_TRIGOUT_DESCR_CMPLT      (CY_DMA_DESCR)
1913     #define CY_DMA_TRIGOUT_DESCRCHAIN_CMPLT (CY_DMA_DESCR_CHAIN)
1914 
1915     #define CY_DMA_TRIGIN_1ELEMENT          (CY_DMA_1ELEMENT)
1916     #define CY_DMA_TRIGIN_XLOOP             (CY_DMA_X_LOOP)
1917     #define CY_DMA_TRIGIN_DESCR             (CY_DMA_DESCR)
1918     #define CY_DMA_TRIGIN_DESCRCHAIN        (CY_DMA_DESCR_CHAIN)
1919 
1920     #define CY_DMA_INVALID_INPUT_PARAMETERS (CY_DMA_BAD_PARAM)
1921 
1922     #define CY_DMA_RETDIG_IM                (CY_DMA_RETRIG_IM)
1923     #define CY_DMA_RETDIG_4CYC              (CY_DMA_RETRIG_4CYC)
1924     #define CY_DMA_RETDIG_16CYC             (CY_DMA_RETRIG_16CYC)
1925 
1926     /* Descriptor structure items */
1927     #define DESCR_CTL                       ctl
1928     #define DESCR_SRC                       src
1929     #define DESCR_DST                       dst
1930     #define DESCR_X_CTL                     xCtl
1931     #define DESCR_Y_CTL                     yCtl
1932     #define DESCR_NEXT_PTR                  nextPtr
1933 
1934     /* Descriptor structure bitfields */
1935     #define DW_DESCR_STRUCT_DESCR_CTL_WAIT_FOR_DEACT_Pos 0UL
1936     #define DW_DESCR_STRUCT_DESCR_CTL_WAIT_FOR_DEACT_Msk 0x3UL
1937     #define DW_DESCR_STRUCT_DESCR_CTL_INTR_TYPE_Pos 2UL
1938     #define DW_DESCR_STRUCT_DESCR_CTL_INTR_TYPE_Msk 0xCUL
1939     #define DW_DESCR_STRUCT_DESCR_CTL_TR_OUT_TYPE_Pos 4UL
1940     #define DW_DESCR_STRUCT_DESCR_CTL_TR_OUT_TYPE_Msk 0x30UL
1941     #define DW_DESCR_STRUCT_DESCR_CTL_TR_IN_TYPE_Pos 6UL
1942     #define DW_DESCR_STRUCT_DESCR_CTL_TR_IN_TYPE_Msk 0xC0UL
1943     #define DW_DESCR_STRUCT_DESCR_CTL_CH_DISABLE_Pos 24UL
1944     #define DW_DESCR_STRUCT_DESCR_CTL_CH_DISABLE_Msk 0x1000000UL
1945     #define DW_DESCR_STRUCT_DESCR_CTL_SRC_TRANSFER_SIZE_Pos 26UL
1946     #define DW_DESCR_STRUCT_DESCR_CTL_SRC_TRANSFER_SIZE_Msk 0x4000000UL
1947     #define DW_DESCR_STRUCT_DESCR_CTL_DST_TRANSFER_SIZE_Pos 27UL
1948     #define DW_DESCR_STRUCT_DESCR_CTL_DST_TRANSFER_SIZE_Msk 0x8000000UL
1949     #define DW_DESCR_STRUCT_DESCR_CTL_DATA_SIZE_Pos 28UL
1950     #define DW_DESCR_STRUCT_DESCR_CTL_DATA_SIZE_Msk 0x30000000UL
1951     #define DW_DESCR_STRUCT_DESCR_CTL_DESCR_TYPE_Pos 30UL
1952     #define DW_DESCR_STRUCT_DESCR_CTL_DESCR_TYPE_Msk 0xC0000000UL
1953     #define DW_DESCR_STRUCT_DESCR_SRC_SRC_ADDR_Pos  0UL
1954     #define DW_DESCR_STRUCT_DESCR_SRC_SRC_ADDR_Msk  0xFFFFFFFFUL
1955     #define DW_DESCR_STRUCT_DESCR_DST_DST_ADDR_Pos  0UL
1956     #define DW_DESCR_STRUCT_DESCR_DST_DST_ADDR_Msk  0xFFFFFFFFUL
1957     #define DW_DESCR_STRUCT_DESCR_X_CTL_SRC_X_INCR_Pos 0UL
1958     #define DW_DESCR_STRUCT_DESCR_X_CTL_SRC_X_INCR_Msk 0xFFFUL
1959     #define DW_DESCR_STRUCT_DESCR_X_CTL_DST_X_INCR_Pos 12UL
1960     #define DW_DESCR_STRUCT_DESCR_X_CTL_DST_X_INCR_Msk 0xFFF000UL
1961     #define DW_DESCR_STRUCT_DESCR_X_CTL_X_COUNT_Pos 24UL
1962     #define DW_DESCR_STRUCT_DESCR_X_CTL_X_COUNT_Msk 0xFF000000UL
1963     #define DW_DESCR_STRUCT_DESCR_Y_CTL_SRC_Y_INCR_Pos 0UL
1964     #define DW_DESCR_STRUCT_DESCR_Y_CTL_SRC_Y_INCR_Msk 0xFFFUL
1965     #define DW_DESCR_STRUCT_DESCR_Y_CTL_DST_Y_INCR_Pos 12UL
1966     #define DW_DESCR_STRUCT_DESCR_Y_CTL_DST_Y_INCR_Msk 0xFFF000UL
1967     #define DW_DESCR_STRUCT_DESCR_Y_CTL_Y_COUNT_Pos 24UL
1968     #define DW_DESCR_STRUCT_DESCR_Y_CTL_Y_COUNT_Msk 0xFF000000UL
1969     #define DW_DESCR_STRUCT_DESCR_NEXT_PTR_ADDR_Pos 2UL
1970     #define DW_DESCR_STRUCT_DESCR_NEXT_PTR_ADDR_Msk 0xFFFFFFFCUL
1971 
1972     /* Functions */
1973     #define Cy_DMA_GetActiveChnl            Cy_DMA_GetActiveChannel
1974     #define Cy_DMA_GetActiveSrcAddr         Cy_DMA_GetActiveSrcAddress
1975     #define Cy_DMA_GetActiveDstAddr         Cy_DMA_GetActiveDstAddress
1976     #define Cy_DMA_Descr_Init               Cy_DMA_Descriptor_Init
1977     #define Cy_DMA_Descr_DeInit             Cy_DMA_Descriptor_DeInit
1978     #define Cy_DMA_Descr_SetSrcAddr         Cy_DMA_Descriptor_SetSrcAddress
1979     #define Cy_DMA_Descr_SetDestAddr        Cy_DMA_Descriptor_SetDstAddress
1980     #define Cy_DMA_Descr_SetNxtDescr        Cy_DMA_Descriptor_SetNextDescriptor
1981     #define Cy_DMA_Descr_SetIntrType        Cy_DMA_Descriptor_SetInterruptType
1982     #define Cy_DMA_Descr_SetTrigInType      Cy_DMA_Descriptor_SetTriggerInType
1983     #define Cy_DMA_Descr_SetTrigOutType     Cy_DMA_Descriptor_SetTriggerOutType
1984     #define Cy_DMA_Chnl_Init                Cy_DMA_Channel_Init
1985     #define Cy_DMA_Chnl_DeInit              Cy_DMA_Channel_DeInit
1986     #define Cy_DMA_Chnl_SetDescr            Cy_DMA_Channel_SetDescriptor
1987     #define Cy_DMA_Chnl_Enable              Cy_DMA_Channel_Enable
1988     #define Cy_DMA_Chnl_Disable             Cy_DMA_Channel_Disable
1989     #define Cy_DMA_Chnl_GetCurrentDescr     Cy_DMA_Channel_GetCurrentDescriptor
1990     #define Cy_DMA_Chnl_SetPriority         Cy_DMA_Channel_SetPriority
1991     #define Cy_DMA_Chnl_GetPriority         Cy_DMA_Channel_GetPriority
1992     #define Cy_DMA_Chnl_GetInterruptStatus  Cy_DMA_Channel_GetInterruptStatus
1993     #define Cy_DMA_Chnl_GetInterruptCause   Cy_DMA_Channel_GetStatus
1994     #define Cy_DMA_Chnl_ClearInterrupt      Cy_DMA_Channel_ClearInterrupt
1995     #define Cy_DMA_Chnl_SetInterrupt        Cy_DMA_Channel_SetInterrupt
1996     #define Cy_DMA_Chnl_GetInterruptMask    Cy_DMA_Channel_GetInterruptMask
1997     #define Cy_DMA_Chnl_GetInterruptStatusMasked Cy_DMA_Channel_GetInterruptStatusMasked
1998     #define Cy_DMA_Chnl_SetInterruptMask(base, channel) (Cy_DMA_Channel_SetInterruptMask(base, channel, CY_DMA_INTR_MASK))
1999 
2000 
2001 /*******************************************************************************
2002 * Function Name: Cy_DMA_Descr_SetTxfrWidth
2003 ****************************************************************************//**
2004 * This is a legacy API function. It is left here just for backward compatibility.
2005 * Do not use it in new designs.
2006 *******************************************************************************/
Cy_DMA_Descr_SetTxfrWidth(cy_stc_dma_descr_t * descriptor,uint32_t dataElementSize,uint32_t srcTxfrWidth,uint32_t dstTxfrWidth)2007     __STATIC_INLINE void Cy_DMA_Descr_SetTxfrWidth(cy_stc_dma_descr_t * descriptor,
2008                                                                uint32_t dataElementSize,
2009                                                                uint32_t srcTxfrWidth,
2010                                                                uint32_t dstTxfrWidth)
2011     {
2012         uint32_t regValue;
2013         regValue = descriptor->ctl & ((uint32_t)(~(DW_DESCR_STRUCT_DESCR_CTL_DATA_SIZE_Msk |
2014             DW_DESCR_STRUCT_DESCR_CTL_SRC_TRANSFER_SIZE_Msk |
2015             DW_DESCR_STRUCT_DESCR_CTL_DST_TRANSFER_SIZE_Msk)));
2016 
2017         descriptor->ctl = regValue |
2018             _VAL2FLD(DW_DESCR_STRUCT_DESCR_CTL_DATA_SIZE, dataElementSize) |
2019             _VAL2FLD(DW_DESCR_STRUCT_DESCR_CTL_SRC_TRANSFER_SIZE, srcTxfrWidth) |
2020             _VAL2FLD(DW_DESCR_STRUCT_DESCR_CTL_DST_TRANSFER_SIZE, dstTxfrWidth);
2021     }
2022 
2023 #endif /* CY_DMA_BWC */
2024 
2025 /** \endcond */
2026 
2027 CY_MISRA_BLOCK_END('MISRA C-2012 Rule 10.8')
2028 
2029 #if defined(__cplusplus)
2030 }
2031 #endif
2032 
2033 #endif /* CY_IP_M4CPUSS_DMA, CY_IP_MXDW */
2034 
2035 #endif  /* (CY_DMA_H) */
2036 
2037 /** \} group_dma */
2038 
2039 
2040 /* [] END OF FILE */
2041