diff options
author | tmk <nobody@nowhere> | 2014-07-17 13:06:48 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2014-07-30 14:38:26 +0900 |
commit | fa545c87f74833856761572ef631d20accc1d026 (patch) | |
tree | 4cc7c02660a2401a9b7638ade6b460c7c573ff93 /keyboard/hhkb_rn42/rn42.c | |
parent | 862f519e241b83113566eebde71841958b2d00b7 (diff) | |
download | qmk_firmware-fa545c87f74833856761572ef631d20accc1d026.tar.gz qmk_firmware-fa545c87f74833856761572ef631d20accc1d026.zip |
Fix rn42.h API
Diffstat (limited to 'keyboard/hhkb_rn42/rn42.c')
-rw-r--r-- | keyboard/hhkb_rn42/rn42.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/keyboard/hhkb_rn42/rn42.c b/keyboard/hhkb_rn42/rn42.c index 89ecb199ca..a041cc366f 100644 --- a/keyboard/hhkb_rn42/rn42.c +++ b/keyboard/hhkb_rn42/rn42.c @@ -24,17 +24,17 @@ host_driver_t rn42_driver = { void rn42_init(void) { - // PF1: check RTS(active low) - DDRF &= ~(1<<1); - PORTF &= ~(1<<1); - // 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); rn42_autoconnect(); - // PD5: CTS (low: allow to send, high:not allowed) + // PF1: RTS(low: allowed to send, high: not allowed) + DDRF &= ~(1<<1); + PORTF &= ~(1<<1); + + // PD5: CTS(low: allow to send, high:not allow) DDRD |= (1<<5); PORTD &= ~(1<<5); @@ -46,22 +46,43 @@ void rn42_putc(uint8_t c) serial_send(c); } +bool rn42_autoconnecting(void) +{ + // GPIO6 for control connection(high: auto connect, low: disconnect) + // Note that this needs config: SM,4(Auto-Connect DTR Mode) + return (PORTF & (1<<7) ? true : false); +} + void rn42_autoconnect(void) { - DDRF &= ~(1<<7); - PORTF &= ~(1<<7); + // hi to auto connect + DDRF |= (1<<7); + PORTF |= (1<<7); } void rn42_disconnect(void) { + // low to disconnect DDRF |= (1<<7); PORTF &= ~(1<<7); } -bool rn42_ready(void) +bool rn42_rts(void) +{ + // low when RN-42 is powered and ready to receive + return PINF&(1<<1); +} + +void rn42_cts_hi(void) { - // RTS low - return PINF&(1<<1) ? false : true; + // not allow to send + PORTD |= (1<<5); +} + +void rn42_cts_lo(void) +{ + // allow to send + PORTD &= ~(1<<5); } |