]> git.donarmstrong.com Git - tmk_firmware.git/blobdiff - keyboard/hhkb_rn42/rn42/rn42.c
Add keyboard LED control via Bluetooth
[tmk_firmware.git] / keyboard / hhkb_rn42 / rn42 / rn42.c
index 556c61af9589e7e971a11e621d46d37e4a3a6a2a..1565b4cf1417a582dd87816a525c2ccfc5f5def0 100644 (file)
@@ -34,7 +34,7 @@ void rn42_init(void)
 
     // PF6: linked(input without pull-up)
     DDRF  &= ~(1<<6);
-    PORTF &= ~(1<<6);
+    PORTF |=  (1<<6);
 
     // PF1: RTS(low: allowed to send, high: not allowed)
     DDRF &= ~(1<<1);
@@ -93,11 +93,17 @@ void rn42_cts_lo(void)
 
 bool rn42_linked(void)
 {
-    return PINF&(1<<6);
+    // RN-42 GPIO2
+    //   Hi-Z:  Not powered
+    //   High:  Linked
+    //   Low:   Connecting
+    return !rn42_rts() && PINF&(1<<6);
 }
 
 
-static uint8_t keyboard_leds(void) { return 0; }
+static uint8_t leds = 0;
+static uint8_t keyboard_leds(void) { return leds; }
+void rn42_set_leds(uint8_t l) { leds = l; }
 
 static void send_keyboard(report_keyboard_t *report)
 {
@@ -195,7 +201,7 @@ host_driver_t rn42_config_driver = {
     config_send_consumer
 };
 
-static uint8_t config_keyboard_leds(void) { return 0; }
+static uint8_t config_keyboard_leds(void) { return leds; }
 static void config_send_keyboard(report_keyboard_t *report) {}
 static void config_send_mouse(report_mouse_t *report) {}
 static void config_send_system(uint16_t data) {}