From f15b2691c92e1d9b3c0e59363c803ec540303f37 Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 15 Jun 2014 13:56:17 +0900 Subject: Add keyboard/mbed_onekey --- keyboard/mbed_onekey/HIDKeyboard.cpp | 256 +++++++++++++++++++++++++++++++++++ keyboard/mbed_onekey/HIDKeyboard.h | 36 +++++ keyboard/mbed_onekey/Makefile | 29 ++++ keyboard/mbed_onekey/common.mk | 19 +++ keyboard/mbed_onekey/gcc.mk | 79 +++++++++++ keyboard/mbed_onekey/main.cpp | 55 ++++++++ keyboard/mbed_onekey/mbed.mk | 92 +++++++++++++ 7 files changed, 566 insertions(+) create mode 100644 keyboard/mbed_onekey/HIDKeyboard.cpp create mode 100644 keyboard/mbed_onekey/HIDKeyboard.h create mode 100644 keyboard/mbed_onekey/Makefile create mode 100644 keyboard/mbed_onekey/common.mk create mode 100644 keyboard/mbed_onekey/gcc.mk create mode 100644 keyboard/mbed_onekey/main.cpp create mode 100644 keyboard/mbed_onekey/mbed.mk (limited to 'keyboard/mbed_onekey') diff --git a/keyboard/mbed_onekey/HIDKeyboard.cpp b/keyboard/mbed_onekey/HIDKeyboard.cpp new file mode 100644 index 0000000000..f40c2d2f2a --- /dev/null +++ b/keyboard/mbed_onekey/HIDKeyboard.cpp @@ -0,0 +1,256 @@ +#include +#include "USBHID.h" +#include "USBHID_Types.h" +#include "USBDescriptor.h" +#include "HIDKeyboard.h" + +#define DEFAULT_CONFIGURATION (1) + + +HIDKeyboard::HIDKeyboard(uint16_t vendor_id, uint16_t product_id, uint16_t product_release): USBDevice(vendor_id, product_id, product_release) +{ + USBDevice::connect(); +} + +bool HIDKeyboard::sendReport(report_keyboard_t report) { + USBDevice::write(EP1IN, report.raw, sizeof(report), MAX_PACKET_SIZE_EP1); + return true; +} + +bool HIDKeyboard::USBCallback_setConfiguration(uint8_t configuration) { + if (configuration != DEFAULT_CONFIGURATION) { + return false; + } + + // Configure endpoints > 0 + addEndpoint(EPINT_IN, MAX_PACKET_SIZE_EPINT); + //addEndpoint(EPINT_OUT, MAX_PACKET_SIZE_EPINT); + + // We activate the endpoint to be able to recceive data + //readStart(EPINT_OUT, MAX_PACKET_SIZE_EPINT); + return true; +} + + +uint8_t * HIDKeyboard::stringImanufacturerDesc() { + static uint8_t stringImanufacturerDescriptor[] = { + 0x18, /*bLength*/ + STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ + 't',0,'m',0,'k',0,'-',0,'k',0,'b',0,'d',0,'.',0,'c',0,'o',0,'m',0 /*bString iManufacturer*/ + }; + return stringImanufacturerDescriptor; +} + +uint8_t * HIDKeyboard::stringIproductDesc() { + static uint8_t stringIproductDescriptor[] = { + 0x0a, /*bLength*/ + STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ + 'm',0,'b',0,'e',0,'d',0 /*bString iProduct*/ + }; + return stringIproductDescriptor; +} + +uint8_t * HIDKeyboard::stringIserialDesc() { + static uint8_t stringIserialDescriptor[] = { + 0x04, /*bLength*/ + STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ + '0',0 /*bString iSerial*/ + }; + return stringIserialDescriptor; +} + +uint8_t * HIDKeyboard::reportDesc() { + static uint8_t reportDescriptor[] = { + USAGE_PAGE(1), 0x01, // Generic Desktop + USAGE(1), 0x06, // Keyboard + COLLECTION(1), 0x01, // Application + + USAGE_PAGE(1), 0x07, // Key Codes + USAGE_MINIMUM(1), 0xE0, + USAGE_MAXIMUM(1), 0xE7, + LOGICAL_MINIMUM(1), 0x00, + LOGICAL_MAXIMUM(1), 0x01, + REPORT_SIZE(1), 0x01, + REPORT_COUNT(1), 0x08, + INPUT(1), 0x02, // Data, Variable, Absolute + + REPORT_COUNT(1), 0x01, + REPORT_SIZE(1), 0x08, + INPUT(1), 0x01, // Constant + + REPORT_COUNT(1), 0x05, + REPORT_SIZE(1), 0x01, + USAGE_PAGE(1), 0x08, // LEDs + USAGE_MINIMUM(1), 0x01, + USAGE_MAXIMUM(1), 0x05, + OUTPUT(1), 0x02, // Data, Variable, Absolute + + REPORT_COUNT(1), 0x01, + REPORT_SIZE(1), 0x03, + OUTPUT(1), 0x01, // Constant + + + REPORT_COUNT(1), 0x06, + REPORT_SIZE(1), 0x08, + LOGICAL_MINIMUM(1), 0x00, + LOGICAL_MAXIMUM(1), 0xFF, + USAGE_PAGE(1), 0x07, // Key Codes + USAGE_MINIMUM(1), 0x00, + USAGE_MAXIMUM(1), 0xFF, + INPUT(1), 0x00, // Data, Array + END_COLLECTION(0), + }; + reportLength = sizeof(reportDescriptor); + return reportDescriptor; +} + +uint16_t HIDKeyboard::reportDescLength() { + reportDesc(); + return reportLength; +} + +#define TOTAL_DESCRIPTOR_LENGTH ((1 * CONFIGURATION_DESCRIPTOR_LENGTH) \ + + (1 * INTERFACE_DESCRIPTOR_LENGTH) \ + + (1 * HID_DESCRIPTOR_LENGTH) \ + + (1 * ENDPOINT_DESCRIPTOR_LENGTH)) +uint8_t * HIDKeyboard::configurationDesc() { + static uint8_t configurationDescriptor[] = { + CONFIGURATION_DESCRIPTOR_LENGTH,// bLength + CONFIGURATION_DESCRIPTOR, // bDescriptorType + LSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (LSB) + MSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (MSB) + 0x01, // bNumInterfaces + DEFAULT_CONFIGURATION, // bConfigurationValue + 0x00, // iConfiguration + C_RESERVED | C_REMOTE_WAKEUP, // bmAttributes + C_POWER(100), // bMaxPowerHello World from Mbed + + INTERFACE_DESCRIPTOR_LENGTH, // bLength + INTERFACE_DESCRIPTOR, // bDescriptorType + 0x00, // bInterfaceNumber + 0x00, // bAlternateSetting + 0x01, // bNumEndpoints + HID_CLASS, // bInterfaceClass + 1, // bInterfaceSubClass (boot) + 1, // bInterfaceProtocol (keyboard) + 0x00, // iInterface + + HID_DESCRIPTOR_LENGTH, // bLength + HID_DESCRIPTOR, // bDescriptorType + LSB(HID_VERSION_1_11), // bcdHID (LSB) + MSB(HID_VERSION_1_11), // bcdHID (MSB) + 0x00, // bCountryCode + 0x01, // bNumDescriptors + REPORT_DESCRIPTOR, // bDescriptorType + (uint8_t)(LSB(reportDescLength())), // wDescriptorLength (LSB) + (uint8_t)(MSB(reportDescLength())), // wDescriptorLength (MSB) + + ENDPOINT_DESCRIPTOR_LENGTH, // bLength + ENDPOINT_DESCRIPTOR, // bDescriptorType + PHY_TO_DESC(EP1IN), // bEndpointAddress + E_INTERRUPT, // bmAttributes + LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) + MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) + 1, // bInterval (milliseconds) + }; + return configurationDescriptor; +} + +#if 0 +uint8_t * HIDKeyboard::deviceDesc() { + static uint8_t deviceDescriptor[] = { + DEVICE_DESCRIPTOR_LENGTH, /* bLength */ + DEVICE_DESCRIPTOR, /* bDescriptorType */ + LSB(USB_VERSION_2_0), /* bcdUSB (LSB) */ + MSB(USB_VERSION_2_0), /* bcdUSB (MSB) */ + 0x00, /* bDeviceClass */ + 0x00, /* bDeviceSubClass */ + 0x00, /* bDeviceprotocol */ + MAX_PACKET_SIZE_EP0, /* bMaxPacketSize0 */ + (uint8_t)(LSB(0xfeed)), /* idVendor (LSB) */ + (uint8_t)(MSB(0xfeed)), /* idVendor (MSB) */ + (uint8_t)(LSB(0x1bed)), /* idProduct (LSB) */ + (uint8_t)(MSB(0x1bed)), /* idProduct (MSB) */ + (uint8_t)(LSB(0x0002)), /* bcdDevice (LSB) */ + (uint8_t)(MSB(0x0002)), /* bcdDevice (MSB) */ + 0, /* iManufacturer */ + 0, /* iProduct */ + 0, /* iSerialNumber */ + 0x01 /* bNumConfigurations */ + }; + return deviceDescriptor; +} +#endif + +bool HIDKeyboard::USBCallback_request() { + bool success = false; + CONTROL_TRANSFER * transfer = getTransferPtr(); + uint8_t *hidDescriptor; + + // Process additional standard requests + + if ((transfer->setup.bmRequestType.Type == STANDARD_TYPE)) + { + switch (transfer->setup.bRequest) + { + case GET_DESCRIPTOR: + switch (DESCRIPTOR_TYPE(transfer->setup.wValue)) + { + case REPORT_DESCRIPTOR: + if ((reportDesc() != NULL) \ + && (reportDescLength() != 0)) + { + transfer->remaining = reportDescLength(); + transfer->ptr = reportDesc(); + transfer->direction = DEVICE_TO_HOST; + success = true; + } + break; + case HID_DESCRIPTOR: + // Find the HID descriptor, after the configuration descriptor + hidDescriptor = findDescriptor(HID_DESCRIPTOR); + if (hidDescriptor != NULL) + { + transfer->remaining = HID_DESCRIPTOR_LENGTH; + transfer->ptr = hidDescriptor; + transfer->direction = DEVICE_TO_HOST; + success = true; + } + break; + + default: + break; + } + break; + default: + break; + } + } + + // Process class-specific requests +/* + if (transfer->setup.bmRequestType.Type == CLASS_TYPE) + { + switch (transfer->setup.bRequest) + { + case SET_REPORT: + // First byte will be used for report ID + //outputReport.data[0] = transfer->setup.wValue & 0xff; + //outputReport.length = transfer->setup.wLength + 1; + outputReport.length = transfer->setup.wLength; + + //transfer->remaining = sizeof(outputReport.data) - 1; + //transfer->ptr = &outputReport.data[1]; + transfer->remaining = sizeof(outputReport.data); + transfer->ptr = &outputReport.data[0]; + transfer->direction = HOST_TO_DEVICE; + transfer->notify = true; + success = true; + default: + break; + } + } +*/ + + return success; +} diff --git a/keyboard/mbed_onekey/HIDKeyboard.h b/keyboard/mbed_onekey/HIDKeyboard.h new file mode 100644 index 0000000000..b00c97b9b0 --- /dev/null +++ b/keyboard/mbed_onekey/HIDKeyboard.h @@ -0,0 +1,36 @@ +#ifndef HIDKEYBOARD_H + +#include "stdint.h" +#include "stdbool.h" +#include "USBHID.h" + + +typedef union { + uint8_t raw[8]; + struct { + uint8_t mods; + uint8_t reserved; + uint8_t keys[6]; + }; +} __attribute__ ((packed)) report_keyboard_t; + + +class HIDKeyboard : public USBDevice { +public: + HIDKeyboard(uint16_t vendor_id = 0xFEED, uint16_t product_id = 0xabed, uint16_t product_release = 0x0001); + + bool sendReport(report_keyboard_t report); +protected: + uint16_t reportLength; + virtual bool USBCallback_setConfiguration(uint8_t configuration); + virtual uint8_t * stringImanufacturerDesc(); + virtual uint8_t * stringIproductDesc(); + virtual uint8_t * stringIserialDesc(); + virtual uint16_t reportDescLength(); + virtual uint8_t * reportDesc(); + virtual uint8_t * configurationDesc(); + //virtual uint8_t * deviceDesc(); + virtual bool USBCallback_request(); +}; + +#endif diff --git a/keyboard/mbed_onekey/Makefile b/keyboard/mbed_onekey/Makefile new file mode 100644 index 0000000000..e194052c10 --- /dev/null +++ b/keyboard/mbed_onekey/Makefile @@ -0,0 +1,29 @@ +# This file was automagically generated by mbed.org. For more information, +# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded + +PROJECT = USBKeyboard_HelloWorld + +TMK_DIR = ../.. +MBED_DIR = ./mbed-sdk + +#VPATH += $(MBED_DIR):$(TMK_DIR) +vpath %.s .:$(MBED_DIR):$(TMK_DIR) +vpath %.c .:$(MBED_DIR):$(TMK_DIR) +vpath %.cpp .:$(MBED_DIR):$(TMK_DIR) + +OBJDIR = ./build + +OBJECTS = \ + $(OBJDIR)/./HIDKeyboard.o \ + $(OBJDIR)/./main.o + +SYS_OBJECTS = + +INCLUDE_PATHS = -I. + +LIBRARY_PATHS = +LIBRARIES = + +include mbed.mk +include common.mk +include gcc.mk diff --git a/keyboard/mbed_onekey/common.mk b/keyboard/mbed_onekey/common.mk new file mode 100644 index 0000000000..f21fce8864 --- /dev/null +++ b/keyboard/mbed_onekey/common.mk @@ -0,0 +1,19 @@ +COMMON_DIR = common +OBJECTS += \ +# $(COMMON_DIR)/host.o \ +# $(COMMON_DIR)/keyboard.o \ +# $(COMMON_DIR)/action.o \ +# $(COMMON_DIR)/action_tapping.o \ +# $(COMMON_DIR)/action_macro.o \ +# $(COMMON_DIR)/action_layer.o \ +# $(COMMON_DIR)/action_util.o \ +# $(COMMON_DIR)/keymap.o \ +# $(COMMON_DIR)/timer.o \ + $(COMMON_DIR)/print.o \ +# $(COMMON_DIR)/bootloader.o \ +# $(COMMON_DIR)/suspend.o \ + $(COMMON_DIR)/xprintf.o \ + $(COMMON_DIR)/util.o + +INCLUDE_PATHS += \ + -I$(TMK_DIR)/$(COMMON_DIR) diff --git a/keyboard/mbed_onekey/gcc.mk b/keyboard/mbed_onekey/gcc.mk new file mode 100644 index 0000000000..e31527bbc1 --- /dev/null +++ b/keyboard/mbed_onekey/gcc.mk @@ -0,0 +1,79 @@ +############################################################################### +GCC_BIN = +AS = $(GCC_BIN)arm-none-eabi-as +CC = $(GCC_BIN)arm-none-eabi-gcc +CPP = $(GCC_BIN)arm-none-eabi-g++ +LD = $(GCC_BIN)arm-none-eabi-gcc +OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy +OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump +SIZE = $(GCC_BIN)arm-none-eabi-size +CHKSUM = ~/Dropbox/MBED/tool/lpc-vector-checksum + +CPU = -mcpu=cortex-m0 -mthumb +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS += -MMD -MP +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 + +LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs +LD_FLAGS += -Wl,-Map=$(OBJDIR)/$(PROJECT).map,--cref +LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys + +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + +all: $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).hex size + +clean: + rm -f $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).elf $(OBJDIR)/$(PROJECT).hex $(OBJDIR)/$(PROJECT).map $(OBJDIR)/$(PROJECT).lst $(OBJECTS) $(DEPS) + rm -fr $(OBJDIR) + +$(OBJDIR)/%.o: %.s + mkdir -p $(@D) + $(AS) $(CPU) -o $@ $< + +$(OBJDIR)/%.o: %.c + mkdir -p $(@D) + $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< + +$(OBJDIR)/%.o: %.cpp + mkdir -p $(@D) + $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 $(INCLUDE_PATHS) -o $@ $< + + +$(OBJDIR)/$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) + $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) + @echo "" + @echo "*****" + @echo "***** You must modify vector checksum value in *.bin and *.hex files." + @echo "*****" + @echo "" + +$(OBJDIR)/$(PROJECT).bin: $(OBJDIR)/$(PROJECT).elf + @$(OBJCOPY) -O binary $< $@ + @echo "Writing vector checksum value into $@ ..." + @$(CHKSUM) $@ + @echo + +$(OBJDIR)/$(PROJECT).hex: $(OBJDIR)/$(PROJECT).elf + @$(OBJCOPY) -O ihex $< $@ + +$(OBJDIR)/$(PROJECT).lst: $(OBJDIR)/$(PROJECT).elf + @$(OBJDUMP) -Sdh $< > $@ + +lst: $(OBJDIR)/$(PROJECT).lst + +size: + $(SIZE) $(OBJDIR)/$(PROJECT).elf + +prog: $(OBJDIR)/$(PROJECT).bin + @echo "Program..." +ifneq ($(shell mount | grep 'CRP DISABLD'),) + umount /dev/nxpisp >/dev/null 2>&1 +endif + dd if=$< of=/dev/nxpisp seek=4 + +DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) +-include $(DEPS) diff --git a/keyboard/mbed_onekey/main.cpp b/keyboard/mbed_onekey/main.cpp new file mode 100644 index 0000000000..581534e025 --- /dev/null +++ b/keyboard/mbed_onekey/main.cpp @@ -0,0 +1,55 @@ +#include "mbed.h" +#include "HIDKeyboard.h" +#include "debug.h" + +/* +//#define DEBUG +#ifdef DEBUG +Serial ser(UART_TX, UART_RX); +#define dprintf(fmt, ...) ser.printf(fmt, ## __VA_ARGS__) +#else +#define dprintf(fmt, ...) +#endif +*/ + + +// button and LEDs +DigitalIn isp(P0_1); +DigitalOut led_red(P0_20); +DigitalOut led_green(P0_21); + +//USBKeyboard +HIDKeyboard keyboard; + + +int main(void) { + //isp.mode(PullUp); + //led_red = 0; + //led_green = 0; + debug_enable = true; + dprintf("HIDKeyboard:\n"); + print("aaa"); + + report_keyboard_t report = { 2, 0, 4, }; //a + report_keyboard_t report_off = { 0 }; + while (1) { + //keyboard.mediaControl(KEY_VOLUME_DOWN); + //keyboard.printf("Hello World from Mbed\r\n"); + //keyboard.keyCode('s', KEY_CTRL); + //keyboard.keyCode(KEY_CAPS_LOCK); + + //led_green = !led_green; + //leds = keyboard.lockStatus(); + //ser.putc(ser.getc()); + + if (isp == 0) { + led_red = 0; // on + keyboard.sendReport(report); + } else { + led_red = 1; // off + keyboard.sendReport(report_off); + } + led_green = !led_green; + //wait(0.5); + } +} diff --git a/keyboard/mbed_onekey/mbed.mk b/keyboard/mbed_onekey/mbed.mk new file mode 100644 index 0000000000..962a05e6e5 --- /dev/null +++ b/keyboard/mbed_onekey/mbed.mk @@ -0,0 +1,92 @@ +OBJECTS += \ + $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/startup_LPC11xx.o \ + $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/cmsis_nvic.o \ + $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/system_LPC11Uxx.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/port_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/spi_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/analogin_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_irq_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/serial_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/i2c_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/sleep.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/us_ticker.o \ + $(OBJDIR)/libraries/mbed/common/board.o \ + $(OBJDIR)/libraries/mbed/common/mbed_interface.o \ + $(OBJDIR)/libraries/mbed/common/exit.o \ + $(OBJDIR)/libraries/mbed/common/rtc_time.o \ + $(OBJDIR)/libraries/mbed/common/us_ticker_api.o \ + $(OBJDIR)/libraries/mbed/common/pinmap_common.o \ + $(OBJDIR)/libraries/mbed/common/error.o \ + $(OBJDIR)/libraries/mbed/common/gpio.o \ + $(OBJDIR)/libraries/mbed/common/semihost_api.o \ + $(OBJDIR)/libraries/mbed/common/wait_api.o \ + $(OBJDIR)/libraries/mbed/common/RawSerial.o \ + $(OBJDIR)/libraries/mbed/common/Ticker.o \ + $(OBJDIR)/libraries/mbed/common/FilePath.o \ + $(OBJDIR)/libraries/mbed/common/I2C.o \ + $(OBJDIR)/libraries/mbed/common/FileBase.o \ + $(OBJDIR)/libraries/mbed/common/retarget.o \ + $(OBJDIR)/libraries/mbed/common/Serial.o \ + $(OBJDIR)/libraries/mbed/common/Stream.o \ + $(OBJDIR)/libraries/mbed/common/FileSystemLike.o \ + $(OBJDIR)/libraries/mbed/common/CallChain.o \ + $(OBJDIR)/libraries/mbed/common/InterruptManager.o \ + $(OBJDIR)/libraries/mbed/common/SerialBase.o \ + $(OBJDIR)/libraries/mbed/common/BusInOut.o \ + $(OBJDIR)/libraries/mbed/common/SPISlave.o \ + $(OBJDIR)/libraries/mbed/common/I2CSlave.o \ + $(OBJDIR)/libraries/mbed/common/FunctionPointer.o \ + $(OBJDIR)/libraries/mbed/common/Timer.o \ + $(OBJDIR)/libraries/mbed/common/SPI.o \ + $(OBJDIR)/libraries/mbed/common/Timeout.o \ + $(OBJDIR)/libraries/mbed/common/Ethernet.o \ + $(OBJDIR)/libraries/mbed/common/TimerEvent.o \ + $(OBJDIR)/libraries/mbed/common/CAN.o \ + $(OBJDIR)/libraries/mbed/common/BusOut.o \ + $(OBJDIR)/libraries/mbed/common/FileLike.o \ + $(OBJDIR)/libraries/mbed/common/BusIn.o \ + $(OBJDIR)/libraries/mbed/common/InterruptIn.o \ + $(OBJDIR)/libraries/mbed/common/LocalFileSystem.o \ + $(OBJDIR)/libraries/USBDevice/USBHID/USBMouse.o \ + $(OBJDIR)/libraries/USBDevice/USBHID/USBHID.o \ + $(OBJDIR)/libraries/USBDevice/USBHID/USBMouseKeyboard.o \ + $(OBJDIR)/libraries/USBDevice/USBHID/USBKeyboard.o \ + $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_KL25Z.o \ + $(OBJDIR)/libraries/USBDevice/USBDevice/USBDevice.o \ + $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC17.o \ + $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC40.o \ + $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC11U.o \ + $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_STM32F4.o \ + $(OBJDIR)/libraries/USBDevice/USBAudio/USBAudio.o \ + $(OBJDIR)/libraries/USBDevice/USBSerial/USBSerial.o \ + $(OBJDIR)/libraries/USBDevice/USBSerial/USBCDC.o \ + $(OBJDIR)/libraries/USBDevice/USBMSD/USBMSD.o \ + $(OBJDIR)/libraries/USBDevice/USBMIDI/USBMIDI.o + +INCLUDE_PATHS += \ + -I$(MBED_DIR)/libraries/mbed/targets \ + -I$(MBED_DIR)/libraries/mbed/targets/hal \ + -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP \ + -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX \ + -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_401 \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_401 \ + -I$(MBED_DIR)/libraries/mbed \ + -I$(MBED_DIR)/libraries/mbed/hal \ + -I$(MBED_DIR)/libraries/mbed/api \ + -I$(MBED_DIR)/libraries/mbed/common \ + -I$(MBED_DIR)/libraries/USBDevice \ + -I$(MBED_DIR)/libraries/USBDevice/USBHID \ + -I$(MBED_DIR)/libraries/USBDevice/USBDevice \ + -I$(MBED_DIR)/libraries/USBDevice/USBAudio \ + -I$(MBED_DIR)/libraries/USBDevice/USBSerial \ + -I$(MBED_DIR)/libraries/USBDevice/USBMSD \ + -I$(MBED_DIR)/libraries/USBDevice/USBMIDI + +LINKER_SCRIPT = $(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_401/LPC11U35.ld -- cgit v1.2.1 From 867f115bee190515aa195dc3e58f1c381ea9695b Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 16 Jun 2014 11:12:45 +0900 Subject: Port timer to mbed --- keyboard/mbed_onekey/common.mk | 29 +++++++++++++++-------------- keyboard/mbed_onekey/main.cpp | 21 ++++++++++++++++----- 2 files changed, 31 insertions(+), 19 deletions(-) (limited to 'keyboard/mbed_onekey') diff --git a/keyboard/mbed_onekey/common.mk b/keyboard/mbed_onekey/common.mk index f21fce8864..975ae9d0da 100644 --- a/keyboard/mbed_onekey/common.mk +++ b/keyboard/mbed_onekey/common.mk @@ -1,19 +1,20 @@ COMMON_DIR = common OBJECTS += \ -# $(COMMON_DIR)/host.o \ -# $(COMMON_DIR)/keyboard.o \ -# $(COMMON_DIR)/action.o \ -# $(COMMON_DIR)/action_tapping.o \ -# $(COMMON_DIR)/action_macro.o \ -# $(COMMON_DIR)/action_layer.o \ -# $(COMMON_DIR)/action_util.o \ -# $(COMMON_DIR)/keymap.o \ -# $(COMMON_DIR)/timer.o \ - $(COMMON_DIR)/print.o \ -# $(COMMON_DIR)/bootloader.o \ -# $(COMMON_DIR)/suspend.o \ - $(COMMON_DIR)/xprintf.o \ - $(COMMON_DIR)/util.o + $(OBJDIR)/$(COMMON_DIR)/mbed/timer.o \ INCLUDE_PATHS += \ -I$(TMK_DIR)/$(COMMON_DIR) + + + + +# $(OBJDIR)/$(COMMON_DIR)/host.o \ +# $(OBJDIR)/$(COMMON_DIR)/keyboard.o \ +# $(OBJDIR)/$(COMMON_DIR)/action.o \ +# $(OBJDIR)/$(COMMON_DIR)/action_tapping.o \ +# $(OBJDIR)/$(COMMON_DIR)/action_macro.o \ +# $(OBJDIR)/$(COMMON_DIR)/action_layer.o \ +# $(OBJDIR)/$(COMMON_DIR)/action_util.o \ +# $(OBJDIR)/$(COMMON_DIR)/keymap.o \ +# $(OBJDIR)/$(COMMON_DIR)/bootloader.o \ +# $(OBJDIR)/$(COMMON_DIR)/suspend.o \ diff --git a/keyboard/mbed_onekey/main.cpp b/keyboard/mbed_onekey/main.cpp index 581534e025..1df940aa97 100644 --- a/keyboard/mbed_onekey/main.cpp +++ b/keyboard/mbed_onekey/main.cpp @@ -1,6 +1,7 @@ #include "mbed.h" #include "HIDKeyboard.h" #include "debug.h" +#include "timer.h" /* //#define DEBUG @@ -27,11 +28,16 @@ int main(void) { //led_red = 0; //led_green = 0; debug_enable = true; - dprintf("HIDKeyboard:\n"); - print("aaa"); + dprintf("HIDKeyboard:\r\n"); + + timer_init(); + xprintf("timer: %i\r\n", timer_read()); report_keyboard_t report = { 2, 0, 4, }; //a report_keyboard_t report_off = { 0 }; + + bool last_isp = isp; + uint32_t last_timer; while (1) { //keyboard.mediaControl(KEY_VOLUME_DOWN); //keyboard.printf("Hello World from Mbed\r\n"); @@ -42,14 +48,19 @@ int main(void) { //leds = keyboard.lockStatus(); //ser.putc(ser.getc()); + if (last_isp == isp) continue; if (isp == 0) { led_red = 0; // on - keyboard.sendReport(report); + xprintf("timer: %i\r\n", timer_read32()); + xprintf("diff: %i\r\n", timer_elapsed32(last_timer)); + //keyboard.sendReport(report); } else { led_red = 1; // off - keyboard.sendReport(report_off); + //keyboard.sendReport(report_off); } - led_green = !led_green; + last_isp = isp; + last_timer = timer_read(); + //led_green = !led_green; //wait(0.5); } } -- cgit v1.2.1 From 04fe78ee0a7fe9baed39f021799a3dbb24ebeb36 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 16 Jun 2014 15:38:39 +0900 Subject: Fix print and timer --- keyboard/mbed_onekey/common.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'keyboard/mbed_onekey') diff --git a/keyboard/mbed_onekey/common.mk b/keyboard/mbed_onekey/common.mk index 975ae9d0da..101a822052 100644 --- a/keyboard/mbed_onekey/common.mk +++ b/keyboard/mbed_onekey/common.mk @@ -1,16 +1,17 @@ COMMON_DIR = common OBJECTS += \ $(OBJDIR)/$(COMMON_DIR)/mbed/timer.o \ + $(OBJDIR)/$(COMMON_DIR)/mbed/xprintf.o \ INCLUDE_PATHS += \ -I$(TMK_DIR)/$(COMMON_DIR) +# $(OBJDIR)/$(COMMON_DIR)/action.o \ # $(OBJDIR)/$(COMMON_DIR)/host.o \ # $(OBJDIR)/$(COMMON_DIR)/keyboard.o \ -# $(OBJDIR)/$(COMMON_DIR)/action.o \ # $(OBJDIR)/$(COMMON_DIR)/action_tapping.o \ # $(OBJDIR)/$(COMMON_DIR)/action_macro.o \ # $(OBJDIR)/$(COMMON_DIR)/action_layer.o \ -- cgit v1.2.1 From c67ae2a6b546c822759352586c14cd9dccbbe0ff Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 17 Jun 2014 00:57:59 +0900 Subject: Port action_* to mbed --- keyboard/mbed_onekey/HIDKeyboard.h | 11 +---------- keyboard/mbed_onekey/Makefile | 1 + keyboard/mbed_onekey/common.mk | 12 ++++++------ 3 files changed, 8 insertions(+), 16 deletions(-) (limited to 'keyboard/mbed_onekey') diff --git a/keyboard/mbed_onekey/HIDKeyboard.h b/keyboard/mbed_onekey/HIDKeyboard.h index b00c97b9b0..4ebe610a63 100644 --- a/keyboard/mbed_onekey/HIDKeyboard.h +++ b/keyboard/mbed_onekey/HIDKeyboard.h @@ -3,16 +3,7 @@ #include "stdint.h" #include "stdbool.h" #include "USBHID.h" - - -typedef union { - uint8_t raw[8]; - struct { - uint8_t mods; - uint8_t reserved; - uint8_t keys[6]; - }; -} __attribute__ ((packed)) report_keyboard_t; +#include "report.h" class HIDKeyboard : public USBDevice { diff --git a/keyboard/mbed_onekey/Makefile b/keyboard/mbed_onekey/Makefile index e194052c10..1bc91bc7e7 100644 --- a/keyboard/mbed_onekey/Makefile +++ b/keyboard/mbed_onekey/Makefile @@ -15,6 +15,7 @@ OBJDIR = ./build OBJECTS = \ $(OBJDIR)/./HIDKeyboard.o \ + $(OBJDIR)/./mbed_driver.o \ $(OBJDIR)/./main.o SYS_OBJECTS = diff --git a/keyboard/mbed_onekey/common.mk b/keyboard/mbed_onekey/common.mk index 101a822052..6eb7f76995 100644 --- a/keyboard/mbed_onekey/common.mk +++ b/keyboard/mbed_onekey/common.mk @@ -2,20 +2,20 @@ COMMON_DIR = common OBJECTS += \ $(OBJDIR)/$(COMMON_DIR)/mbed/timer.o \ $(OBJDIR)/$(COMMON_DIR)/mbed/xprintf.o \ + $(OBJDIR)/$(COMMON_DIR)/action.o \ + $(OBJDIR)/$(COMMON_DIR)/action_tapping.o \ + $(OBJDIR)/$(COMMON_DIR)/action_macro.o \ + $(OBJDIR)/$(COMMON_DIR)/action_layer.o \ + $(OBJDIR)/$(COMMON_DIR)/action_util.o \ + $(OBJDIR)/$(COMMON_DIR)/host.o \ INCLUDE_PATHS += \ -I$(TMK_DIR)/$(COMMON_DIR) -# $(OBJDIR)/$(COMMON_DIR)/action.o \ -# $(OBJDIR)/$(COMMON_DIR)/host.o \ # $(OBJDIR)/$(COMMON_DIR)/keyboard.o \ -# $(OBJDIR)/$(COMMON_DIR)/action_tapping.o \ -# $(OBJDIR)/$(COMMON_DIR)/action_macro.o \ -# $(OBJDIR)/$(COMMON_DIR)/action_layer.o \ -# $(OBJDIR)/$(COMMON_DIR)/action_util.o \ # $(OBJDIR)/$(COMMON_DIR)/keymap.o \ # $(OBJDIR)/$(COMMON_DIR)/bootloader.o \ # $(OBJDIR)/$(COMMON_DIR)/suspend.o \ -- cgit v1.2.1 From e81c70149ecf73256f8bb7d77cefc07f2b91d2be Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 17 Jun 2014 22:41:14 +0900 Subject: Fix common files for mbed --- keyboard/mbed_onekey/Makefile | 8 +++ keyboard/mbed_onekey/common.mk | 70 ++++++++++++++++++++-- keyboard/mbed_onekey/config.h | 7 +++ keyboard/mbed_onekey/gcc.mk | 3 +- keyboard/mbed_onekey/main.cpp | 109 ++++++++++++++--------------------- keyboard/mbed_onekey/mbed_driver.cpp | 41 +++++++++++++ keyboard/mbed_onekey/mbed_driver.h | 3 + 7 files changed, 168 insertions(+), 73 deletions(-) create mode 100644 keyboard/mbed_onekey/config.h create mode 100644 keyboard/mbed_onekey/mbed_driver.cpp create mode 100644 keyboard/mbed_onekey/mbed_driver.h (limited to 'keyboard/mbed_onekey') diff --git a/keyboard/mbed_onekey/Makefile b/keyboard/mbed_onekey/Makefile index 1bc91bc7e7..e686f424e6 100644 --- a/keyboard/mbed_onekey/Makefile +++ b/keyboard/mbed_onekey/Makefile @@ -18,6 +18,8 @@ OBJECTS = \ $(OBJDIR)/./mbed_driver.o \ $(OBJDIR)/./main.o +CONFIG_H = config.h + SYS_OBJECTS = INCLUDE_PATHS = -I. @@ -25,6 +27,12 @@ INCLUDE_PATHS = -I. LIBRARY_PATHS = LIBRARIES = +# Build Options +# Comment out to disable +#BOOTMAGIC_ENABLE = yes +MOUSEKEY_ENABLE = yes + + include mbed.mk include common.mk include gcc.mk diff --git a/keyboard/mbed_onekey/common.mk b/keyboard/mbed_onekey/common.mk index 6eb7f76995..1bd7d6edbe 100644 --- a/keyboard/mbed_onekey/common.mk +++ b/keyboard/mbed_onekey/common.mk @@ -1,21 +1,79 @@ COMMON_DIR = common OBJECTS += \ - $(OBJDIR)/$(COMMON_DIR)/mbed/timer.o \ - $(OBJDIR)/$(COMMON_DIR)/mbed/xprintf.o \ $(OBJDIR)/$(COMMON_DIR)/action.o \ $(OBJDIR)/$(COMMON_DIR)/action_tapping.o \ $(OBJDIR)/$(COMMON_DIR)/action_macro.o \ $(OBJDIR)/$(COMMON_DIR)/action_layer.o \ $(OBJDIR)/$(COMMON_DIR)/action_util.o \ $(OBJDIR)/$(COMMON_DIR)/host.o \ + $(OBJDIR)/$(COMMON_DIR)/keymap.o \ + $(OBJDIR)/$(COMMON_DIR)/keyboard.o \ + $(OBJDIR)/$(COMMON_DIR)/util.o \ + $(OBJDIR)/$(COMMON_DIR)/mbed/suspend.o \ + $(OBJDIR)/$(COMMON_DIR)/mbed/timer.o \ + $(OBJDIR)/$(COMMON_DIR)/mbed/xprintf.o \ + $(OBJDIR)/$(COMMON_DIR)/mbed/bootloader.o \ INCLUDE_PATHS += \ -I$(TMK_DIR)/$(COMMON_DIR) +CC_FLAGS += -include $(CONFIG_H) + + + +# Option modules +ifdef BOOTMAGIC_ENABLE + $(error Not Supported) + OBJECTS += $(OBJDIR)/$(COMMON_DIR)/bootmagic.o + OBJECTS += $(OBJDIR)/$(COMMON_DIR)/mbed/eeprom.o + OPT_DEFS += -DBOOTMAGIC_ENABLE +endif + +ifdef MOUSEKEY_ENABLE + OBJECTS += $(OBJDIR)/$(COMMON_DIR)/mousekey.o + OPT_DEFS += -DMOUSEKEY_ENABLE + OPT_DEFS += -DMOUSE_ENABLE +endif + +ifdef EXTRAKEY_ENABLE + $(error Not Supported) + OPT_DEFS += -DEXTRAKEY_ENABLE +endif + +ifdef CONSOLE_ENABLE + $(error Not Supported) + OPT_DEFS += -DCONSOLE_ENABLE +else + OPT_DEFS += -DNO_PRINT + OPT_DEFS += -DNO_DEBUG +endif + +ifdef COMMAND_ENABLE + $(error Not Supported) + SRC += $(COMMON_DIR)/command.c + OPT_DEFS += -DCOMMAND_ENABLE +endif + +ifdef NKRO_ENABLE + $(error Not Supported) + OPT_DEFS += -DNKRO_ENABLE +endif +ifdef SLEEP_LED_ENABLE + $(error Not Supported) + SRC += $(COMMON_DIR)/sleep_led.c + OPT_DEFS += -DSLEEP_LED_ENABLE + OPT_DEFS += -DNO_SUSPEND_POWER_DOWN +endif +ifdef BACKLIGHT_ENABLE + $(error Not Supported) + SRC += $(COMMON_DIR)/backlight.c + OPT_DEFS += -DBACKLIGHT_ENABLE +endif -# $(OBJDIR)/$(COMMON_DIR)/keyboard.o \ -# $(OBJDIR)/$(COMMON_DIR)/keymap.o \ -# $(OBJDIR)/$(COMMON_DIR)/bootloader.o \ -# $(OBJDIR)/$(COMMON_DIR)/suspend.o \ +ifdef KEYMAP_SECTION_ENABLE + $(error Not Supported) + OPT_DEFS += -DKEYMAP_SECTION_ENABLE + EXTRALDFLAGS = -Wl,-L$(TOP_DIR),-Tldscript_keymap_avr5.x +endif diff --git a/keyboard/mbed_onekey/config.h b/keyboard/mbed_onekey/config.h new file mode 100644 index 0000000000..a3aadd0389 --- /dev/null +++ b/keyboard/mbed_onekey/config.h @@ -0,0 +1,7 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#define MATRIX_ROWS 1 +#define MATRIX_COLS 1 + +#endif diff --git a/keyboard/mbed_onekey/gcc.mk b/keyboard/mbed_onekey/gcc.mk index e31527bbc1..0fc41fe275 100644 --- a/keyboard/mbed_onekey/gcc.mk +++ b/keyboard/mbed_onekey/gcc.mk @@ -10,7 +10,8 @@ SIZE = $(GCC_BIN)arm-none-eabi-size CHKSUM = ~/Dropbox/MBED/tool/lpc-vector-checksum CPU = -mcpu=cortex-m0 -mthumb -CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections + +CC_FLAGS += $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_FLAGS += -MMD -MP 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 diff --git a/keyboard/mbed_onekey/main.cpp b/keyboard/mbed_onekey/main.cpp index 1df940aa97..b2f7243c85 100644 --- a/keyboard/mbed_onekey/main.cpp +++ b/keyboard/mbed_onekey/main.cpp @@ -1,66 +1,43 @@ -#include "mbed.h" -#include "HIDKeyboard.h" -#include "debug.h" -#include "timer.h" - -/* -//#define DEBUG -#ifdef DEBUG -Serial ser(UART_TX, UART_RX); -#define dprintf(fmt, ...) ser.printf(fmt, ## __VA_ARGS__) -#else -#define dprintf(fmt, ...) -#endif -*/ - - -// button and LEDs -DigitalIn isp(P0_1); -DigitalOut led_red(P0_20); -DigitalOut led_green(P0_21); - -//USBKeyboard -HIDKeyboard keyboard; - - -int main(void) { - //isp.mode(PullUp); - //led_red = 0; - //led_green = 0; - debug_enable = true; - dprintf("HIDKeyboard:\r\n"); - - timer_init(); - xprintf("timer: %i\r\n", timer_read()); - - report_keyboard_t report = { 2, 0, 4, }; //a - report_keyboard_t report_off = { 0 }; - - bool last_isp = isp; - uint32_t last_timer; - while (1) { - //keyboard.mediaControl(KEY_VOLUME_DOWN); - //keyboard.printf("Hello World from Mbed\r\n"); - //keyboard.keyCode('s', KEY_CTRL); - //keyboard.keyCode(KEY_CAPS_LOCK); - - //led_green = !led_green; - //leds = keyboard.lockStatus(); - //ser.putc(ser.getc()); - - if (last_isp == isp) continue; - if (isp == 0) { - led_red = 0; // on - xprintf("timer: %i\r\n", timer_read32()); - xprintf("diff: %i\r\n", timer_elapsed32(last_timer)); - //keyboard.sendReport(report); - } else { - led_red = 1; // off - //keyboard.sendReport(report_off); - } - last_isp = isp; - last_timer = timer_read(); - //led_green = !led_green; - //wait(0.5); - } -} +#include "mbed.h" +#include "debug.h" +#include "timer.h" +#include "action.h" +#include "keycode.h" +#include "host.h" +#include "host_driver.h" +#include "mbed_driver.h" + + +// Button and LEDs of LPC11U35 board +DigitalIn isp(P0_1); // ISP button +DigitalOut led_red(P0_20); +DigitalOut led_green(P0_21); + + +int main(void) { + isp.mode(PullUp); + led_red = 1; + led_green = 0; + + timer_init(); + host_set_driver(&mbed_driver); + + //debug_enable = true; + xprintf("mbed_onekey ver.eee:\r\n"); + + + bool last_isp = isp; + while (1) { + //led_green = !led_green; + if (last_isp == isp) continue; + last_isp = isp; + if (last_isp == 0) { + led_red = 0; // on + dprintf("timer: %i\r\n", timer_read()); + register_code(KC_A); + } else { + led_red = 1; // off + unregister_code(KC_A); + } + } +} diff --git a/keyboard/mbed_onekey/mbed_driver.cpp b/keyboard/mbed_onekey/mbed_driver.cpp new file mode 100644 index 0000000000..333f8e3782 --- /dev/null +++ b/keyboard/mbed_onekey/mbed_driver.cpp @@ -0,0 +1,41 @@ +#include "HIDKeyboard.h" +#include "host.h" +#include "host_driver.h" +#include "mbed_driver.h" + +HIDKeyboard keyboard; + + +/* 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); + +host_driver_t mbed_driver = { + keyboard_leds, + send_keyboard, + send_mouse, + send_system, + send_consumer +}; + + +static uint8_t keyboard_leds(void) +{ + return 0; +} +static void send_keyboard(report_keyboard_t *report) +{ + keyboard.sendReport(*report); +} +static void send_mouse(report_mouse_t *report) +{ +} +static void send_system(uint16_t data) +{ +} +static void send_consumer(uint16_t data) +{ +} diff --git a/keyboard/mbed_onekey/mbed_driver.h b/keyboard/mbed_onekey/mbed_driver.h new file mode 100644 index 0000000000..dd1153b43a --- /dev/null +++ b/keyboard/mbed_onekey/mbed_driver.h @@ -0,0 +1,3 @@ +#include "host_driver.h" + +extern host_driver_t mbed_driver; -- cgit v1.2.1 From 80c3ff5fa03429f1e4ea15032f665ceb88c9b8c3 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 18 Jun 2014 02:22:59 +0900 Subject: Fix build files for mbed --- keyboard/mbed_onekey/HIDKeyboard.cpp | 256 ----------------------------------- keyboard/mbed_onekey/HIDKeyboard.h | 27 ---- keyboard/mbed_onekey/Makefile | 13 +- keyboard/mbed_onekey/common.mk | 79 ----------- keyboard/mbed_onekey/gcc.mk | 80 ----------- keyboard/mbed_onekey/mbed.mk | 92 ------------- keyboard/mbed_onekey/mbed_driver.cpp | 41 ------ keyboard/mbed_onekey/mbed_driver.h | 3 - 8 files changed, 4 insertions(+), 587 deletions(-) delete mode 100644 keyboard/mbed_onekey/HIDKeyboard.cpp delete mode 100644 keyboard/mbed_onekey/HIDKeyboard.h delete mode 100644 keyboard/mbed_onekey/common.mk delete mode 100644 keyboard/mbed_onekey/gcc.mk delete mode 100644 keyboard/mbed_onekey/mbed.mk delete mode 100644 keyboard/mbed_onekey/mbed_driver.cpp delete mode 100644 keyboard/mbed_onekey/mbed_driver.h (limited to 'keyboard/mbed_onekey') diff --git a/keyboard/mbed_onekey/HIDKeyboard.cpp b/keyboard/mbed_onekey/HIDKeyboard.cpp deleted file mode 100644 index f40c2d2f2a..0000000000 --- a/keyboard/mbed_onekey/HIDKeyboard.cpp +++ /dev/null @@ -1,256 +0,0 @@ -#include -#include "USBHID.h" -#include "USBHID_Types.h" -#include "USBDescriptor.h" -#include "HIDKeyboard.h" - -#define DEFAULT_CONFIGURATION (1) - - -HIDKeyboard::HIDKeyboard(uint16_t vendor_id, uint16_t product_id, uint16_t product_release): USBDevice(vendor_id, product_id, product_release) -{ - USBDevice::connect(); -} - -bool HIDKeyboard::sendReport(report_keyboard_t report) { - USBDevice::write(EP1IN, report.raw, sizeof(report), MAX_PACKET_SIZE_EP1); - return true; -} - -bool HIDKeyboard::USBCallback_setConfiguration(uint8_t configuration) { - if (configuration != DEFAULT_CONFIGURATION) { - return false; - } - - // Configure endpoints > 0 - addEndpoint(EPINT_IN, MAX_PACKET_SIZE_EPINT); - //addEndpoint(EPINT_OUT, MAX_PACKET_SIZE_EPINT); - - // We activate the endpoint to be able to recceive data - //readStart(EPINT_OUT, MAX_PACKET_SIZE_EPINT); - return true; -} - - -uint8_t * HIDKeyboard::stringImanufacturerDesc() { - static uint8_t stringImanufacturerDescriptor[] = { - 0x18, /*bLength*/ - STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ - 't',0,'m',0,'k',0,'-',0,'k',0,'b',0,'d',0,'.',0,'c',0,'o',0,'m',0 /*bString iManufacturer*/ - }; - return stringImanufacturerDescriptor; -} - -uint8_t * HIDKeyboard::stringIproductDesc() { - static uint8_t stringIproductDescriptor[] = { - 0x0a, /*bLength*/ - STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ - 'm',0,'b',0,'e',0,'d',0 /*bString iProduct*/ - }; - return stringIproductDescriptor; -} - -uint8_t * HIDKeyboard::stringIserialDesc() { - static uint8_t stringIserialDescriptor[] = { - 0x04, /*bLength*/ - STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ - '0',0 /*bString iSerial*/ - }; - return stringIserialDescriptor; -} - -uint8_t * HIDKeyboard::reportDesc() { - static uint8_t reportDescriptor[] = { - USAGE_PAGE(1), 0x01, // Generic Desktop - USAGE(1), 0x06, // Keyboard - COLLECTION(1), 0x01, // Application - - USAGE_PAGE(1), 0x07, // Key Codes - USAGE_MINIMUM(1), 0xE0, - USAGE_MAXIMUM(1), 0xE7, - LOGICAL_MINIMUM(1), 0x00, - LOGICAL_MAXIMUM(1), 0x01, - REPORT_SIZE(1), 0x01, - REPORT_COUNT(1), 0x08, - INPUT(1), 0x02, // Data, Variable, Absolute - - REPORT_COUNT(1), 0x01, - REPORT_SIZE(1), 0x08, - INPUT(1), 0x01, // Constant - - REPORT_COUNT(1), 0x05, - REPORT_SIZE(1), 0x01, - USAGE_PAGE(1), 0x08, // LEDs - USAGE_MINIMUM(1), 0x01, - USAGE_MAXIMUM(1), 0x05, - OUTPUT(1), 0x02, // Data, Variable, Absolute - - REPORT_COUNT(1), 0x01, - REPORT_SIZE(1), 0x03, - OUTPUT(1), 0x01, // Constant - - - REPORT_COUNT(1), 0x06, - REPORT_SIZE(1), 0x08, - LOGICAL_MINIMUM(1), 0x00, - LOGICAL_MAXIMUM(1), 0xFF, - USAGE_PAGE(1), 0x07, // Key Codes - USAGE_MINIMUM(1), 0x00, - USAGE_MAXIMUM(1), 0xFF, - INPUT(1), 0x00, // Data, Array - END_COLLECTION(0), - }; - reportLength = sizeof(reportDescriptor); - return reportDescriptor; -} - -uint16_t HIDKeyboard::reportDescLength() { - reportDesc(); - return reportLength; -} - -#define TOTAL_DESCRIPTOR_LENGTH ((1 * CONFIGURATION_DESCRIPTOR_LENGTH) \ - + (1 * INTERFACE_DESCRIPTOR_LENGTH) \ - + (1 * HID_DESCRIPTOR_LENGTH) \ - + (1 * ENDPOINT_DESCRIPTOR_LENGTH)) -uint8_t * HIDKeyboard::configurationDesc() { - static uint8_t configurationDescriptor[] = { - CONFIGURATION_DESCRIPTOR_LENGTH,// bLength - CONFIGURATION_DESCRIPTOR, // bDescriptorType - LSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (LSB) - MSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (MSB) - 0x01, // bNumInterfaces - DEFAULT_CONFIGURATION, // bConfigurationValue - 0x00, // iConfiguration - C_RESERVED | C_REMOTE_WAKEUP, // bmAttributes - C_POWER(100), // bMaxPowerHello World from Mbed - - INTERFACE_DESCRIPTOR_LENGTH, // bLength - INTERFACE_DESCRIPTOR, // bDescriptorType - 0x00, // bInterfaceNumber - 0x00, // bAlternateSetting - 0x01, // bNumEndpoints - HID_CLASS, // bInterfaceClass - 1, // bInterfaceSubClass (boot) - 1, // bInterfaceProtocol (keyboard) - 0x00, // iInterface - - HID_DESCRIPTOR_LENGTH, // bLength - HID_DESCRIPTOR, // bDescriptorType - LSB(HID_VERSION_1_11), // bcdHID (LSB) - MSB(HID_VERSION_1_11), // bcdHID (MSB) - 0x00, // bCountryCode - 0x01, // bNumDescriptors - REPORT_DESCRIPTOR, // bDescriptorType - (uint8_t)(LSB(reportDescLength())), // wDescriptorLength (LSB) - (uint8_t)(MSB(reportDescLength())), // wDescriptorLength (MSB) - - ENDPOINT_DESCRIPTOR_LENGTH, // bLength - ENDPOINT_DESCRIPTOR, // bDescriptorType - PHY_TO_DESC(EP1IN), // bEndpointAddress - E_INTERRUPT, // bmAttributes - LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) - MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) - 1, // bInterval (milliseconds) - }; - return configurationDescriptor; -} - -#if 0 -uint8_t * HIDKeyboard::deviceDesc() { - static uint8_t deviceDescriptor[] = { - DEVICE_DESCRIPTOR_LENGTH, /* bLength */ - DEVICE_DESCRIPTOR, /* bDescriptorType */ - LSB(USB_VERSION_2_0), /* bcdUSB (LSB) */ - MSB(USB_VERSION_2_0), /* bcdUSB (MSB) */ - 0x00, /* bDeviceClass */ - 0x00, /* bDeviceSubClass */ - 0x00, /* bDeviceprotocol */ - MAX_PACKET_SIZE_EP0, /* bMaxPacketSize0 */ - (uint8_t)(LSB(0xfeed)), /* idVendor (LSB) */ - (uint8_t)(MSB(0xfeed)), /* idVendor (MSB) */ - (uint8_t)(LSB(0x1bed)), /* idProduct (LSB) */ - (uint8_t)(MSB(0x1bed)), /* idProduct (MSB) */ - (uint8_t)(LSB(0x0002)), /* bcdDevice (LSB) */ - (uint8_t)(MSB(0x0002)), /* bcdDevice (MSB) */ - 0, /* iManufacturer */ - 0, /* iProduct */ - 0, /* iSerialNumber */ - 0x01 /* bNumConfigurations */ - }; - return deviceDescriptor; -} -#endif - -bool HIDKeyboard::USBCallback_request() { - bool success = false; - CONTROL_TRANSFER * transfer = getTransferPtr(); - uint8_t *hidDescriptor; - - // Process additional standard requests - - if ((transfer->setup.bmRequestType.Type == STANDARD_TYPE)) - { - switch (transfer->setup.bRequest) - { - case GET_DESCRIPTOR: - switch (DESCRIPTOR_TYPE(transfer->setup.wValue)) - { - case REPORT_DESCRIPTOR: - if ((reportDesc() != NULL) \ - && (reportDescLength() != 0)) - { - transfer->remaining = reportDescLength(); - transfer->ptr = reportDesc(); - transfer->direction = DEVICE_TO_HOST; - success = true; - } - break; - case HID_DESCRIPTOR: - // Find the HID descriptor, after the configuration descriptor - hidDescriptor = findDescriptor(HID_DESCRIPTOR); - if (hidDescriptor != NULL) - { - transfer->remaining = HID_DESCRIPTOR_LENGTH; - transfer->ptr = hidDescriptor; - transfer->direction = DEVICE_TO_HOST; - success = true; - } - break; - - default: - break; - } - break; - default: - break; - } - } - - // Process class-specific requests -/* - if (transfer->setup.bmRequestType.Type == CLASS_TYPE) - { - switch (transfer->setup.bRequest) - { - case SET_REPORT: - // First byte will be used for report ID - //outputReport.data[0] = transfer->setup.wValue & 0xff; - //outputReport.length = transfer->setup.wLength + 1; - outputReport.length = transfer->setup.wLength; - - //transfer->remaining = sizeof(outputReport.data) - 1; - //transfer->ptr = &outputReport.data[1]; - transfer->remaining = sizeof(outputReport.data); - transfer->ptr = &outputReport.data[0]; - transfer->direction = HOST_TO_DEVICE; - transfer->notify = true; - success = true; - default: - break; - } - } -*/ - - return success; -} diff --git a/keyboard/mbed_onekey/HIDKeyboard.h b/keyboard/mbed_onekey/HIDKeyboard.h deleted file mode 100644 index 4ebe610a63..0000000000 --- a/keyboard/mbed_onekey/HIDKeyboard.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef HIDKEYBOARD_H - -#include "stdint.h" -#include "stdbool.h" -#include "USBHID.h" -#include "report.h" - - -class HIDKeyboard : public USBDevice { -public: - HIDKeyboard(uint16_t vendor_id = 0xFEED, uint16_t product_id = 0xabed, uint16_t product_release = 0x0001); - - bool sendReport(report_keyboard_t report); -protected: - uint16_t reportLength; - virtual bool USBCallback_setConfiguration(uint8_t configuration); - virtual uint8_t * stringImanufacturerDesc(); - virtual uint8_t * stringIproductDesc(); - virtual uint8_t * stringIserialDesc(); - virtual uint16_t reportDescLength(); - virtual uint8_t * reportDesc(); - virtual uint8_t * configurationDesc(); - //virtual uint8_t * deviceDesc(); - virtual bool USBCallback_request(); -}; - -#endif diff --git a/keyboard/mbed_onekey/Makefile b/keyboard/mbed_onekey/Makefile index e686f424e6..d0d1148ce2 100644 --- a/keyboard/mbed_onekey/Makefile +++ b/keyboard/mbed_onekey/Makefile @@ -1,7 +1,4 @@ -# This file was automagically generated by mbed.org. For more information, -# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded - -PROJECT = USBKeyboard_HelloWorld +PROJECT = mbed_onekey TMK_DIR = ../.. MBED_DIR = ./mbed-sdk @@ -14,8 +11,6 @@ vpath %.cpp .:$(MBED_DIR):$(TMK_DIR) OBJDIR = ./build OBJECTS = \ - $(OBJDIR)/./HIDKeyboard.o \ - $(OBJDIR)/./mbed_driver.o \ $(OBJDIR)/./main.o CONFIG_H = config.h @@ -33,6 +28,6 @@ LIBRARIES = MOUSEKEY_ENABLE = yes -include mbed.mk -include common.mk -include gcc.mk +include $(TMK_DIR)/tool/mbed/mbed.mk +include $(TMK_DIR)/tool/mbed/common.mk +include $(TMK_DIR)/tool/mbed/gcc.mk diff --git a/keyboard/mbed_onekey/common.mk b/keyboard/mbed_onekey/common.mk deleted file mode 100644 index 1bd7d6edbe..0000000000 --- a/keyboard/mbed_onekey/common.mk +++ /dev/null @@ -1,79 +0,0 @@ -COMMON_DIR = common -OBJECTS += \ - $(OBJDIR)/$(COMMON_DIR)/action.o \ - $(OBJDIR)/$(COMMON_DIR)/action_tapping.o \ - $(OBJDIR)/$(COMMON_DIR)/action_macro.o \ - $(OBJDIR)/$(COMMON_DIR)/action_layer.o \ - $(OBJDIR)/$(COMMON_DIR)/action_util.o \ - $(OBJDIR)/$(COMMON_DIR)/host.o \ - $(OBJDIR)/$(COMMON_DIR)/keymap.o \ - $(OBJDIR)/$(COMMON_DIR)/keyboard.o \ - $(OBJDIR)/$(COMMON_DIR)/util.o \ - $(OBJDIR)/$(COMMON_DIR)/mbed/suspend.o \ - $(OBJDIR)/$(COMMON_DIR)/mbed/timer.o \ - $(OBJDIR)/$(COMMON_DIR)/mbed/xprintf.o \ - $(OBJDIR)/$(COMMON_DIR)/mbed/bootloader.o \ - -INCLUDE_PATHS += \ - -I$(TMK_DIR)/$(COMMON_DIR) - -CC_FLAGS += -include $(CONFIG_H) - - - -# Option modules -ifdef BOOTMAGIC_ENABLE - $(error Not Supported) - OBJECTS += $(OBJDIR)/$(COMMON_DIR)/bootmagic.o - OBJECTS += $(OBJDIR)/$(COMMON_DIR)/mbed/eeprom.o - OPT_DEFS += -DBOOTMAGIC_ENABLE -endif - -ifdef MOUSEKEY_ENABLE - OBJECTS += $(OBJDIR)/$(COMMON_DIR)/mousekey.o - OPT_DEFS += -DMOUSEKEY_ENABLE - OPT_DEFS += -DMOUSE_ENABLE -endif - -ifdef EXTRAKEY_ENABLE - $(error Not Supported) - OPT_DEFS += -DEXTRAKEY_ENABLE -endif - -ifdef CONSOLE_ENABLE - $(error Not Supported) - OPT_DEFS += -DCONSOLE_ENABLE -else - OPT_DEFS += -DNO_PRINT - OPT_DEFS += -DNO_DEBUG -endif - -ifdef COMMAND_ENABLE - $(error Not Supported) - SRC += $(COMMON_DIR)/command.c - OPT_DEFS += -DCOMMAND_ENABLE -endif - -ifdef NKRO_ENABLE - $(error Not Supported) - OPT_DEFS += -DNKRO_ENABLE -endif - -ifdef SLEEP_LED_ENABLE - $(error Not Supported) - SRC += $(COMMON_DIR)/sleep_led.c - OPT_DEFS += -DSLEEP_LED_ENABLE - OPT_DEFS += -DNO_SUSPEND_POWER_DOWN -endif - -ifdef BACKLIGHT_ENABLE - $(error Not Supported) - SRC += $(COMMON_DIR)/backlight.c - OPT_DEFS += -DBACKLIGHT_ENABLE -endif - -ifdef KEYMAP_SECTION_ENABLE - $(error Not Supported) - OPT_DEFS += -DKEYMAP_SECTION_ENABLE - EXTRALDFLAGS = -Wl,-L$(TOP_DIR),-Tldscript_keymap_avr5.x -endif diff --git a/keyboard/mbed_onekey/gcc.mk b/keyboard/mbed_onekey/gcc.mk deleted file mode 100644 index 0fc41fe275..0000000000 --- a/keyboard/mbed_onekey/gcc.mk +++ /dev/null @@ -1,80 +0,0 @@ -############################################################################### -GCC_BIN = -AS = $(GCC_BIN)arm-none-eabi-as -CC = $(GCC_BIN)arm-none-eabi-gcc -CPP = $(GCC_BIN)arm-none-eabi-g++ -LD = $(GCC_BIN)arm-none-eabi-gcc -OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy -OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump -SIZE = $(GCC_BIN)arm-none-eabi-size -CHKSUM = ~/Dropbox/MBED/tool/lpc-vector-checksum - -CPU = -mcpu=cortex-m0 -mthumb - -CC_FLAGS += $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -CC_FLAGS += -MMD -MP -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 - -LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs -LD_FLAGS += -Wl,-Map=$(OBJDIR)/$(PROJECT).map,--cref -LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys - -ifeq ($(DEBUG), 1) - CC_FLAGS += -DDEBUG -O0 -else - CC_FLAGS += -DNDEBUG -Os -endif - -all: $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).hex size - -clean: - rm -f $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).elf $(OBJDIR)/$(PROJECT).hex $(OBJDIR)/$(PROJECT).map $(OBJDIR)/$(PROJECT).lst $(OBJECTS) $(DEPS) - rm -fr $(OBJDIR) - -$(OBJDIR)/%.o: %.s - mkdir -p $(@D) - $(AS) $(CPU) -o $@ $< - -$(OBJDIR)/%.o: %.c - mkdir -p $(@D) - $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< - -$(OBJDIR)/%.o: %.cpp - mkdir -p $(@D) - $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 $(INCLUDE_PATHS) -o $@ $< - - -$(OBJDIR)/$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) - $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) - @echo "" - @echo "*****" - @echo "***** You must modify vector checksum value in *.bin and *.hex files." - @echo "*****" - @echo "" - -$(OBJDIR)/$(PROJECT).bin: $(OBJDIR)/$(PROJECT).elf - @$(OBJCOPY) -O binary $< $@ - @echo "Writing vector checksum value into $@ ..." - @$(CHKSUM) $@ - @echo - -$(OBJDIR)/$(PROJECT).hex: $(OBJDIR)/$(PROJECT).elf - @$(OBJCOPY) -O ihex $< $@ - -$(OBJDIR)/$(PROJECT).lst: $(OBJDIR)/$(PROJECT).elf - @$(OBJDUMP) -Sdh $< > $@ - -lst: $(OBJDIR)/$(PROJECT).lst - -size: - $(SIZE) $(OBJDIR)/$(PROJECT).elf - -prog: $(OBJDIR)/$(PROJECT).bin - @echo "Program..." -ifneq ($(shell mount | grep 'CRP DISABLD'),) - umount /dev/nxpisp >/dev/null 2>&1 -endif - dd if=$< of=/dev/nxpisp seek=4 - -DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) --include $(DEPS) diff --git a/keyboard/mbed_onekey/mbed.mk b/keyboard/mbed_onekey/mbed.mk deleted file mode 100644 index 962a05e6e5..0000000000 --- a/keyboard/mbed_onekey/mbed.mk +++ /dev/null @@ -1,92 +0,0 @@ -OBJECTS += \ - $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/startup_LPC11xx.o \ - $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/cmsis_nvic.o \ - $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/system_LPC11Uxx.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/port_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/spi_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/analogin_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_irq_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/serial_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/i2c_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/sleep.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/us_ticker.o \ - $(OBJDIR)/libraries/mbed/common/board.o \ - $(OBJDIR)/libraries/mbed/common/mbed_interface.o \ - $(OBJDIR)/libraries/mbed/common/exit.o \ - $(OBJDIR)/libraries/mbed/common/rtc_time.o \ - $(OBJDIR)/libraries/mbed/common/us_ticker_api.o \ - $(OBJDIR)/libraries/mbed/common/pinmap_common.o \ - $(OBJDIR)/libraries/mbed/common/error.o \ - $(OBJDIR)/libraries/mbed/common/gpio.o \ - $(OBJDIR)/libraries/mbed/common/semihost_api.o \ - $(OBJDIR)/libraries/mbed/common/wait_api.o \ - $(OBJDIR)/libraries/mbed/common/RawSerial.o \ - $(OBJDIR)/libraries/mbed/common/Ticker.o \ - $(OBJDIR)/libraries/mbed/common/FilePath.o \ - $(OBJDIR)/libraries/mbed/common/I2C.o \ - $(OBJDIR)/libraries/mbed/common/FileBase.o \ - $(OBJDIR)/libraries/mbed/common/retarget.o \ - $(OBJDIR)/libraries/mbed/common/Serial.o \ - $(OBJDIR)/libraries/mbed/common/Stream.o \ - $(OBJDIR)/libraries/mbed/common/FileSystemLike.o \ - $(OBJDIR)/libraries/mbed/common/CallChain.o \ - $(OBJDIR)/libraries/mbed/common/InterruptManager.o \ - $(OBJDIR)/libraries/mbed/common/SerialBase.o \ - $(OBJDIR)/libraries/mbed/common/BusInOut.o \ - $(OBJDIR)/libraries/mbed/common/SPISlave.o \ - $(OBJDIR)/libraries/mbed/common/I2CSlave.o \ - $(OBJDIR)/libraries/mbed/common/FunctionPointer.o \ - $(OBJDIR)/libraries/mbed/common/Timer.o \ - $(OBJDIR)/libraries/mbed/common/SPI.o \ - $(OBJDIR)/libraries/mbed/common/Timeout.o \ - $(OBJDIR)/libraries/mbed/common/Ethernet.o \ - $(OBJDIR)/libraries/mbed/common/TimerEvent.o \ - $(OBJDIR)/libraries/mbed/common/CAN.o \ - $(OBJDIR)/libraries/mbed/common/BusOut.o \ - $(OBJDIR)/libraries/mbed/common/FileLike.o \ - $(OBJDIR)/libraries/mbed/common/BusIn.o \ - $(OBJDIR)/libraries/mbed/common/InterruptIn.o \ - $(OBJDIR)/libraries/mbed/common/LocalFileSystem.o \ - $(OBJDIR)/libraries/USBDevice/USBHID/USBMouse.o \ - $(OBJDIR)/libraries/USBDevice/USBHID/USBHID.o \ - $(OBJDIR)/libraries/USBDevice/USBHID/USBMouseKeyboard.o \ - $(OBJDIR)/libraries/USBDevice/USBHID/USBKeyboard.o \ - $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_KL25Z.o \ - $(OBJDIR)/libraries/USBDevice/USBDevice/USBDevice.o \ - $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC17.o \ - $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC40.o \ - $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC11U.o \ - $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_STM32F4.o \ - $(OBJDIR)/libraries/USBDevice/USBAudio/USBAudio.o \ - $(OBJDIR)/libraries/USBDevice/USBSerial/USBSerial.o \ - $(OBJDIR)/libraries/USBDevice/USBSerial/USBCDC.o \ - $(OBJDIR)/libraries/USBDevice/USBMSD/USBMSD.o \ - $(OBJDIR)/libraries/USBDevice/USBMIDI/USBMIDI.o - -INCLUDE_PATHS += \ - -I$(MBED_DIR)/libraries/mbed/targets \ - -I$(MBED_DIR)/libraries/mbed/targets/hal \ - -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP \ - -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX \ - -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_401 \ - -I$(MBED_DIR)/libraries/mbed/targets/cmsis \ - -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP \ - -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX \ - -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM \ - -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_401 \ - -I$(MBED_DIR)/libraries/mbed \ - -I$(MBED_DIR)/libraries/mbed/hal \ - -I$(MBED_DIR)/libraries/mbed/api \ - -I$(MBED_DIR)/libraries/mbed/common \ - -I$(MBED_DIR)/libraries/USBDevice \ - -I$(MBED_DIR)/libraries/USBDevice/USBHID \ - -I$(MBED_DIR)/libraries/USBDevice/USBDevice \ - -I$(MBED_DIR)/libraries/USBDevice/USBAudio \ - -I$(MBED_DIR)/libraries/USBDevice/USBSerial \ - -I$(MBED_DIR)/libraries/USBDevice/USBMSD \ - -I$(MBED_DIR)/libraries/USBDevice/USBMIDI - -LINKER_SCRIPT = $(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_401/LPC11U35.ld diff --git a/keyboard/mbed_onekey/mbed_driver.cpp b/keyboard/mbed_onekey/mbed_driver.cpp deleted file mode 100644 index 333f8e3782..0000000000 --- a/keyboard/mbed_onekey/mbed_driver.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "HIDKeyboard.h" -#include "host.h" -#include "host_driver.h" -#include "mbed_driver.h" - -HIDKeyboard keyboard; - - -/* 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); - -host_driver_t mbed_driver = { - keyboard_leds, - send_keyboard, - send_mouse, - send_system, - send_consumer -}; - - -static uint8_t keyboard_leds(void) -{ - return 0; -} -static void send_keyboard(report_keyboard_t *report) -{ - keyboard.sendReport(*report); -} -static void send_mouse(report_mouse_t *report) -{ -} -static void send_system(uint16_t data) -{ -} -static void send_consumer(uint16_t data) -{ -} diff --git a/keyboard/mbed_onekey/mbed_driver.h b/keyboard/mbed_onekey/mbed_driver.h deleted file mode 100644 index dd1153b43a..0000000000 --- a/keyboard/mbed_onekey/mbed_driver.h +++ /dev/null @@ -1,3 +0,0 @@ -#include "host_driver.h" - -extern host_driver_t mbed_driver; -- cgit v1.2.1 From 4c8e0fd0bd1712421f957ec5e0ca16fc6bbb3856 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 19 Jun 2014 16:13:35 +0900 Subject: Port ps2_usb to mbed --- keyboard/mbed_onekey/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboard/mbed_onekey') diff --git a/keyboard/mbed_onekey/Makefile b/keyboard/mbed_onekey/Makefile index d0d1148ce2..2f7399ba02 100644 --- a/keyboard/mbed_onekey/Makefile +++ b/keyboard/mbed_onekey/Makefile @@ -1,7 +1,7 @@ PROJECT = mbed_onekey TMK_DIR = ../.. -MBED_DIR = ./mbed-sdk +MBED_DIR = $(TMK_DIR)/mbed-sdk #VPATH += $(MBED_DIR):$(TMK_DIR) vpath %.s .:$(MBED_DIR):$(TMK_DIR) -- cgit v1.2.1 From 2e0e21d444cc279699881563cf02e7ef05725bae Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 17 Jun 2014 00:57:59 +0900 Subject: Port action_* to mbed --- keyboard/mbed_onekey/common.mk | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 keyboard/mbed_onekey/common.mk (limited to 'keyboard/mbed_onekey') diff --git a/keyboard/mbed_onekey/common.mk b/keyboard/mbed_onekey/common.mk new file mode 100644 index 0000000000..6eb7f76995 --- /dev/null +++ b/keyboard/mbed_onekey/common.mk @@ -0,0 +1,21 @@ +COMMON_DIR = common +OBJECTS += \ + $(OBJDIR)/$(COMMON_DIR)/mbed/timer.o \ + $(OBJDIR)/$(COMMON_DIR)/mbed/xprintf.o \ + $(OBJDIR)/$(COMMON_DIR)/action.o \ + $(OBJDIR)/$(COMMON_DIR)/action_tapping.o \ + $(OBJDIR)/$(COMMON_DIR)/action_macro.o \ + $(OBJDIR)/$(COMMON_DIR)/action_layer.o \ + $(OBJDIR)/$(COMMON_DIR)/action_util.o \ + $(OBJDIR)/$(COMMON_DIR)/host.o \ + +INCLUDE_PATHS += \ + -I$(TMK_DIR)/$(COMMON_DIR) + + + + +# $(OBJDIR)/$(COMMON_DIR)/keyboard.o \ +# $(OBJDIR)/$(COMMON_DIR)/keymap.o \ +# $(OBJDIR)/$(COMMON_DIR)/bootloader.o \ +# $(OBJDIR)/$(COMMON_DIR)/suspend.o \ -- cgit v1.2.1 From 50bcaa66c468f350a538279667a0fa68090c55a9 Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 20 Jul 2014 02:24:34 +0900 Subject: Clean up mbed_onekey --- keyboard/mbed_onekey/Makefile | 2 +- keyboard/mbed_onekey/common.mk | 21 --------------------- keyboard/mbed_onekey/main.cpp | 10 ---------- 3 files changed, 1 insertion(+), 32 deletions(-) delete mode 100644 keyboard/mbed_onekey/common.mk (limited to 'keyboard/mbed_onekey') diff --git a/keyboard/mbed_onekey/Makefile b/keyboard/mbed_onekey/Makefile index 2f7399ba02..b1e5f5e594 100644 --- a/keyboard/mbed_onekey/Makefile +++ b/keyboard/mbed_onekey/Makefile @@ -25,7 +25,7 @@ LIBRARIES = # Build Options # Comment out to disable #BOOTMAGIC_ENABLE = yes -MOUSEKEY_ENABLE = yes +#MOUSEKEY_ENABLE = yes include $(TMK_DIR)/tool/mbed/mbed.mk diff --git a/keyboard/mbed_onekey/common.mk b/keyboard/mbed_onekey/common.mk deleted file mode 100644 index 6eb7f76995..0000000000 --- a/keyboard/mbed_onekey/common.mk +++ /dev/null @@ -1,21 +0,0 @@ -COMMON_DIR = common -OBJECTS += \ - $(OBJDIR)/$(COMMON_DIR)/mbed/timer.o \ - $(OBJDIR)/$(COMMON_DIR)/mbed/xprintf.o \ - $(OBJDIR)/$(COMMON_DIR)/action.o \ - $(OBJDIR)/$(COMMON_DIR)/action_tapping.o \ - $(OBJDIR)/$(COMMON_DIR)/action_macro.o \ - $(OBJDIR)/$(COMMON_DIR)/action_layer.o \ - $(OBJDIR)/$(COMMON_DIR)/action_util.o \ - $(OBJDIR)/$(COMMON_DIR)/host.o \ - -INCLUDE_PATHS += \ - -I$(TMK_DIR)/$(COMMON_DIR) - - - - -# $(OBJDIR)/$(COMMON_DIR)/keyboard.o \ -# $(OBJDIR)/$(COMMON_DIR)/keymap.o \ -# $(OBJDIR)/$(COMMON_DIR)/bootloader.o \ -# $(OBJDIR)/$(COMMON_DIR)/suspend.o \ diff --git a/keyboard/mbed_onekey/main.cpp b/keyboard/mbed_onekey/main.cpp index b2f7243c85..71342e7ec3 100644 --- a/keyboard/mbed_onekey/main.cpp +++ b/keyboard/mbed_onekey/main.cpp @@ -1,10 +1,7 @@ #include "mbed.h" -#include "debug.h" -#include "timer.h" #include "action.h" #include "keycode.h" #include "host.h" -#include "host_driver.h" #include "mbed_driver.h" @@ -19,21 +16,14 @@ int main(void) { led_red = 1; led_green = 0; - timer_init(); host_set_driver(&mbed_driver); - //debug_enable = true; - xprintf("mbed_onekey ver.eee:\r\n"); - - bool last_isp = isp; while (1) { - //led_green = !led_green; if (last_isp == isp) continue; last_isp = isp; if (last_isp == 0) { led_red = 0; // on - dprintf("timer: %i\r\n", timer_read()); register_code(KC_A); } else { led_red = 1; // off -- cgit v1.2.1