www.pudn.com > comper.rar > General.c


/**************************************************************************** 
文件名:general.c 
编写者:czhang 
描述:通用子程序库 
内容:DelayMs:延时程序 
      ToBCD:将一个整数转换为BCD码 
版本:2003年10月11日   1.0 
*****************************************************************************/ 
#include "general.h" 
 
/************************************************************************** 
延时 
ms:延时的毫秒数 
***************************************************************************/ 
void DelayMs(unsigned int ms) 
{ 
	unsigned int iq0, iq1; 
	for (iq0 = ms; iq0 > 0; iq0--) 
	for (iq1 = LOOPCNT; iq1 > 0; iq1--) 
	; 
} 
 
/************************************************************************** 
将一个无符号整数转换为BCD码 
shu:要转换的无符号整数 
pdst:指向转化完成后保存的数组的首地址,*pdest放最高位, *(pdest+3)放最低位 
***************************************************************************/ 
void ToBCD(unsigned char shu,unsigned char *pdest) 
{ 
	unsigned int iq1; 
 
	*pdest=shu/1000; 
	iq1=shu%1000; 
	pdest++; 
	*pdest=iq1/100; 
	iq1=iq1%100; 
	pdest++; 
	*pdest=iq1/10; 
	pdest++; 
	*pdest=iq1%10; 
}