/* Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/ All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /* * ======== fwkSim.c ======== */ #include #include #include #include #include #include #include #include #include #include #include "fwkSim.h" #ifdef SIMULATE_SIO #define SIM_TIMER_HWI ( 7 ) // Global debug counters Uint32 gTimerRxCnt=0; Uint32 gTimerTxCnt=0; #endif // SIMULATE_SIO #ifdef SIMULATE_RX_ALPHA // Global debug counter Uint32 gClockRxAlphaCnt=0; #endif #ifdef SIMULATE_SIO /* * ======== timerRxFxn ======== */ Void timerRxFxn(UArg a0) { gTimerRxCnt++; /* Post semaphore indicating Rx audio frame */ Semaphore_post(semaphoreRxAudio); } /* * ======== timerTxFxn ======== */ Void timerTxFxn(UArg a0) { gTimerTxCnt++; /* Post semaphore indicating Tx audio frame */ Semaphore_post(semaphoreTxAudio); } // Simulation initialization Void simInit(Void) { Hwi_Params hwiParams; //Error_Block eb; // Initialize the error block //Error_init(&eb); // Initialize simulation // Plug the function and argument for Timer1L event and enable it // Plug the function and argument for Timer2L event and enable it EventCombiner_dispatchPlug(CSL_C66X_COREPAC_TIMER_1_INTL, &timerRxFxn, 0, TRUE); EventCombiner_dispatchPlug(CSL_C66X_COREPAC_TIMER_2_INTL, &timerTxFxn, 0, TRUE); // Initialize the Hwi parameters Hwi_Params_init(&hwiParams); // The eventId must be set to the combined event for Timer1L or Timer2L event. // The combined event is event 1 for both. If the combined events are // different, then another Hwi must be used for the other combined event. hwiParams.eventId = CSL_C66X_COREPAC_EVT1; // The arg must be set to hwiParams.eventId hwiParams.arg = hwiParams.eventId; // Enable the interrupt hwiParams.enableInt = FALSE; //TRUE; // Events Timer1L and Timer2L are on the same combined event so create a single Hwi. // Create the Hwi on interrupt 15 then specify 'EventCombiner_dispatch' // as the function. //Hwi_create(SIM_TIMER_HWI, &EventCombiner_dispatch, &hwiParams, &eb); Hwi_create(SIM_TIMER_HWI, &EventCombiner_dispatch, &hwiParams, NULL); } // Simulation start Void simStart(Void) { UInt32 curTime; // Start Rx audio clock -- Simulate Rx audio frame time */ //System_printf("Start Rx audio clock\n"); Log_info0("Start Rx audio clock"); Timer_start(timerRxAudio); // Wait for Rx-Tx delay system ticks before starting Tx audio clock. // Control phase difference between Rx and Tx audio clocks. curTime = Clock_getTicks(); while (Clock_getTicks() <= (curTime + RX_TX_AUDIO_DELTA_TICKS)) { ; } // Start Tx audio clock -- Simulate Tx audio frame time //System_printf("Start Tx audio clock\n"); Log_info0("Start Tx audio clock"); Timer_start(timerTxAudio); Hwi_enableInterrupt(SIM_TIMER_HWI); } // Simulation stop Void simStop(Void) { Hwi_disableInterrupt(SIM_TIMER_HWI); Hwi_clearInterrupt(SIM_TIMER_HWI); EventCombiner_disableEvent(CSL_C66X_COREPAC_TIMER_1_INTL); EventCombiner_disableEvent(CSL_C66X_COREPAC_TIMER_2_INTL); } #endif // SIMULATE_SIO #ifdef SIMULATE_RX_ALPHA /* * ======== clockRxAlphaFxn ======== */ Void clockRxAlphaFxn(UArg a0) { gClockRxAlphaCnt++; /* Post semaphore indicating Rx alpha command */ Semaphore_post(semaphoreRxAlpha); } #endif // Simulate load Void simLoad( Uint32 loadTime // load time in system clock ticks ) { UInt32 curTime; curTime = Clock_getTicks(); while (Clock_getTicks() <= (curTime + loadTime)) { ; } }