aboutsummaryrefslogtreecommitdiff
path: root/keyboard/hhkb_rn42/rn42.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboard/hhkb_rn42/rn42.c')
-rw-r--r--keyboard/hhkb_rn42/rn42.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/keyboard/hhkb_rn42/rn42.c b/keyboard/hhkb_rn42/rn42.c
index 89ecb199c..a041cc366 100644
--- a/keyboard/hhkb_rn42/rn42.c
+++ b/keyboard/hhkb_rn42/rn42.c
@@ -24,17 +24,17 @@ host_driver_t rn42_driver = {
24 24
25void rn42_init(void) 25void rn42_init(void)
26{ 26{
27 // PF1: check RTS(active low)
28 DDRF &= ~(1<<1);
29 PORTF &= ~(1<<1);
30
31 // PF7: BT connection control(HiZ: connect, low: disconnect) 27 // PF7: BT connection control(HiZ: connect, low: disconnect)
32 // JTAG disable for PORT F. write JTD bit twice within four cycles. 28 // JTAG disable for PORT F. write JTD bit twice within four cycles.
33 MCUCR |= (1<<JTD); 29 MCUCR |= (1<<JTD);
34 MCUCR |= (1<<JTD); 30 MCUCR |= (1<<JTD);
35 rn42_autoconnect(); 31 rn42_autoconnect();
36 32
37 // PD5: CTS (low: allow to send, high:not allowed) 33 // PF1: RTS(low: allowed to send, high: not allowed)
34 DDRF &= ~(1<<1);
35 PORTF &= ~(1<<1);
36
37 // PD5: CTS(low: allow to send, high:not allow)
38 DDRD |= (1<<5); 38 DDRD |= (1<<5);
39 PORTD &= ~(1<<5); 39 PORTD &= ~(1<<5);
40 40
@@ -46,22 +46,43 @@ void rn42_putc(uint8_t c)
46 serial_send(c); 46 serial_send(c);
47} 47}
48 48
49bool rn42_autoconnecting(void)
50{
51 // GPIO6 for control connection(high: auto connect, low: disconnect)
52 // Note that this needs config: SM,4(Auto-Connect DTR Mode)
53 return (PORTF & (1<<7) ? true : false);
54}
55
49void rn42_autoconnect(void) 56void rn42_autoconnect(void)
50{ 57{
51 DDRF &= ~(1<<7); 58 // hi to auto connect
52 PORTF &= ~(1<<7); 59 DDRF |= (1<<7);
60 PORTF |= (1<<7);
53} 61}
54 62
55void rn42_disconnect(void) 63void rn42_disconnect(void)
56{ 64{
65 // low to disconnect
57 DDRF |= (1<<7); 66 DDRF |= (1<<7);
58 PORTF &= ~(1<<7); 67 PORTF &= ~(1<<7);
59} 68}
60 69
61bool rn42_ready(void) 70bool rn42_rts(void)
71{
72 // low when RN-42 is powered and ready to receive
73 return PINF&(1<<1);
74}
75
76void rn42_cts_hi(void)
62{ 77{
63 // RTS low 78 // not allow to send
64 return PINF&(1<<1) ? false : true; 79 PORTD |= (1<<5);
80}
81
82void rn42_cts_lo(void)
83{
84 // allow to send
85 PORTD &= ~(1<<5);
65} 86}
66 87
67 88