⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xsost.c

📁 优龙YLP270开发板 光盘自带的BIOS和实验例程源码 强烈推荐
💻 C
📖 第 1 页 / 共 3 页
字号:

	case 3:
		returnValue = XsIcDisableIrqDeviceInt(XSIC_OST_REG3_SGNL);
		if(!returnValue)
		{
			returnValue = XsIcUnRegisterHandler(XSIC_OST_REG3_SGNL);
		}
	break;

	default:
		printf(" Error! Invalid Channel\r\n");
	break;

	}//end switch

	if(!returnValue)
	{
		returnValue = XsOstDisableInterrupt(XsOstCurrentChannel);
	}

	if(!returnValue)
	{
		XsOstFreeChannel((UINT32)XsOstCurrentChannel);
	}

	XsOstCurrentChannel = 0;

	return returnValue;


}//end XsOstCleanupTimer





/*
*******************************************************************************
*
* FUNCTION:
*    <Function name here>
*
* DESCRIPTION:
*    Start a timer
*
* INPUT PARAMETERS:
*    <Input parameters here>
*
* RETURNS:
*    <Returns descriptions here>
*
* GLOBAL EFFECTS:
*    <Other global effects here>
*
* ASSUMPTIONS:
*    <Notes or Assumptions here>
*
* CALLS:
*    <Dependent function calls here>
*
* CALLED BY:
*    <Who calls this procedure here>
*
* PROTOTYPE:
*    <Enter the function prototype here>
*
*******************************************************************************
*/
int startTimer (OSTContextT * ostCtxP, int count, int interval,
                DM_TimerCallback_T cb, void *param)
{


//    int rc = Timer_Start (ostCtxP, count, interval, cb, param);
    int i;


    for (i = 0; i < MAX_TIMER; i++)
    {
#ifdef temp
        if (!(timers[i].used))
        {
            timers[i].used = 1;
            timers[i].count = count;
            timers[i].curCount = count;
            timers[i].interval = interval;
            timers[i].curInterval = 0;
            timers[i].cb = cb;
            timers[i].param = param;
            timers[i].enable = 1;
            return DM_TimerNoError;
        }
		else
		{
		    return DM_TimerNoFreeTimer;
		}
#endif
    }

// EnableInterrupt has been replaced with the call to enable interrupts
// on Cotulla - XsIcEnableInterruiptsIrq?
    XsIcEnableIrqDeviceInt (XSIC_OST_REG0_SGNL);

    return 0;
}

/*
*******************************************************************************
*
* FUNCTION:
*    <Function name here>
*
* DESCRIPTION:
*    Stop a timer
*
* INPUT PARAMETERS:
*    <Input parameters here>
*
* RETURNS:
*    <Returns descriptions here>
*
* GLOBAL EFFECTS:
*    <Other global effects here>
*
* ASSUMPTIONS:
*    <Notes or Assumptions here>
*
* CALLS:
*    <Dependent function calls here>
*
* CALLED BY:
*    <Who calls this procedure here>
*
* PROTOTYPE:
*    <Enter the function prototype here>
*
*******************************************************************************
*/
static
int stopTimer (OSTContextT * ostCtxP, int count, int interval,
               DM_TimerCallback_T cb, void *param)
{
//    int rc = Timer_Stop (ostCtxP, count, interval, cb, param);
    int i;


    for (i = 0; i < MAX_TIMER; i++)
    {
#ifdef temp
        if ( (timers[i].used) &&
             (timers[i].count == count) &&
             (timers[i].interval == interval) &&
             (timers[i].cb == cb) &&
             (timers[i].param == param) )
        {
            timers[i].enable = 0;
            timers[i].used = 0;
            return DM_TimerNoError;
        }
		else
		{
		    return DM_TimerNotFound;			
		}
#endif		
    }

#ifdef STOP_INTERRUPTS
  if (Timer_Count(funcP) == 0)
  {
// DisableInterrupt has been replaced with the call to disable interrupts
// on Cotulla - XsIcDisableInterruiptsIrq?
      XsIcDisableIrqDeviceInt (XSIC_OST_REG0_SGNL);
  }
#endif

    return 0;
}

/*
*******************************************************************************
*
* FUNCTION:
*    <Function name here>
*
* DESCRIPTION:
*    Get timer interval
*
* INPUT PARAMETERS:
*    <Input parameters here>
*
* RETURNS:
*    <Returns descriptions here>
*
* GLOBAL EFFECTS:
*    <Other global effects here>
*
* ASSUMPTIONS:
*    <Notes or Assumptions here>
*
* CALLS:
*    <Dependent function calls here>
*
* CALLED BY:
*    <Who calls this procedure here>
*
* PROTOTYPE:
*    <Enter the function prototype here>
*
*******************************************************************************
*/
static
int getInterval (OSTContextT * ostCtxP)
{
    return TEST_INTERVAL;
}

