?? delay.c
字號(hào):
/***************************************************************************
* This code and information is provided "as is" without warranty of any *
* kind, either expressed or implied, including but not limited to the *
* implied warranties of merchantability and/or fitness for a particular *
* purpose. *
* *
* Copyright (C) 2006 Teridian Semiconductor Corp. All Rights Reserved. *
***************************************************************************/
//**************************************************************************
//
// DESCRIPTION: 71M65xx - Delay Routines.
//
// AUTHOR: RGV
//
// HISTORY: See end of file
//
//**************************************************************************
//
// File: DELAY.C
// This implements a looped delay. It adapts to clock rate changes.
//
//**************************************************************************
// delay loop API.
//
#include "options.h"
#if 1 // DELAY
#include "batmodes.h"
#include "delay.h"
// delay at least r1/32768 seconds, even when running 4.9MHz clock
#pragma save
#pragma NOAREGS
#if TRACE10 || M6520
uint8r_t mclkitr[] = // map clocks to iterations
{ 10, 5, 3, 2, 1, 0, 0, 0 }; // assumes 15 clock cycles per inner loop
// the compiler doesn't even get close to compiling a DJNZ...
#else
#error unknown device
#endif
void delay_clks (uint8_t cclk) small reentrant
{
register uint8_t r, rperclk;
#if BROWNOUT_BATMODE
if (batmode_is_brownout())
{
rperclk = 0;
}
else
{
rperclk = mclkitr[CONFIG0 & MPU_DIV];
}
#else
rperclk = mclkitr[CONFIG0 & MPU_DIV];
#endif
if (rperclk == 0)
{
do {
} while ((--cclk) != 0);
}
else
{
do {
r = rperclk;
do {
} while ((--r) != 0);
} while ((--cclk) != 0);
}
}
#pragma restore
#if EXTRAS
#pragma save
#pragma NOAREGS
void delay (uint32_t cclk) small reentrant
{
do {
if(cclk > 255)
{
delay_clks (255);
cclk -= 255;
}
else
{
delay_clks ((uint8_t)cclk);
cclk = 0;
}
} while (cclk != 0);
}
#pragma restore
#endif
#endif // delay
/***************************************************************************
* $Log: delay.c,v $
* Revision 1.4 2006/10/13 00:47:27 tvander
* Removed compile options for 6530, 6515;
* renamed 6511 and 6513 to trace11 and trace13;
* Binary verified unchanged from previous version.
*
* Revision 1.3 2006/09/09 01:09:09 gmikef
* *** empty log message ***
*
* Revision 1.2 2006/09/06 21:40:03 tvander
* Parameterized delay table for CPU
*
* Revision 1.1 2006/09/06 02:10:26 tvander
* Separated delay loop into its own file. Copes with different speeds, as best it can.
*
* 2006 september 5 First Version
*
* Copyright (C) 2006 Teridian Semiconductor Corp. All Rights Reserved. *
* this program is fully protected by the United States copyright *
* laws and is the property of Teridian Semiconductor Corporation. *
***************************************************************************/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -