therm.c

来自「数字温度计原代码」· C语言 代码 · 共 60 行

C
60
字号
#include <string.h>
#include <stdlib.h>
ioport unsigned int portbfff;
extern void dspinit();
extern void bsp2init();
extern void writetherm(unsigned int);
extern unsigned int  readtherm();
extern void resettherm();
/////////////////////////////////////////////////////////////
void smg_dis(unsigned int address,unsigned int dot,unsigned int value, unsigned int light)
{
	unsigned int temp;
	temp=((address<<6)&0xc0)+(dot?0x10:0x00)+(light?0x20:0x00)+value;
	portbfff=temp;
}
void dis_therm(unsigned int value)
{
	unsigned int temp;
	temp=value&0x0f;
	temp=temp*10/16;
	smg_dis(0,0,temp,1);
	value=value>>4;
	temp=value%10;
	value=value/10;
	smg_dis(1,1,temp,1);
	temp=value%10;
	smg_dis(2,0,temp,1);
	temp=value/10;
	smg_dis(3,0,temp,1);
}

void main()
{
	unsigned int i;
	
	dspinit();
	bsp2init();
	while(1)
	{
		resettherm();
		writetherm(0xcc);
		writetherm(0x44);
		i=readtherm();
		while(i!=0xfff)
		{
			i=readtherm();
		}
		for(i=0;i<0xfff;i++);
		resettherm();
		writetherm(0xcc);
		writetherm(0xbe);
		i=readtherm();	
		dis_therm(i);
	}
}




⌨️ 快捷键说明

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