diff options
-rw-r--r-- | doxygen-todo | 1 | ||||
-rw-r--r-- | tmk_core/protocol/bluefruit.mk | 11 | ||||
-rw-r--r-- | tmk_core/protocol/bluefruit/bluefruit.c | 168 | ||||
-rw-r--r-- | tmk_core/protocol/bluefruit/bluefruit.h | 24 | ||||
-rw-r--r-- | tmk_core/protocol/bluefruit/main.c | 87 |
5 files changed, 0 insertions, 291 deletions
diff --git a/doxygen-todo b/doxygen-todo index 6483b47c6..39fb498d9 100644 --- a/doxygen-todo +++ b/doxygen-todo | |||
@@ -1,5 +1,4 @@ | |||
1 | tmk_core/protocol | 1 | tmk_core/protocol |
2 | tmk_core/protocol/bluefruit | ||
3 | tmk_core/protocol/chibios | 2 | tmk_core/protocol/chibios |
4 | tmk_core/protocol/iwrap | 3 | tmk_core/protocol/iwrap |
5 | tmk_core/protocol/lufa | 4 | tmk_core/protocol/lufa |
diff --git a/tmk_core/protocol/bluefruit.mk b/tmk_core/protocol/bluefruit.mk deleted file mode 100644 index 13a0693c5..000000000 --- a/tmk_core/protocol/bluefruit.mk +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | BLUEFRUIT_DIR = protocol/bluefruit | ||
2 | |||
3 | SRC += $(BLUEFRUIT_DIR)/main.c \ | ||
4 | $(BLUEFRUIT_DIR)/bluefruit.c \ | ||
5 | serial_uart.c | ||
6 | |||
7 | # Search Path | ||
8 | VPATH += $(TMK_DIR)/$(BLUEFRUIT_DIR) | ||
9 | #VPATH += $(TMK_DIR)/$(BLUEFRUIT_DIR)/usb_debug_only | ||
10 | |||
11 | OPT_DEFS += -DPROTOCOL_BLUEFRUIT | ||
diff --git a/tmk_core/protocol/bluefruit/bluefruit.c b/tmk_core/protocol/bluefruit/bluefruit.c deleted file mode 100644 index fb001855e..000000000 --- a/tmk_core/protocol/bluefruit/bluefruit.c +++ /dev/null | |||
@@ -1,168 +0,0 @@ | |||
1 | /* | ||
2 | Bluefruit Protocol for TMK firmware | ||
3 | Author: Benjamin Gould, 2013 | ||
4 | Based on code Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation, either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | You should have received a copy of the GNU General Public License | ||
14 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include <stdint.h> | ||
18 | #include "host.h" | ||
19 | #include "report.h" | ||
20 | #include "print.h" | ||
21 | #include "debug.h" | ||
22 | #include "host_driver.h" | ||
23 | #include "serial.h" | ||
24 | #include "bluefruit.h" | ||
25 | |||
26 | #define BLUEFRUIT_TRACE_SERIAL 1 | ||
27 | |||
28 | static uint8_t bluefruit_keyboard_leds = 0; | ||
29 | |||
30 | static void bluefruit_serial_send(uint8_t); | ||
31 | |||
32 | void bluefruit_keyboard_print_report(report_keyboard_t *report) { | ||
33 | if (!debug_keyboard) return; | ||
34 | dprintf("keys: "); | ||
35 | for (int i = 0; i < KEYBOARD_REPORT_KEYS; i++) { | ||
36 | debug_hex8(report->keys[i]); | ||
37 | dprintf(" "); | ||
38 | } | ||
39 | dprintf(" mods: "); | ||
40 | debug_hex8(report->mods); | ||
41 | dprintf(" reserved: "); | ||
42 | debug_hex8(report->reserved); | ||
43 | dprintf("\n"); | ||
44 | } | ||
45 | |||
46 | #ifdef BLUEFRUIT_TRACE_SERIAL | ||
47 | static void bluefruit_trace_header() { | ||
48 | dprintf("+------------------------------------+\n"); | ||
49 | dprintf("| HID report to Bluefruit via serial |\n"); | ||
50 | dprintf("+------------------------------------+\n|"); | ||
51 | } | ||
52 | |||
53 | static void bluefruit_trace_footer() { dprintf("|\n+------------------------------------+\n\n"); } | ||
54 | #endif | ||
55 | |||
56 | static void bluefruit_serial_send(uint8_t data) { | ||
57 | #ifdef BLUEFRUIT_TRACE_SERIAL | ||
58 | dprintf(" "); | ||
59 | debug_hex8(data); | ||
60 | dprintf(" "); | ||
61 | #endif | ||
62 | serial_send(data); | ||
63 | } | ||
64 | |||
65 | /*------------------------------------------------------------------* | ||
66 | * Host driver | ||
67 | *------------------------------------------------------------------*/ | ||
68 | |||
69 | static uint8_t keyboard_leds(void); | ||
70 | static void send_keyboard(report_keyboard_t *report); | ||
71 | static void send_mouse(report_mouse_t *report); | ||
72 | static void send_system(uint16_t data); | ||
73 | static void send_consumer(uint16_t data); | ||
74 | |||
75 | void sendString(char string[], int length) { | ||
76 | for (int i = 0; i < length; i++) { | ||
77 | serial_send(string[i]); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer}; | ||
82 | |||
83 | host_driver_t *bluefruit_driver(void) { return &driver; } | ||
84 | |||
85 | static uint8_t keyboard_leds(void) { return bluefruit_keyboard_leds; } | ||
86 | |||
87 | static void send_keyboard(report_keyboard_t *report) { | ||
88 | #ifdef BLUEFRUIT_TRACE_SERIAL | ||
89 | bluefruit_trace_header(); | ||
90 | #endif | ||
91 | bluefruit_serial_send(0xFD); | ||
92 | for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) { | ||
93 | bluefruit_serial_send(report->raw[i]); | ||
94 | } | ||
95 | #ifdef BLUEFRUIT_TRACE_SERIAL | ||
96 | bluefruit_trace_footer(); | ||
97 | #endif | ||
98 | } | ||
99 | |||
100 | static void send_mouse(report_mouse_t *report) { | ||
101 | #ifdef BLUEFRUIT_TRACE_SERIAL | ||
102 | bluefruit_trace_header(); | ||
103 | #endif | ||
104 | bluefruit_serial_send(0xFD); | ||
105 | bluefruit_serial_send(0x00); | ||
106 | bluefruit_serial_send(0x03); | ||
107 | bluefruit_serial_send(report->buttons); | ||
108 | bluefruit_serial_send(report->x); | ||
109 | bluefruit_serial_send(report->y); | ||
110 | bluefruit_serial_send(report->v); // should try sending the wheel v here | ||
111 | bluefruit_serial_send(report->h); // should try sending the wheel h here | ||
112 | bluefruit_serial_send(0x00); | ||
113 | #ifdef BLUEFRUIT_TRACE_SERIAL | ||
114 | bluefruit_trace_footer(); | ||
115 | #endif | ||
116 | } | ||
117 | |||
118 | static void send_system(uint16_t data) {} | ||
119 | |||
120 | /* | ||
121 | +-----------------+-------------------+-------+ | ||
122 | | Consumer Key | Bit Map | Hex | | ||
123 | +-----------------+-------------------+-------+ | ||
124 | | Home | 00000001 00000000 | 01 00 | | ||
125 | | KeyboardLayout | 00000010 00000000 | 02 00 | | ||
126 | | Search | 00000100 00000000 | 04 00 | | ||
127 | | Snapshot | 00001000 00000000 | 08 00 | | ||
128 | | VolumeUp | 00010000 00000000 | 10 00 | | ||
129 | | VolumeDown | 00100000 00000000 | 20 00 | | ||
130 | | Play/Pause | 01000000 00000000 | 40 00 | | ||
131 | | Fast Forward | 10000000 00000000 | 80 00 | | ||
132 | | Rewind | 00000000 00000001 | 00 01 | | ||
133 | | Scan Next Track | 00000000 00000010 | 00 02 | | ||
134 | | Scan Prev Track | 00000000 00000100 | 00 04 | | ||
135 | | Random Play | 00000000 00001000 | 00 08 | | ||
136 | | Stop | 00000000 00010000 | 00 10 | | ||
137 | +-------------------------------------+-------+ | ||
138 | */ | ||
139 | #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))))))))))))))))))) | ||
140 | |||
141 | static void send_consumer(uint16_t data) { | ||
142 | static uint16_t last_data = 0; | ||
143 | if (data == last_data) return; | ||
144 | last_data = data; | ||
145 | |||
146 | uint16_t bitmap = CONSUMER2BLUEFRUIT(data); | ||
147 | |||
148 | #ifdef BLUEFRUIT_TRACE_SERIAL | ||
149 | dprintf("\nData: "); | ||
150 | debug_hex16(data); | ||
151 | dprintf("; bitmap: "); | ||
152 | debug_hex16(bitmap); | ||
153 | dprintf("\n"); | ||
154 | bluefruit_trace_header(); | ||
155 | #endif | ||
156 | bluefruit_serial_send(0xFD); | ||
157 | bluefruit_serial_send(0x00); | ||
158 | bluefruit_serial_send(0x02); | ||
159 | bluefruit_serial_send((bitmap >> 8) & 0xFF); | ||
160 | bluefruit_serial_send(bitmap & 0xFF); | ||
161 | bluefruit_serial_send(0x00); | ||
162 | bluefruit_serial_send(0x00); | ||
163 | bluefruit_serial_send(0x00); | ||
164 | bluefruit_serial_send(0x00); | ||
165 | #ifdef BLUEFRUIT_TRACE_SERIAL | ||
166 | bluefruit_trace_footer(); | ||
167 | #endif | ||
168 | } \ No newline at end of file | ||
diff --git a/tmk_core/protocol/bluefruit/bluefruit.h b/tmk_core/protocol/bluefruit/bluefruit.h deleted file mode 100644 index 7b636abb9..000000000 --- a/tmk_core/protocol/bluefruit/bluefruit.h +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | /* | ||
2 | Bluefruit Protocol for TMK firmware | ||
3 | Author: Benjamin Gould, 2013 | ||
4 | Based on code Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation, either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | You should have received a copy of the GNU General Public License | ||
14 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #ifndef VUSB_H | ||
18 | #define VUSB_H | ||
19 | |||
20 | #include "host_driver.h" | ||
21 | |||
22 | host_driver_t *bluefruit_driver(void); | ||
23 | |||
24 | #endif \ No newline at end of file | ||
diff --git a/tmk_core/protocol/bluefruit/main.c b/tmk_core/protocol/bluefruit/main.c deleted file mode 100644 index aca46206d..000000000 --- a/tmk_core/protocol/bluefruit/main.c +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | /* | ||
2 | Bluefruit Protocol for TMK firmware | ||
3 | Author: Benjamin Gould, 2013 | ||
4 | Based on code Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
5 | |||
6 | This program is free software: you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation, either version 2 of the License, or | ||
9 | (at your option) any later version. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | #include <stdint.h> | ||
21 | #include <avr/interrupt.h> | ||
22 | #include <avr/wdt.h> | ||
23 | #include <avr/sleep.h> | ||
24 | #include <util/delay.h> | ||
25 | #include "../serial.h" | ||
26 | #include "keyboard.h" | ||
27 | #include "host.h" | ||
28 | #include "timer.h" | ||
29 | #include "print.h" | ||
30 | #include "debug.h" | ||
31 | #include "sendchar.h" | ||
32 | #include "suspend.h" | ||
33 | #include "bluefruit.h" | ||
34 | |||
35 | #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) | ||
36 | |||
37 | int main(void) { | ||
38 | CPU_PRESCALE(0); | ||
39 | |||
40 | // DDRD = _BV(PD5); | ||
41 | // DDRB = _BV(PB0); | ||
42 | |||
43 | // PORTD = _BV(PD5); | ||
44 | // PORTB = _BV(PB0); | ||
45 | |||
46 | print_set_sendchar(sendchar); | ||
47 | |||
48 | keyboard_setup(); | ||
49 | |||
50 | dprintf("Initializing keyboard...\n"); | ||
51 | keyboard_init(); | ||
52 | |||
53 | dprintf("Setting host driver to bluefruit...\n"); | ||
54 | host_set_driver(bluefruit_driver()); | ||
55 | |||
56 | dprintf("Initializing serial...\n"); | ||
57 | serial_init(); | ||
58 | |||
59 | // char swpa[] = "+++\r\n"; | ||
60 | // for (int i = 0; i < 5; i++) { | ||
61 | // serial_send(swpa[i]); | ||
62 | // } | ||
63 | |||
64 | // char ble_enable[] = "AT+BLEKEYBOARDEN=1\r\n"; | ||
65 | // for (int i = 0; i < 20; i++) { | ||
66 | // serial_send(ble_enable[i]); | ||
67 | // } | ||
68 | |||
69 | // char reset[] = "ATZ\r\n"; | ||
70 | // for (int i = 0; i < 5; i++) { | ||
71 | // serial_send(reset[i]); | ||
72 | // } | ||
73 | |||
74 | // for (int i = 0; i < 5; i++) { | ||
75 | // serial_send(swpa[i]); | ||
76 | // } | ||
77 | |||
78 | // wait an extra second for the PC's operating system | ||
79 | // to load drivers and do whatever it does to actually | ||
80 | // be ready for input | ||
81 | _delay_ms(1000); | ||
82 | // PORTD = ~_BV(PD5); | ||
83 | dprintf("Starting main loop"); | ||
84 | while (1) { | ||
85 | keyboard_task(); | ||
86 | } | ||
87 | } | ||