/** * \brief Configures Dma * * \param chanNum - Dma channel number * * \return Dma handle */ CSL_DMA_Handle CSL_configDmaForUart(CSL_DMA_ChannelObj *dmaChanObj, CSL_DMAChanNum chanNum) { CSL_DMA_Handle dmaHandle; CSL_Status status; dmaHandle = NULL; /* Initialize Dma */ status = DMA_init(); if (status != CSL_SOK) { printf("DMA_init Failed!\n"); } /* Open A Dma channel */ dmaHandle = DMA_open(chanNum, dmaChanObj, &status); if(dmaHandle == NULL) { printf("DMA_open Failed!\n"); } /* Configure a Dma channel */ status = DMA_config(dmaHandle, &dmaConfig); if(status != CSL_SOK) { printf("DMA_config Failed!\n"); dmaHandle = NULL; } return(dmaHandle); }
///// program flow reaches expected exit point(s). ///// void main(void) { CSL_DMA_ChannelObj dmaObj; CSL_Status status; Uint16 chanNumber; Uint16 i; printf("\n DMA POLLED MODE TEST!\n"); for(i = 0; i < CSL_DMA_BUFFER_SIZE; i++) { dmaSRCBuff[i] = 0xFFFF; dmaDESTBuff[i] = 0x0000; } #if (defined(CHIP_C5505_C5515) || defined(CHIP_C5504_C5514) || defined(CHIP_C5517)) dmaConfig.pingPongMode = CSL_DMA_PING_PONG_DISABLE; #endif dmaConfig.autoMode = CSL_DMA_AUTORELOAD_DISABLE; dmaConfig.burstLen = CSL_DMA_TXBURST_8WORD; dmaConfig.trigger = CSL_DMA_SOFTWARE_TRIGGER; dmaConfig.dmaEvt = CSL_DMA_EVT_NONE; dmaConfig.dmaInt = CSL_DMA_INTERRUPT_DISABLE; dmaConfig.chanDir = CSL_DMA_READ; dmaConfig.trfType = CSL_DMA_TRANSFER_MEMORY; dmaConfig.dataLen = CSL_DMA_BUFFER_SIZE * 2; dmaConfig.srcAddr = (Uint32)dmaSRCBuff; dmaConfig.destAddr = (Uint32)dmaDESTBuff; status = DMA_init(); if (status != CSL_SOK) { printf("DMA_init() Failed \n"); /////INSTRUMENTATION FOR BATCH TESTING -- Part 2 -- ///// Reseting PaSs_StAtE to 0 if error detected here. PaSs_StAtE = 0x0000; // Was intialized to 1 at declaration. ///// } for( chanNumber = 0; chanNumber < CSL_DMA_CHAN_MAX; chanNumber++) { printf("\n Test for DMA Channel No : %d \t", chanNumber); dmaHandle = DMA_open((CSL_DMAChanNum)chanNumber,&dmaObj, &status); if (dmaHandle == NULL) { printf("DMA_open() Failed \n"); break; } status = DMA_config(dmaHandle, &dmaConfig); if (status != CSL_SOK) { printf("DMA_config() Failed \n"); break; } status = DMA_getConfig(dmaHandle, &getdmaConfig); if (status != CSL_SOK) { printf("DMA_getConfig() Failed \n"); break; } status = DMA_start(dmaHandle); if (status != CSL_SOK) { printf("DMA_start() Failed \n"); break; } while(DMA_getStatus(dmaHandle)); status = DMA_reset(dmaHandle); if (status != CSL_SOK) { printf("DMA_close() Failed \n"); break; } status = DMA_close(dmaHandle); if (status != CSL_SOK) { printf("DMA_reset() Failed \n"); break; } /* validation for set and get config parameter */ if((dmaConfig.autoMode) != (getdmaConfig.autoMode)) { printf("Mode not matched\n"); } if(((dmaConfig.burstLen) != (getdmaConfig.burstLen))) { printf("Burst length not matched\n"); } if(((dmaConfig.trigger) != (getdmaConfig.trigger))) { printf("Triger type not matched\n"); } if(((dmaConfig.dmaEvt) != (getdmaConfig.dmaEvt)) ) { printf("Event not matched\n"); } if(((dmaConfig.dmaInt) != (getdmaConfig.dmaInt))) { printf("Interrupt state not matched\n"); } if(((dmaConfig.chanDir) != (getdmaConfig.chanDir))) { printf("Direction read or write not matched\n"); } if(((dmaConfig.trfType) != (getdmaConfig.trfType))) { printf("Transfer type not matched\n"); } if(((dmaConfig.dataLen) != (getdmaConfig.dataLen))) { printf("data length of transfer not matched\n"); } if(((dmaConfig.srcAddr) != (getdmaConfig.srcAddr))) { printf("Source address not matched\n"); } if(((dmaConfig.destAddr) != (getdmaConfig.destAddr))) { printf("Destination address not matched\n"); } for(i = 0; i < CSL_DMA_BUFFER_SIZE; i ++) { if(dmaSRCBuff[i] != dmaDESTBuff[i]) { printf("Buffer miss matched at position %d\n",i); break; } } if(i == CSL_DMA_BUFFER_SIZE) { printf("Success"); } for(i = 0; i < CSL_DMA_BUFFER_SIZE; i++) { dmaSRCBuff[i] = 0xFFFF; dmaDESTBuff[i] = 0x0000; } } if(chanNumber == 16) { printf("\n\n DMA POLLED MODE TEST PASSED!!\n"); } else { printf("\n\n DMA POLLED MODE TEST FAILED!!\n"); /////INSTRUMENTATION FOR BATCH TESTING -- Part 2 -- ///// Reseting PaSs_StAtE to 0 if error detected here. PaSs_StAtE = 0x0000; // Was intialized to 1 at declaration. ///// } /////INSTRUMENTATION FOR BATCH TESTING -- Part 3 -- ///// At program exit, copy "PaSs_StAtE" into "PaSs". PaSs = PaSs_StAtE; //If flow gets here, override PaSs' initial 0 with ///// // pass/fail value determined during program execution. ///// Note: Program should next exit to C$$EXIT and halt, where DSS, under ///// control of a host PC script, will read and record the PaSs' value. ///// }
CSL_Status configSdCard(CSL_MMCSDOpMode opMode) { CSL_Status status; Uint16 actCard; Uint16 clockDiv; Uint16 rca; /* Get the clock divider value for the current CPU frequency */ clockDiv = computeClkRate(); /* Initialize MMCSD CSL module */ status = MMC_init(); status = SYS_setEBSR(CSL_EBSR_FIELD_SP0MODE, CSL_EBSR_SP0MODE_0); status |= SYS_setEBSR(CSL_EBSR_FIELD_SP1MODE, CSL_EBSR_SP1MODE_0); if (CSL_SOK != status) { printf("SYS_setEBSR failed\n"); return (status); } /* Open MMCSD CSL module */ #ifdef C5515_EZDSP mmcsdHandle = MMC_open(&pMmcsdContObj, CSL_MMCSD1_INST, opMode, &status); #else mmcsdHandle = MMC_open(&pMmcsdContObj, CSL_MMCSD1_INST, opMode, &status); #endif if (mmcsdHandle == NULL) { printf("MMC_open Failed\n"); return (status); } /* Configure the DMA in case of operating mode is set to DMA */ if (opMode == CSL_MMCSD_OPMODE_DMA) { /* Initialize Dma */ status = DMA_init(); if (status != CSL_SOK) { printf("DMA_init Failed!\n"); return (status); } /* Open Dma channel for MMCSD write */ dmaWrHandle = DMA_open(CSL_DMA_CHAN0, &dmaWrChanObj, &status); if ((dmaWrHandle == NULL) || (status != CSL_SOK)) { printf("DMA_open for MMCSD Write Failed!\n"); return (status); } /* Open Dma channel for MMCSD read */ dmaRdHandle = DMA_open(CSL_DMA_CHAN1, &dmaRdChanObj, &status); if ((dmaRdHandle == NULL) || (status != CSL_SOK)) { printf("DMA_open for MMCSD Read Failed!\n"); return (status); } /* Set the DMA handle for MMC read */ status = MMC_setDmaHandle(mmcsdHandle, dmaWrHandle, dmaRdHandle); if (status != CSL_SOK) { printf("API: MMC_setDmaHandle for MMCSD Failed\n"); return (status); } } /* Reset the SD card */ status = MMC_sendGoIdle(mmcsdHandle); if (status != CSL_SOK) { printf("MMC_sendGoIdle Failed\n"); return (status); } /* Check for the card */ status = MMC_selectCard(mmcsdHandle, &mmcCardObj); if ((status == CSL_ESYS_BADHANDLE) || (status == CSL_ESYS_INVPARAMS)) { printf("MMC_selectCard Failed\n"); return (status); } /* Verify whether the SD card is detected or not */ if (mmcCardObj.cardType == CSL_SD_CARD) { printf("SD Card detected\n"); /* Check if the card is high capacity card */ if (mmcsdHandle->cardObj->sdHcDetected == TRUE) { printf("SD card is High Capacity Card\n"); printf("Memory Access will use Block Addressing\n"); } else { printf("SD card is Standard Capacity Card\n"); printf("Memory Access will use Byte Addressing\n"); } } else { if (mmcCardObj.cardType == CSL_CARD_NONE) { printf("No Card detected\n"); } else { printf("SD Card not detected\n"); } printf("Please Insert SD Card\n"); return (CSL_ESYS_FAIL); } /* Set the init clock */ status = MMC_sendOpCond(mmcsdHandle, 70); if (status != CSL_SOK) { printf("MMC_sendOpCond Failed\n"); return (status); } /* Send the card identification Data */ status = SD_sendAllCID(mmcsdHandle, &sdCardIdObj); if (status != CSL_SOK) { printf("SD_sendAllCID Failed\n"); return (status); } /* Set the Relative Card Address */ status = SD_sendRca(mmcsdHandle, &mmcCardObj, &rca); if (status != CSL_SOK) { printf("SD_sendRca Failed\n"); return (status); } /* Read the SD Card Specific Data */ status = SD_getCardCsd(mmcsdHandle, &sdCardCsdObj); if (status != CSL_SOK) { printf("SD_getCardCsd Failed\n"); return (status); } /* Set the card type in internal data structures */ status = MMC_setCardType(&mmcCardObj, CSL_SD_CARD); if (status != CSL_SOK) { printf("MMC_setCardType Failed\n"); return (status); } /* Set the card pointer in internal data structures */ status = MMC_setCardPtr(mmcsdHandle, &mmcCardObj); if (status != CSL_SOK) { printf("MMC_setCardPtr Failed\n"); return (status); } /* Get the number of cards */ status = MMC_getNumberOfCards(mmcsdHandle, &actCard); if (status != CSL_SOK) { printf("MMC_getNumberOfCards Failed\n"); return (status); } /* Set clock for read-write access */ status = MMC_sendOpCond(mmcsdHandle, clockDiv); if (status != CSL_SOK) { printf("MMC_sendOpCond Failed\n"); return (status); } /* Set Endian mode for read and write operations */ status = MMC_setEndianMode(mmcsdHandle, CSL_MMCSD_ENDIAN_LITTLE, CSL_MMCSD_ENDIAN_LITTLE); if (status != CSL_SOK) { printf("MMC_setEndianMode Failed\n"); return (status); } /* Set block length for the memory card * For high capacity cards setting the block length will have * no effect */ status = MMC_setBlockLength(mmcsdHandle, CSL_MMCSD_BLOCK_LENGTH); if (status != CSL_SOK) { printf("MMC_setBlockLength Failed\n"); return (status); } return (status); }