]> git.donarmstrong.com Git - tmk_firmware.git/blobdiff - keyboard/hhkb_rn42/rn42/rn42.c
Fix rn42_linked() to use pullup
[tmk_firmware.git] / keyboard / hhkb_rn42 / rn42 / rn42.c
index e7d8ba45cc23a0bea7d115b10dfc2d0bb4d7622c..bdffad766777af1c965cd070e5f6cf54eadf18fd 100644 (file)
@@ -25,12 +25,17 @@ host_driver_t rn42_driver = {
 
 void rn42_init(void)
 {
-    // PF7: BT connection control(HiZ: connect, low: disconnect)
     // JTAG disable for PORT F. write JTD bit twice within four cycles.
     MCUCR |= (1<<JTD);
     MCUCR |= (1<<JTD);
+
+    // PF7: BT connection control(high: connect, low: disconnect)
     rn42_autoconnect();
 
+    // PF6: linked(input without pull-up)
+    DDRF  &= ~(1<<6);
+    PORTF |=  (1<<6);
+
     // PF1: RTS(low: allowed to send, high: not allowed)
     DDRF &= ~(1<<1);
     PORTF &= ~(1<<1);
@@ -88,7 +93,11 @@ 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);
 }