/*..........................................................................*/ void BSP_init(void) { PLL_Config pllCfg_100MHz = { 0x8BE8U, 0x8000U, 0x0806U, 0x0000U }; PLL_Obj pllObj; uint16_t i; PLL_init(&pllObj, CSL_PLL_INST_0); PLL_reset(&pllObj); PLL_config(&pllObj, &pllCfg_100MHz); QF_zero(); /* clear the QF variables, see NOTE01 */ CSL_SYSCTRL_REGS->PCGCR1 = 0U; /* enable clocks to all peripherals */ CSL_SYSCTRL_REGS->PCGCR2 = 0U; CSL_SYSCTRL_REGS->EBSR = 0x1800U; /* configure I/O muxing */ CSL_SYSCTRL_REGS->PSRCR = 0x0020U; /* reset all peripherals */ CSL_SYSCTRL_REGS->PRCR = 0x00BFU; ULED_init(); /* configure the User LEDs... */ IRQ_globalDisable(); IRQ_disableAll(); /* disable all the interrupts */ IRQ_clearAll(); /* clear any pending interrupts */ IRQ_setVecs((uint32_t)&VECSTART); /* set the vector table */ for (i = 1U; i < 32U; ++i) { /* pre-fill the Vector table */ IRQ_plug(i, &illegal_isr); /* with illegal ISR */ } /* plug in all ISRs into the vector table...*/ // IRQ_plug(TINT_EVENT, &TINT_isr); // IRQ_plug(RTC_EVENT, &RTC_isr); /* ... */ if (QS_INIT((void *)0) == 0) { /* initialize the QS software tracing */ Q_ERROR(); } QS_OBJ_DICTIONARY(&l_TINT_isr); }
/* * usb_test() * USB Bulk transfer test. Device is detected as an eZDSP5535 when * connected to PC while test is running. Bulk transfers can be * made using USB_55xx program. * */ CSL_Status usb_test(void) { CSL_IRQ_Config config; CSL_Status result; Uint16 eventMask; result = CSL_USB_TEST_FAILED; usbConfig.opMode = CSL_USB_OPMODE_POLLED; usbConfig.devNum = CSL_USB0; usbConfig.maxCurrent = CSL_USB_MAX_CURRENT; usbConfig.appSuspendCallBack = (CSL_USB_APP_CALLBACK)CSL_suspendCallBack; usbConfig.appWakeupCallBack = (CSL_USB_APP_CALLBACK)CSL_selfWakeupCallBack; usbConfig.startTransferCallback = CSL_startTransferCallback; usbConfig.completeTransferCallback = CSL_completeTransferCallback; hEpObjArray[0] = &usbCtrlOutEpObj; hEpObjArray[1] = &usbCtrlInEpObj; hEpObjArray[2] = &usbBulkOutEpObj; hEpObjArray[3] = &usbBulkInEpObj; /* Set the interrupt vector start address */ IRQ_setVecs((Uint32)(&VECSTART)); /* Plug the USB Isr into vector table */ config.funcAddr = &usb_isr; IRQ_plug(USB_EVENT, config.funcAddr); /* Enable USB Interrupts */ IRQ_enable(USB_EVENT); /* Enable CPU Interrupts */ IRQ_globalEnable(); /* Initialize the USB module */ status = USB_init(&usbConfig); if(status != CSL_SOK) { printf("USB init failed\n"); return(result); } /* Reset the USB device */ status = USB_resetDev(CSL_USB0); if(status != CSL_SOK) { printf("USB Reset failed\n"); return(result); } /* Initialize the Control Endpoint OUT 0 */ eventMask = (CSL_USB_EVENT_RESET | CSL_USB_EVENT_SETUP | CSL_USB_EVENT_SUSPEND | CSL_USB_EVENT_RESUME | CSL_USB_EVENT_RESET | CSL_USB_EVENT_EOT); status = USB_initEndptObj(CSL_USB0, hEpObjArray[0], CSL_USB_OUT_EP0,CSL_USB_CTRL, CSL_USB_EP0_PACKET_SIZE, eventMask, NULL); if(status != CSL_SOK) { printf("USB End point init failed\n"); return(result); } /* Initialize the Control Endpoint IN 0 */ status = USB_initEndptObj(CSL_USB0, hEpObjArray[1], CSL_USB_IN_EP0, CSL_USB_CTRL, CSL_USB_EP0_PACKET_SIZE, CSL_USB_EVENT_EOT, NULL); if(status != CSL_SOK) { printf("USB End point init failed\n"); return(result); } /* Initialize the Bulk Endpoint IN 1 */ eventMask = (CSL_USB_EVENT_RESET | CSL_USB_EVENT_EOT); status = USB_initEndptObj(CSL_USB0, hEpObjArray[2], CSL_USB_IN_EP1, CSL_USB_BULK, CSL_USB_EP1_PACKET_SIZE_FS, eventMask, NULL); if(status != CSL_SOK) { printf("USB End point init failed\n"); return(result); } /* Initialize the Bulk Endpoint OUT 2 */ status = USB_initEndptObj(CSL_USB0, hEpObjArray[3], CSL_USB_OUT_EP1, CSL_USB_BULK, CSL_USB_EP1_PACKET_SIZE_FS, CSL_USB_EVENT_EOT, NULL); if(status != CSL_SOK) { printf("USB End point init failed\n"); return(result); } /* Set the parameters */ status = USB_setParams(CSL_USB0, hEpObjArray, FALSE); if(status != CSL_SOK) { printf("USB Set params failed\n"); return(result); } /* Connect the USB device */ status = USB_connectDev(CSL_USB0); if(status != CSL_SOK) { printf("USB Connect failed\n"); return(result); } deviceDescPtr = (Uint16 *)deviceDesc; cfgDescPtr = (Uint16 *)cfgDesc; strDescPtr = (Uint16 *)strDesc; dataReadBuffPtr = (Uint16 *)dataReadBuff; dataWriteBuffPtr = (Uint16 *)dataWriteBuff; while(stopRunning != TRUE); result = CSL_USB_TEST_PASSED; return(result); }
/** * \brief Audio Class intialization function * * \param None * * \return None */ void CSL_acTest(void) { I2sInitPrms i2sInitPrms; CSL_UsbConfig usbConfig; PSP_Result result; Int16 status; HWI_Attrs attrs; LOG_printf(&trace, "USB ISO FULL SPEED MODE\n"); /* Initialize audio module */ result = AIC3254_init(); if(result != 0) { LOG_printf(&trace, "ERROR: Unable to configure audio codec"); } else { #if !defined(SAMPLE_BY_SAMPLE_PB) || !defined(SAMPLE_BY_SAMPLE_REC) DMA_HwInit(); DMA_DrvInit(); #endif /* Initialize I2S and associated DMA channels for Playback and Record */ i2sInitPrms.enablePlayback = TRUE; i2sInitPrms.enableStereoPb = TRUE; #ifdef SAMPLE_BY_SAMPLE_PB i2sInitPrms.sampleBySamplePb = TRUE; #else /* Configuration untested since ASRC only works with I2S in sample-by-sample mode */ i2sInitPrms.sampleBySamplePb = FALSE; i2sInitPrms.enableDmaPingPongPb = FALSE; i2sInitPrms.pingI2sTxLeftBuf = ping_i2sTxLeftBuf; i2sInitPrms.pongI2sTxLeftBuf = pong_i2sTxLeftBuf; i2sInitPrms.pingI2sTxRightBuf = ping_i2sTxRightBuf; i2sInitPrms.pongI2sTxRightBuf = pong_i2sTxRightBuf; i2sInitPrms.zeroBuf = ZeroBuf; #endif i2sInitPrms.i2sPb = PSP_I2S_TX_INST_ID; i2sInitPrms.enableRecord = TRUE; i2sInitPrms.enableStereoRec = FALSE; #ifdef SAMPLE_BY_SAMPLE_REC i2sInitPrms.sampleBySampleRec = TRUE; #else i2sInitPrms.sampleBySampleRec = FALSE; i2sInitPrms.enableDmaPingPongRec = TRUE; i2sInitPrms.pingI2sRxLeftBuf = (Int16 *)ping_pong_i2sRxLeftBuf; i2sInitPrms.pongI2sRxLeftBuf = NULL; i2sInitPrms.pingI2sRxRightBuf = (Int16 *)ping_pong_i2sRxRightBuf; i2sInitPrms.pongI2sRxRightBuf = NULL; #endif i2sInitPrms.i2sRec = PSP_I2S_RX_INST_ID; status = i2sInit(&i2sInitPrms); if (status != I2SSAMPLE_SOK) { LOG_printf(&trace, "ERROR: Unable to initialize I2S"); } #ifdef C5535_EZDSP_DEMO // initialize the OLED display oled_init(); #endif /* Initialising the Pointer to the Audio Class Handle to the Buffer Allocated */ AC_AppHandle.pAcObj = &ACAppBuffer[0]; usbConfig.devNum = CSL_USB0; usbConfig.opMode = CSL_USB_OPMODE_POLLED; #ifdef APP_USB_SELF_POWERED usbConfig.selfPowered = TRUE; #else usbConfig.selfPowered = FALSE; #endif usbConfig.maxCurrent = APP_USB_MAX_CURRENT; usbConfig.appSuspendCallBack = (CSL_USB_APP_CALLBACK)CSL_suspendCallBack; usbConfig.appWakeupCallBack = (CSL_USB_APP_CALLBACK)CSL_selfWakeupCallBack; usbConfig.startTransferCallback = StartTransfer; usbConfig.completeTransferCallback = CompleteTransfer; USB_init(&usbConfig); USB_setFullSpeedMode(0x40); /* parameter is EP0 data size in bytes */ USB_resetDev(CSL_USB0); /* Calling init routine */ /* Giving all the table hanldes and the buffers to the Audio Class module */ AC_AppHandle.strDescrApp = (char **)&string_descriptor[0]; AC_AppHandle.lbaBufferPbApp = &lbaBufferPbApp[0]; AC_AppHandle.lbaBufferRecApp = &lbaBufferRecApp[0]; AC_AppHandle.lbaBufferHidReportApp = &lbaBufferHidReportApp[0]; AC_AppHandle.acReqTableApp = USB_ReqTable; AC_AppHandle.pId = pId; AC_AppHandle.vId = vId; #ifndef ENABLE_PLAYBACK_TWO_SAMPLE_RATES #ifdef SAMPLE_RATE_TX_48kHz LOG_printf(&trace, "PLAYBACK: 48KHZ "); #ifdef ENABLE_STEREO_PLAYBACK LOG_printf(&trace, "STEREO\n"); AC_AppHandle.rxPktSize = EP_PB_MAXP; // max packet size for 48K stereo #else // ENABLE_STEREO_PLAYBACK LOG_printf(&trace, "MONO\n"); AC_AppHandle.rxPktSize = 0x60; // max packet size for 48K mono #endif // ENABLE_STEREO_PLAYBACK #endif // SAMPLE_RATE_TX_48kHz #ifdef SAMPLE_RATE_TX_44_1kHz LOG_printf(&trace, "PLAYBACK: 44.1KHZ "); #ifdef ENABLE_STEREO_PLAYBACK LOG_printf(&trace, "STEREO\n"); AC_AppHandle.rxPktSize = 0xB0; // max packet size for 44.1 stereo #else // ENABLE_STEREO_PLAYBACK LOG_printf(&trace, "MONO\n"); AC_AppHandle.rxPktSize = 0x58; // max packet size for 44.1 mono #endif // ENABLE_STEREO_PLAYBACK #endif // SAMPLE_RATE_TX_44_1kHz #ifdef SAMPLE_RATE_TX_32kHz LOG_printf(&trace, "PLAYBACK: 32KHZ "); #ifdef ENABLE_STEREO_PLAYBACK LOG_printf(&trace, "STEREO\n"); AC_AppHandle.rxPktSize = 0x80; // max packet size for 32K stereo #else // ENABLE_STEREO_PLAYBACK LOG_printf(&trace, "MONO\n"); AC_AppHandle.rxPktSize = 0x40; // max packet size for 32K mono #endif // ENABLE_STEREO_PLAYBACK #endif // SAMPLE_RATE_TX_32kHz #ifdef SAMPLE_RATE_TX_16kHz LOG_printf(&trace, "PLAYBACK: 16KHZ "); #ifdef ENABLE_STEREO_PLAYBACK LOG_printf(&trace, "STEREO\n"); AC_AppHandle.rxPktSize = RX_PKT_SIZE_16K_PLAYBACK_STEREO; // max packet size for 16K stereo rx_pkt_size_16K_playback = RX_PKT_SIZE_16K_PLAYBACK_STEREO; // max packet size for 16K stereo #else // ENABLE_STEREO_PLAYBACK LOG_printf(&trace, "MONO\n"); AC_AppHandle.rxPktSize = RX_PKT_SIZE_16K_PLAYBACK_MONO; // max packet size for 16K mono rx_pkt_size_16K_playback = RX_PKT_SIZE_16K_PLAYBACK_MONO; // max packet size for 16K mono #endif // ENABLE_STEREO_PLAYBACK #endif // SAMPLE_RATE_TX_16kHz #else /* ENABLE_PLAYBACK_TWO_SAMPLE_RATES */ LOG_printf(&trace, "PLAYBACK: 48KHZ "); #ifdef ENABLE_STEREO_PLAYBACK LOG_printf(&trace, "STEREO\n"); AC_AppHandle.rxPktSize = EP_PB_MAXP; // max packet size for 48K stereo #else // ENABLE_STEREO_PLAYBACK LOG_printf(&trace, "MONO\n"); AC_AppHandle.rxPktSize = 0x60; // max packet size for 48K mono #endif // ENABLE_STEREO_PLAYBACK LOG_printf(&trace, "PLAYBACK: 16KHZ "); #ifdef ENABLE_STEREO_PLAYBACK rx_pkt_size_16K_playback = RX_PKT_SIZE_16K_PLAYBACK_STEREO; // max packet size for 16K stereo LOG_printf(&trace, "STEREO\n"); #else // ENABLE_STEREO_PLAYBACK rx_pkt_size_16K_playback = RX_PKT_SIZE_16K_PLAYBACK_MONO; // max packet size for 16K mono LOG_printf(&trace, "MONO\n"); #endif // ENABLE_STEREO_PLAYBACK #endif /* ENABLE_PLAYBACK_TWO_SAMPLE_RATES */ AC_AppHandle.txPktSize = EP_REC_MAXP; // max packet size for 16K mono AC_AppHandle.hidTxPktSize = EP_HID_MAXP; // max packet size for HID output report /* All Function Handlers need to be Initialised */ AC_AppHandle.playAudioApp = appPlayAudio; AC_AppHandle.recordAudioApp = appRecordAudio; AC_AppHandle.initPlayAudioApp = appInitPlayAudio; AC_AppHandle.initRecordAudioApp = appInitRecordAudio; AC_AppHandle.stopPlayAudioApp = appStopPlayAudio; AC_AppHandle.stopRecordAudioApp = appStopRecordAudio; AC_AppHandle.mediaGetPresentStateApp = AppGetMediaStatus; AC_AppHandle.mediaInitApp = AppMediaInit; AC_AppHandle.mediaEjectApp = AppMediaEject; AC_AppHandle.mediaLockUnitApp = AppLockMedia; AC_AppHandle.getMediaSizeApp = AppGetMediaSize; AC_AppHandle.getHidReportApp = appGetHidReport; AC_AppHandle.ctrlHandler = appCtrlFxn; AC_AppHandle.isoHandler = appIsoFxn; AC_AppHandle.hidHandler = appHidFxn; AC_AppHandle.numLun = 2; /* Initialize End point descriptors */ AC_initDescriptors(AC_AppHandle.pAcObj, (Uint16 *)deviceDescriptorB, CSL_AC_DEVICE_DESCR, sizeof(deviceDescriptorB)); AC_initDescriptors(AC_AppHandle.pAcObj, (Uint16 *)deviceQualifierDescr, CSL_AC_DEVICE_QUAL_DESCR, 10); AC_initDescriptors(AC_AppHandle.pAcObj, (Uint16 *)configDescriptor, CSL_AC_CONFIG_DESCR, sizeof(configDescriptor)); AC_initDescriptors(AC_AppHandle.pAcObj, (Uint16 *)stringLanId, CSL_AC_STRING_LANGID_DESC, 6); AC_initDescriptors(AC_AppHandle.pAcObj, (Uint16 *)acHidReportDescriptor, CSL_AC_HID_REPORT_DESC, sizeof(acHidReportDescriptor)); /* Initialize HID */ AC_AppHandle.acHidIfNum = IF_NUM_HID; // HID interface number AC_AppHandle.acHidReportId = HID_REPORT_ID; // HID report ID AC_AppHandle.acHidReportLen = HID_REPORT_SIZE_BYTES; // HID report length (bytes) genHidReport(UI_PUSH_BUTTON_NONE, gHidReport); // init. HID report for Get Report /* Call Init API */ AC_Open(&AC_AppHandle); /* Enable CPU USB interrupts */ CSL_FINST(CSL_CPU_REGS->IER1, CPU_IER1_USB, ENABLE); /* Initialize active sample rate */ initSampleRate(RATE_48_KHZ, &active_sample_rate, &i2sTxBuffSz); /* Initialize ASRC */ Init_Sample_Rate_Converter(active_sample_rate); /* Reset codec output buffer */ reset_codec_output_buffer(); #ifdef ENABLE_RECORD #ifdef SAMPLE_RATE_RX_48kHz LOG_printf(&trace, "RECORD: 48KHZ "); #else LOG_printf(&trace, "RECORD: 16KHZ "); #endif // SAMPLE_RATE_RX_48kHz // start the rx DMAs DMA_StartTransfer(hDmaRxLeft); #ifdef ENABLE_STEREO_RECORD LOG_printf(&trace, "STEREO NOT SUPPORTED - RECORD WILL BE MONO\n"); DMA_StartTransfer(hDmaRxRight); #else LOG_printf(&trace, "MONO\n"); #endif #endif // ENABLE_RECORD #ifdef STORE_PARAMETERS_TO_SDRAM initSdram(FALSE, 0x0000); #endif // STORE_PARAMETERS_TO_SDRAM #ifdef SAMPLE_BY_SAMPLE_PB /* SampleBySample, init interrupt */ /* Use with compiler "interrupt" keyword */ //IRQ_plug(I2S_TX_EVENT, i2s_txIsr); /* Use with dispatcher, no "interrupt" keyword */ attrs.ier0mask = 0xFFFF; attrs.ier1mask = 0xFFFF; HWI_dispatchPlug(I2S_TX_EVENT, (Fxn)i2s_txIsr, &attrs); IRQ_enable(I2S_TX_EVENT); /* SampleBySample, enable IRQ for I2S Tx */ #endif #if defined(SAMPLE_BY_SAMPLE_REC) && !defined(COMBINE_I2S_TX_RX_ISR) /* SampleBySample, init interrupt */ /* Use with compiler "interrupt" keyword */ IRQ_plug(I2S_RX_EVENT, i2s_rxIsr); /* Use with dispatcher, no "interrupt" keyword */ //attrs.ier0mask = 0xFFFF; //attrs.ier1mask = 0xFFFF; //HWI_dispatchPlug(I2S_RX_EVENT, (Fxn)i2s_rxIsr, &attrs); IRQ_enable(I2S_RX_EVENT); /* SampleBySample, enable IRQ for I2S Rx */ #endif #if defined(SAMPLE_BY_SAMPLE_PB) || defined(SAMPLE_BY_SAMLE_REC) DDC_I2S_transEnable((DDC_I2SHandle)i2sHandleTx, TRUE); /* SampleBySample, enable I2S transmit and receive */ #endif #ifndef SAMPLE_BY_SAMPLE_PB i2sTxStart(); // - moved from appPlayAudio() #endif #ifdef C5535_EZDSP_DEMO // clock gating usused peripherals ClockGating(); #endif } }
/** * \brief UART interrupt Test function * * This function verifies the UART operation in interrupt mode. * This function runs in an infinite loop to read the characters * from HyperTerminal and echo the characters back to HyperTerminal. * * \param none * * \return Test result(Only Failure Case) */ CSL_Status uart_IntcSample(void) { CSL_UartIsrAddr isrAddr; CSL_Status status; Uint32 sysClk; sysClk = getSysClk(); mySetup.clkInput = sysClk; /* Loop counter and error flag */ status = UART_init(&uartObj,CSL_UART_INST_0,UART_INTERRUPT); if(CSL_SOK != status) { printf("UART_init failed error code %d\n",status); return(status); } else { printf("UART_init Successful\n"); } /* Handle created */ hUart = (CSL_UartHandle)(&uartObj); /* Configure UART registers using setup structure */ status = UART_setup(hUart,&mySetup); if(CSL_SOK != status) { printf("UART_setup failed error code %d\n",status); return(status); } else { printf("UART_setup Successful\n"); } /* Send the details of the test to HyperTerminal */ status = UART_fputs(hUart,"\r\n\nUART INTERRUPT TEST!",0); if(CSL_SOK != status) { printf("UART_fputs failed error code %d\n",status); return(status); } status = UART_fputs(hUart,"\r\nTEST READS A CHARACTER FROM HYPERTERMINAL CONTINUOUSLY",0); if(CSL_SOK != status) { printf("UART_fputs failed error code %d\n",status); return(status); } status = UART_fputs(hUart,"\r\nENTER '$' TO END THE TEST\r\n",0); if(CSL_SOK != status) { printf("UART_fputs failed error code %d\n",status); return(status); } /* Configure and Register the UART interrupts */ isrAddr.rbiAddr = uart_rxIsr; isrAddr.tbeiAddr = uart_txIsr; isrAddr.ctoi = uart_ctoIsr; isrAddr.lsiAddr = uart_lsiIsr; /* Disable interrupt */ IRQ_globalDisable(); /* Clear any pending interrupts */ IRQ_clearAll(); /* Disable all the interrupts */ IRQ_disableAll(); IRQ_setVecs((Uint32)(&VECSTART)); /* Configuring Interrupt */ IRQ_plug (UART_EVENT, &UART_intrDispatch); /* Enabling Interrupt */ IRQ_enable(UART_EVENT); IRQ_globalEnable(); /* Set the UART callback function */ status = UART_setCallback(hUart,&isrAddr); if(status != CSL_SOK) { printf("UART_setCallback Failed\n"); return(status); } /* Enable the UART Events */ status = UART_eventEnable(hUart, CSL_UART_XMITOR_REG_EMPTY_INTERRUPT); if(status != CSL_SOK) { printf("UART_eventEnable Failed\n"); return(status); } status = UART_eventEnable(hUart, CSL_UART_RECVOR_REG_DATA_INTERRUPT); if(status != CSL_SOK) { printf("UART_eventEnable Failed\n"); return(status); } status = UART_eventEnable(hUart, CSL_UART_RECVOR_LINE_STATUS_INTERRUPT); if(status != CSL_SOK) { printf("UART_eventEnable Failed\n"); return(status); } /* Tests runs until users enters Symbol '$' on the HyperTerminal */ while(endOfTest == FALSE) { } printf("\nUSER ENTERED '$' on HyperTerminal\n"); printf("END OF TEST!\n"); /* Disable UART interrupts */ IRQ_disable(UART_EVENT); /* Disable GLobal Interrupts */ IRQ_globalDisable(); /* Send the END OF TEST MESSAGE to HyperTerminal */ status = UART_fputs(hUart,"\r\n\nYOU HAVE ENTERED '$'.",0); if(CSL_SOK != status) { printf("UART_fputs failed error code %d\n",status); return(status); } status = UART_fputs(hUart,"\r\nEND OF THE TEST!!\r\n",0); if(CSL_SOK != status) { printf("UART_fputs failed error code %d\n",status); return(status); } /* Disable interrupt */ IRQ_globalDisable(); /* Clear any pending interrupts */ IRQ_clearAll(); /* Disable all the interrupts */ IRQ_disableAll(); return(CSL_SOK); }