diff --git a/Lib/Interrupts.h b/Lib/Interrupts.h index 943fdb9..127e344 100644 --- a/Lib/Interrupts.h +++ b/Lib/Interrupts.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 by Jacob Alexander +/* Copyright (C) 2013-2014 by Jacob Alexander * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,9 +29,9 @@ #define __INTERRUPTS_H // ARM -#if defined(_mk20dx128_) +#if defined(_mk20dx128_) || defined(_mk20dx256_) -#include +#include // AVR #elif defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) @@ -45,7 +45,7 @@ // ----- Defines ----- // ARM -#if defined(_mk20dx128_) +#if defined(_mk20dx128_) || defined(_mk20dx256_) // Map the Interrupt Enable/Disable to the AVR names #define cli() __disable_irq() diff --git a/Lib/MacroLib.h b/Lib/MacroLib.h index 8b92489..bc433da 100644 --- a/Lib/MacroLib.h +++ b/Lib/MacroLib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 by Jacob Alexander +/* Copyright (C) 2013-2014 by Jacob Alexander * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -34,9 +34,9 @@ // ARM -#if defined(_mk20dx128_) +#if defined(_mk20dx128_) || defined(_mk20dx256_) -#include +#include #include #include diff --git a/Lib/MainLib.h b/Lib/MainLib.h index b3aa20e..05d3999 100644 --- a/Lib/MainLib.h +++ b/Lib/MainLib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 by Jacob Alexander +/* Copyright (C) 2013-2014 by Jacob Alexander * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -34,9 +34,9 @@ // ARM -#if defined(_mk20dx128_) +#if defined(_mk20dx128_) || defined(_mk20dx256_) -#include +#include #include #endif diff --git a/Lib/USBLib.h b/Lib/OutputLib.h similarity index 90% rename from Lib/USBLib.h rename to Lib/OutputLib.h index 59b837c..594260f 100644 --- a/Lib/USBLib.h +++ b/Lib/OutputLib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 by Jacob Alexander +/* Copyright (C) 2013-2014 by Jacob Alexander * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,15 +24,15 @@ // Additional includes should only be added to this file if they should be added to *all* Scan modules. -#ifndef __USBLIB_H -#define __USBLIB_H +#ifndef __OUTPUTLIB_H +#define __OUTPUTLIB_H // ----- Includes ----- // ARM -#if defined(_mk20dx128_) +#if defined(_mk20dx128_) || defined(_mk20dx256_) -#include +#include #include #endif diff --git a/Lib/ScanLib.h b/Lib/ScanLib.h index d14b091..bff0ae7 100644 --- a/Lib/ScanLib.h +++ b/Lib/ScanLib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 by Jacob Alexander +/* Copyright (C) 2013-2014 by Jacob Alexander * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -34,9 +34,9 @@ // ARM -#if defined(_mk20dx128_) +#if defined(_mk20dx128_) || defined(_mk20dx256_) -#include +#include #include #include diff --git a/Lib/delay.c b/Lib/delay.c index 9e19b9b..2975f3e 100644 --- a/Lib/delay.c +++ b/Lib/delay.c @@ -1,6 +1,6 @@ #include "delay.h" -#include "mk20dx128.h" +#include "mk20dx.h" // the systick interrupt is supposed to increment this at 1 kHz rate volatile uint32_t systick_millis_count = 0; diff --git a/Lib/mk20dx128.c b/Lib/mk20dx.c similarity index 99% rename from Lib/mk20dx128.c rename to Lib/mk20dx.c index 0c75a90..c6f8750 100644 --- a/Lib/mk20dx128.c +++ b/Lib/mk20dx.c @@ -28,7 +28,7 @@ * SOFTWARE. */ -#include "mk20dx128.h" +#include "mk20dx.h" extern unsigned long _stext; diff --git a/Lib/mk20dx128.h b/Lib/mk20dx.h similarity index 99% rename from Lib/mk20dx128.h rename to Lib/mk20dx.h index 6de3a0c..b00c1f7 100644 --- a/Lib/mk20dx128.h +++ b/Lib/mk20dx.h @@ -28,8 +28,8 @@ * SOFTWARE. */ -#ifndef _mk20dx128_h_ -#define _mk20dx128_h_ +#ifndef _mk20dx_h_ +#define _mk20dx_h_ //#define F_CPU 96000000 //#define F_CPU 48000000 diff --git a/Lib/mk20dx256.ld b/Lib/mk20dx256.ld new file mode 100644 index 0000000..8b787b3 --- /dev/null +++ b/Lib/mk20dx256.ld @@ -0,0 +1,146 @@ +/* Teensyduino Core Library + * http://www.pjrc.com/teensy/ + * Copyright (c) 2013 PJRC.COM, LLC. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * 1. The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * 2. If the Software is incorporated into a build system that allows + * selection among a list of target devices, then similar target + * devices manufactured by PJRC.COM must be included in the list of + * target devices and selectable in the same manner. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K + RAM (rwx) : ORIGIN = 0x1FFF8000, LENGTH = 64K +} + + +/* INCLUDE common.ld */ + + +/* Teensyduino Core Library + * http://www.pjrc.com/teensy/ + * Copyright (c) 2013 PJRC.COM, LLC. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * 1. The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * 2. If the Software is incorporated into a build system that allows + * selection among a list of target devices, then similar target + * devices manufactured by PJRC.COM must be included in the list of + * target devices and selectable in the same manner. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + + + +SECTIONS +{ + .text : { + . = 0; + KEEP(*(.vectors)) + *(.startup*) + /* TODO: does linker detect startup overflow onto flashconfig? */ + . = 0x400; + KEEP(*(.flashconfig*)) + *(.text*) + *(.rodata*) + . = ALIGN(4); + KEEP(*(.init)) + . = ALIGN(4); + __preinit_array_start = .; + KEEP (*(.preinit_array)) + __preinit_array_end = .; + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; + } > FLASH = 0xFF + + .ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + __exidx_end = .; + } > FLASH + _etext = .; + + .usbdescriptortable (NOLOAD) : { + /* . = ORIGIN(RAM); */ + . = ALIGN(512); + *(.usbdescriptortable*) + } > RAM + + .dmabuffers (NOLOAD) : { + . = ALIGN(4); + *(.dmabuffers*) + } > RAM + + .usbbuffers (NOLOAD) : { + . = ALIGN(4); + *(.usbbuffers*) + } > RAM + + .data : AT (_etext) { + . = ALIGN(4); + _sdata = .; + *(.data*) + . = ALIGN(4); + _edata = .; + } > RAM + + .noinit (NOLOAD) : { + *(.noinit*) + } > RAM + + .bss : { + . = ALIGN(4); + _sbss = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + _ebss = .; + __bss_end = .; + } > RAM + + _estack = ORIGIN(RAM) + LENGTH(RAM); +} + + + + diff --git a/Output/pjrcUSB/arm/usb_dev.c b/Output/pjrcUSB/arm/usb_dev.c index 52c886b..1737367 100644 --- a/Output/pjrcUSB/arm/usb_dev.c +++ b/Output/pjrcUSB/arm/usb_dev.c @@ -28,7 +28,7 @@ * SOFTWARE. */ -#include +#include #include "usb_dev.h" #include "usb_mem.h" diff --git a/Output/pjrcUSB/arm/usb_keyboard.c b/Output/pjrcUSB/arm/usb_keyboard.c index 89d235b..6abcd41 100644 --- a/Output/pjrcUSB/arm/usb_keyboard.c +++ b/Output/pjrcUSB/arm/usb_keyboard.c @@ -30,7 +30,7 @@ #include "usb_dev.h" #include "usb_keyboard.h" -#include +#include #include // for memcpy() diff --git a/Output/pjrcUSB/arm/usb_mem.c b/Output/pjrcUSB/arm/usb_mem.c index 2ff8b64..9793e56 100644 --- a/Output/pjrcUSB/arm/usb_mem.c +++ b/Output/pjrcUSB/arm/usb_mem.c @@ -28,7 +28,7 @@ * SOFTWARE. */ -#include +#include #include "usb_dev.h" #include "usb_mem.h" diff --git a/Output/pjrcUSB/arm/usb_serial.c b/Output/pjrcUSB/arm/usb_serial.c index 3d47069..94d003e 100644 --- a/Output/pjrcUSB/arm/usb_serial.c +++ b/Output/pjrcUSB/arm/usb_serial.c @@ -30,7 +30,7 @@ #include "usb_dev.h" #include "usb_serial.h" -#include +#include #include // For memcpy // defined by usb_dev.h -> usb_desc.h diff --git a/Output/pjrcUSB/output_com.c b/Output/pjrcUSB/output_com.c index d39f9bf..78c797e 100644 --- a/Output/pjrcUSB/output_com.c +++ b/Output/pjrcUSB/output_com.c @@ -22,7 +22,7 @@ // ----- Includes ----- // Compiler Includes -#include +#include // Project Includes #include diff --git a/arm.cmake b/arm.cmake index 7fe1e05..aa2bdf1 100644 --- a/arm.cmake +++ b/arm.cmake @@ -1,6 +1,6 @@ ###| CMAKE Kiibohd Controller |### # -# Jacob Alexander 2011-2013 +# Jacob Alexander 2011-2014 # Due to this file's usefulness: # # Released into the Public Domain @@ -34,18 +34,31 @@ set( SIZE "arm-none-eabi-size" ) #| type "make clean" after changing this, so all files will be rebuilt #| #| "mk20dx128" # Teensy 3.0 +#| "mk20dx256" # Teensy 3.1 set( CHIP "mk20dx128" ) +#set( CHIP "mk20dx256" ) message( STATUS "Chip Selected:" ) message( "${CHIP}" ) set( MCU "${CHIP}" ) # For loading script compatibility +#| Chip Base Type +#| Automatically chosed based on the chip name. +if ( "${CHIP}" MATCHES "^mk20dx.*$" ) + set( CHIP_FAMILY "mk20dx" ) + message( STATUS "Chip Family:" ) + message( "${CHIP_FAMILY}" ) +else () + message( FATAL_ERROR "Unknown chip family: ${CHIP}" ) +endif () + + #| CPU Type #| You _MUST_ set this to match the board you are using #| type "make clean" after changing this, so all files will be rebuilt #| -#| "cortex-m4" # Teensy 3.0 +#| "cortex-m4" # Teensy 3.0, 3.1 set( CPU "cortex-m4" ) message( STATUS "CPU Selected:" ) @@ -55,7 +68,7 @@ message( "${CPU}" ) #| Extra Compiler Sources #| Mostly for convenience functions like interrupt handlers set( COMPILER_SRCS - Lib/${CHIP}.c + Lib/${CHIP_FAMILY}.c Lib/delay.c ) @@ -87,7 +100,7 @@ set( WARN "-Wall -g" ) set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar" ) -#| Optimization level, can be [0, 1, 2, 3, s]. +#| Optimization level, can be [0, 1, 2, 3, s]. #| 0 = turn off optimization. s = optimize for size. #| (Note: 3 is not always the best optimization level.) set( OPT "s" )