aboutsummaryrefslogtreecommitdiff
path: root/keyboard/mbed_onekey
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-06-17 22:41:14 +0900
committertmk <nobody@nowhere>2014-07-30 14:07:43 +0900
commite81c70149ecf73256f8bb7d77cefc07f2b91d2be (patch)
treed918595b92aa099537640cd02285f914b343bd67 /keyboard/mbed_onekey
parentee70fe59ee8ebc6dcbf55171b1a2dd72e1744ae6 (diff)
downloadqmk_firmware-e81c70149ecf73256f8bb7d77cefc07f2b91d2be.tar.gz
qmk_firmware-e81c70149ecf73256f8bb7d77cefc07f2b91d2be.zip
Fix common files for mbed
Diffstat (limited to 'keyboard/mbed_onekey')
-rw-r--r--keyboard/mbed_onekey/Makefile8
-rw-r--r--keyboard/mbed_onekey/common.mk70
-rw-r--r--keyboard/mbed_onekey/config.h7
-rw-r--r--keyboard/mbed_onekey/gcc.mk3
-rw-r--r--keyboard/mbed_onekey/main.cpp109
-rw-r--r--keyboard/mbed_onekey/mbed_driver.cpp41
-rw-r--r--keyboard/mbed_onekey/mbed_driver.h3
7 files changed, 168 insertions, 73 deletions
diff --git a/keyboard/mbed_onekey/Makefile b/keyboard/mbed_onekey/Makefile
index 1bc91bc7e..e686f424e 100644
--- a/keyboard/mbed_onekey/Makefile
+++ b/keyboard/mbed_onekey/Makefile
@@ -18,6 +18,8 @@ OBJECTS = \
18 $(OBJDIR)/./mbed_driver.o \ 18 $(OBJDIR)/./mbed_driver.o \
19 $(OBJDIR)/./main.o 19 $(OBJDIR)/./main.o
20 20
21CONFIG_H = config.h
22
21SYS_OBJECTS = 23SYS_OBJECTS =
22 24
23INCLUDE_PATHS = -I. 25INCLUDE_PATHS = -I.
@@ -25,6 +27,12 @@ INCLUDE_PATHS = -I.
25LIBRARY_PATHS = 27LIBRARY_PATHS =
26LIBRARIES = 28LIBRARIES =
27 29
30# Build Options
31# Comment out to disable
32#BOOTMAGIC_ENABLE = yes
33MOUSEKEY_ENABLE = yes
34
35
28include mbed.mk 36include mbed.mk
29include common.mk 37include common.mk
30include gcc.mk 38include gcc.mk
diff --git a/keyboard/mbed_onekey/common.mk b/keyboard/mbed_onekey/common.mk
index 6eb7f7699..1bd7d6edb 100644
--- a/keyboard/mbed_onekey/common.mk
+++ b/keyboard/mbed_onekey/common.mk
@@ -1,21 +1,79 @@
1COMMON_DIR = common 1COMMON_DIR = common
2OBJECTS += \ 2OBJECTS += \
3 $(OBJDIR)/$(COMMON_DIR)/mbed/timer.o \
4 $(OBJDIR)/$(COMMON_DIR)/mbed/xprintf.o \
5 $(OBJDIR)/$(COMMON_DIR)/action.o \ 3 $(OBJDIR)/$(COMMON_DIR)/action.o \
6 $(OBJDIR)/$(COMMON_DIR)/action_tapping.o \ 4 $(OBJDIR)/$(COMMON_DIR)/action_tapping.o \
7 $(OBJDIR)/$(COMMON_DIR)/action_macro.o \ 5 $(OBJDIR)/$(COMMON_DIR)/action_macro.o \
8 $(OBJDIR)/$(COMMON_DIR)/action_layer.o \ 6 $(OBJDIR)/$(COMMON_DIR)/action_layer.o \
9 $(OBJDIR)/$(COMMON_DIR)/action_util.o \ 7 $(OBJDIR)/$(COMMON_DIR)/action_util.o \
10 $(OBJDIR)/$(COMMON_DIR)/host.o \ 8 $(OBJDIR)/$(COMMON_DIR)/host.o \
9 $(OBJDIR)/$(COMMON_DIR)/keymap.o \
10 $(OBJDIR)/$(COMMON_DIR)/keyboard.o \
11 $(OBJDIR)/$(COMMON_DIR)/util.o \
12 $(OBJDIR)/$(COMMON_DIR)/mbed/suspend.o \
13 $(OBJDIR)/$(COMMON_DIR)/mbed/timer.o \
14 $(OBJDIR)/$(COMMON_DIR)/mbed/xprintf.o \
15 $(OBJDIR)/$(COMMON_DIR)/mbed/bootloader.o \
11 16
12INCLUDE_PATHS += \ 17INCLUDE_PATHS += \
13 -I$(TMK_DIR)/$(COMMON_DIR) 18 -I$(TMK_DIR)/$(COMMON_DIR)
14 19
20CC_FLAGS += -include $(CONFIG_H)
21
22
23
24# Option modules
25ifdef BOOTMAGIC_ENABLE
26 $(error Not Supported)
27 OBJECTS += $(OBJDIR)/$(COMMON_DIR)/bootmagic.o
28 OBJECTS += $(OBJDIR)/$(COMMON_DIR)/mbed/eeprom.o
29 OPT_DEFS += -DBOOTMAGIC_ENABLE
30endif
31
32ifdef MOUSEKEY_ENABLE
33 OBJECTS += $(OBJDIR)/$(COMMON_DIR)/mousekey.o
34 OPT_DEFS += -DMOUSEKEY_ENABLE
35 OPT_DEFS += -DMOUSE_ENABLE
36endif
37
38ifdef EXTRAKEY_ENABLE
39 $(error Not Supported)
40 OPT_DEFS += -DEXTRAKEY_ENABLE
41endif
42
43ifdef CONSOLE_ENABLE
44 $(error Not Supported)
45 OPT_DEFS += -DCONSOLE_ENABLE
46else
47 OPT_DEFS += -DNO_PRINT
48 OPT_DEFS += -DNO_DEBUG
49endif
50
51ifdef COMMAND_ENABLE
52 $(error Not Supported)
53 SRC += $(COMMON_DIR)/command.c
54 OPT_DEFS += -DCOMMAND_ENABLE
55endif
56
57ifdef NKRO_ENABLE
58 $(error Not Supported)
59 OPT_DEFS += -DNKRO_ENABLE
60endif
15 61
62ifdef SLEEP_LED_ENABLE
63 $(error Not Supported)
64 SRC += $(COMMON_DIR)/sleep_led.c
65 OPT_DEFS += -DSLEEP_LED_ENABLE
66 OPT_DEFS += -DNO_SUSPEND_POWER_DOWN
67endif
16 68
69ifdef BACKLIGHT_ENABLE
70 $(error Not Supported)
71 SRC += $(COMMON_DIR)/backlight.c
72 OPT_DEFS += -DBACKLIGHT_ENABLE
73endif
17 74
18# $(OBJDIR)/$(COMMON_DIR)/keyboard.o \ 75ifdef KEYMAP_SECTION_ENABLE
19# $(OBJDIR)/$(COMMON_DIR)/keymap.o \ 76 $(error Not Supported)
20# $(OBJDIR)/$(COMMON_DIR)/bootloader.o \ 77 OPT_DEFS += -DKEYMAP_SECTION_ENABLE
21# $(OBJDIR)/$(COMMON_DIR)/suspend.o \ 78 EXTRALDFLAGS = -Wl,-L$(TOP_DIR),-Tldscript_keymap_avr5.x
79endif
diff --git a/keyboard/mbed_onekey/config.h b/keyboard/mbed_onekey/config.h
new file mode 100644
index 000000000..a3aadd038
--- /dev/null
+++ b/keyboard/mbed_onekey/config.h
@@ -0,0 +1,7 @@
1#ifndef CONFIG_H
2#define CONFIG_H
3
4#define MATRIX_ROWS 1
5#define MATRIX_COLS 1
6
7#endif
diff --git a/keyboard/mbed_onekey/gcc.mk b/keyboard/mbed_onekey/gcc.mk
index e31527bbc..0fc41fe27 100644
--- a/keyboard/mbed_onekey/gcc.mk
+++ b/keyboard/mbed_onekey/gcc.mk
@@ -10,7 +10,8 @@ SIZE = $(GCC_BIN)arm-none-eabi-size
10CHKSUM = ~/Dropbox/MBED/tool/lpc-vector-checksum 10CHKSUM = ~/Dropbox/MBED/tool/lpc-vector-checksum
11 11
12CPU = -mcpu=cortex-m0 -mthumb 12CPU = -mcpu=cortex-m0 -mthumb
13CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections 13
14CC_FLAGS += $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections
14CC_FLAGS += -MMD -MP 15CC_FLAGS += -MMD -MP
15CC_SYMBOLS = -DTARGET_LPC11U35_401 -DTARGET_M0 -DTARGET_NXP -DTARGET_LPC11UXX -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M0 -DARM_MATH_CM0 -DMBED_BUILD_TIMESTAMP=1399108688.49 -D__MBED__=1 16CC_SYMBOLS = -DTARGET_LPC11U35_401 -DTARGET_M0 -DTARGET_NXP -DTARGET_LPC11UXX -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M0 -DARM_MATH_CM0 -DMBED_BUILD_TIMESTAMP=1399108688.49 -D__MBED__=1
16 17
diff --git a/keyboard/mbed_onekey/main.cpp b/keyboard/mbed_onekey/main.cpp
index 1df940aa9..b2f7243c8 100644
--- a/keyboard/mbed_onekey/main.cpp
+++ b/keyboard/mbed_onekey/main.cpp
@@ -1,66 +1,43 @@
1#include "mbed.h" 1#include "mbed.h"
2#include "HIDKeyboard.h" 2#include "debug.h"
3#include "debug.h" 3#include "timer.h"
4#include "timer.h" 4#include "action.h"
5 5#include "keycode.h"
6/* 6#include "host.h"
7//#define DEBUG 7#include "host_driver.h"
8#ifdef DEBUG 8#include "mbed_driver.h"
9Serial ser(UART_TX, UART_RX); 9
10#define dprintf(fmt, ...) ser.printf(fmt, ## __VA_ARGS__) 10
11#else 11// Button and LEDs of LPC11U35 board
12#define dprintf(fmt, ...) 12DigitalIn isp(P0_1); // ISP button
13#endif 13DigitalOut led_red(P0_20);
14*/ 14DigitalOut led_green(P0_21);
15 15
16 16
17// button and LEDs 17int main(void) {
18DigitalIn isp(P0_1); 18 isp.mode(PullUp);
19DigitalOut led_red(P0_20); 19 led_red = 1;
20DigitalOut led_green(P0_21); 20 led_green = 0;
21 21
22//USBKeyboard 22 timer_init();
23HIDKeyboard keyboard; 23 host_set_driver(&mbed_driver);
24 24
25 25 //debug_enable = true;
26int main(void) { 26 xprintf("mbed_onekey ver.eee:\r\n");
27 //isp.mode(PullUp); 27
28 //led_red = 0; 28
29 //led_green = 0; 29 bool last_isp = isp;
30 debug_enable = true; 30 while (1) {
31 dprintf("HIDKeyboard:\r\n"); 31 //led_green = !led_green;
32 32 if (last_isp == isp) continue;
33 timer_init(); 33 last_isp = isp;
34 xprintf("timer: %i\r\n", timer_read()); 34 if (last_isp == 0) {
35 35 led_red = 0; // on
36 report_keyboard_t report = { 2, 0, 4, }; //a 36 dprintf("timer: %i\r\n", timer_read());
37 report_keyboard_t report_off = { 0 }; 37 register_code(KC_A);
38 38 } else {
39 bool last_isp = isp; 39 led_red = 1; // off
40 uint32_t last_timer; 40 unregister_code(KC_A);
41 while (1) { 41 }
42 //keyboard.mediaControl(KEY_VOLUME_DOWN); 42 }
43 //keyboard.printf("Hello World from Mbed\r\n"); 43}
44 //keyboard.keyCode('s', KEY_CTRL);
45 //keyboard.keyCode(KEY_CAPS_LOCK);
46
47 //led_green = !led_green;
48 //leds = keyboard.lockStatus();
49 //ser.putc(ser.getc());
50
51 if (last_isp == isp) continue;
52 if (isp == 0) {
53 led_red = 0; // on
54 xprintf("timer: %i\r\n", timer_read32());
55 xprintf("diff: %i\r\n", timer_elapsed32(last_timer));
56 //keyboard.sendReport(report);
57 } else {
58 led_red = 1; // off
59 //keyboard.sendReport(report_off);
60 }
61 last_isp = isp;
62 last_timer = timer_read();
63 //led_green = !led_green;
64 //wait(0.5);
65 }
66}
diff --git a/keyboard/mbed_onekey/mbed_driver.cpp b/keyboard/mbed_onekey/mbed_driver.cpp
new file mode 100644
index 000000000..333f8e378
--- /dev/null
+++ b/keyboard/mbed_onekey/mbed_driver.cpp
@@ -0,0 +1,41 @@
1#include "HIDKeyboard.h"
2#include "host.h"
3#include "host_driver.h"
4#include "mbed_driver.h"
5
6HIDKeyboard keyboard;
7
8
9/* Host driver */
10static uint8_t keyboard_leds(void);
11static void send_keyboard(report_keyboard_t *report);
12static void send_mouse(report_mouse_t *report);
13static void send_system(uint16_t data);
14static void send_consumer(uint16_t data);
15
16host_driver_t mbed_driver = {
17 keyboard_leds,
18 send_keyboard,
19 send_mouse,
20 send_system,
21 send_consumer
22};
23
24
25static uint8_t keyboard_leds(void)
26{
27 return 0;
28}
29static void send_keyboard(report_keyboard_t *report)
30{
31 keyboard.sendReport(*report);
32}
33static void send_mouse(report_mouse_t *report)
34{
35}
36static void send_system(uint16_t data)
37{
38}
39static void send_consumer(uint16_t data)
40{
41}
diff --git a/keyboard/mbed_onekey/mbed_driver.h b/keyboard/mbed_onekey/mbed_driver.h
new file mode 100644
index 000000000..dd1153b43
--- /dev/null
+++ b/keyboard/mbed_onekey/mbed_driver.h
@@ -0,0 +1,3 @@
1#include "host_driver.h"
2
3extern host_driver_t mbed_driver;