Oops, not merging in the bit read for SPI test
[fw/altos] / target / ee / ee.c
index 221d597939a54c569a95c9a15b361dfdc2f949c2..f105388bb3d66b36dff29dfe432cf6154fc45398 100644 (file)
@@ -73,6 +73,7 @@ delay (unsigned char n)
 void
 cs(uint8_t b)
 {
+       SCK = 0;
        CS = b;
        delay(1);
 }
@@ -81,10 +82,10 @@ void
 out_bit(uint8_t b)
 {
        MOSI = b;
+       delay(1);
        SCK = 1;
        delay(1);
        SCK = 0;
-       delay(1);
 }
 
 void
@@ -103,11 +104,12 @@ uint8_t
 in_bit(void)
 {
        uint8_t b;
+       
+       delay(1);
        SCK = 1;
        delay(1);
        b = MISO;
        SCK = 0;
-       delay(1);
        return b;
 }
 
@@ -121,7 +123,7 @@ in_byte(void)
        for (s = 0; s < 8; s++) {
                b = in_bit();
                byte = byte << 1;
-               byte |= s;
+               byte |= b;
        }
        return byte;
 }