X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=main.c;h=bcc4008fb06047bb719be722feeba1a856712947;hb=267a3bfd1e8892f8ae75bc4b3d1a5c4b310f1805;hp=ee6b1a17b7e60d4a90236151df4b11fa9e6b04ac;hpb=6b61bdbca74f12def23fc5f7099cc633aba420b3;p=temper-clone.git diff --git a/main.c b/main.c index ee6b1a1..bcc4008 100644 --- a/main.c +++ b/main.c @@ -221,36 +221,6 @@ void set_serial(void) } } -uint16_t read_temp(void) -{ - uint8_t buf[9]; - - cli(); - if (!w1_reset()) { - return 0xFFFF; - sei(); - } - - w1_write(0xCC); /* SKIP ROM */ - w1_write(0x44); /* Convert T */ - - do { - w1_read(buf, 1); - } while (buf[0] != 0xFF); - - if (!w1_reset()) { - return 0xFFFF; - sei(); - } - - w1_write(0xCC); /* SKIP ROM */ - w1_write(0xBE); /* Read Scratchpad */ - w1_read(buf, 9); - sei(); - - return buf[2] << 8 | buf[1]; -} - usbMsgLen_t usbFunctionDescriptor(usbRequest_t *rq) { if (rq->wValue.bytes[1] == USBDESCR_STRING && @@ -418,31 +388,31 @@ int main(void) if (temp_state == 1) { if (w1_reset()) { - temp_state = 2; + temp_state++; } else { temp_state = 0; } } else if (temp_state == 2) { w1_write(0xCC); /* SKIP ROM */ - temp_state = 3; + temp_state++; } else if (temp_state == 3) { w1_write(0x44); /* Convert T */ - temp_state = 4; + temp_state++; } else if (temp_state == 4) { if (w1_read_bit()) - temp_state = 5; + temp_state++; } else if (temp_state == 5) { if (w1_reset()) { - temp_state = 6; + temp_state++; } else { temp_state = 0; } } else if (temp_state == 6) { w1_write(0xCC); /* SKIP ROM */ - temp_state = 7; + temp_state++; } else if (temp_state == 7) { w1_write(0xBE); /* Read Scratchpad */ - temp_state = 8; + temp_state++; } else if (temp_state > 7 && temp_state < 17) { buf[temp_state - 8] = w1_read_byte(); temp_state++;