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

📄 util.c

📁 Windows CE 6.0 BSP for VOIPAC Board (PXA270) Version 2b.
💻 C
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
//  File: util.c
//
//  This function contain implementation of OALStall and OALGetTickCount 
//  functions from timer module suitable for most MIPS based CPU/SoC. It is
//  using CP0 count register to obtain actual
//
#include <windows.h>
#include <oal_timer.h>

//------------------------------------------------------------------------------
//
//  External function:  OALTimerGetCount
//
//  This function is implemented in MIPS CP0 library. It returns actual CP0
//  count register value.
//
UINT32 OALTimerGetCount();

//------------------------------------------------------------------------------
//
//  Function:  OALStall
//
//  Wait for time specified in parameter in microseconds (busy wait). This
//  function can be called in hardware/kernel initialization process.
//
VOID OALStall(UINT32 microSec)
{
    UINT32 base, counts;

    while (microSec > 0) {
        if (microSec > 1000) {
            counts = g_oalTimer.countsPerMSec;
            microSec -= 1000;
        } else {
            counts = (microSec * g_oalTimer.countsPerMSec)/1000;
            microSec = 0;
        }            
        base = OALTimerGetCount();
        while ((OALTimerGetCount() - base) < counts);
    }
}

//------------------------------------------------------------------------------
//
//  Function:  OALGetTickCount
//
//  Function returns number of 1ms ticks since system reboot/reset.
//
UINT32 OALGetTickCount()
{
    static UINT32 base = 0, offset = 0;
    UINT32 plus, delta;

    delta = OALTimerGetCount() - base;
    plus = delta/g_oalTimer.countsPerMSec;
    offset += plus;
    base += plus * g_oalTimer.countsPerMSec;
    return offset;
}

//------------------------------------------------------------------------------

⌨️ 快捷键说明

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