vuywsdfwf 发表于 2020-8-4 15:33
starterware user guide里有说明。
http://processors.wiki.ti.com/index.php/StarterWare_01.20.01.01_User_Guide#Example_Application_.28EDMA.29
int main(void)
[
/* Initialize EDMA3 Controller */
EDMA3Initialize(); //
// /* Initialize UART */
// UARTStdioInit();
/* Request DMA Channel and TCC for UART Transmit*/
EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
EDMA3_CHA_UART2_TX, EDMA3_CHA_UART2_TX,
EVT_QUEUE_NUM);
/* Registering Callback Function for TX*/
cb_Fxn[EDMA3_CHA_UART2_TX] = &callback;
/* Request DMA Channel and TCC for UART Receive */
EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
EDMA3_CHA_UART2_RX, EDMA3_CHA_UART2_RX,
EVT_QUEUE_NUM);
/* Registering Callback Function for RX*/
cb_Fxn[EDMA3_CHA_UART2_RX] = &callback; //发送与接收都用同一个回调函数,这个回调函数的作用就是uartdmadisable,然后flag变为一!!!!!!
/* Used for bCnt */
buffLength = strlen((const char *) enter);
/* Transmit Data for Enter Message */
UartTransmitData(EDMA3_CHA_UART2_TX, EDMA3_CHA_UART2_TX,
enter, buffLength);
/* Enabling UART in DMA Mode*/
UARTDMAEnable(SOC_UART_2_REGS, UART_RX_TRIG_LEVEL_1 |
UART_DMAMODE |
UART_FIFO_MODE );
/* Wait for control to return from call-back function */
while(0 == flag);
flag = 0;
/* Receive Data for Input */
UartReceiveData(EDMA3_CHA_UART2_RX, EDMA3_CHA_UART2_RX, buffer);
/* Enabling UART in DMA Mode*/
UARTDMAEnable(SOC_UART_2_REGS, UART_RX_TRIG_LEVEL_1 |
UART_DMAMODE |
UART_FIFO_MODE );
/* Wait for return from callback */
while(0 == flag);
flag = 0;
/* Transmit Data for Entered value */
UartTransmitData(EDMA3_CHA_UART2_TX, EDMA3_CHA_UART2_TX,
buffer, RX_BUFFER_SIZE);
/* Enabling UART in DMA Mode*/
UARTDMAEnable(SOC_UART_2_REGS, UART_RX_TRIG_LEVEL_1 |
UART_DMAMODE |
UART_FIFO_MODE );
/* Wait for return from callback */
while(0 == flag);
flag = 0;
/* Free EDMA3 Channels for TX and RX */
EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
EDMA3_CHA_UART2_TX, EDMA3_TRIG_MODE_EVENT,
EDMA3_CHA_UART2_TX, EVT_QUEUE_NUM);
EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
EDMA3_CHA_UART2_RX, EDMA3_TRIG_MODE_EVENT,
EDMA3_CHA_UART2_RX, EVT_QUEUE_NUM);
while(1);
]
这个为Starterware中关于Uart的edma3例程,为什么在下面的地方来了这个while(0==flag)
/* Transmit Data for Enter Message */
UartTransmitData(EDMA3_CHA_UART2_TX, EDMA3_CHA_UART2_TX,
enter, buffLength);
/* Enabling UART in DMA Mode*/
UARTDMAEnable(SOC_UART_2_REGS, UART_RX_TRIG_LEVEL_1 |
UART_DMAMODE |
UART_FIFO_MODE );
/* Wait for control to return from call-back function */
while(0 == flag);
flag = 0;
注释中Wait for control to return from call-back function 是用来干什么的?
还有这个例程是不是只能接收一次,回复一次就不能再接收了??
谢谢,求助!!