summaryrefslogtreecommitdiff
path: root/tmk_core/protocol/bluefruit
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2019-08-30 11:19:03 -0700
committerFlorian Didron <fdidron@users.noreply.github.com>2019-10-01 10:21:12 +0900
commit93f6749e06b70ba81e15f8b77e5a18675dacddfe (patch)
treefcf75ef930800a948e5a3ba015d6759889f2284d /tmk_core/protocol/bluefruit
parentda34bddba16ba7a8495dc30bfe4542551ba87ed4 (diff)
clang-format changes
Diffstat (limited to 'tmk_core/protocol/bluefruit')
-rw-r--r--tmk_core/protocol/bluefruit/bluefruit.c123
-rw-r--r--tmk_core/protocol/bluefruit/bluefruit.h1
-rw-r--r--tmk_core/protocol/bluefruit/main.c91
3 files changed, 86 insertions, 129 deletions
diff --git a/tmk_core/protocol/bluefruit/bluefruit.c b/tmk_core/protocol/bluefruit/bluefruit.c
index 47c63555cd..fb001855ea 100644
--- a/tmk_core/protocol/bluefruit/bluefruit.c
+++ b/tmk_core/protocol/bluefruit/bluefruit.c
@@ -29,31 +29,31 @@ static uint8_t bluefruit_keyboard_leds = 0;
static void bluefruit_serial_send(uint8_t);
-void bluefruit_keyboard_print_report(report_keyboard_t *report)
-{
+void bluefruit_keyboard_print_report(report_keyboard_t *report) {
if (!debug_keyboard) return;
- dprintf("keys: "); for (int i = 0; i < KEYBOARD_REPORT_KEYS; i++) { debug_hex8(report->keys[i]); dprintf(" "); }
- dprintf(" mods: "); debug_hex8(report->mods);
- dprintf(" reserved: "); debug_hex8(report->reserved);
+ dprintf("keys: ");
+ for (int i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
+ debug_hex8(report->keys[i]);
+ dprintf(" ");
+ }
+ dprintf(" mods: ");
+ debug_hex8(report->mods);
+ dprintf(" reserved: ");
+ debug_hex8(report->reserved);
dprintf("\n");
}
#ifdef BLUEFRUIT_TRACE_SERIAL
-static void bluefruit_trace_header()
-{
+static void bluefruit_trace_header() {
dprintf("+------------------------------------+\n");
dprintf("| HID report to Bluefruit via serial |\n");
dprintf("+------------------------------------+\n|");
}
-static void bluefruit_trace_footer()
-{
- dprintf("|\n+------------------------------------+\n\n");
-}
+static void bluefruit_trace_footer() { dprintf("|\n+------------------------------------+\n\n"); }
#endif
-static void bluefruit_serial_send(uint8_t data)
-{
+static void bluefruit_serial_send(uint8_t data) {
#ifdef BLUEFRUIT_TRACE_SERIAL
dprintf(" ");
debug_hex8(data);
@@ -67,53 +67,38 @@ static void bluefruit_serial_send(uint8_t data)
*------------------------------------------------------------------*/
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 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);
void sendString(char string[], int length) {
- for(int i = 0; i < length; i++) {
+ for (int i = 0; i < length; i++) {
serial_send(string[i]);
}
}
-static host_driver_t driver = {
- keyboard_leds,
- send_keyboard,
- send_mouse,
- send_system,
- send_consumer
-};
-
-host_driver_t *bluefruit_driver(void)
-{
- return &driver;
-}
+static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer};
-static uint8_t keyboard_leds(void) {
- return bluefruit_keyboard_leds;
-}
+host_driver_t *bluefruit_driver(void) { return &driver; }
+
+static uint8_t keyboard_leds(void) { return bluefruit_keyboard_leds; }
-static void send_keyboard(report_keyboard_t *report)
-{
-#ifdef BLUEFRUIT_TRACE_SERIAL
+static void send_keyboard(report_keyboard_t *report) {
+#ifdef BLUEFRUIT_TRACE_SERIAL
bluefruit_trace_header();
#endif
bluefruit_serial_send(0xFD);
for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) {
-
bluefruit_serial_send(report->raw[i]);
}
-#ifdef BLUEFRUIT_TRACE_SERIAL
- bluefruit_trace_footer();
+#ifdef BLUEFRUIT_TRACE_SERIAL
+ bluefruit_trace_footer();
#endif
}
-static void send_mouse(report_mouse_t *report)
-{
-#ifdef BLUEFRUIT_TRACE_SERIAL
+static void send_mouse(report_mouse_t *report) {
+#ifdef BLUEFRUIT_TRACE_SERIAL
bluefruit_trace_header();
#endif
bluefruit_serial_send(0xFD);
@@ -122,17 +107,15 @@ static void send_mouse(report_mouse_t *report)
bluefruit_serial_send(report->buttons);
bluefruit_serial_send(report->x);
bluefruit_serial_send(report->y);
- bluefruit_serial_send(report->v); // should try sending the wheel v here
- bluefruit_serial_send(report->h); // should try sending the wheel h here
+ bluefruit_serial_send(report->v); // should try sending the wheel v here
+ bluefruit_serial_send(report->h); // should try sending the wheel h here
bluefruit_serial_send(0x00);
#ifdef BLUEFRUIT_TRACE_SERIAL
bluefruit_trace_footer();
#endif
}
-static void send_system(uint16_t data)
-{
-}
+static void send_system(uint16_t data) {}
/*
+-----------------+-------------------+-------+
@@ -153,48 +136,28 @@ static void send_system(uint16_t data)
| Stop | 00000000 00010000 | 00 10 |
+-------------------------------------+-------+
*/
-#define CONSUMER2BLUEFRUIT(usage) \
- (usage == AUDIO_MUTE ? 0x0000 : \
- (usage == AUDIO_VOL_UP ? 0x1000 : \
- (usage == AUDIO_VOL_DOWN ? 0x2000 : \
- (usage == TRANSPORT_NEXT_TRACK ? 0x0002 : \
- (usage == TRANSPORT_PREV_TRACK ? 0x0004 : \
- (usage == TRANSPORT_STOP ? 0x0010 : \
- (usage == TRANSPORT_STOP_EJECT ? 0x0000 : \
- (usage == TRANSPORT_PLAY_PAUSE ? 0x4000 : \
- (usage == AL_CC_CONFIG ? 0x0000 : \
- (usage == AL_EMAIL ? 0x0000 : \
- (usage == AL_CALCULATOR ? 0x0000 : \
- (usage == AL_LOCAL_BROWSER ? 0x0000 : \
- (usage == AC_SEARCH ? 0x0400 : \
- (usage == AC_HOME ? 0x0100 : \
- (usage == AC_BACK ? 0x0000 : \
- (usage == AC_FORWARD ? 0x0000 : \
- (usage == AC_STOP ? 0x0000 : \
- (usage == AC_REFRESH ? 0x0000 : \
- (usage == AC_BOOKMARKS ? 0x0000 : 0)))))))))))))))))))
-
-static void send_consumer(uint16_t data)
-{
+#define CONSUMER2BLUEFRUIT(usage) (usage == AUDIO_MUTE ? 0x0000 : (usage == AUDIO_VOL_UP ? 0x1000 : (usage == AUDIO_VOL_DOWN ? 0x2000 : (usage == TRANSPORT_NEXT_TRACK ? 0x0002 : (usage == TRANSPORT_PREV_TRACK ? 0x0004 : (usage == TRANSPORT_STOP ? 0x0010 : (usage == TRANSPORT_STOP_EJECT ? 0x0000 : (usage == TRANSPORT_PLAY_PAUSE ? 0x4000 : (usage == AL_CC_CONFIG ? 0x0000 : (usage == AL_EMAIL ? 0x0000 : (usage == AL_CALCULATOR ? 0x0000 : (usage == AL_LOCAL_BROWSER ? 0x0000 : (usage == AC_SEARCH ? 0x0400 : (usage == AC_HOME ? 0x0100 : (usage == AC_BACK ? 0x0000 : (usage == AC_FORWARD ? 0x0000 : (usage == AC_STOP ? 0x0000 : (usage == AC_REFRESH ? 0x0000 : (usage == AC_BOOKMARKS ? 0x0000 : 0)))))))))))))))))))
+
+static void send_consumer(uint16_t data) {
static uint16_t last_data = 0;
if (data == last_data) return;
last_data = data;
-
+
uint16_t bitmap = CONSUMER2BLUEFRUIT(data);
-
-#ifdef BLUEFRUIT_TRACE_SERIAL
- dprintf("\nData: ");
- debug_hex16(data);
- dprintf("; bitmap: ");
- debug_hex16(bitmap);
+
+#ifdef BLUEFRUIT_TRACE_SERIAL
+ dprintf("\nData: ");
+ debug_hex16(data);
+ dprintf("; bitmap: ");
+ debug_hex16(bitmap);
dprintf("\n");
bluefruit_trace_header();
#endif
bluefruit_serial_send(0xFD);
bluefruit_serial_send(0x00);
bluefruit_serial_send(0x02);
- bluefruit_serial_send((bitmap>>8)&0xFF);
- bluefruit_serial_send(bitmap&0xFF);
+ bluefruit_serial_send((bitmap >> 8) & 0xFF);
+ bluefruit_serial_send(bitmap & 0xFF);
bluefruit_serial_send(0x00);
bluefruit_serial_send(0x00);
bluefruit_serial_send(0x00);
diff --git a/tmk_core/protocol/bluefruit/bluefruit.h b/tmk_core/protocol/bluefruit/bluefruit.h
index ceacc4a367..7b636abb95 100644
--- a/tmk_core/protocol/bluefruit/bluefruit.h
+++ b/tmk_core/protocol/bluefruit/bluefruit.h
@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "host_driver.h"
-
host_driver_t *bluefruit_driver(void);
#endif \ No newline at end of file
diff --git a/tmk_core/protocol/bluefruit/main.c b/tmk_core/protocol/bluefruit/main.c
index 8a6386b4eb..3adcab4f42 100644
--- a/tmk_core/protocol/bluefruit/main.c
+++ b/tmk_core/protocol/bluefruit/main.c
@@ -34,16 +34,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "bluefruit.h"
#include "pjrc.h"
-#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
+#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
-#define HOST_DRIVER_NOT_SET 0
-#define BLUEFRUIT_HOST_DRIVER 1
-#define PJRC_HOST_DRIVER 2
-
-
-int main(void)
-{
+#define HOST_DRIVER_NOT_SET 0
+#define BLUEFRUIT_HOST_DRIVER 1
+#define PJRC_HOST_DRIVER 2
+int main(void) {
CPU_PRESCALE(0);
// DDRD = _BV(PD5);
@@ -58,7 +55,6 @@ int main(void)
// _delay_ms(2000);
// while (!usb_configured()) /* wait */
-
keyboard_setup();
dprintf("Initializing keyboard...\n");
@@ -76,11 +72,11 @@ int main(void)
// DDRB = _BV(PB6);
// PORTB |= _BV(PB6);
- dprintf("Setting host driver to bluefruit...\n");
- host_set_driver(bluefruit_driver());
+ dprintf("Setting host driver to bluefruit...\n");
+ host_set_driver(bluefruit_driver());
- dprintf("Initializing serial...\n");
- serial_init();
+ dprintf("Initializing serial...\n");
+ serial_init();
// char swpa[] = "+++\r\n";
// for (int i = 0; i < 5; i++) {
@@ -101,39 +97,38 @@ int main(void)
// serial_send(swpa[i]);
// }
- // wait an extra second for the PC's operating system
- // to load drivers and do whatever it does to actually
- // be ready for input
- _delay_ms(1000);
- // PORTD = ~_BV(PD5);
- dprintf("Starting main loop");
- while (1) {
- keyboard_task();
- }
-
-// } else {
-
-// // I'm not smart enough to get this done with LUFA - BCG
-// dprintf("Setting host driver to PJRC...\n");
-// host_set_driver(pjrc_driver());
-// #ifdef SLEEP_LED_ENABLE
-// sleep_led_init();
-// #endif
-// // wait an extra second for the PC's operating system
-// // to load drivers and do whatever it does to actually
-// // be ready for input
-// _delay_ms(1000);
-// PORTB = ~_BV(PB0);
-// dprintf("Starting main loop");
-// while (1) {
-// while (suspend) {
-// suspend_power_down();
-// if (remote_wakeup && suspend_wakeup_condition()) {
-// usb_remote_wakeup();
-// }
-// }
-// keyboard_task();
-// }
-// }
-
+ // wait an extra second for the PC's operating system
+ // to load drivers and do whatever it does to actually
+ // be ready for input
+ _delay_ms(1000);
+ // PORTD = ~_BV(PD5);
+ dprintf("Starting main loop");
+ while (1) {
+ keyboard_task();
+ }
+
+ // } else {
+
+ // // I'm not smart enough to get this done with LUFA - BCG
+ // dprintf("Setting host driver to PJRC...\n");
+ // host_set_driver(pjrc_driver());
+ // #ifdef SLEEP_LED_ENABLE
+ // sleep_led_init();
+ // #endif
+ // // wait an extra second for the PC's operating system
+ // // to load drivers and do whatever it does to actually
+ // // be ready for input
+ // _delay_ms(1000);
+ // PORTB = ~_BV(PB0);
+ // dprintf("Starting main loop");
+ // while (1) {
+ // while (suspend) {
+ // suspend_power_down();
+ // if (remote_wakeup && suspend_wakeup_condition()) {
+ // usb_remote_wakeup();
+ // }
+ // }
+ // keyboard_task();
+ // }
+ // }
}