]> git.donarmstrong.com Git - tmk_firmware.git/blobdiff - protocol/adb.c
Fix ADB missing keystrokes problem Thanks, blargg! #14
[tmk_firmware.git] / protocol / adb.c
index 2f3f667b79e78c5d536adbf0bd77f14431f9b5a1..155d223fe7ed1f0c438a2ef5226d7b4f88c5ea7e 100644 (file)
@@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #include <avr/io.h>
 #include <avr/interrupt.h>
 #include "adb.h"
+#include "debug.h"
 
 
 static inline void data_lo(void);
@@ -63,7 +64,6 @@ static inline uint8_t wait_data_hi(uint8_t us);
 
 void adb_host_init(void)
 {
-DDRF |= (1<<1);
     data_hi();
 #ifdef ADB_PSW_BIT
     psw_hi();
@@ -83,6 +83,12 @@ bool adb_host_psw(void)
 }
 #endif
 
+/*
+ * Don't call this in a row without the delay, otherwise it makes some of poor controllers
+ * overloaded and misses strokes. Recommended delay is 16ms.
+ *
+ * Thanks a lot, blargg! <http://geekhack.org/index.php?topic=14290.msg1068919#msg1068919>
+ */
 uint16_t adb_host_kbd_recv(void)
 {
     uint16_t data = 0;
@@ -94,6 +100,7 @@ uint16_t adb_host_kbd_recv(void)
     }
     if (!read_bit()) {          // Startbit(1)
         // Service Request
+        dprintf("Startbit ERROR\n");
         return -2;
     }
 
@@ -105,6 +112,7 @@ uint16_t adb_host_kbd_recv(void)
     sei();
 
     if (stop) {
+        dprintf("Stopbit ERROR\n");
         return -3;
     }
     return data;