]> the.earth.li Git - temper-clone.git/blobdiff - main.c
Do USB disconnect/reconnect dance before initialising USB
[temper-clone.git] / main.c
diff --git a/main.c b/main.c
index 0adfed8cc246c636c0180b32bffe295d9fdc20ca..4e3d72c3c4667e5a55a9713d8eff3466b8d9e0b8 100644 (file)
--- a/main.c
+++ b/main.c
@@ -358,6 +358,13 @@ usbMsgLen_t usbFunctionWrite(uint8_t * data, uchar len)
        return 0;
 }
 
+void hadUsbReset(void)
+{
+       /* Reset our state machine back to having nothing to send */
+       temp_state = 0;
+       have_temp_int = false;
+}
+
 int main(void)
 {
        unsigned char i;
@@ -368,17 +375,16 @@ int main(void)
        w1_setup();
        set_serial();
 
-       usbInit();
        usbDeviceDisconnect();
-
        i = 0;
        while (--i) {
                wdt_reset();
                _delay_ms(1);
        }
-
        usbDeviceConnect();
 
+       usbInit();
+
        /* PB1 as output for LED */
        DDRB |= 1 << PB1;
 
@@ -419,7 +425,7 @@ int main(void)
                        w1_write(0x44);         /* Convert T */
                        temp_state = 4;
                } else if (temp_state == 4) {
-                       if (w1_read_byte() == 0xFF)
+                       if (w1_read_bit())
                                temp_state = 5;
                } else if (temp_state == 5) {
                        if (w1_reset()) {