wait.c

来自「ti-Chipcon CC1010 1G以下Soc源码库。包括rf,powerm」· C语言 代码 · 共 68 行

C
68
字号
/*****************************************************************************
 *                                                                           *
 *        **********                                                         *
 *       ************                                                        *
 *      ***        ***                                                       *
 *      ***   +++   ***                                                      *
 *      ***   + +   ***                                                      *
 *      ***   +                            CHIPCON CC1010                    *
 *      ***   + +   ***                     HAL - Wait                       *
 *      ***   +++   ***                                                      *
 *      ***       ***                                                        *
 *       ***********                                                         *
 *        *********                                                          *
 *                                                                           *
 *****************************************************************************
 *                                                                           *
 *****************************************************************************
 * Author:              ROH                                                  *
 *****************************************************************************
 * Revision history:                                                         *
 *                                                                           *
 * $Log: Wait.c,v $
 * Revision 1.4  2004/01/08 19:21:46  tos
 * Reverted to "old" algorithm constant.
 *
 * Revision 1.3  2003/08/11 15:02:39  tos
 * Corrected reentrant usage in library: reentrant only if using large memory model.
 *
 * Revision 1.2  2003/07/29 11:25:33  tos
 * Made halWait() and halConfigTimer23() reentrant.
 *
 * Revision 1.1  2002/10/14 13:04:37  tos
 * Initial version in CVS.
 *
 *                                                                           *
 ****************************************************************************/

#include <chipcon/hal.h>


//----------------------------------------------------------------------------
//  byte* halWait(...)
//
//  Description:
//      A wait functions which performs a number of iterations of a simple
//      wait loop, so that at least _timeOut_ ms goes by before the
//      function returns.
//
//  Arguments:
//      byte timeOut
//          The time to wait in ms.
//      word clkFreq
//          The XOSC clock frequency in kHz.
//
//  Return value:
//      void
//----------------------------------------------------------------------------
#if (__MODEL__ == 0)  // Memory model: 0 = SMALL, 1 = COMPACT, 2 = LARGE
void halWait(byte timeOut, word clkFreq) {
#else
void halWait(byte timeOut, word clkFreq) reentrant {
#endif
    ulong wait;
    
    wait=(ulong)timeOut*(ulong)clkFreq/192;
    while (wait--);
}

⌨️ 快捷键说明

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