diff --git a/ds18b20.c b/ds18b20.c index 20083ba..d93a34c 100755 --- a/ds18b20.c +++ b/ds18b20.c @@ -50,18 +50,16 @@ unsigned char read_char(void) unsigned char dat = 0; // spin_lock(&lock); - DQ_OUT; for(i=0; i<8; i++) { + DQ_OUT; DQ_L; udelay(2); - dat >>= 1; DQ_IN; - udelay(12); + dat >>= 1; + udelay(2); if (DQ_V) dat |= 0x80; - udelay(50); - DQ_OUT; - udelay(2); + udelay(60); } //spin_unlock(&lock); return dat; @@ -125,6 +123,7 @@ void readDs18b20Data(unsigned char *value) // local_irq_enable(); mdelay(750); + //msleep(750); // local_irq_disable(); @@ -136,11 +135,27 @@ void readDs18b20Data(unsigned char *value) } write_char(0xCC); write_char(0xBE); -// local_irq_enable(); - mutex_unlock(&mutex); value[0] = 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)