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 --- .gitignore | 2 + 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 - protocol/mbed/HIDKeyboard.cpp | 256 +++++++++++++++++++++++++++++++++++ protocol/mbed/HIDKeyboard.h | 27 ++++ protocol/mbed/mbed_driver.cpp | 41 ++++++ protocol/mbed/mbed_driver.h | 3 + tool/mbed/common.mk | 79 +++++++++++ tool/mbed/gcc.mk | 80 +++++++++++ tool/mbed/mbed.mk | 99 ++++++++++++++ 16 files changed, 591 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 create mode 100644 protocol/mbed/HIDKeyboard.cpp create mode 100644 protocol/mbed/HIDKeyboard.h create mode 100644 protocol/mbed/mbed_driver.cpp create mode 100644 protocol/mbed/mbed_driver.h create mode 100644 tool/mbed/common.mk create mode 100644 tool/mbed/gcc.mk create mode 100644 tool/mbed/mbed.mk diff --git a/.gitignore b/.gitignore index c25d41d238..b79d72b7c7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ *.map *.sym tags +build/ +*.bak 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; diff --git a/protocol/mbed/HIDKeyboard.cpp b/protocol/mbed/HIDKeyboard.cpp new file mode 100644 index 0000000000..f40c2d2f2a --- /dev/null +++ b/protocol/mbed/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/protocol/mbed/HIDKeyboard.h b/protocol/mbed/HIDKeyboard.h new file mode 100644 index 0000000000..4ebe610a63 --- /dev/null +++ b/protocol/mbed/HIDKeyboard.h @@ -0,0 +1,27 @@ +#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/protocol/mbed/mbed_driver.cpp b/protocol/mbed/mbed_driver.cpp new file mode 100644 index 0000000000..333f8e3782 --- /dev/null +++ b/protocol/mbed/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/protocol/mbed/mbed_driver.h b/protocol/mbed/mbed_driver.h new file mode 100644 index 0000000000..dd1153b43a --- /dev/null +++ b/protocol/mbed/mbed_driver.h @@ -0,0 +1,3 @@ +#include "host_driver.h" + +extern host_driver_t mbed_driver; diff --git a/tool/mbed/common.mk b/tool/mbed/common.mk new file mode 100644 index 0000000000..1bd7d6edbe --- /dev/null +++ b/tool/mbed/common.mk @@ -0,0 +1,79 @@ +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/tool/mbed/gcc.mk b/tool/mbed/gcc.mk new file mode 100644 index 0000000000..0fc41fe275 --- /dev/null +++ b/tool/mbed/gcc.mk @@ -0,0 +1,80 @@ +############################################################################### +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/tool/mbed/mbed.mk b/tool/mbed/mbed.mk new file mode 100644 index 0000000000..0f12ee2af3 --- /dev/null +++ b/tool/mbed/mbed.mk @@ -0,0 +1,99 @@ +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 + +OBJECTS += \ + $(OBJDIR)/protocol/mbed/mbed_driver.o \ + $(OBJDIR)/protocol/mbed/HIDKeyboard.o \ + +INCLUDE_PATHS += \ + -I$(TMK_DIR)/protocol/mbed + +LINKER_SCRIPT = $(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_401/LPC11U35.ld -- cgit v1.2.3