/*********************************************************************************************************
* Initialization Program
* QiZhao,2007
* All Rights Reserved
* File : initial.h
* By : QiZhao
* Contact :zq1987731@163.com
*
* Version : V2.1 γ
* Corrector : QiZhao
* Date : 2008.2.1 (Last modified)
*
* Remarks : Common set of macro definitions keyword, and by setting controlled
* crystal oscillator frequency precision delay subroutine.
*
*********************************************************************************************************/
#ifndef _initial_h_
#define _initial_h_
/*********************************************************************************************************
*
* Global macro definitions
*
*********************************************************************************************************/
#include
#include // Absolute address access
#include
#include
#include
#include
#include
#include
#define TRUE 1
#define FALSE 0
#define bool bit // Boolean variable
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
#define FOSC 12000000UL // The frequency of crystal
#define NOP _nop_();
/*********************************************************************************************************
*
* Accurate delay(5us,10us)
*
*********************************************************************************************************/
void delay10us (void) // FOSC->12000000
{
NOP
NOP
NOP
NOP
NOP
NOP
}
void delay5us (void) // FOSC->12000000
{
NOP
}
/*********************************************************************************************************
*
* Accurate delay(1ms~255ms)
*
*********************************************************************************************************/
#define WAITE_HI (FOSC / 2 / 12 / 1000 >> 8 )
#define WAITE_LOW (FOSC / 2 / 12 / 1000 & 0xFF)
void delayms (uchar time)
{
do
{
uchar j;
#if WAITE_HI != 0
j = 0;
{
uchar i;
for(i = WAITE_HI; i > 0; i--)
{
while (--j);
}
}
#endif
#if WAITE_LOW != 0
j = WAITE_LOW;
while (--j);
#endif
}while (--time);
}
/*********************************************************************************************************
*
* Includes not repeat
*
*********************************************************************************************************/
#endif