void DCI_DMA_Init(uint32_t DMA_Memory0BaseAddr, uint32_t DMA_Memory1BaseAddr, uint16_t DMA_BufferSize)
{
dma_single_data_parameter_struct dma_single_struct;
// DCI DMA configuration
rcu_periph_clock_enable(RCU_DMA1);
//
pData0 = (uint32_t *)DMA_Memory0BaseAddr;
pData1 = (uint32_t *)DMA_Memory1BaseAddr;
mDatalen = DMA_BufferSize;
dma_single_data_para_struct_init(&dma_single_struct);
#if (DCI_DMA_CON == DCI_DMA_CH1)
dma_deinit(DMA1,DMA_CH1);
#else
dma_deinit(DMA1,DMA_CH7);
#endif
dma_single_struct.periph_addr = (uint32_t)DCI_DR_ADDRESS;
dma_single_struct.memory0_addr = (uint32_t)DMA_Memory0BaseAddr;
dma_single_struct.direction = DMA_PERIPH_TO_MEMORY;
dma_single_struct.number = DMA_BufferSize;
dma_single_struct.periph_inc = DMA_PERIPH_INCREASE_DISABLE;
dma_single_struct.memory_inc = DMA_MEMORY_INCREASE_ENABLE;
dma_single_struct.periph_memory_width = DMA_PERIPH_WIDTH_32BIT;
dma_single_struct.priority = DMA_PRIORITY_HIGH;
dma_single_struct.circular_mode = DMA_CIRCULAR_MODE_ENABLE;
#if (DCI_DMA_CON == DCI_DMA_CH1)
dma_priority_config(DMA1,DMA_CH1,DMA_PRIORITY_ULTRA_HIGH);
dma_single_data_mode_init(DMA1,DMA_CH1,&dma_single_struct);
dma_channel_subperipheral_select(DMA1,DMA_CH1,DMA_SUBPERI1);
#else
dma_priority_config(DMA1,DMA_CH7,DMA_PRIORITY_ULTRA_HIGH);
dma_single_data_mode_init(DMA1,DMA_CH7,&dma_single_struct);
dma_channel_subperipheral_select(DMA1,DMA_CH7,DMA_SUBPERI1);
#endif
// dma_flow_controller_config(DMA1,DMA_CH7,DMA_FLOW_CONTROLLER_PERI);
if(DMA_Memory1BaseAddr)
{
#if (DCI_DMA_CON == DCI_DMA_CH1)
dma_switch_buffer_mode_config(DMA1,DMA_CH1,DMA_Memory1BaseAddr,DMA_MEMORY_0);
dma_switch_buffer_mode_enable(DMA1,DMA_CH1,ENABLE);
#else
dma_switch_buffer_mode_config(DMA1,DMA_CH7,DMA_Memory1BaseAddr,DMA_MEMORY_0);
dma_switch_buffer_mode_enable(DMA1,DMA_CH7,ENABLE);
#endif
}
#if (DCI_DMA_CON == DCI_DMA_CH1)
dma_interrupt_enable(DMA1,DMA_CH1,DMA_CHXCTL_FTFIE);
nvic_irq_enable(DMA1_Channel1_IRQn, 0, 0);
#else
dma_interrupt_flag_clear(DMA1,DMA_CH7,DMA_CHXCTL_FTFIE);
dma_interrupt_enable(DMA1,DMA_CH7,DMA_CHXCTL_FTFIE);
nvic_irq_enable(DMA1_Channel7_IRQn, 0, 0);
#endif
} |