配置的过程是这样的:
过程如下:
#define UART9_RX_DMA_CH (9)
#define UART9_PDMA_OPENED_CH_RX (1 << UART9_RX_DMA_CH)
UART9_Init(230400);
set_flag(flag_UART9_RX_end, DISABLE);
SYS_ResetModule(PDMA0_RST);
UART_PDMA_ENABLE(UART9, UART_INTEN_RXPDMAEN_Msk);
PDMA_Open(PDMA0, UART9_PDMA_OPENED_CH_RX);
PDMA_SetTransferCnt(PDMA0, UART9_RX_DMA_CH, PDMA_WIDTH_8, RX_size9);
PDMA_SetTransferAddr(PDMA0, UART9_RX_DMA_CH, UART9_BASE, PDMA_SAR_FIX, ((uint32_t) (&UART9_RXBuffer[0])), PDMA_DAR_INC);
PDMA_SetTransferMode(PDMA0, UART9_RX_DMA_CH, PDMA_UART9_RX, 0, 0);
PDMA_SetBurstType(PDMA0, UART9_RX_DMA_CH, PDMA_REQ_SINGLE, 0);
PDMA_DisableInt(PDMA0, UART9_RX_DMA_CH, PDMA_INT_TEMPTY );
PDMA_EnableInt(PDMA0, UART9_RX_DMA_CH, PDMA_INT_TRANS_DONE);
PDMA_EnableInt(PDMA0, UART9_RX_DMA_CH, PDMA_INT_TIMEOUT);
PDMA_SetTimeOut(PDMA0, UART9_RX_DMA_CH, OPEN, pdmat9);
NVIC_EnableIRQ(PDMA0_IRQn);
void PDMA0_IRQHandler(void)
{
uint32_t status = PDMA_GET_INT_STATUS(PDMA0);
。。。。。。。。。。。。。。。部分省略
if (PDMA_GET_TD_STS(PDMA0) & UART9_PDMA_OPENED_CH_RX)//UART9-done-RX
{
printf("\r\n uart9-done \r\n");
set_flag(flag_UART9_RX_end, ENABLE);
PDMA_CLR_TD_FLAG(PDMA0, UART9_PDMA_OPENED_CH_RX);
}
。。。。。。。。。。。。。。。部分省略
else if (status & (PDMA_INTSTS_REQTOF9_Msk)) //UART9-timeout
{
printf("\r\n uart9-timerout \r\n");
PDMA_SetTimeOut(PDMA0, UART9_RX_DMA_CH, DISABLE, 0);
PDMA_CLR_TMOUT_FLAG(PDMA0, UART9_RX_DMA_CH);
PDMA_SetTimeOut(PDMA0, UART9_RX_DMA_CH, ENABLE, pdmat9);
set_flag(flag_UART9_RX_end, ENABLE);
}
}
while(1)
{
if (is_flag_set(flag_UART9_RX_end))
{
set_flag(flag_UART9_RX_end, DISABLE);
reset_buffer(UART9_RXBuffer, 0x00, RX_size9);
PDMA_SetTransferCnt (PDMA0,UART9_RX_DMA_CH, PDMA_WIDTH_8, RX_size9);
PDMA_SetTransferAddr(PDMA0,UART9_RX_DMA_CH, UART9_BASE, PDMA_SAR_FIX, ((uint32_t) (&UART9_RXBuffer[0])), PDMA_DAR_INC);
PDMA_SetTransferMode(PDMA0,UART9_RX_DMA_CH, PDMA_UART9_RX, FALSE, 0);
}
}
|