summaryrefslogtreecommitdiff
path: root/keyboard/hhkb_rn42/rn42/rn42.c
diff options
context:
space:
mode:
authortmk <hasu@tmk-kbd.com>2015-01-15 17:12:26 +0900
committertmk <hasu@tmk-kbd.com>2015-01-15 17:12:26 +0900
commit65a2ce94a305f46c8f258e2f1613201a69bc8114 (patch)
treeacd515b6e5f9ab0f010bc5eac9ae9677f9bad618 /keyboard/hhkb_rn42/rn42/rn42.c
parent10a6b2c7d8bc9c5d2657acdeefa1102be5035280 (diff)
parent517817b9c7f00b180385c6bdf5310234185e5b98 (diff)
Merge branch 'rn42'
Diffstat (limited to 'keyboard/hhkb_rn42/rn42/rn42.c')
-rw-r--r--keyboard/hhkb_rn42/rn42/rn42.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/keyboard/hhkb_rn42/rn42/rn42.c b/keyboard/hhkb_rn42/rn42/rn42.c
index 1565b4cf14..756285d7bb 100644
--- a/keyboard/hhkb_rn42/rn42/rn42.c
+++ b/keyboard/hhkb_rn42/rn42/rn42.c
@@ -4,6 +4,7 @@
#include "serial.h"
#include "rn42.h"
#include "print.h"
+#include "timer.h"
#include "wait.h"
@@ -47,11 +48,39 @@ void rn42_init(void)
serial_init();
}
+int16_t rn42_getc(void)
+{
+ return serial_recv2();
+}
+
+const char *rn42_gets(uint16_t timeout)
+{
+ static char s[24];
+ uint16_t t = timer_read();
+ uint8_t i = 0;
+ int16_t c;
+ while (i < 23 && timer_elapsed(t) < timeout) {
+ if ((c = rn42_getc()) != -1) {
+ if ((char)c == '\r') continue;
+ if ((char)c == '\n') break;
+ s[i++] = c;
+ }
+ }
+ s[i] = '\0';
+ return s;
+}
+
void rn42_putc(uint8_t c)
{
serial_send(c);
}
+void rn42_puts(char *s)
+{
+ while (*s)
+ serial_send(*s++);
+}
+
bool rn42_autoconnecting(void)
{
// GPIO6 for control connection(high: auto connect, low: disconnect)
@@ -97,7 +126,7 @@ bool rn42_linked(void)
// Hi-Z: Not powered
// High: Linked
// Low: Connecting
- return !rn42_rts() && PINF&(1<<6);
+ return PINF&(1<<6);
}