summaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol/iwrap
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2019-08-30 11:19:03 -0700
committerskullydazed <skullydazed@users.noreply.github.com>2019-08-30 15:01:52 -0700
commitb624f32f944acdc59dcb130674c09090c5c404cb (patch)
treebc13adbba137d122d9a2c2fb2fafcbb08ac10e25 /tmk_core/protocol/iwrap
parent61af76a10d00aba185b8338604171de490a13e3b (diff)
clang-format changes
Diffstat (limited to 'tmk_core/protocol/iwrap')
-rw-r--r--tmk_core/protocol/iwrap/iwrap.c202
-rw-r--r--tmk_core/protocol/iwrap/iwrap.h16
-rw-r--r--tmk_core/protocol/iwrap/main.c312
-rw-r--r--tmk_core/protocol/iwrap/suart.h4
-rw-r--r--tmk_core/protocol/iwrap/wd.h134
5 files changed, 327 insertions, 341 deletions
diff --git a/tmk_core/protocol/iwrap/iwrap.c b/tmk_core/protocol/iwrap/iwrap.c
index 71ccc493e2..05e632da38 100644
--- a/tmk_core/protocol/iwrap/iwrap.c
+++ b/tmk_core/protocol/iwrap/iwrap.c
@@ -37,43 +37,39 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "iwrap.h"
#include "print.h"
-
/* iWRAP MUX mode utils. 3.10 HID raw mode(iWRAP_HID_Application_Note.pdf) */
-#define MUX_HEADER(LINK, LENGTH) do { \
- xmit(0xbf); /* SOF */ \
- xmit(LINK); /* Link */ \
- xmit(0x00); /* Flags */ \
- xmit(LENGTH); /* Length */ \
-} while (0)
-#define MUX_FOOTER(LINK) xmit(LINK^0xff)
-
+#define MUX_HEADER(LINK, LENGTH) \
+ do { \
+ xmit(0xbf); /* SOF */ \
+ xmit(LINK); /* Link */ \
+ xmit(0x00); /* Flags */ \
+ xmit(LENGTH); /* Length */ \
+ } while (0)
+#define MUX_FOOTER(LINK) xmit(LINK ^ 0xff)
static uint8_t connected = 0;
-//static uint8_t channel = 1;
+// static uint8_t channel = 1;
/* iWRAP buffer */
#define MUX_BUF_SIZE 64
-static char buf[MUX_BUF_SIZE];
+static char buf[MUX_BUF_SIZE];
static uint8_t snd_pos = 0;
#define MUX_RCV_BUF_SIZE 256
-static char rcv_buf[MUX_RCV_BUF_SIZE];
+static char rcv_buf[MUX_RCV_BUF_SIZE];
static uint8_t rcv_head = 0;
static uint8_t rcv_tail = 0;
-
/* receive buffer */
-static void rcv_enq(char c)
-{
+static void rcv_enq(char c) {
uint8_t next = (rcv_head + 1) % MUX_RCV_BUF_SIZE;
if (next != rcv_tail) {
rcv_buf[rcv_head] = c;
- rcv_head = next;
+ rcv_head = next;
}
}
-static char rcv_deq(void)
-{
+static char rcv_deq(void) {
char c = 0;
if (rcv_head != rcv_tail) {
c = rcv_buf[rcv_tail++];
@@ -91,38 +87,33 @@ static char rcv_peek(void)
}
*/
-static void rcv_clear(void)
-{
- rcv_tail = rcv_head = 0;
-}
+static void rcv_clear(void) { rcv_tail = rcv_head = 0; }
/* iWRAP response */
-ISR(PCINT1_vect, ISR_BLOCK) // recv() runs away in case of ISR_NOBLOCK
+ISR(PCINT1_vect, ISR_BLOCK) // recv() runs away in case of ISR_NOBLOCK
{
- if ((SUART_IN_PIN & (1<<SUART_IN_BIT)))
- return;
+ if ((SUART_IN_PIN & (1 << SUART_IN_BIT))) return;
static volatile uint8_t mux_state = 0xff;
- static volatile uint8_t mux_link = 0xff;
- uint8_t c = recv();
+ static volatile uint8_t mux_link = 0xff;
+ uint8_t c = recv();
switch (mux_state) {
- case 0xff: // SOF
- if (c == 0xbf)
- mux_state--;
+ case 0xff: // SOF
+ if (c == 0xbf) mux_state--;
break;
- case 0xfe: // Link
+ case 0xfe: // Link
mux_state--;
mux_link = c;
break;
- case 0xfd: // Flags
+ case 0xfd: // Flags
mux_state--;
break;
- case 0xfc: // Length
+ case 0xfc: // Length
mux_state = c;
break;
case 0x00:
mux_state = 0xff;
- mux_link = 0xff;
+ mux_link = 0xff;
break;
default:
if (mux_state--) {
@@ -132,12 +123,10 @@ ISR(PCINT1_vect, ISR_BLOCK) // recv() runs away in case of ISR_NOBLOCK
}
}
-
/*------------------------------------------------------------------*
* iWRAP communication
*------------------------------------------------------------------*/
-void iwrap_init(void)
-{
+void iwrap_init(void) {
// reset iWRAP if in already MUX mode after AVR software-reset
iwrap_send("RESET");
iwrap_mux_send("RESET");
@@ -147,43 +136,34 @@ void iwrap_init(void)
iwrap_check_connection();
}
-void iwrap_mux_send(const char *s)
-{
+void iwrap_mux_send(const char *s) {
rcv_clear();
MUX_HEADER(0xff, strlen((char *)s));
iwrap_send(s);
MUX_FOOTER(0xff);
}
-void iwrap_send(const char *s)
-{
- while (*s)
- xmit(*s++);
+void iwrap_send(const char *s) {
+ while (*s) xmit(*s++);
}
/* send buffer */
-void iwrap_buf_add(uint8_t c)
-{
+void iwrap_buf_add(uint8_t c) {
// need space for '\0'
- if (snd_pos < MUX_BUF_SIZE-1)
- buf[snd_pos++] = c;
+ if (snd_pos < MUX_BUF_SIZE - 1) buf[snd_pos++] = c;
}
-void iwrap_buf_del(void)
-{
- if (snd_pos)
- snd_pos--;
+void iwrap_buf_del(void) {
+ if (snd_pos) snd_pos--;
}
-void iwrap_buf_send(void)
-{
+void iwrap_buf_send(void) {
buf[snd_pos] = '\0';
- snd_pos = 0;
+ snd_pos = 0;
iwrap_mux_send(buf);
}
-void iwrap_call(void)
-{
+void iwrap_call(void) {
char *p;
iwrap_mux_send("SET BT PAIR");
@@ -193,7 +173,7 @@ void iwrap_call(void)
while (!strncmp(p, "SET BT PAIR", 11)) {
p += 7;
strncpy(p, "CALL", 4);
- strncpy(p+22, " 11 HID\n\0", 9);
+ strncpy(p + 22, " 11 HID\n\0", 9);
print_S(p);
iwrap_mux_send(p);
// TODO: skip to next line
@@ -224,20 +204,21 @@ void iwrap_call(void)
iwrap_check_connection();
}
-void iwrap_kill(void)
-{
+void iwrap_kill(void) {
char c;
iwrap_mux_send("LIST");
_delay_ms(500);
- while ((c = rcv_deq()) && c != '\n') ;
+ while ((c = rcv_deq()) && c != '\n')
+ ;
if (strncmp(rcv_buf + rcv_tail, "LIST ", 5)) {
print("no connection to kill.\n");
return;
}
// skip 10 'space' chars
for (uint8_t i = 10; i; i--)
- while ((c = rcv_deq()) && c != ' ') ;
+ while ((c = rcv_deq()) && c != ' ')
+ ;
char *p = rcv_buf + rcv_tail - 5;
strncpy(p, "KILL ", 5);
@@ -249,47 +230,34 @@ void iwrap_kill(void)
iwrap_check_connection();
}
-void iwrap_unpair(void)
-{
+void iwrap_unpair(void) {
iwrap_mux_send("SET BT PAIR");
_delay_ms(500);
char *p = rcv_buf + rcv_tail;
if (!strncmp(p, "SET BT PAIR", 11)) {
- strncpy(p+29, "\n\0", 2);
+ strncpy(p + 29, "\n\0", 2);
print_S(p);
iwrap_mux_send(p);
}
}
-void iwrap_sleep(void)
-{
- iwrap_mux_send("SLEEP");
-}
+void iwrap_sleep(void) { iwrap_mux_send("SLEEP"); }
-void iwrap_sniff(void)
-{
-}
+void iwrap_sniff(void) {}
-void iwrap_subrate(void)
-{
-}
+void iwrap_subrate(void) {}
-bool iwrap_failed(void)
-{
+bool iwrap_failed(void) {
if (strncmp(rcv_buf, "SYNTAX ERROR", 12))
return true;
else
return false;
}
-uint8_t iwrap_connected(void)
-{
- return connected;
-}
+uint8_t iwrap_connected(void) { return connected; }
-uint8_t iwrap_check_connection(void)
-{
+uint8_t iwrap_check_connection(void) {
iwrap_mux_send("LIST");
_delay_ms(100);
@@ -300,44 +268,31 @@ uint8_t iwrap_check_connection(void)
return connected;
}
-
/*------------------------------------------------------------------*
* Host driver
*------------------------------------------------------------------*/
static uint8_t keyboard_leds(void);
-static void send_keyboard(report_keyboard_t *report);
-static void send_mouse(report_mouse_t *report);
-static void send_system(uint16_t data);
-static void send_consumer(uint16_t data);
-
-static host_driver_t driver = {
- keyboard_leds,
- send_keyboard,
- send_mouse,
- send_system,
- send_consumer
-};
-
-host_driver_t *iwrap_driver(void)
-{
- return &driver;
-}
+static void send_keyboard(report_keyboard_t *report);
+static void send_mouse(report_mouse_t *report);
+static void send_system(uint16_t data);
+static void send_consumer(uint16_t data);
-static uint8_t keyboard_leds(void) {
- return 0;
-}
+static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer};
-static void send_keyboard(report_keyboard_t *report)
-{
+host_driver_t *iwrap_driver(void) { return &driver; }
+
+static uint8_t keyboard_leds(void) { return 0; }
+
+static void send_keyboard(report_keyboard_t *report) {
if (!iwrap_connected() && !iwrap_check_connection()) return;
MUX_HEADER(0x01, 0x0c);
// HID raw mode header
xmit(0x9f);
- xmit(0x0a); // Length
- xmit(0xa1); // DATA(Input)
- xmit(0x01); // Report ID
+ xmit(0x0a); // Length
+ xmit(0xa1); // DATA(Input)
+ xmit(0x01); // Report ID
xmit(report->mods);
- xmit(0x00); // reserved byte(always 0)
+ xmit(0x00); // reserved byte(always 0)
xmit(report->keys[0]);
xmit(report->keys[1]);
xmit(report->keys[2]);
@@ -347,16 +302,15 @@ static void send_keyboard(report_keyboard_t *report)
MUX_FOOTER(0x01);
}
-static void send_mouse(report_mouse_t *report)
-{
+static void send_mouse(report_mouse_t *report) {
#if defined(MOUSEKEY_ENABLE) || defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
if (!iwrap_connected() && !iwrap_check_connection()) return;
MUX_HEADER(0x01, 0x09);
// HID raw mode header
xmit(0x9f);
- xmit(0x07); // Length
- xmit(0xa1); // DATA(Input)
- xmit(0x02); // Report ID
+ xmit(0x07); // Length
+ xmit(0xa1); // DATA(Input)
+ xmit(0x02); // Report ID
xmit(report->buttons);
xmit(report->x);
xmit(report->y);
@@ -366,18 +320,14 @@ static void send_mouse(report_mouse_t *report)
#endif
}
-static void send_system(uint16_t data)
-{
- /* not supported */
-}
+static void send_system(uint16_t data) { /* not supported */ }
-static void send_consumer(uint16_t data)
-{
+static void send_consumer(uint16_t data) {
#ifdef EXTRAKEY_ENABLE
static uint16_t last_data = 0;
- uint8_t bits1 = 0;
- uint8_t bits2 = 0;
- uint8_t bits3 = 0;
+ uint8_t bits1 = 0;
+ uint8_t bits2 = 0;
+ uint8_t bits3 = 0;
if (!iwrap_connected() && !iwrap_check_connection()) return;
if (data == last_data) return;
@@ -458,9 +408,9 @@ static void send_consumer(uint16_t data)
MUX_HEADER(0x01, 0x07);
xmit(0x9f);
- xmit(0x05); // Length
- xmit(0xa1); // DATA(Input)
- xmit(0x03); // Report ID
+ xmit(0x05); // Length
+ xmit(0xa1); // DATA(Input)
+ xmit(0x03); // Report ID
xmit(bits1);
xmit(bits2);
xmit(bits3);
diff --git a/tmk_core/protocol/iwrap/iwrap.h b/tmk_core/protocol/iwrap/iwrap.h
index ffaad9395d..51f2b5670b 100644
--- a/tmk_core/protocol/iwrap/iwrap.h
+++ b/tmk_core/protocol/iwrap/iwrap.h
@@ -22,11 +22,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
#include "host_driver.h"
-
/* enable iWRAP MUX mode */
#define MUX_MODE
-
host_driver_t *iwrap_driver(void);
void iwrap_init(void);
@@ -36,13 +34,13 @@ void iwrap_buf_send(void);
void iwrap_buf_add(uint8_t c);
void iwrap_buf_del(void);
-void iwrap_call(void);
-void iwrap_kill(void);
-void iwrap_unpair(void);
-void iwrap_sleep(void);
-void iwrap_sniff(void);
-void iwrap_subrate(void);
-bool iwrap_failed(void);
+void iwrap_call(void);
+void iwrap_kill(void);
+void iwrap_unpair(void);
+void iwrap_sleep(void);
+void iwrap_sniff(void);
+void iwrap_subrate(void);
+bool iwrap_failed(void);
uint8_t iwrap_connected(void);
uint8_t iwrap_check_connection(void);
diff --git a/tmk_core/protocol/iwrap/main.c b/tmk_core/protocol/iwrap/main.c
index 3abdce8dfc..7ba780ede7 100644
--- a/tmk_core/protocol/iwrap/main.c
+++ b/tmk_core/protocol/iwrap/main.c
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <avr/interrupt.h>
#include <avr/io.h>
//#include <avr/wdt.h>
-#include "wd.h" // in order to use watchdog in interrupt mode
+#include "wd.h" // in order to use watchdog in interrupt mode
#include <avr/sleep.h>
#include <util/delay.h>
#include <avr/power.h>
@@ -28,8 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action.h"
#include "iwrap.h"
#ifdef PROTOCOL_VUSB
-# include "vusb.h"
-# include "usbdrv.h"
+# include "vusb.h"
+# include "usbdrv.h"
#endif
#include "uart.h"
#include "suart.h"
@@ -38,13 +38,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "keycode.h"
#include "command.h"
-
-static void sleep(uint8_t term);
-static bool console(void);
-static bool console_command(uint8_t c);
+static void sleep(uint8_t term);
+static bool console(void);
+static bool console_command(uint8_t c);
static uint8_t key2asc(uint8_t key);
-
/*
static void set_prr(void)
{
@@ -78,37 +76,32 @@ static void pullup_pins(void)
}
*/
-
#ifdef PROTOCOL_VUSB
-static void disable_vusb(void)
-{
+static void disable_vusb(void) {
// disable interrupt & disconnect to prevent host from enumerating
USB_INTR_ENABLE &= ~(1 << USB_INTR_ENABLE_BIT);
usbDeviceDisconnect();
}
-static void enable_vusb(void)
-{
+static void enable_vusb(void) {
USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT);
usbDeviceConnect();
}
-static void init_vusb(void)
-{
+static void init_vusb(void) {
uint8_t i = 0;
usbInit();
disable_vusb();
/* fake USB disconnect for > 250 ms */
- while(--i){
+ while (--i) {
_delay_ms(1);
}
enable_vusb();
}
#endif
-void change_driver(host_driver_t *driver)
-{
+void change_driver(host_driver_t *driver) {
/*
host_clear_keyboard_report();
host_swap_keyboard_report();
@@ -120,20 +113,18 @@ void change_driver(host_driver_t *driver)
host_set_driver(driver);
}
-
-static bool sleeping = false;
-static bool insomniac = false; // TODO: should be false for power saving
+static bool sleeping = false;
+static bool insomniac = false; // TODO: should be false for power saving
static uint16_t last_timer = 0;
-int main(void)
-{
+int main(void) {
MCUSR = 0;
clock_prescale_set(clock_div_1);
WD_SET(WD_OFF);
// power saving: the result is worse than nothing... why?
- //pullup_pins();
- //set_prr();
+ // pullup_pins();
+ // set_prr();
#ifdef PROTOCOL_VUSB
disable_vusb();
@@ -146,11 +137,11 @@ int main(void)
print("suart init\n");
// suart init
// PC4: Tx Output IDLE(Hi)
- PORTC |= (1<<4);
- DDRC |= (1<<4);
+ PORTC |= (1 << 4);
+ DDRC |= (1 << 4);
// PC5: Rx Input(pull-up)
- PORTC |= (1<<5);
- DDRC &= ~(1<<5);
+ PORTC |= (1 << 5);
+ DDRC &= ~(1 << 5);
// suart receive interrut(PC5/PCINT13)
PCMSK1 = 0b00100000;
PCICR = 0b00000010;
@@ -164,18 +155,16 @@ int main(void)
last_timer = timer_read();
while (true) {
#ifdef PROTOCOL_VUSB
- if (host_get_driver() == vusb_driver())
- usbPoll();
+ if (host_get_driver() == vusb_driver()) usbPoll();
#endif
keyboard_task();
#ifdef PROTOCOL_VUSB
- if (host_get_driver() == vusb_driver())
- vusb_transfer_keyboard();
+ if (host_get_driver() == vusb_driver()) vusb_transfer_keyboard();
#endif
// TODO: depricated
if (matrix_is_modified() || console()) {
last_timer = timer_read();
- sleeping = false;
+ sleeping = false;
} else if (!sleeping && timer_elapsed(last_timer) > 4000) {
sleeping = true;
iwrap_check_connection();
@@ -184,7 +173,7 @@ int main(void)
// TODO: suspend.h
if (host_get_driver() == iwrap_driver()) {
if (sleeping && !insomniac) {
- _delay_ms(1); // wait for UART to send
+ _delay_ms(1); // wait for UART to send
iwrap_sleep();
sleep(WDTO_60MS);
}
@@ -192,8 +181,7 @@ int main(void)
}
}
-static void sleep(uint8_t term)
-{
+static void sleep(uint8_t term) {
WD_SET(WD_IRQ, term);
cli();
@@ -207,51 +195,46 @@ static void sleep(uint8_t term)
WD_SET(WD_OFF);
}
-static bool console(void)
-{
- // Send to Bluetoot module WT12
- static bool breaked = false;
- if (!uart_available())
- return false;
- else {
- uint8_t c;
- c = uart_getchar();
- uart_putchar(c);
- switch (c) {
- case 0x00: // BREAK signal
- if (!breaked) {
- print("break(? for help): ");
- breaked = true;
- }
- break;
- case '\r':
- uart_putchar('\n');
- iwrap_buf_send();
- break;
- case '\b':
- iwrap_buf_del();
- break;
- default:
- if (breaked) {
- print("\n");
- console_command(c);
- breaked = false;
- } else {
- iwrap_buf_add(c);
- }
- break;
- }
- return true;
+static bool console(void) {
+ // Send to Bluetoot module WT12
+ static bool breaked = false;
+ if (!uart_available())
+ return false;
+ else {
+ uint8_t c;
+ c = uart_getchar();
+ uart_putchar(c);
+ switch (c) {
+ case 0x00: // BREAK signal
+ if (!breaked) {
+ print("break(? for help): ");
+ breaked = true;
+ }
+ break;
+ case '\r':
+ uart_putchar('\n');
+ iwrap_buf_send();
+ break;
+ case '\b':
+ iwrap_buf_del();
+ break;
+ default:
+ if (breaked) {
+ print("\n");
+ console_command(c);
+ breaked = false;
+ } else {
+ iwrap_buf_add(c);
+ }
+ break;
}
+ return true;
+ }
}
-bool command_extra(uint8_t code)
-{
- return console_command(key2asc(code));
-}
+bool command_extra(uint8_t code) { return console_command(key2asc(code)); }
-static bool console_command(uint8_t c)
-{
+static bool console_command(uint8_t c) {
switch (c) {
case 'h':
case '?':
@@ -287,11 +270,11 @@ static bool console_command(uint8_t c)
print("USB mode\n");
init_vusb();
change_driver(vusb_driver());
- //iwrap_kill();
- //iwrap_sleep();
+ // iwrap_kill();
+ // iwrap_sleep();
// disable suart receive interrut(PC5/PCINT13)
PCMSK1 &= ~(0b00100000);
- PCICR &= ~(0b00000010);
+ PCICR &= ~(0b00000010);
return 1;
case 'w':
print("iWRAP mode\n");
@@ -299,7 +282,7 @@ static bool console_command(uint8_t c)
disable_vusb();
// enable suart receive interrut(PC5/PCINT13)
PCMSK1 |= 0b00100000;
- PCICR |= 0b00000010;
+ PCICR |= 0b00000010;
return 1;
#endif
case 'k':
@@ -315,62 +298,115 @@ static bool console_command(uint8_t c)
}
// convert keycode into ascii charactor
-static uint8_t key2asc(uint8_t key)
-{
+static uint8_t key2asc(uint8_t key) {
switch (key) {
- case KC_A: return 'a';
- case KC_B: return 'b';
- case KC_C: return 'c';
- case KC_D: return 'd';
- case KC_E: return 'e';
- case KC_F: return 'f';
- case KC_G: return 'g';
- case KC_H: return 'h';
- case KC_I: return 'i';
- case KC_J: return 'j';
- case KC_K: return 'k';
- case KC_L: return 'l';
- case KC_M: return 'm';
- case KC_N: return 'n';
- case KC_O: return 'o';
- case KC_P: return 'p';
- case KC_Q: return 'q';
- case KC_R: return 'r';
- case KC_S: return 's';
- case KC_T: return 't';
- case KC_U: return 'u';
- case KC_V: return 'v';
- case KC_W: return 'w';
- case KC_X: return 'x';
- case KC_Y: return 'y';
- case KC_Z: return 'z';
- case KC_1: return '1';
- case KC_2: return '2';
- case KC_3: return '3';
- case KC_4: return '4';
- case KC_5: return '5';
- case KC_6: return '6';
- case KC_7: return '7';
- case KC_8: return '8';
- case KC_9: return '9';
- case KC_0: return '0';
- case KC_ENTER: return '\n';
- case KC_ESCAPE: return 0x1B;
- case KC_BSPACE: return '\b';
- case KC_TAB: return '\t';
- case KC_SPACE: return ' ';
- case KC_MINUS: return '-';
- case KC_EQUAL: return '=';
- case KC_LBRACKET: return '[';
- case KC_RBRACKET: return ']';
- case KC_BSLASH: return '\\';
- case KC_NONUS_HASH: return '\\';
- case KC_SCOLON: return ';';
- case KC_QUOTE: return '\'';
- case KC_GRAVE: return '`';
- case KC_COMMA: return ',';
- case KC_DOT: return '.';
- case KC_SLASH: return '/';
- default: return 0x00;
+ case KC_A:
+ return 'a';
+ case KC_B:
+ return 'b';
+ case KC_C:
+ return 'c';
+ case KC_D:
+ return 'd';
+ case KC_E:
+ return 'e';
+ case KC_F:
+ return 'f';
+ case KC_G:
+ return 'g';
+ case KC_H:
+ return 'h';
+ case KC_I:
+ return 'i';
+ case KC_J:
+ return 'j';
+ case KC_K:
+ return 'k';
+ case KC_L:
+ return 'l';
+ case KC_M:
+ return 'm';
+ case KC_N:
+ return 'n';
+ case KC_O:
+ return 'o';
+ case KC_P:
+ return 'p';
+ case KC_Q:
+ return 'q';
+ case KC_R:
+ return 'r';
+ case KC_S:
+ return 's';
+ case KC_T:
+ return 't';
+ case KC_U:
+ return 'u';
+ case KC_V:
+ return 'v';
+ case KC_W:
+ return 'w';
+ case KC_X:
+ return 'x';
+ case KC_Y:
+ return 'y';
+ case KC_Z:
+ return 'z';
+ case KC_1:
+ return '1';
+ case KC_2:
+ return '2';
+ case KC_3:
+ return '3';
+ case KC_4:
+ return '4';
+ case KC_5:
+ return '5';
+ case KC_6:
+ return '6';
+ case KC_7:
+ return '7';
+ case KC_8:
+ return '8';
+ case KC_9:
+ return '9';
+ case KC_0:
+ return '0';
+ case KC_ENTER:
+ return '\n';
+ case KC_ESCAPE:
+ return 0x1B;
+ case KC_BSPACE:
+ return '\b';
+ case KC_TAB:
+ return '\t';
+ case KC_SPACE:
+ return ' ';
+ case KC_MINUS:
+ return '-';
+ case KC_EQUAL:
+ return '=';
+ case KC_LBRACKET:
+ return '[';
+ case KC_RBRACKET:
+ return ']';
+ case KC_BSLASH:
+ return '\\';
+ case KC_NONUS_HASH:
+ return '\\';
+ case KC_SCOLON:
+ return ';';
+ case KC_QUOTE:
+ return '\'';
+ case KC_GRAVE:
+ return '`';
+ case KC_COMMA:
+ return ',';
+ case KC_DOT:
+ return '.';
+ case KC_SLASH:
+ return '/';
+ default:
+ return 0x00;
}
}
diff --git a/tmk_core/protocol/iwrap/suart.h b/tmk_core/protocol/iwrap/suart.h
index 7d92be0692..c634bbc2f4 100644
--- a/tmk_core/protocol/iwrap/suart.h
+++ b/tmk_core/protocol/iwrap/suart.h
@@ -1,8 +1,8 @@
#ifndef SUART
#define SUART
-void xmit(uint8_t);
+void xmit(uint8_t);
uint8_t rcvr(void);
uint8_t recv(void);
-#endif /* SUART */
+#endif /* SUART */
diff --git a/tmk_core/protocol/iwrap/wd.h b/tmk_core/protocol/iwrap/wd.h
index 12395bf696..083d6d44d6 100644
--- a/tmk_core/protocol/iwrap/wd.h
+++ b/tmk_core/protocol/iwrap/wd.h
@@ -61,55 +61,58 @@ cleared on every power up or reset, along with disabling the watchdog-
*/
-//reset registers to the same name (MCUCSR)
+// reset registers to the same name (MCUCSR)
#if !defined(MCUCSR)
-#define MCUCSR MCUSR
+# define MCUCSR MCUSR
#endif
-//watchdog registers to the same name (WDTCSR)
+// watchdog registers to the same name (WDTCSR)
#if !defined(WDTCSR)
-#define WDTCSR WDTCR
+# define WDTCSR WDTCR
#endif
-//if enhanced watchdog, define irq values, create disable macro
+// if enhanced watchdog, define irq values, create disable macro
#if defined(WDIF)
-#define WD_IRQ 0xC0
-#define WD_RST_IRQ 0xC8
-#define WD_DISABLE() do{ \
- MCUCSR &= ~(1<<WDRF); \
- WD_SET(WD_OFF); \
- }while(0)
+# define WD_IRQ 0xC0
+# define WD_RST_IRQ 0xC8
+# define WD_DISABLE() \
+ do { \
+ MCUCSR &= ~(1 << WDRF); \
+ WD_SET(WD_OFF); \
+ } while (0)
#endif
-//all watchdogs
-#define WD_RST 8
-#define WD_OFF 0
-
-//prescale values
-#define WDTO_15MS 0
-#define WDTO_30MS 1
-#define WDTO_60MS 2
-#define WDTO_120MS 3
-#define WDTO_250MS 4
-#define WDTO_500MS 5
-#define WDTO_1S 6
-#define WDTO_2S 7
-
-//prescale values for avrs with WDP3
+// all watchdogs
+#define WD_RST 8
+#define WD_OFF 0
+
+// prescale values
+#define WDTO_15MS 0
+#define WDTO_30MS 1
+#define WDTO_60MS 2
+#define WDTO_120MS 3
+#define WDTO_250MS 4
+#define WDTO_500MS 5
+#define WDTO_1S 6
+#define WDTO_2S 7
+
+// prescale values for avrs with WDP3
#if defined(WDP3)
-#define WDTO_4S 0x20
-#define WDTO_8S 0x21
+# define WDTO_4S 0x20
+# define WDTO_8S 0x21
#endif
-//watchdog reset
-#define WDR() __asm__ __volatile__("wdr")
+// watchdog reset
+#define WDR() __asm__ __volatile__("wdr")
-//avr reset using watchdog
-#define WD_AVR_RESET() do{ \
- __asm__ __volatile__("cli"); \
- WD_SET_UNSAFE(WD_RST); \
- while(1); \
- }while(0)
+// avr reset using watchdog
+#define WD_AVR_RESET() \
+ do { \
+ __asm__ __volatile__("cli"); \
+ WD_SET_UNSAFE(WD_RST); \
+ while (1) \
+ ; \
+ } while (0)
/*set the watchdog-
1. save SREG
@@ -119,41 +122,40 @@ cleared on every power up or reset, along with disabling the watchdog-
5. write watchdog value
6. restore SREG (restoring irq status)
*/
-#define WD_SET(val,...) \
- __asm__ __volatile__( \
- "in __tmp_reg__,__SREG__" "\n\t" \
- "cli" "\n\t" \
- "wdr" "\n\t" \
- "sts %[wdreg],%[wden]" "\n\t" \
- "sts %[wdreg],%[wdval]" "\n\t" \
- "out __SREG__,__tmp_reg__" "\n\t" \
- : \
- : [wdreg] "M" (&WDTCSR), \
- [wden] "r" ((uint8_t)(0x18)), \
- [wdval] "r" ((uint8_t)(val|(__VA_ARGS__+0))) \
- : "r0" \
-)
+#define WD_SET(val, ...) \
+ __asm__ __volatile__("in __tmp_reg__,__SREG__" \
+ "\n\t" \
+ "cli" \
+ "\n\t" \
+ "wdr" \
+ "\n\t" \
+ "sts %[wdreg],%[wden]" \
+ "\n\t" \
+ "sts %[wdreg],%[wdval]" \
+ "\n\t" \
+ "out __SREG__,__tmp_reg__" \
+ "\n\t" \
+ : \
+ : [ wdreg ] "M"(&WDTCSR), [ wden ] "r"((uint8_t)(0x18)), [ wdval ] "r"((uint8_t)(val | (__VA_ARGS__ + 0))) \
+ : "r0")
/*set the watchdog when I bit in SREG known to be clear-
1. reset watchdog timer
2. enable watchdog change
5. write watchdog value
*/
-#define WD_SET_UNSAFE(val,...) \
- __asm__ __volatile__( \
- "wdr" "\n\t" \
- "sts %[wdreg],%[wden]" "\n\t" \
- "sts %[wdreg],%[wdval]" "\n\t" \
- : \
- : [wdreg] "M" (&WDTCSR), \
- [wden] "r" ((uint8_t)(0x18)), \
- [wdval] "r" ((uint8_t)(val|(__VA_ARGS__+0))) \
-)
-
-
-//for compatibility with avr/wdt.h
-#define wdt_enable(val) WD_SET(WD_RST,val)
-#define wdt_disable() WD_SET(WD_OFF)
-
+#define WD_SET_UNSAFE(val, ...) \
+ __asm__ __volatile__("wdr" \
+ "\n\t" \
+ "sts %[wdreg],%[wden]" \
+ "\n\t" \
+ "sts %[wdreg],%[wdval]" \
+ "\n\t" \
+ : \
+ : [ wdreg ] "M"(&WDTCSR), [ wden ] "r"((uint8_t)(0x18)), [ wdval ] "r"((uint8_t)(val | (__VA_ARGS__ + 0))))
+
+// for compatibility with avr/wdt.h
+#define wdt_enable(val) WD_SET(WD_RST, val)
+#define wdt_disable() WD_SET(WD_OFF)
#endif /* _AVR_WD_H_ */