/* * initEdma() - Initialize the DMA controller. Use linked transfers to * automatically transition from ping to pong and visa-versa. */ void initEdma(void) { /* Configure transmit channel */ hEdmaXmt = EDMA_open(EDMA_CHA_XEVT1, EDMA_OPEN_RESET); // get hEdmaXmt handle and reset channel hEdmaReloadXmtPing = EDMA_allocTable(-1); // get hEdmaReloadXmtPing handle hEdmaReloadXmtPong = EDMA_allocTable(-1); // get hEdmaReloadXmtPong handle gEdmaConfigXmt.dst = MCBSP_getXmtAddr(hMcbsp1); // set the desination address to McBSP1 DXR gXmtChan = EDMA_intAlloc(-1); // get an open TCC gEdmaConfigXmt.opt |= EDMA_FMK(OPT,TCC,gXmtChan); // set TCC to gXmtChan EDMA_config(hEdmaXmt, &gEdmaConfigXmt); // then configure the registers EDMA_config(hEdmaReloadXmtPing, &gEdmaConfigXmt); // and the reload for Ping gEdmaConfigXmt.src = EDMA_SRC_OF(gBufferXmtPong); // change the structure to have a source of Pong EDMA_config(hEdmaReloadXmtPong, &gEdmaConfigXmt); // and configure the reload for Pong EDMA_link(hEdmaXmt,hEdmaReloadXmtPong); // link the regs to Pong EDMA_link(hEdmaReloadXmtPong,hEdmaReloadXmtPing); // link Pong to Ping EDMA_link(hEdmaReloadXmtPing,hEdmaReloadXmtPong); // and link Ping to Pong /* Configure receive channel */ hEdmaRcv = EDMA_open(EDMA_CHA_REVT1, EDMA_OPEN_RESET); // get hEdmaRcv handle and reset channel hEdmaReloadRcvPing = EDMA_allocTable(-1); // get hEdmaReloadRcvPing handle hEdmaReloadRcvPong = EDMA_allocTable(-1); // get hEdmaReloadRcvPong handle gEdmaConfigRcv.src = MCBSP_getRcvAddr(hMcbsp1); // and the desination address to McBSP1 DXR gRcvChan = EDMA_intAlloc(-1); // get an open TCC gEdmaConfigRcv.opt |= EDMA_FMK(OPT,TCC,gRcvChan); // set TCC to gRcvChan EDMA_config(hEdmaRcv, &gEdmaConfigRcv); // then configure the registers EDMA_config(hEdmaReloadRcvPing, &gEdmaConfigRcv); // and the reload for Ping gEdmaConfigRcv.dst = EDMA_DST_OF(gBufferRcvPong); // change the structure to have a destination of Pong EDMA_config(hEdmaReloadRcvPong, &gEdmaConfigRcv); // and configure the reload for Pong EDMA_link(hEdmaRcv,hEdmaReloadRcvPong); // link the regs to Pong EDMA_link(hEdmaReloadRcvPong,hEdmaReloadRcvPing); // link Pong to Ping EDMA_link(hEdmaReloadRcvPing,hEdmaReloadRcvPong); // and link Ping to Pong /* Enable interrupts in the EDMA controller */ EDMA_intClear(gXmtChan); EDMA_intClear(gRcvChan); // clear any possible spurious interrupts EDMA_intEnable(gXmtChan); // enable EDMA interrupts (CIER) EDMA_intEnable(gRcvChan); // enable EDMA interrupts (CIER) EDMA_enableChannel(hEdmaXmt); // enable EDMA channel EDMA_enableChannel(hEdmaRcv); // enable EDMA channel /* Do a dummy write to generate the first McBSP transmit event */ MCBSP_write(hMcbsp1, 0); }
/* * EDMA receive channel config */ EDMA_Config gEdmaRcvConfig = { EDMA_OPT_RMK( EDMA_OPT_PRI_LOW, EDMA_OPT_ESIZE_32BIT, EDMA_OPT_2DS_NO, EDMA_OPT_SUM_NONE, // no source address update EDMA_OPT_2DD_NO, EDMA_OPT_DUM_INC, // increment destination address EDMA_OPT_TCINT_YES, // Source address update mode EDMA_OPT_TCC_DEFAULT, EDMA_OPT_LINK_YES, EDMA_OPT_FS_NO), // Frame synchronisation, we copy element by element EDMA_SRC_OF(0x00000000), // EDMA Channel Source Address EDMA_CNT_RMK(0, 108), // Frame count (FRMCNT), Element count (FRMCNT) EDMA_DST_OF((Uint32) &gRcvBufferA), // EDMA Channel Destination Address EDMA_IDX_RMK(EDMA_IDX_FRMIDX_DEFAULT, EDMA_IDX_ELEIDX_DEFAULT), // Frame index, Element index EDMA_RLD_RMK(0x0000, 0x0000) // Element count reload, Link address }; /* * EDMA transmit channel config */ EDMA_Config gEdmaXmtConfig = { EDMA_OPT_RMK( EDMA_OPT_PRI_LOW, EDMA_OPT_ESIZE_32BIT, EDMA_OPT_2DS_NO, EDMA_OPT_SUM_INC, // increment source address