/******************************************************************************* * cvPlatformMiliSecDelay - halts the system for a desired mili - seconds. * * DESCRIPTION: * This function halts the system for a desired mili-seconds delivered * by the parameter ‘miliSec’.It uses one of the 8 counter/timers within * the MV by loading it with the ‘miliSec’ parameter multiplied * with 1 mili-second ( 1 mili-second is calculated by dividing the ‘ * Tclock’ parameter by 1000) and waiting in a loop for it to end the * count. * INPUT: * miliSec - The desirable time ( in mili -seconds) to halt the system. * Tclock - The MV core clock . * countNum - The desired counter/timer (one out of possible 8 * counter/timers within the MV). * OUTPUT: * None. * * RETURN: * None. * *******************************************************************************/ MV_VOID cvPlatformMiliSecDelay(MV_U32 miliSec,MV_U32 Tclock, MV_U32 countNum) { MV_U32 oneMiliSec; MV_CNTMR_CTRL counterCnrl; counterCnrl.enable = MV_TRUE; counterCnrl.autoEnable = MV_FALSE; oneMiliSec = Tclock/1000; mvCntmrDisable(countNum); mvCntmrCtrlSet(countNum,&counterCnrl); mvCntmrLoad(countNum,miliSec * oneMiliSec); mvCntmrEnable(countNum); while(mvCntmrRead(countNum)); }
/******************************************************************************* * mvCntmrStart - * * DESCRIPTION: * Combined all the sub-operations above to one function: Load,setMode,Enable * * INPUT: * countNum - counter number * value - value of the counter\timer to be set * pCtrl - pointer to MV_CNTMR_CTRL structure * * OUTPUT: * None. * * RETURN: * MV_BAD_PARAM on bad parameters , MV_ERROR on error ,MV_OK on sucess *******************************************************************************/ MV_STATUS mvCntmrStart(MV_U32 countNum, MV_U32 value, MV_CNTMR_CTRL *pCtrl) { if (countNum >= MV_CNTMR_MAX_COUNTER) { mvOsPrintf(("mvCntmrDisable: Err. illegal counter number \n")); return MV_BAD_PARAM;; } /* load value onto counter\timer */ mvCntmrLoad(countNum, value); /* set control for timer \ cunter and enable */ mvCntmrCtrlSet(countNum, pCtrl); return MV_OK; }