stall.c

来自「老外的一个开源项目」· C语言 代码 · 共 80 行

C
80
字号
// Copyright (c) David Vescovi.  All rights reserved.
// Part of Project DrumStix
// Windows Embedded Developers Interest Group (WE-DIG) community project.
// http://www.we-dig.org
// Copyright (c) Microsoft Corporation.  All rights reserved.
//------------------------------------------------------------------------------
//
//  File:  stall.c            
//
//  This module implements the OALStall.
//
//------------------------------------------------------------------------------
#include <bsp.h>
 
//------------------------------------------------------------------------------
// Defines 
//
 
//------------------------------------------------------------------------------
// Externs
//
 
//------------------------------------------------------------------------------
// Global Variables 
 
//------------------------------------------------------------------------------
// Local Variables 
//

//------------------------------------------------------------------------------
// Local Functions 
//

//------------------------------------------------------------------------------
//
//  Function: OALStall
//
//  Delays us 
//
//------------------------------------------------------------------------------

void OALStall(UINT32 microSeconds)
{
	volatile OST_REG_T *pOSTRegs= (volatile OST_REG_T *) OALPAtoVA((PXA255_BASE_REG_PA_OST), FALSE);
	UINT32_T expireTime, time;

	time = pOSTRegs->OSCR;
	expireTime = time + (microSeconds * OEM_TICKS_1US);
	//
	// Check if we wrapped on the expireTime
	// and delay first part until wrap
	//
	if (expireTime < time) 
	{
		while (time < pOSTRegs->OSCR);
	}
	while (pOSTRegs->OSCR <= expireTime);
}


//------------------------------------------------------------------------------
//
//  Function:  OALSpinForever
//
//  Never ending loop.
//
//------------------------------------------------------------------------------
void OALSpinForever(void)
{

    while (1)
    {
        ;
    }
}




⌨️ 快捷键说明

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