2 **************************************************************************
3 * @file at32f435_437_dma.c
6 * @brief contains all the functions for the dma firmware library
7 **************************************************************************
8 * Copyright notice & Disclaimer
10 * The software Board Support Package (BSP) that is made available to
11 * download from Artery official website is the copyrighted work of Artery.
12 * Artery authorizes customers to use, copy, and distribute the BSP
13 * software and its related documentation for the purpose of design and
14 * development in conjunction with Artery microcontrollers. Use of the
15 * software is governed by this copyright notice and the following disclaimer.
17 * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
18 * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
19 * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
20 * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
21 * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
24 **************************************************************************
27 #include "at32f435_437_conf.h"
29 /** @addtogroup AT32F435_437_periph_driver
34 * @brief DMA driver modules
38 #ifdef DMA_MODULE_ENABLED
40 /** @defgroup DMA_private_functions
45 * @brief reset dmax channely register.
46 * @param dmax_channely:
47 * this parameter can be one of the following values:
64 void dma_reset(dma_channel_type
*dmax_channely
)
67 dmax_channely
->ctrl_bit
.chen
= FALSE
;
68 dmax_channely
->ctrl
= 0;
69 dmax_channely
->dtcnt
= 0;
70 dmax_channely
->paddr
= 0;
71 dmax_channely
->maddr
= 0;
73 temp
= (uint32_t)dmax_channely
;
75 if((temp
& 0x6FF) < 0x608)
78 DMA1
->clr
|= (uint32_t)(0x0F << ((((temp
& 0xFF) - 0x08) / 0x14) * 4));
80 else if((temp
& 0x6FF) < 0x688)
83 DMA2
->clr
|= (uint32_t)(0x0F << ((((temp
& 0xFF) - 0x08) / 0x14) * 4));
88 * @brief set the number of data to be transferred.
89 * @param dmax_channely:
90 * this parameter can be one of the following values:
105 * @param data_number: the number of data to be transferred (0x0000~0xFFFF).
108 void dma_data_number_set(dma_channel_type
*dmax_channely
, uint16_t data_number
)
110 dmax_channely
->dtcnt
= data_number
;
114 * @brief get the number of data to be transferred.
115 * @param dmax_channely:
116 * this parameter can be one of the following values:
131 * @retval the number value.
133 uint16_t dma_data_number_get(dma_channel_type
*dmax_channely
)
135 return (uint16_t)dmax_channely
->dtcnt
;
139 * @brief enable or disable dma interrupt.
140 * @param dmax_channely:
141 * this parameter can be one of the following values:
157 * this parameter can be any combination of the following values:
161 * @param new_state (TRUE or FALSE)
164 void dma_interrupt_enable(dma_channel_type
*dmax_channely
, uint32_t dma_int
, confirm_state new_state
)
166 if(new_state
!= FALSE
)
168 dmax_channely
->ctrl
|= dma_int
;
172 dmax_channely
->ctrl
&= ~dma_int
;
177 * @brief enable or disable dma channel.
178 * @param dmax_channely:
179 * this parameter can be one of the following values:
194 * @param new_state (TRUE or FALSE).
197 void dma_channel_enable(dma_channel_type
*dmax_channely
, confirm_state new_state
)
199 dmax_channely
->ctrl_bit
.chen
= new_state
;
203 * @brief dma flag get.
205 * - DMA1_GL1_FLAG - DMA1_FDT1_FLAG - DMA1_HDT1_FLAG - DMA1_DTERR1_FLAG
206 * - DMA1_GL2_FLAG - DMA1_FDT2_FLAG - DMA1_HDT2_FLAG - DMA1_DTERR2_FLAG
207 * - DMA1_GL3_FLAG - DMA1_FDT3_FLAG - DMA1_HDT3_FLAG - DMA1_DTERR3_FLAG
208 * - DMA1_GL4_FLAG - DMA1_FDT4_FLAG - DMA1_HDT4_FLAG - DMA1_DTERR4_FLAG
209 * - DMA1_GL5_FLAG - DMA1_FDT5_FLAG - DMA1_HDT5_FLAG - DMA1_DTERR5_FLAG
210 * - DMA1_GL6_FLAG - DMA1_FDT6_FLAG - DMA1_HDT6_FLAG - DMA1_DTERR6_FLAG
211 * - DMA1_GL7_FLAG - DMA1_FDT7_FLAG - DMA1_HDT7_FLAG - DMA1_DTERR7_FLAG
212 * - DMA2_GL1_FLAG - DMA2_FDT1_FLAG - DMA2_HDT1_FLAG - DMA2_DTERR1_FLAG
213 * - DMA2_GL2_FLAG - DMA2_FDT2_FLAG - DMA2_HDT2_FLAG - DMA2_DTERR2_FLAG
214 * - DMA2_GL3_FLAG - DMA2_FDT3_FLAG - DMA2_HDT3_FLAG - DMA2_DTERR3_FLAG
215 * - DMA2_GL4_FLAG - DMA2_FDT4_FLAG - DMA2_HDT4_FLAG - DMA2_DTERR4_FLAG
216 * - DMA2_GL5_FLAG - DMA2_FDT5_FLAG - DMA2_HDT5_FLAG - DMA2_DTERR5_FLAG
217 * - DMA2_GL6_FLAG - DMA2_FDT6_FLAG - DMA2_HDT6_FLAG - DMA2_DTERR6_FLAG
218 * - DMA2_GL7_FLAG - DMA2_FDT7_FLAG - DMA2_HDT7_FLAG - DMA2_DTERR7_FLAG
219 * @retval state of dma flag.
221 flag_status
dma_flag_get(uint32_t dmax_flag
)
225 if(dmax_flag
> 0x10000000)
234 if((temp
& dmax_flag
) != RESET
)
245 * @brief dma flag clear.
247 * this parameter can be one of the following values:
248 * - DMA1_GL1_FLAG - DMA1_FDT1_FLAG - DMA1_HDT1_FLAG - DMA1_DTERR1_FLAG
249 * - DMA1_GL2_FLAG - DMA1_FDT2_FLAG - DMA1_HDT2_FLAG - DMA1_DTERR2_FLAG
250 * - DMA1_GL3_FLAG - DMA1_FDT3_FLAG - DMA1_HDT3_FLAG - DMA1_DTERR3_FLAG
251 * - DMA1_GL4_FLAG - DMA1_FDT4_FLAG - DMA1_HDT4_FLAG - DMA1_DTERR4_FLAG
252 * - DMA1_GL5_FLAG - DMA1_FDT5_FLAG - DMA1_HDT5_FLAG - DMA1_DTERR5_FLAG
253 * - DMA1_GL6_FLAG - DMA1_FDT6_FLAG - DMA1_HDT6_FLAG - DMA1_DTERR6_FLAG
254 * - DMA1_GL7_FLAG - DMA1_FDT7_FLAG - DMA1_HDT7_FLAG - DMA1_DTERR7_FLAG
255 * - DMA2_GL1_FLAG - DMA2_FDT1_FLAG - DMA2_HDT1_FLAG - DMA2_DTERR1_FLAG
256 * - DMA2_GL2_FLAG - DMA2_FDT2_FLAG - DMA2_HDT2_FLAG - DMA2_DTERR2_FLAG
257 * - DMA2_GL3_FLAG - DMA2_FDT3_FLAG - DMA2_HDT3_FLAG - DMA2_DTERR3_FLAG
258 * - DMA2_GL4_FLAG - DMA2_FDT4_FLAG - DMA2_HDT4_FLAG - DMA2_DTERR4_FLAG
259 * - DMA2_GL5_FLAG - DMA2_FDT5_FLAG - DMA2_HDT5_FLAG - DMA2_DTERR5_FLAG
260 * - DMA2_GL6_FLAG - DMA2_FDT6_FLAG - DMA2_HDT6_FLAG - DMA2_DTERR6_FLAG
261 * - DMA2_GL7_FLAG - DMA2_FDT7_FLAG - DMA2_HDT7_FLAG - DMA2_DTERR7_FLAG
264 void dma_flag_clear(uint32_t dmax_flag
)
266 if(dmax_flag
> ((uint32_t)0x10000000))
268 DMA2
->clr
= (uint32_t)(dmax_flag
& 0x0FFFFFFF);
272 DMA1
->clr
= dmax_flag
;
277 * @brief dma init config with its default value.
278 * @param dma_init_struct: pointer to a dma_init_type structure which will be initialized.
281 void dma_default_para_init(dma_init_type
*dma_init_struct
)
283 dma_init_struct
->peripheral_base_addr
= 0;
284 dma_init_struct
->memory_base_addr
= 0;
285 dma_init_struct
->direction
= DMA_DIR_PERIPHERAL_TO_MEMORY
;
286 dma_init_struct
->buffer_size
= 0;
287 dma_init_struct
->peripheral_inc_enable
= FALSE
;
288 dma_init_struct
->memory_inc_enable
= FALSE
;
289 dma_init_struct
->peripheral_data_width
= DMA_PERIPHERAL_DATA_WIDTH_BYTE
;
290 dma_init_struct
->memory_data_width
= DMA_MEMORY_DATA_WIDTH_BYTE
;
291 dma_init_struct
->loop_mode_enable
= FALSE
;
292 dma_init_struct
->priority
= DMA_PRIORITY_LOW
;
297 * @param dmax_channely:
298 * this parameter can be one of the following values:
313 * @param dma_init_struct: pointer to a dma_init_type structure.
316 void dma_init(dma_channel_type
*dmax_channely
, dma_init_type
*dma_init_struct
)
318 /* clear ctrl register dtd bit and m2m bit */
319 dmax_channely
->ctrl
&= 0xbfef;
320 dmax_channely
->ctrl
|= dma_init_struct
->direction
;
322 dmax_channely
->ctrl_bit
.chpl
= dma_init_struct
->priority
;
323 dmax_channely
->ctrl_bit
.mwidth
= dma_init_struct
->memory_data_width
;
324 dmax_channely
->ctrl_bit
.pwidth
= dma_init_struct
->peripheral_data_width
;
325 dmax_channely
->ctrl_bit
.mincm
= dma_init_struct
->memory_inc_enable
;
326 dmax_channely
->ctrl_bit
.pincm
= dma_init_struct
->peripheral_inc_enable
;
327 dmax_channely
->ctrl_bit
.lm
= dma_init_struct
->loop_mode_enable
;
328 dmax_channely
->dtcnt_bit
.cnt
= dma_init_struct
->buffer_size
;
329 dmax_channely
->paddr
= dma_init_struct
->peripheral_base_addr
;
330 dmax_channely
->maddr
= dma_init_struct
->memory_base_addr
;
333 * @brief dmamux init.
334 * @param dma_x: pointer to a dma_type structure, can be DMA1 or DMA2.
335 * @param dmamux_channelx:
336 * this parameter can be one of the following values:
351 * @param dmamux_req_sel:
352 * this parameter can be one of the following values:
353 * - DMAMUX_DMAREQ_ID_REQ_G1 - DMAMUX_DMAREQ_ID_REQ_G2 - DMAMUX_DMAREQ_ID_REQ_G3 - DMAMUX_DMAREQ_ID_REQ_G4
354 * - DMAMUX_DMAREQ_ID_ADC1 - DMAMUX_DMAREQ_ID_ADC2 - DMAMUX_DMAREQ_ID_ADC3 - DMAMUX_DMAREQ_ID_DAC1
355 * - DMAMUX_DMAREQ_ID_DAC2 - DMAMUX_DMAREQ_ID_TMR6_OVERFLOW- DMAMUX_DMAREQ_ID_TMR7_OVERFLOW- DMAMUX_DMAREQ_ID_SPI1_RX
356 * - DMAMUX_DMAREQ_ID_SPI1_TX - DMAMUX_DMAREQ_ID_SPI2_RX - DMAMUX_DMAREQ_ID_SPI2_TX - DMAMUX_DMAREQ_ID_SPI3_RX
357 * - DMAMUX_DMAREQ_ID_SPI3_TX - DMAMUX_DMAREQ_ID_SPI4_RX - DMAMUX_DMAREQ_ID_SPI4_TX - DMAMUX_DMAREQ_ID_I2S2_EXT_RX
358 * - DMAMUX_DMAREQ_ID_I2S2_EXT_TX - DMAMUX_DMAREQ_ID_I2S3_EXT_RX - DMAMUX_DMAREQ_ID_I2S3_EXT_TX - DMAMUX_DMAREQ_ID_I2C1_RX
359 * - DMAMUX_DMAREQ_ID_I2C1_TX - DMAMUX_DMAREQ_ID_I2C2_RX - DMAMUX_DMAREQ_ID_I2C2_TX - DMAMUX_DMAREQ_ID_I2C3_RX
360 * - DMAMUX_DMAREQ_ID_I2C3_TX - DMAMUX_DMAREQ_ID_USART1_RX - DMAMUX_DMAREQ_ID_USART1_TX - DMAMUX_DMAREQ_ID_USART2_RX
361 * - DMAMUX_DMAREQ_ID_USART2_TX - DMAMUX_DMAREQ_ID_USART3_RX - DMAMUX_DMAREQ_ID_USART3_TX - DMAMUX_DMAREQ_ID_UART4_RX
362 * - DMAMUX_DMAREQ_ID_UART4_TX - DMAMUX_DMAREQ_ID_UART5_RX - DMAMUX_DMAREQ_ID_UART5_TX - DMAMUX_DMAREQ_ID_USART6_RX
363 * - DMAMUX_DMAREQ_ID_USART6_TX - DMAMUX_DMAREQ_ID_UART7_RX - DMAMUX_DMAREQ_ID_UART7_TX - DMAMUX_DMAREQ_ID_UART8_RX
364 * - DMAMUX_DMAREQ_ID_UART8_TX - DMAMUX_DMAREQ_ID_SDIO1 - DMAMUX_DMAREQ_ID_SDIO2 - DMAMUX_DMAREQ_ID_QSPI1
365 * - DMAMUX_DMAREQ_ID_QSPI2 - DMAMUX_DMAREQ_ID_TMR1_CH1 - DMAMUX_DMAREQ_ID_TMR1_CH2 - DMAMUX_DMAREQ_ID_TMR1_CH3
366 * - DMAMUX_DMAREQ_ID_TMR1_CH4 - DMAMUX_DMAREQ_ID_TMR1_OVERFLOW- DMAMUX_DMAREQ_ID_TMR1_TRIG - DMAMUX_DMAREQ_ID_TMR1_COM
367 * - DMAMUX_DMAREQ_ID_TMR8_CH1 - DMAMUX_DMAREQ_ID_TMR8_CH2 - DMAMUX_DMAREQ_ID_TMR8_CH3 - DMAMUX_DMAREQ_ID_TMR8_CH4
368 * - DMAMUX_DMAREQ_ID_TMR8_UP - DMAMUX_DMAREQ_ID_TMR8_TRIG - DMAMUX_DMAREQ_ID_TMR8_COM - DMAMUX_DMAREQ_ID_TMR2_CH1
369 * - DMAMUX_DMAREQ_ID_TMR2_CH2 - DMAMUX_DMAREQ_ID_TMR2_CH3 - DMAMUX_DMAREQ_ID_TMR2_CH4 - DMAMUX_DMAREQ_ID_TMR2_OVERFLOW
370 * - DMAMUX_DMAREQ_ID_TMR2_TRIG - DMAMUX_DMAREQ_ID_TMR3_CH1 - DMAMUX_DMAREQ_ID_TMR3_CH2 - DMAMUX_DMAREQ_ID_TMR3_CH3
371 * - DMAMUX_DMAREQ_ID_TMR3_CH4 - DMAMUX_DMAREQ_ID_TMR3_OVERFLOW- DMAMUX_DMAREQ_ID_TMR3_TRIG - DMAMUX_DMAREQ_ID_TMR4_CH1
372 * - DMAMUX_DMAREQ_ID_TMR4_CH2 - DMAMUX_DMAREQ_ID_TMR4_CH3 - DMAMUX_DMAREQ_ID_TMR4_CH4 - DMAMUX_DMAREQ_ID_TMR4_OVERFLOW
373 * - DMAMUX_DMAREQ_ID_TMR4_TRIG - DMAMUX_DMAREQ_ID_TMR5_CH1 - DMAMUX_DMAREQ_ID_TMR5_CH2 - DMAMUX_DMAREQ_ID_TMR5_CH3
374 * - DMAMUX_DMAREQ_ID_TMR5_CH4 - DMAMUX_DMAREQ_ID_TMR5_OVERFLOW- DMAMUX_DMAREQ_ID_TMR5_TRIG - DMAMUX_DMAREQ_ID_TMR20_CH1
375 * - DMAMUX_DMAREQ_ID_TMR20_CH2 - DMAMUX_DMAREQ_ID_TMR20_CH3 - DMAMUX_DMAREQ_ID_TMR20_CH4 - DMAMUX_DMAREQ_ID_TMR20_OVERFLOW
376 * - DMAMUX_DMAREQ_ID_TMR20_TRIG - DMAMUX_DMAREQ_ID_TMR20_HALL - DMAMUX_DMAREQ_ID_DVP
379 void dma_flexible_config(dma_type
* dma_x
, dmamux_channel_type
*dmamux_channelx
, dmamux_requst_id_sel_type dmamux_req_sel
)
381 dma_x
->muxsel_bit
.tblsel
= TRUE
;
382 dmamux_channelx
->muxctrl_bit
.reqsel
= dmamux_req_sel
;
386 * @brief enable or disable the dmamux.
387 * @param dma_x: pointer to a dma_type structure, can be DMA1 or DMA2.
388 * @param new_state (TRUE or FALSE) .
391 void dmamux_enable(dma_type
*dma_x
, confirm_state new_state
)
393 dma_x
->muxsel_bit
.tblsel
= new_state
;
397 * @brief dmamux init.
398 * @param dmamux_channelx:
399 * this parameter can be one of the following values:
414 * @param dmamux_req_sel:
415 * this parameter can be one of the following values:
416 * - DMAMUX_DMAREQ_ID_REQ_G1 - DMAMUX_DMAREQ_ID_REQ_G2 - DMAMUX_DMAREQ_ID_REQ_G3 - DMAMUX_DMAREQ_ID_REQ_G4
417 * - DMAMUX_DMAREQ_ID_ADC1 - DMAMUX_DMAREQ_ID_ADC2 - DMAMUX_DMAREQ_ID_ADC3 - DMAMUX_DMAREQ_ID_DAC1
418 * - DMAMUX_DMAREQ_ID_DAC2 - DMAMUX_DMAREQ_ID_TMR6_OVERFLOW- DMAMUX_DMAREQ_ID_TMR7_OVERFLOW- DMAMUX_DMAREQ_ID_SPI1_RX
419 * - DMAMUX_DMAREQ_ID_SPI1_TX - DMAMUX_DMAREQ_ID_SPI2_RX - DMAMUX_DMAREQ_ID_SPI2_TX - DMAMUX_DMAREQ_ID_SPI3_RX
420 * - DMAMUX_DMAREQ_ID_SPI3_TX - DMAMUX_DMAREQ_ID_SPI4_RX - DMAMUX_DMAREQ_ID_SPI4_TX - DMAMUX_DMAREQ_ID_I2S2_EXT_RX
421 * - DMAMUX_DMAREQ_ID_I2S2_EXT_TX - DMAMUX_DMAREQ_ID_I2S3_EXT_RX - DMAMUX_DMAREQ_ID_I2S3_EXT_TX - DMAMUX_DMAREQ_ID_I2C1_RX
422 * - DMAMUX_DMAREQ_ID_I2C1_TX - DMAMUX_DMAREQ_ID_I2C2_RX - DMAMUX_DMAREQ_ID_I2C2_TX - DMAMUX_DMAREQ_ID_I2C3_RX
423 * - DMAMUX_DMAREQ_ID_I2C3_TX - DMAMUX_DMAREQ_ID_USART1_RX - DMAMUX_DMAREQ_ID_USART1_TX - DMAMUX_DMAREQ_ID_USART2_RX
424 * - DMAMUX_DMAREQ_ID_USART2_TX - DMAMUX_DMAREQ_ID_USART3_RX - DMAMUX_DMAREQ_ID_USART3_TX - DMAMUX_DMAREQ_ID_UART4_RX
425 * - DMAMUX_DMAREQ_ID_UART4_TX - DMAMUX_DMAREQ_ID_UART5_RX - DMAMUX_DMAREQ_ID_UART5_TX - DMAMUX_DMAREQ_ID_USART6_RX
426 * - DMAMUX_DMAREQ_ID_USART6_TX - DMAMUX_DMAREQ_ID_UART7_RX - DMAMUX_DMAREQ_ID_UART7_TX - DMAMUX_DMAREQ_ID_UART8_RX
427 * - DMAMUX_DMAREQ_ID_UART8_TX - DMAMUX_DMAREQ_ID_SDIO1 - DMAMUX_DMAREQ_ID_SDIO2 - DMAMUX_DMAREQ_ID_QSPI1
428 * - DMAMUX_DMAREQ_ID_QSPI2 - DMAMUX_DMAREQ_ID_TMR1_CH1 - DMAMUX_DMAREQ_ID_TMR1_CH2 - DMAMUX_DMAREQ_ID_TMR1_CH3
429 * - DMAMUX_DMAREQ_ID_TMR1_CH4 - DMAMUX_DMAREQ_ID_TMR1_OVERFLOW- DMAMUX_DMAREQ_ID_TMR1_TRIG - DMAMUX_DMAREQ_ID_TMR1_COM
430 * - DMAMUX_DMAREQ_ID_TMR8_CH1 - DMAMUX_DMAREQ_ID_TMR8_CH2 - DMAMUX_DMAREQ_ID_TMR8_CH3 - DMAMUX_DMAREQ_ID_TMR8_CH4
431 * - DMAMUX_DMAREQ_ID_TMR8_UP - DMAMUX_DMAREQ_ID_TMR8_TRIG - DMAMUX_DMAREQ_ID_TMR8_COM - DMAMUX_DMAREQ_ID_TMR2_CH1
432 * - DMAMUX_DMAREQ_ID_TMR2_CH2 - DMAMUX_DMAREQ_ID_TMR2_CH3 - DMAMUX_DMAREQ_ID_TMR2_CH4 - DMAMUX_DMAREQ_ID_TMR2_OVERFLOW
433 * - DMAMUX_DMAREQ_ID_TMR2_TRIG - DMAMUX_DMAREQ_ID_TMR3_CH1 - DMAMUX_DMAREQ_ID_TMR3_CH2 - DMAMUX_DMAREQ_ID_TMR3_CH3
434 * - DMAMUX_DMAREQ_ID_TMR3_CH4 - DMAMUX_DMAREQ_ID_TMR3_OVERFLOW- DMAMUX_DMAREQ_ID_TMR3_TRIG - DMAMUX_DMAREQ_ID_TMR4_CH1
435 * - DMAMUX_DMAREQ_ID_TMR4_CH2 - DMAMUX_DMAREQ_ID_TMR4_CH3 - DMAMUX_DMAREQ_ID_TMR4_CH4 - DMAMUX_DMAREQ_ID_TMR4_OVERFLOW
436 * - DMAMUX_DMAREQ_ID_TMR4_TRIG - DMAMUX_DMAREQ_ID_TMR5_CH1 - DMAMUX_DMAREQ_ID_TMR5_CH2 - DMAMUX_DMAREQ_ID_TMR5_CH3
437 * - DMAMUX_DMAREQ_ID_TMR5_CH4 - DMAMUX_DMAREQ_ID_TMR5_OVERFLOW- DMAMUX_DMAREQ_ID_TMR5_TRIG - DMAMUX_DMAREQ_ID_TMR20_CH1
438 * - DMAMUX_DMAREQ_ID_TMR20_CH2 - DMAMUX_DMAREQ_ID_TMR20_CH3 - DMAMUX_DMAREQ_ID_TMR20_CH4 - DMAMUX_DMAREQ_ID_TMR20_OVERFLOW
439 * - DMAMUX_DMAREQ_ID_TMR20_TRIG - DMAMUX_DMAREQ_ID_TMR20_HALL - DMAMUX_DMAREQ_ID_DVP
442 void dmamux_init(dmamux_channel_type
*dmamux_channelx
, dmamux_requst_id_sel_type dmamux_req_sel
)
444 dmamux_channelx
->muxctrl_bit
.reqsel
= dmamux_req_sel
;
448 * @brief dmamux sync init struct config with its default value.
449 * @param dmamux_sync_init_struct: pointer to a dmamux_sync_init_type structure which will be initialized.
452 void dmamux_sync_default_para_init(dmamux_sync_init_type
*dmamux_sync_init_struct
)
454 dmamux_sync_init_struct
->sync_enable
= FALSE
;
455 dmamux_sync_init_struct
->sync_event_enable
= FALSE
;
456 dmamux_sync_init_struct
->sync_polarity
= DMAMUX_SYNC_POLARITY_DISABLE
;
457 dmamux_sync_init_struct
->sync_request_number
= 0x0;
458 dmamux_sync_init_struct
->sync_signal_sel
= (dmamux_sync_id_sel_type
)0;
462 * @brief dmamux synchronization config.
463 * @param dmamux_channelx:
464 * this parameter can be one of the following values:
479 * @param dmamux_sync_init_struct: ointer to a dmamux_sync_init_type structure.
482 void dmamux_sync_config(dmamux_channel_type
*dmamux_channelx
, dmamux_sync_init_type
*dmamux_sync_init_struct
)
484 dmamux_channelx
->muxctrl_bit
.syncsel
= dmamux_sync_init_struct
->sync_signal_sel
;
485 dmamux_channelx
->muxctrl_bit
.syncpol
= dmamux_sync_init_struct
->sync_polarity
;
486 dmamux_channelx
->muxctrl_bit
.reqcnt
= dmamux_sync_init_struct
->sync_request_number
;
487 dmamux_channelx
->muxctrl_bit
.evtgen
= dmamux_sync_init_struct
->sync_event_enable
;
488 dmamux_channelx
->muxctrl_bit
.syncen
= dmamux_sync_init_struct
->sync_enable
;
492 * @brief dmamux request generator init struct config with its default value.
493 * @param dmamux_gen_init_struct: pointer to a dmamux_gen_init_type structure which will be initialized.
496 void dmamux_generator_default_para_init(dmamux_gen_init_type
*dmamux_gen_init_struct
)
498 dmamux_gen_init_struct
->gen_enable
= FALSE
;
499 dmamux_gen_init_struct
->gen_polarity
= DMAMUX_GEN_POLARITY_DISABLE
;
500 dmamux_gen_init_struct
->gen_request_number
= 0x0;
501 dmamux_gen_init_struct
->gen_signal_sel
= (dmamux_gen_id_sel_type
)0x0;
505 * @brief dmamux request generator init.
506 * @param dmamux_gen_x :
507 * this parameter can be one of the following values:
508 * - DMA1MUX_GENERATOR1
509 * - DMA1MUX_GENERATOR2
510 * - DMA1MUX_GENERATOR3
511 * - DMA1MUX_GENERATOR4
512 * - DMA2MUX_GENERATOR1
513 * - DMA2MUX_GENERATOR2
514 * - DMA2MUX_GENERATOR3
515 * - DMA2MUX_GENERATOR4
516 * @param dmamux_gen_init_struct: pointer to a dmamux_gen_init_type structure which will be initialized.
519 void dmamux_generator_config(dmamux_generator_type
*dmamux_gen_x
, dmamux_gen_init_type
*dmamux_gen_init_struct
)
521 dmamux_gen_x
->gctrl_bit
.sigsel
= dmamux_gen_init_struct
->gen_signal_sel
;
522 dmamux_gen_x
->gctrl_bit
.gpol
= dmamux_gen_init_struct
->gen_polarity
;
523 dmamux_gen_x
->gctrl_bit
.greqcnt
= dmamux_gen_init_struct
->gen_request_number
;
524 dmamux_gen_x
->gctrl_bit
.gen
= dmamux_gen_init_struct
->gen_enable
;
528 * @brief enable or disable the dmamux sync interrupts.
529 * @param dmamux_channelx:
530 * this parameter can be one of the following values:
545 * @param new_state (TRUE or FALSE).
548 void dmamux_sync_interrupt_enable(dmamux_channel_type
*dmamux_channelx
, confirm_state new_state
)
550 if(new_state
!= FALSE
)
552 dmamux_channelx
->muxctrl_bit
.syncovien
= TRUE
;
556 dmamux_channelx
->muxctrl_bit
.syncovien
= FALSE
;
561 * @brief enable or disable the dmamux request generator interrupts.
562 * @param dmamux_gen_x : pointer to a dmamux_generator_type structure.
563 * this parameter can be one of the following values:
564 * - DMA1MUX_GENERATOR1
565 * - DMA1MUX_GENERATOR2
566 * - DMA1MUX_GENERATOR3
567 * - DMA1MUX_GENERATOR4
568 * - DMA2MUX_GENERATOR1
569 * - DMA2MUX_GENERATOR2
570 * - DMA2MUX_GENERATOR3
571 * - DMA2MUX_GENERATOR4
572 * @param new_state (TRUE or FALSE).
575 void dmamux_generator_interrupt_enable(dmamux_generator_type
*dmamux_gen_x
, confirm_state new_state
)
577 if(new_state
!= FALSE
)
579 dmamux_gen_x
->gctrl_bit
.trgovien
= TRUE
;
583 dmamux_gen_x
->gctrl_bit
.trgovien
= FALSE
;
588 * @brief dmamux sync flag get.
589 * @param dma_x : pointer to a dma_type structure, can be DMA1 or DMA2.
591 * this parameter can be any combination of the following values:
592 * - DMAMUX_SYNC_OV1_FLAG
593 * - DMAMUX_SYNC_OV2_FLAG
594 * - DMAMUX_SYNC_OV3_FLAG
595 * - DMAMUX_SYNC_OV4_FLAG
596 * - DMAMUX_SYNC_OV5_FLAG
597 * - DMAMUX_SYNC_OV6_FLAG
598 * - DMAMUX_SYNC_OV7_FLAG
599 * @retval state of dmamux sync flag.
601 flag_status
dmamux_sync_flag_get(dma_type
*dma_x
, uint32_t flag
)
603 if((dma_x
->muxsyncsts
& flag
) != RESET
)
614 * @brief dmamux sync flag clear.
615 * @param dma_x : pointer to a dma_type structure, can be DMA1 or DMA2.
617 * this parameter can be any combination of the following values:
618 * - DMAMUX_SYNC_OV1_FLAG
619 * - DMAMUX_SYNC_OV2_FLAG
620 * - DMAMUX_SYNC_OV3_FLAG
621 * - DMAMUX_SYNC_OV4_FLAG
622 * - DMAMUX_SYNC_OV5_FLAG
623 * - DMAMUX_SYNC_OV6_FLAG
624 * - DMAMUX_SYNC_OV7_FLAG
627 void dmamux_sync_flag_clear(dma_type
*dma_x
, uint32_t flag
)
629 dma_x
->muxsyncclr
= flag
;
633 * @brief dmamux request generator flag get.
634 * @param dma_x : pointer to a dma_type structure, can be DMA1 or DMA2.
636 * this parameter can be any combination of the following values:
637 * - DMAMUX_GEN_TRIG_OV1_FLAG
638 * - DMAMUX_GEN_TRIG_OV2_FLAG
639 * - DMAMUX_GEN_TRIG_OV3_FLAG
640 * - DMAMUX_GEN_TRIG_OV4_FLAG
641 * @retval state of dmamux sync flag.
643 flag_status
dmamux_generator_flag_get(dma_type
*dma_x
, uint32_t flag
)
645 if((dma_x
->muxgsts
& flag
) != RESET
)
656 * @brief dmamux request generator flag clear.
657 * @param dma_x : pointer to a dma_type structure, can be DMA1 or DMA2.
659 * this parameter can be any combination of the following values:
660 * - DMAMUX_GEN_TRIG_OV1_FLAG
661 * - DMAMUX_GEN_TRIG_OV2_FLAG
662 * - DMAMUX_GEN_TRIG_OV3_FLAG
663 * - DMAMUX_GEN_TRIG_OV4_FLAG
666 void dmamux_generator_flag_clear(dma_type
*dma_x
, uint32_t flag
)
668 dma_x
->muxgclr
= flag
;