diff options
| author | tmk <nobody@nowhere> | 2014-06-17 22:41:14 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2014-07-30 14:07:43 +0900 |
| commit | e81c70149ecf73256f8bb7d77cefc07f2b91d2be (patch) | |
| tree | d918595b92aa099537640cd02285f914b343bd67 /keyboard/mbed_onekey | |
| parent | ee70fe59ee8ebc6dcbf55171b1a2dd72e1744ae6 (diff) | |
| download | qmk_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/Makefile | 8 | ||||
| -rw-r--r-- | keyboard/mbed_onekey/common.mk | 70 | ||||
| -rw-r--r-- | keyboard/mbed_onekey/config.h | 7 | ||||
| -rw-r--r-- | keyboard/mbed_onekey/gcc.mk | 3 | ||||
| -rw-r--r-- | keyboard/mbed_onekey/main.cpp | 109 | ||||
| -rw-r--r-- | keyboard/mbed_onekey/mbed_driver.cpp | 41 | ||||
| -rw-r--r-- | keyboard/mbed_onekey/mbed_driver.h | 3 |
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 | ||
| 21 | CONFIG_H = config.h | ||
| 22 | |||
| 21 | SYS_OBJECTS = | 23 | SYS_OBJECTS = |
| 22 | 24 | ||
| 23 | INCLUDE_PATHS = -I. | 25 | INCLUDE_PATHS = -I. |
| @@ -25,6 +27,12 @@ INCLUDE_PATHS = -I. | |||
| 25 | LIBRARY_PATHS = | 27 | LIBRARY_PATHS = |
| 26 | LIBRARIES = | 28 | LIBRARIES = |
| 27 | 29 | ||
| 30 | # Build Options | ||
| 31 | # Comment out to disable | ||
| 32 | #BOOTMAGIC_ENABLE = yes | ||
| 33 | MOUSEKEY_ENABLE = yes | ||
| 34 | |||
| 35 | |||
| 28 | include mbed.mk | 36 | include mbed.mk |
| 29 | include common.mk | 37 | include common.mk |
| 30 | include gcc.mk | 38 | include 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 @@ | |||
| 1 | COMMON_DIR = common | 1 | COMMON_DIR = common |
| 2 | OBJECTS += \ | 2 | OBJECTS += \ |
| 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 | ||
| 12 | INCLUDE_PATHS += \ | 17 | INCLUDE_PATHS += \ |
| 13 | -I$(TMK_DIR)/$(COMMON_DIR) | 18 | -I$(TMK_DIR)/$(COMMON_DIR) |
| 14 | 19 | ||
| 20 | CC_FLAGS += -include $(CONFIG_H) | ||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | # Option modules | ||
| 25 | ifdef 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 | ||
| 30 | endif | ||
| 31 | |||
| 32 | ifdef MOUSEKEY_ENABLE | ||
| 33 | OBJECTS += $(OBJDIR)/$(COMMON_DIR)/mousekey.o | ||
| 34 | OPT_DEFS += -DMOUSEKEY_ENABLE | ||
| 35 | OPT_DEFS += -DMOUSE_ENABLE | ||
| 36 | endif | ||
| 37 | |||
| 38 | ifdef EXTRAKEY_ENABLE | ||
| 39 | $(error Not Supported) | ||
| 40 | OPT_DEFS += -DEXTRAKEY_ENABLE | ||
| 41 | endif | ||
| 42 | |||
| 43 | ifdef CONSOLE_ENABLE | ||
| 44 | $(error Not Supported) | ||
| 45 | OPT_DEFS += -DCONSOLE_ENABLE | ||
| 46 | else | ||
| 47 | OPT_DEFS += -DNO_PRINT | ||
| 48 | OPT_DEFS += -DNO_DEBUG | ||
| 49 | endif | ||
| 50 | |||
| 51 | ifdef COMMAND_ENABLE | ||
| 52 | $(error Not Supported) | ||
| 53 | SRC += $(COMMON_DIR)/command.c | ||
| 54 | OPT_DEFS += -DCOMMAND_ENABLE | ||
| 55 | endif | ||
| 56 | |||
| 57 | ifdef NKRO_ENABLE | ||
| 58 | $(error Not Supported) | ||
| 59 | OPT_DEFS += -DNKRO_ENABLE | ||
| 60 | endif | ||
| 15 | 61 | ||
| 62 | ifdef 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 | ||
| 67 | endif | ||
| 16 | 68 | ||
| 69 | ifdef BACKLIGHT_ENABLE | ||
| 70 | $(error Not Supported) | ||
| 71 | SRC += $(COMMON_DIR)/backlight.c | ||
| 72 | OPT_DEFS += -DBACKLIGHT_ENABLE | ||
| 73 | endif | ||
| 17 | 74 | ||
| 18 | # $(OBJDIR)/$(COMMON_DIR)/keyboard.o \ | 75 | ifdef 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 |
| 79 | endif | ||
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 | |||
| 10 | CHKSUM = ~/Dropbox/MBED/tool/lpc-vector-checksum | 10 | CHKSUM = ~/Dropbox/MBED/tool/lpc-vector-checksum |
| 11 | 11 | ||
| 12 | CPU = -mcpu=cortex-m0 -mthumb | 12 | CPU = -mcpu=cortex-m0 -mthumb |
| 13 | CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections | 13 | |
| 14 | CC_FLAGS += $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections | ||
| 14 | CC_FLAGS += -MMD -MP | 15 | CC_FLAGS += -MMD -MP |
| 15 | CC_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 | CC_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" |
| 9 | Serial 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, ...) | 12 | DigitalIn isp(P0_1); // ISP button |
| 13 | #endif | 13 | DigitalOut led_red(P0_20); |
| 14 | */ | 14 | DigitalOut led_green(P0_21); |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | // button and LEDs | 17 | int main(void) { |
| 18 | DigitalIn isp(P0_1); | 18 | isp.mode(PullUp); |
| 19 | DigitalOut led_red(P0_20); | 19 | led_red = 1; |
| 20 | DigitalOut led_green(P0_21); | 20 | led_green = 0; |
| 21 | 21 | ||
| 22 | //USBKeyboard | 22 | timer_init(); |
| 23 | HIDKeyboard keyboard; | 23 | host_set_driver(&mbed_driver); |
| 24 | 24 | ||
| 25 | 25 | //debug_enable = true; | |
| 26 | int 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 | |||
| 6 | HIDKeyboard keyboard; | ||
| 7 | |||
| 8 | |||
| 9 | /* Host driver */ | ||
| 10 | static uint8_t keyboard_leds(void); | ||
| 11 | static void send_keyboard(report_keyboard_t *report); | ||
| 12 | static void send_mouse(report_mouse_t *report); | ||
| 13 | static void send_system(uint16_t data); | ||
| 14 | static void send_consumer(uint16_t data); | ||
| 15 | |||
| 16 | host_driver_t mbed_driver = { | ||
| 17 | keyboard_leds, | ||
| 18 | send_keyboard, | ||
| 19 | send_mouse, | ||
| 20 | send_system, | ||
| 21 | send_consumer | ||
| 22 | }; | ||
| 23 | |||
| 24 | |||
| 25 | static uint8_t keyboard_leds(void) | ||
| 26 | { | ||
| 27 | return 0; | ||
| 28 | } | ||
| 29 | static void send_keyboard(report_keyboard_t *report) | ||
| 30 | { | ||
| 31 | keyboard.sendReport(*report); | ||
| 32 | } | ||
| 33 | static void send_mouse(report_mouse_t *report) | ||
| 34 | { | ||
| 35 | } | ||
| 36 | static void send_system(uint16_t data) | ||
| 37 | { | ||
| 38 | } | ||
| 39 | static 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 | |||
| 3 | extern host_driver_t mbed_driver; | ||
