]> git.friedersdorff.com Git - max/tmk_keyboard.git/blobdiff - adb.c
rewrite code of layer switching
[max/tmk_keyboard.git] / adb.c
diff --git a/adb.c b/adb.c
index e66a501b7c632f1408e0a95c9213c604da805906..6848fa652b1513cd015f064e164a43ab3616e39c 100644 (file)
--- a/adb.c
+++ b/adb.c
@@ -42,9 +42,9 @@ uint16_t adb_host_kbd_recv(void)
 {
     uint16_t data = 0;
     attention();
-    send_byte(0x2C);            // Addr:2, Cmd:talk(11), Reg:0(00)
-    place_bit0();               // Stopbit
-    if (!wait_data_lo(0xFF))    // Stop to Start(140-260us)
+    send_byte(0x2C);            // Addr:Keyboard(0010), Cmd:Talk(11), Register0(00)
+    place_bit0();               // Stopbit(0)
+    if (!wait_data_lo(0xFF))    // Tlt/Stop to Start(140-260us)
         return 0;               // No data to send
     if (!read_bit())            // Startbit(1)
         return -2;
@@ -55,6 +55,19 @@ uint16_t adb_host_kbd_recv(void)
     return data;
 }
 
+// send state of LEDs
+void adb_host_kbd_led(uint8_t led)
+{
+    attention();
+    send_byte(0x2A);            // Addr:Keyboard(0010), Cmd:Listen(10), Register2(10)
+    place_bit0();               // Stopbit(0)
+    _delay_us(200);             // Tlt/Stop to Start
+    place_bit1();               // Startbit(1)
+    send_byte(0);               // send upper byte (not used)
+    send_byte(led&0x07);        // send lower byte (bit2: ScrollLock, bit1: CapsLock, bit0: NumLock)
+    place_bit0();               // Stopbit(0);
+}
+
 
 static inline void data_lo()
 {