// Disable I2S TX with PDMA function void StopPlay(void) { I2S_DISABLE_TXDMA(I2S1); I2S_DISABLE_TX(I2S1); PDMA_Close(); // disable sound output PI3 = 1; audioInfo.mp3Playing = 0; printf("Stop ...\n"); }
/*---------------------------------------------------------------------------------------------------------*/ int PDMA_Example(void) { uint32_t u32EndSrc, u32EndDst; /* Init System, IP clock and multi-function I/O */ SYS_Init(); //In the end of SYS_Init() will issue SYS_LockReg() to lock protected register. If user want to write protected register, please issue SYS_UnlockReg() to unlock protected register. /* Init UART for printf */ UART0_Init(); printf("\n\nCPU @ %dHz\n", SystemCoreClock); printf("+------------------------------------------------------+ \n"); printf("| NUC400 PDMA Memory to Memory Driver Sample Code | \n"); printf("+------------------------------------------------------+ \n"); /* Open Channel 2 */ PDMA_Open(1 << 2); PDMA_SetTransferCnt(2, PDMA_WIDTH_32, PDMA_TEST_LENGTH); u32EndSrc = (uint32_t)SrcArray + PDMA_TEST_LENGTH * 4; u32EndDst = (uint32_t)DestArray + PDMA_TEST_LENGTH * 4; PDMA_SetTransferAddr(2, u32EndSrc, PDMA_SAR_INC, u32EndDst, PDMA_DAR_INC); PDMA_SetTransferMode(2, PDMA_MEM, 0, 0); PDMA_SetBurstType(2, PDMA_REQ_BURST, PDMA_BURST_4); PDMA_SetTimeOut(2, 0, 0x5); PDMA_EnableInt(2, 0); NVIC_EnableIRQ(PDMA_IRQn); u32IsTestOver = 0; PDMA_Trigger(2); while(u32IsTestOver == 0); if (u32IsTestOver == 1) printf("test done...\n"); else if (u32IsTestOver == 2) printf("target abort...\n"); else if (u32IsTestOver == 3) printf("timeout...\n"); PDMA_Close(); }