spi2配置没问题,可以正常使用,但是加上dma,发现dma没有开启,有没有大佬告诉我一下,我下面的代码配置哪里有问题,找了好久找不出来,谢谢谢谢!!!
uint8_t spi2_tx_buf[6] = {0};
uint8_t spi2_rx_buf[6] = {0};
void DMA0_CH0_Config()//spi——RX
{
dma_single_data_parameter_struct dma_init_spi2_rx;
rcu_periph_clock_enable(RCU_DMA0);
dma_deinit(DMA0, DMA_CH0);
dma_init_spi2_rx.direction = DMA_PERIPH_TO_MEMORY;
dma_init_spi2_rx.memory0_addr = (uint32_t)(spi2_rx_buf); // 存储器地址
dma_init_spi2_rx.memory_inc = DMA_MEMORY_INCREASE_ENABLE;
dma_init_spi2_rx.periph_addr = (uint32_t)&SPI_DATA(SPI2);
dma_init_spi2_rx.periph_inc = DMA_PERIPH_INCREASE_DISABLE;
dma_init_spi2_rx.periph_memory_width = DMA_PERIPH_WIDTH_8BIT;
dma_init_spi2_rx.number = sizeof(spi2_rx_buf);
dma_init_spi2_rx.priority = DMA_PRIORITY_ULTRA_HIGH;
dma_init_spi2_rx.circular_mode = DMA_CIRCULAR_MODE_DISABLE;
dma_single_data_mode_init(DMA0, DMA_CH0, &dma_init_spi2_rx);
dma_channel_subperipheral_select(DMA0, DMA_CH0, DMA_SUBPERI4);
dma_memory_address_config(DMA0, DMA_CH0, DMA_MEMORY_0, (uint32_t)(spi2_rx_buf)); // 存储器地址
dma_transfer_number_config(DMA0, DMA_CH0, sizeof(spi2_rx_buf));
dma_channel_enable(DMA0, DMA_CH0);
spi_dma_enable(SPI2,SPI_DMA_RECEIVE);
}
|