summaryrefslogtreecommitdiff
path: root/keyboard
diff options
context:
space:
mode:
Diffstat (limited to 'keyboard')
-rw-r--r--keyboard/infinity/MEMO.txt398
-rw-r--r--keyboard/infinity/Makefile30
-rw-r--r--keyboard/infinity/config.h39
-rw-r--r--keyboard/infinity/infinity.ld156
-rw-r--r--keyboard/infinity/main.cpp29
5 files changed, 652 insertions, 0 deletions
diff --git a/keyboard/infinity/MEMO.txt b/keyboard/infinity/MEMO.txt
new file mode 100644
index 0000000000..ca0da937d7
--- /dev/null
+++ b/keyboard/infinity/MEMO.txt
@@ -0,0 +1,398 @@
+mbed patch for Infinity
+-----------------------
+Without ld script patch vector table it doesn't place vector table in binary file.
+And clock setting is changed as Infinity uses internal oscillator instead of exteranl crystal.
+
+diff --git a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
+index 600751c..55c3393 100644
+--- a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
++++ b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
+@@ -43,7 +43,7 @@ SECTIONS
+ .isr_vector :
+ {
+ __vector_table = .;
+- KEEP(*(.vector_table))
++ KEEP(*(.isr_vector))
+ *(.text.Reset_Handler)
+ *(.text.System_Init)
+ . = ALIGN(4);
+diff --git a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
+index 393d1f0..b78b71a 100644
+--- a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
++++ b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
+@@ -44,7 +44,7 @@
+
+ #define DISABLE_WDOG 1
+
+-#define CLOCK_SETUP 1
++#define CLOCK_SETUP 0
+ /* Predefined clock setups
+ 0 ... Multipurpose Clock Generator (MCG) in FLL Engaged Internal (FEI) mode
+ Reference clock source for MCG module is the slow internal clock source 32.768kHz
+
+
+
+CMSIS/mbed HAL
+==============
+http://developer.mbed.org/users/MACRUM/notebook/mbed-library-internals/
+
+api/ mbed API
+├── AnalogIn.h
+├── AnalogOut.h
+├── BusIn.h
+├── BusInOut.h
+├── BusOut.h
+├── CallChain.h
+├── CAN.h
+├── can_helper.h
+├── DigitalIn.h
+├── DigitalInOut.h
+├── DigitalOut.h
+├── DirHandle.h
+├── Ethernet.h
+├── FileBase.h
+├── FileHandle.h
+├── FileLike.h
+├── FilePath.h
+├── FileSystemLike.h
+├── FunctionPointer.h
+├── I2C.h
+├── I2CSlave.h
+├── InterruptIn.h
+├── InterruptManager.h
+├── LocalFileSystem.h
+├── mbed_assert.h
+├── mbed_debug.h
+├── mbed_error.h
+├── mbed.h
+├── mbed_interface.h
+├── platform.h
+├── PortIn.h
+├── PortInOut.h
+├── PortOut.h
+├── PwmOut.h
+├── RawSerial.h
+├── rtc_time.h
+├── semihost_api.h
+├── SerialBase.h
+├── Serial.h
+├── SPI.h
+├── SPISlave.h
+├── Stream.h
+├── Ticker.h
+├── Timeout.h
+├── TimerEvent.h
+├── Timer.h
+├── toolchain.h
+└── wait_api.h
+
+common/ mbed API implementation
+
+hal/ mbed HAL implementation interface
+├── analogin_api.h
+├── analogout_api.h
+├── can_api.h
+├── ethernet_api.h
+├── gpio_api.h
+├── gpio_irq_api.h
+├── i2c_api.h
+├── pinmap.h
+├── port_api.h
+├── pwmout_api.h
+├── rtc_api.h
+├── serial_api.h
+├── sleep_api.h
+├── spi_api.h
+└── us_ticker_api.h
+
+targets/hal/TARGET_<vendor>/TARGET_<board>/
+ mbed HAL implementation
+
+targets/cmsis/ CMSIS interface
+ core_caInstr.h
+ core_ca9.h
+ core_cmFunc.h
+ core_caFunc.h
+ core_cmInstr.h
+ core_cm4_simd.h
+ core_ca_mmu.h
+ core_cm0.h
+ core_cm0plus.h
+ core_cm3.h
+ core_cm4.h
+
+targets/cmsis/TARGET_<vendor>/TARGET_<chip>/
+ <chip>.h
+ system_<chip>.[ch]
+ cmsis.h 
+ cmsis_nvic.[ch]
+
+targets/cmsis/TARGET_<vendor>/TARGET_<chip>/TOOLSCHAIN_<tool>/
+ startup_<chip>.s
+ linker-script
+
+
+
+Infinity
+========
+Massdrop Infinity Keyboard:
+https://www.massdrop.com/buy/infinity-keyboard-kit
+
+Freescale MK20DX128VLF5 48-QFP:
+http://cache.freescale.com/files/32bit/doc/data_sheet/K20P48M50SF0.pdf
+
+kiibohd controller(MD1):
+https://github.com/kiibohd/controller
+
+DFU bootloader:
+https://github.com/kiibohd/controller/tree/master/Bootloader
+
+Program with bootloader:
+ $ dfu-util -D kiibohd.dfu.bin
+
+Pinout:
+https://github.com/kiibohd/controller/blob/master/Scan/MD1/pinout
+
+
+
+Pin Usage
+=========
+
+mk20dx128vlf5
+
+ ----
+|Keys|
+ ----
+
+* Strobe (Columns)
+
+PTB0
+PTB1
+PTB2
+PTB3
+PTB16
+PTB17
+PTC4
+PTC5
+PTD0
+
+
+* Sense (Rows)
+
+PTD1
+PTD2
+PTD3
+PTD4
+PTD5
+PTD6
+PTD7
+
+
+ -----
+|Debug|
+ -----
+
+* SWD
+
+PTA0 (Pull-down)
+PTA3 (Pull-up)
+
+* LEDs
+
+PTA19 (LED only for PCB, not McHCK) (XTAL)
+
+* UARTs
+
+PTA1 - RX0
+PTA2 - TX0
+
+
+ ------
+|Unused|
+ ------
+
+* GPIO
+
+PTA1 (Not broken out on PCB, available on McHCK) (Pull-up)
+PTA2 (")
+PTA4 (Pull-up)
+PTA18 (EXTAL)
+
+PTC0
+PTC1
+PTC2
+PTC3
+PTC6
+PTC7
+
+* Analog
+
+ADC0_DP0
+ADC0_DM0
+
+
+
+Freescale kinetis MK20DX128
+===========================
+If FSEC of flash config at 0x400-40F is changed accidentally SWD/JTAG debug access will be lost and very difficult to get back.
+For example, high level adapter like stlink cannot work to get access back after FSEC is changed. To regain the chip to be programmable low level DAP inteface like JTAG, CMSIS-DAP or OpenSAD.
+
+
+Memory map
+==========
+kiibohd bootloader: Lib/mk20dx128vlf5.bootloader.ld
+0x0000_0000 +-------------------+ -----------------+---------------+
+ | .vectors | ---------. | StackPointer0 |
+ | .startup | \ | ResetHandler1 |
+ | .rodata | \ | ... |
+0x0000_0400 | .flashconfig | 0x10 \ | ... |
+ | .text | \ | ... 61 | 0xF7
+ | .init | `--+---------------+ 0xF8
+0x0000_1000 +-------------------+ 4KB
+ | _app_rom |
+ ~ ~
+ ~ ~
+ | |
+0x07FF_FFFF +-------------------+ 128KB
+
+
+0x1FFF_E000 +-------------------+
+ | |
+ | RAM |
+ | 8KB|
+0x2000_0000 +-------------------+
+ | |
+ | RAM |
+ | 8KB|
+0x2000_2000 +-------------------+ _estack
+
+
+
+
+
+OpenOCD
+========
+Synopsis of SWD, JTAG and SWJ-DP transport:
+https://fedcsis.org/proceedings/2012/pliks/279.pdf
+
+OpenSDA Freescale: Mass storage bootloader & serial port; part of CMSIS-DAP?
+http://cache.freescale.com/files/32bit/doc/user_guide/OPENSDAUG.pdf
+
+
+interface_list:
+ 1: ftdi
+ 2: usb_blaster
+ 3: usbprog
+ 4: jlink
+ 5: vsllink
+ 6: rlink
+ 7: ulink
+ 8: arm-jtag-ew
+ 9: hla
+ 10: osbdm
+ 11: opendous
+ 12: aice
+ 13: cmsis-dap
+
+transport list:
+ stlink_swim
+ hla_jtag
+ hla_swd
+ aice_jtag
+ swd
+ cmsis-dap
+ jtag
+
+target types:
+ arm7tdmi
+ arm9tdmi
+ arm920t
+ arm720t
+ arm966e
+ arm946e
+ arm926ejs
+ fa526
+ feroceon
+ dragonite
+ xscale
+ cortex_m
+ cortex_a
+ cortex_r4
+ arm11
+ mips_m4k
+ avr
+ dsp563xx
+ dsp5680xx
+ testee
+ avr32_ap7k
+ hla_target
+ nds32_v2
+ nds32_v3
+ nds32_v3m
+ or1k
+ quark_x10xx
+
+
+TAP
+---
+http://openocd.sourceforge.net/doc/html/TAP-Declaration.html#TAP-Declaration
+ jtag newtap chipname tapname configparams...
+ hla newtap chipname tapname configparams...
+ swd newtap chipname tapname configparams...
+ cmsis-dap newtap chipname tapname configparams...
+
+ The tapname reflects the role of that TAP, and should follow this convention:
+ bs – For boundary scan if this is a separate TAP;
+ cpu – The main CPU of the chip, alternatively arm and dsp on chips with both ARM and DSP CPUs, arm1 and arm2 on chips with two ARMs, and so forth;
+ etb – For an embedded trace buffer (example: an ARM ETB11);
+ flash – If the chip has a flash TAP, like the str912;
+ jrc – For JTAG route controller (example: the ICEPick modules on many Texas Instruments chips, like the OMAP3530 on Beagleboards);
+ tap – Should be used only for FPGA- or CPLD-like devices with a single TAP;
+ unknownN – If you have no idea what the TAP is for (N is a number);
+ when in doubt – Use the chip maker's name in their data sheet. For example, the Freescale i.MX31 has a SDMA (Smart DMA) with a JTAG TAP; that TAP should be named sdma.
+
+-irlen NUMBER
+The length in bits of the instruction register, such as 4 or 5 bits.
+
+Target
+------
+http://openocd.sourceforge.net/doc/html/CPU-Configuration.html#CPU-Configuration
+
+ target create target_name type configparams...
+ $target_name configure configparams...
+
+ -chain-position dotted.name – names the TAP used to access this target.
+ -endian (big|little) – specifies whether the CPU uses big or little endian conventions
+ -event event_name event_body – See Target Events. Note that this updates a list of named event handlers. Calling this twice with two different event names assigns two different handlers, but calling it twice with the same event name assigns only one handler.
+ -work-area-backup (0|1) – says whether the work area gets backed up; by default, it is not backed up. When possible, use a working_area that doesn't need to be backed up, since performing a backup slows down operations. For example, the beginning of an SRAM block is likely to be used by most build systems, but the end is often unused.
+ -work-area-size size – specify work are size, in bytes. The same size applies regardless of whether its physical or virtual address is being used.
+ -work-area-phys address – set the work area base address to be used when no MMU is active.
+ -work-area-virt address – set the work area base address to be used when an MMU is active. Do not specify a value for this except on targets with an MMU. The value should normally correspond to a static mapping for the -work-area-phys address, set up by the current operating system.
+ -rtos rtos_type – enable rtos support for target, rtos_type can be one of auto|eCos|ThreadX| FreeRTOS|linux|ChibiOS|embKernel See RTOS Support.
+
+Flash
+-----
+http://openocd.sourceforge.net/doc/html/Flash-Commands.html#norconfiguration
+
+ flash bank name driver base size chip_width bus_width target [driver_options]
+
+ name ... may be used to reference the flash bank in other flash commands. A number is also available.
+ driver ... identifies the controller driver associated with the flash bank being declared. This is usually cfi for external flash, or else the name of a microcontroller with embedded flash memory. See Flash Driver List.
+ base ... Base address of the flash chip.
+ size ... Size of the chip, in bytes. For some drivers, this value is detected from the hardware.
+ chip_width ... Width of the flash chip, in bytes; ignored for most microcontroller drivers.
+ bus_width ... Width of the data bus used to access the chip, in bytes; ignored for most microcontroller drivers.
+ target ... Names the target used to issue commands to the flash controller.
+ driver_options ... drivers may support, or require, additional parameters. See the driver-specific documentation for more information.
+
+ flash write_image [erase] [unlock] filename [offset] [type]
+
+
+Memory Access
+-------------
+http://openocd.sourceforge.net/doc/html/General-Commands.html#imageaccess
+ {mdw,mdh,mdb} addr [count]
+ dump {word, half-word, byte} data
+ {mww,mwh,mwb} addr data
+ write data
+
diff --git a/keyboard/infinity/Makefile b/keyboard/infinity/Makefile
new file mode 100644
index 0000000000..ec9dc00278
--- /dev/null
+++ b/keyboard/infinity/Makefile
@@ -0,0 +1,30 @@
+PROJECT = infinity
+
+TMK_DIR = ../..
+MBED_DIR = $(TMK_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)/main.o
+
+CONFIG_H = config.h
+
+INCLUDE_PATHS = -I.
+
+
+# Build Options
+# Comment out to disable
+#BOOTMAGIC_ENABLE = yes
+#MOUSEKEY_ENABLE = yes
+
+
+include $(TMK_DIR)/tool/mbed/mk20d50m.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/infinity/config.h b/keyboard/infinity/config.h
new file mode 100644
index 0000000000..28f2ca0293
--- /dev/null
+++ b/keyboard/infinity/config.h
@@ -0,0 +1,39 @@
+/*
+Copyright 2014 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#if 0
+// duplicated name against mbed USBDeivce
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0x3BED
+#endif
+#define DEVICE_VER 0x0001
+#define MANUFACTURER tmk.
+#define PRODUCT Infinitiy
+#define DESCRIPTION Massdrop Infinity keyboard firmware by tmk
+
+
+/* matrix size */
+#define MATRIX_ROWS 9 // Strobe
+#define MATRIX_COLS 7 // Sense
+
+/* key combination for command */
+#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
+
+#endif
diff --git a/keyboard/infinity/infinity.ld b/keyboard/infinity/infinity.ld
new file mode 100644
index 0000000000..5f699a536f
--- /dev/null
+++ b/keyboard/infinity/infinity.ld
@@ -0,0 +1,156 @@
+/*
+ * Linker script for Massdrop Infinity
+ * Infinity has bootloader in top 4KB sector of flash and app should be placed after the area.
+ *
+ * based on mbed.org K20 ARM GCC linker script file: MK20D5.ld
+ */
+
+MEMORY
+{
+ /* Infinity blootloader uses 4KB */
+ FLASH (rx) : ORIGIN = 4K, LENGTH = 128K - 4K
+ RAM (rwx) : ORIGIN = 0x1FFFE000, LENGTH = 16K
+}
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ * _reset_init : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ * __exidx_start
+ * __exidx_end
+ * __etext
+ * __data_start__
+ * __preinit_array_start
+ * __preinit_array_end
+ * __init_array_start
+ * __init_array_end
+ * __fini_array_start
+ * __fini_array_end
+ * __data_end__
+ * __bss_start__
+ * __bss_end__
+ * __end__
+ * end
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+ .text :
+ {
+ __vector_table = .;
+ KEEP(*(.isr_vector))
+ *(.text.Reset_Handler)
+ *(.text.System_Init)
+ . = ALIGN(4);
+
+ *(.text*)
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ *(.rodata*)
+
+ KEEP(*(.eh_frame*))
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > FLASH
+
+ __exidx_start = .;
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > FLASH
+ __exidx_end = .;
+
+ __etext = .;
+
+ .data : AT (__etext)
+ {
+ __data_start__ = .;
+ *(vtable)
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP(*(.preinit_array))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP(*(SORT(.init_array.*)))
+ KEEP(*(.init_array))
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP(*(SORT(.fini_array.*)))
+ KEEP(*(.fini_array))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+
+ } > RAM
+
+ .bss :
+ {
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ __bss_end__ = .;
+ } > RAM
+
+ .heap :
+ {
+ __end__ = .;
+ end = __end__;
+ *(.heap*)
+ __HeapLimit = .;
+ } > RAM
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy :
+ {
+ *(.stack)
+ } > RAM
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(RAM) + LENGTH(RAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
+}
diff --git a/keyboard/infinity/main.cpp b/keyboard/infinity/main.cpp
new file mode 100644
index 0000000000..7db59cdfb9
--- /dev/null
+++ b/keyboard/infinity/main.cpp
@@ -0,0 +1,29 @@
+//#include "mbed.h"
+#include "MK20D5.h"
+#include "wait.h"
+#include "gpio_api.h"
+#include "PinNames.h"
+
+
+//DigitalOut led(PTA19);
+
+int main() {
+ gpio_t led;
+ gpio_init_out(&led, PTA19);
+ while(1) {
+ gpio_write(&led, 1);
+ wait_ms(500);
+ gpio_write(&led, 0);
+ wait_ms(500);
+ }
+/*
+ SIM->SCGC6 |= SIM_SCGC5_PORTA_MASK;
+ PORTA->PCR[19] = PORT_PCR_SRE_MASK | PORT_PCR_DSE_MASK | PORT_PCR_MUX(1);
+ PTA->PDDR |= (1<<19);
+ PTA->PSOR |= (1<<19);
+ while(1) {
+ PTA->PTOR |= (1<<19);
+ wait_ms(500);
+ }
+*/
+}