update
This commit is contained in:
parent
9ca61be337
commit
d0c34bf05c
31
ds18b20.c
31
ds18b20.c
@ -50,18 +50,16 @@ unsigned char read_char(void)
|
|||||||
unsigned char dat = 0;
|
unsigned char dat = 0;
|
||||||
|
|
||||||
// spin_lock(&lock);
|
// spin_lock(&lock);
|
||||||
DQ_OUT;
|
|
||||||
for(i=0; i<8; i++) {
|
for(i=0; i<8; i++) {
|
||||||
|
DQ_OUT;
|
||||||
DQ_L;
|
DQ_L;
|
||||||
udelay(2);
|
udelay(2);
|
||||||
dat >>= 1;
|
|
||||||
DQ_IN;
|
DQ_IN;
|
||||||
udelay(12);
|
dat >>= 1;
|
||||||
|
udelay(2);
|
||||||
if (DQ_V)
|
if (DQ_V)
|
||||||
dat |= 0x80;
|
dat |= 0x80;
|
||||||
udelay(50);
|
udelay(60);
|
||||||
DQ_OUT;
|
|
||||||
udelay(2);
|
|
||||||
}
|
}
|
||||||
//spin_unlock(&lock);
|
//spin_unlock(&lock);
|
||||||
return dat;
|
return dat;
|
||||||
@ -125,6 +123,7 @@ void readDs18b20Data(unsigned char *value)
|
|||||||
// local_irq_enable();
|
// local_irq_enable();
|
||||||
|
|
||||||
mdelay(750);
|
mdelay(750);
|
||||||
|
//msleep(750);
|
||||||
|
|
||||||
// local_irq_disable();
|
// local_irq_disable();
|
||||||
|
|
||||||
@ -136,11 +135,27 @@ void readDs18b20Data(unsigned char *value)
|
|||||||
}
|
}
|
||||||
write_char(0xCC);
|
write_char(0xCC);
|
||||||
write_char(0xBE);
|
write_char(0xBE);
|
||||||
// local_irq_enable();
|
|
||||||
mutex_unlock(&mutex);
|
|
||||||
|
|
||||||
value[0] = read_char();
|
value[0] = read_char();
|
||||||
value[1] = read_char();
|
value[1] = read_char();
|
||||||
|
// local_irq_enable();
|
||||||
|
mutex_unlock(&mutex);
|
||||||
|
|
||||||
|
//printk("%d: TH:%x, TL:%x, c:%x", gpio_num,read_char(),read_char(),read_char());
|
||||||
|
|
||||||
|
// mdelay(1);
|
||||||
|
|
||||||
|
// init_DS18B20();
|
||||||
|
//write_char(0xB4);
|
||||||
|
//DQ_OUT;
|
||||||
|
//printk("%d: EC:%d", gpio_num,DQ_V);
|
||||||
|
//write_char(0x4E);
|
||||||
|
//write_char(0x64);
|
||||||
|
//write_char(0x00);
|
||||||
|
//write_char(0x7F);
|
||||||
|
|
||||||
|
//init_DS18B20();
|
||||||
|
//write_char(0x48);
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeDs18b20(void)
|
void freeDs18b20(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user