/*
*******************************************************************************
*
* FUNCTION:
*    <Function name here>
*
* DESCRIPTION:
*    Get timer base
*
* INPUT PARAMETERS:
*    <Input parameters here>
*
* RETURNS:
*    <Returns descriptions here>
*
* GLOBAL EFFECTS:
*    <Other global effects here>
*
* ASSUMPTIONS:
*    <Notes or Assumptions here>
*
* CALLS:
*    <Dependent function calls here>
*
* CALLED BY:
*    <Who calls this procedure here>
*
* PROTOTYPE:
*    <Enter the function prototype here>
*
*******************************************************************************
*/
static
int getTimebase (OSTContextT * ostCtxP)
{
    return 3250000;
}

/*
*******************************************************************************
*
* FUNCTION:
*    <Function name here>
*
* DESCRIPTION:
*    Get timer value
*
* INPUT PARAMETERS:
*    <Input parameters here>
*
* RETURNS:
*    <Returns descriptions here>
*
* GLOBAL EFFECTS:
*    <Other global effects here>
*
* ASSUMPTIONS:
*    <Notes or Assumptions here>
*
* CALLS:
*    <Dependent function calls here>
*
* CALLED BY:
*    <Who calls this procedure here>
*
* PROTOTYPE:
*    <Enter the function prototype here>
*
*******************************************************************************
*/
int getTimer (OSTContextT *ostCtxP)
{
    volatile OSTRegsT *OstControlRegsP = ostCtxP->regsP;

    return OstControlRegsP->OSCR;
}

/*
*******************************************************************************
*
* FUNCTION:
*    <Function name here>
*
* DESCRIPTION:
*    Get timer delta
*
* INPUT PARAMETERS:
*    <Input parameters here>
*
* RETURNS:
*    <Returns descriptions here>
*
* GLOBAL EFFECTS:
*    <Other global effects here>
*
* ASSUMPTIONS:
*    <Notes or Assumptions here>
*
* CALLS:
*    <Dependent function calls here>
*
* CALLED BY:
*    <Who calls this procedure here>
*
* PROTOTYPE:
*    <Enter the function prototype here>
*
*******************************************************************************
*/
static
int getDelta (OSTContextT *ostCtxP, unsigned start)
{
    volatile OSTRegsT *OstControlRegsP = ostCtxP->regsP;

    unsigned stop = OstControlRegsP->OSCR;
    if (stop < start)
        return stop + (start^0xffffffff) + 1;
    return stop - start;
}

/*
*******************************************************************************
*
* FUNCTION:
*    waitTimer.
*
* DESCRIPTION:
*    Timer interface wait function. Spin for specific microsecond count.
*
* INPUT PARAMETERS:
*    OSTContextT *ctxP - Pointer the the Device Context Structure.
*    UINT count - Number of ticks to wait.
*
* RETURNS:
*    None.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    DCS has been initialized.
*
* CALLS:
*    None.
*
* CALLED BY:
*    DM driver and test code.
*
* PROTOTYPE:
*    static
*    VOID waitTimer (OSTContextT *ctxP, UINT count);
*
*******************************************************************************
*/
static
VOID waitTimer (OSTContextT *ctxP, UINT count)
{
    volatile OSTRegsT *OstControlRegsP = ctxP->regsP;

    // Timer is run from 3.6864Mhz clock, do tick calc without overflow. If
    // a rough clac is all that is required this could be rounded off.
    UINT ticks = (3 * count) + (6 * count / 10) + (8 * count / 100) +
                 (6 * count / 1000) + (4 * count / 10000);
    UINT start = OstControlRegsP->OSCR;
    while (OstControlRegsP->OSCR - start < ticks)
    {
    }
}


/*
*******************************************************************************
*
* FUNCTION:
*    <Function name here>
*
* DESCRIPTION:
*    <Description or algorithm here>
*
* INPUT PARAMETERS:
*    <Input parameters here>
*
* RETURNS:
*    <Returns descriptions here>
*
* GLOBAL EFFECTS:
*    <Other global effects here>
*
* ASSUMPTIONS:
*    <Notes or Assumptions here>
*
* CALLS:
*    <Dependent function calls here>
*
* CALLED BY:
*    <Who calls this procedure here>
*
* PROTOTYPE:
*    <Enter the function prototype here>
*
*******************************************************************************
*/
VOID XsOstSWInitX(OSTContextT *ctxP)
{
    ctxP->regsP = (struct ostreg*)OST_REGISTER_BASE;
	ctxP->setup_fnp = (DM_TimerSetup_T) XsOstSetupTimer;
	ctxP->cleanup_fnp = (DM_TimerCleanup_T) XsOstCleanupTimer;
    ctxP->start_fnp = (DM_TimerStart_T) startTimer;
    ctxP->stop_fnp = (DM_TimerStop_T) stopTimer;
    ctxP->wait_fnp = (DM_TimerWait_T) waitTimer;
    ctxP->getInterval_fnp = (DM_TimerGetInterval_T) getInterval;
    ctxP->getTimebase_fnp = (DM_TimerGetTimebase_T) getTimebase;
    ctxP->getTimer_fnp = (DM_TimerGetTimer_T) getTimer;
    ctxP->getDelta_fnp = (DM_TimerGetDelta_T) getDelta;
}

void XsOstSWInit(VOID)
{
    XsOstSWInitX(&Ost);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -