ds1624.c

来自「基于p89lpc931的ds1624的驱动程序」· C语言 代码 · 共 42 行

C
42
字号
//this child program is about to the temperture conver operation command

void ds1624_init(void)                    //set the temperature as one tempture convert mode
{
	extern i2c_init(void);
	
	extern i2c_sendaddr(0x90);        //send ds1624's address and a write operations
	extern i2c_senddata(0xAC);        //config the status command
	extern i2c_senddata(0x4D);        //config the status as 01001011(DONE=0,1SHOT=1)
}

void temperature_start(void)  	          //temperatrue start convert
{
	ds1624_init(void);
	
	extern i2c_sendaddr(0x90);
	extern i2c_senddata(0xEE);	  //start convert command
	
	extern delay_1s();		  //converts temperature to digital word 1 second
}

uchar temperature_read()
{
	uchar lsb,msb;
	ds1624_init(void);
	
	extern i2c_sendaddr(0x90);  	  //send ds1624's address and a write operations
	extern i2c_senddata(0xAA); 	  //read temperature command
	
	I2CON=0x44;		  	  //start i2c (I2EN=1,AA=1(low level to SDA as acknowledge))
	extern i2c_sendaddr(0x91);	  //send ds1624's address and a read operations
	extern i2c_readdata(msb);         //read MSB
	extern i2c_readdata(lsb);	  //read LSB
		
}


	
	


⌨️ 快捷键说明

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