📄 timer.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.
//
/******************************************************************************
* FileName: timer.c - Time and Date.
*
* SanDisk Host Developer's Toolkit
*
* Copyright (c) 1997 - 1999 SanDisk Corporation
* All rights reserved.
*
******************************************************************************/
/* timer.c - Timer service routines for run-time drivers.
*
* These routines provide executive services for the run-time drivers
* running on a PC with no executive kernel. Equivalent services should
* be provided by the kernel environment, replacing these.
*
* The following functions must be provided
*
* SDVOID oem_getsysdate() - Date and time information
* ULONG platform_get_ticks() - Return the current system tick count
* ULONG platform_ticks_per_second() - Return the tick period
*
*/
#include <windows.h>
#include <winbase.h>
#include "oem.h"
#define TICKS_PER_SECOND 18
ULONG delayTime = 0L;
DWORD CurMSec;
/* ======================= Timer management functions ===================== */
/****************************************************************************
** Name: PLATFORM_TICK_P_SECOND - Get current tick per second (USER SUPPLIED)
**
** Summary:
**
** #include "oem.h"
**
** platform_tick_p_second(SDVOID)
**
** Description:
** Provide a way to get the number of ticks per second.
** The default is 18 ticks per second for INTEL platform
** and 60 ticks per second for other platforms.
**
**
** NOTE: Be sure to retain the property of returning its argument. The
** package depends on it.
**
** Entries:
** None
**
** Returns
** The ticks per second.
**
**
*****************************************************************************/
ULONG platform_ticks_p_second(SDVOID) /*__fn__*/
{
return(TICKS_PER_SECOND);
}
/****************************************************************************
** Name: PLATFORM_DELAYMS - delay in certain time (USER SUPPLIED)
**
** Summary:
**
** #include "oem.h"
**
** platform_delayms(SDVOID)
**
** Description:
** Wait for a certain time requested by the user
**
** Entries:
** sleep The granularity in miliseconds
**
** Returns
** None.
**
** Example:
** #include "oem.h"
**
** Note:
** The calculation of the ticks at a given delay time in millisecond is:
** one tick in millisecond = 1000 millisecond / TICKS_PER_SECOND
** no. ticks = (delay time in millisecond) / (onetick in millisecond)
**
*****************************************************************************/
SDVOID platform_delayms(COUNT delay_millis) /*__fn__*/
{
Sleep( delay_millis);
}
/****************************************************************************
** Name: PLATFORM_GET_TICKS - Get current timer tick (USER SUPPLIED)
**
** Summary:
**
** #include "oem.h"
**
** platform_get_ticks(SDVOID)
**
** Description:
** Provide a way to get the current timer tick.
**
** Entries:
** None
**
** Returns
** The granularity timer ticks.
**
** Example:
** #include "oem.h"
**
**
*****************************************************************************/
ULONG platform_get_ticks(SDVOID) /*__fn__*/
{
return GetTickCount();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -