📄 ds1624.c
字号:
//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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -