dma_transfer_number_config(DMA_CH2,sizeof(g_dma_rx_buf)); dma_channel_enable(DMA_CH2); /* 开启DMA传输 */ g_dma_rx_finish= 1; } } } 注意:dma_transfer_number_get是获取配置的接收数据长度减去已接收数据的长度,所以上面拷贝接收数据时用总长度减去了这个获取的剩余区间...
DMA_CH1);//关闭DMA,在没有读取该接收帧数据之前禁止DMA再接收数据// DMA_INTC0(DMA0) |= DMA_FLAG_ADD(DMA_CHINTF_RESET_VALUE, DMA_CH1);dma_memory_address_config(DMA0, DMA_CH1, DMA_MEMORY_0, (uint32_t)(recv_buf));// 存储器地址dma_transfer_number_config(DMA0,...
if(usart_interrupt_flag_get(BSP_USART,USART_INT_FLAG_IDLE) == SET)//检测到帧中断{ usart_data_receive(BSP_USART);//必须要读,读出来的值不能要/*处理DMA接收到的数据*/g_recv_length= ARRAYNUM(g_recv_buff) - dma_transfer_number_get(BSP_DMA, BSP_DMA_CH);//获取实际接收到的数据长度g_r...
dma_init_struct.number = 0;dma_init_struct.direction = DMA_MEMORY_TO_PERIPHERAL;dma_init...
uint32_tdma_transfer_number_get(uint32_tdma_periph,dma_channel_enumchannelx) 1. 比如我们要获取 DMA 通道3还有多少个数据没有传输,方法是: dma_transfer_number_get(DMA0,DMA_CH3); 1. 最后看看UART0的DMA整体配置。 /** * @brief USART0 TX DMA 配置,内存到外设(USART0+0x04) ...
dma_init_struct.number = USART0_DMA_RXBUF_SIZE; //传输长度 dma_init_struct.periph_addr...
new_tx_dma_transfer_number = dma_transfer_number_get(); BytesToWrite -= last_tx_dma_transfer_number - new_tx_dma_transfer_number; last_tx_dma_transfer_number = new_tx_dma_transfer_number; if(new_tx_dma_transfer_number != 0){ return; } if(BytesToWrite == 0){ return; } dma_cha...
(Com1Rx_DMA_buffer)-dma_transfer_number_get(DMA0,DMA_CH5);memcpy(Subg_Com1RxData,Com1Rx_DMA_buffer,Com1Rx_DMA_BuffNum);/* 转存数据到待处理数据缓冲区*/Subg_Com1RxData[Com1Rx_DMA_BuffNum]='\0';/* 添加字符串结束符 *//* 重新设置DMA传输 */dma_memory_address_config(DMA0,DMA_...
while(dma_flag_get(DMA_CH1, DMA_INTF_FTFIF)==RESET); dma_flag_clear(DMA_CH1,DMA_INTC_FTFIFC); dma_channel_disable(DMA_CH1); dma_transfer_number_config(DMA_CH1,sizeof(RGB_buffer)); for(j=1;j<=num;++j) { for(i=0;i<24;++i) ...
g_rxBuffer.uCount =GetRingBufferLengthDMA(); g_txBuffer.uCount = g_rxBuffer.uCount;memcpy((void*)&g_txBuffer.byData, (void*)&g_rxBuffer.byData, g_rxBuffer.uCount);//继续接收下一帧数据LPUART_TransferAbortReceiveEDMA(DEMO_LPUART, &g_lpuartEdmaHandle);memset((void*)&g_rxBuffer,0,...