1
0

Merge remote-tracking branch 'upstream/master'

Conflicts:
	common/avr/suspend.c
This commit is contained in:
Kai Ryu 2015-04-07 14:57:03 +09:00
commit ee163c66ab
33 changed files with 309 additions and 160 deletions

6
.gitmodules vendored
View File

@ -1,6 +1,6 @@
[submodule "protocol/usb_hid/USB_Host_Shield_2.0"]
path = protocol/usb_hid/USB_Host_Shield_2.0
url = git@github.com:tmk/USB_Host_Shield_2.0.git
[submodule "protocol/lufa/LUFA-git"]
path = protocol/lufa/LUFA-git
url = https://github.com/abcminiuser/lufa.git
[submodule "protocol/usb_hid/USB_Host_Shield_2.0"]
path = protocol/usb_hid/USB_Host_Shield_2.0
url = https://github.com/felis/USB_Host_Shield_2.0.git

View File

@ -53,6 +53,16 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
* [macway](keyboard/macway/) - [Compact keyboard mod][GH_macway] [retired]
* [KMAC](keyboard/kmac/) - Korean custom keyboard
* [Lightsaber](keyboard/lightsaber/) - Korean custom keyboard
* [Infinity](keyboard/infinity/) - Massdrop [Infinity keyboard][Infinity]
* [NerD](keyboard/nerd/) - Korean custom keyboard
* [KittenPaw](keyboard/kitten_paw) - Custom Majestouch controller
* [Lightpad](keyboard/lightpad) - Korean custom keypad
* [ghost_squid](keyboard/ghost_squid/) - [The Ghost Squid][ghost_squid] controller for [Cooler Master QuickFire XT][cmxt]
### Extenal projects using tmk_keyboard
* [ErgoDox_cub-uanic][cub-uanic] - Split Ergonomic Keyboard [ErgoDox][ergodox_org]
* [mcdox][mcdox_tmk] - [mcdox][mcdox]
[GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930
[GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047
@ -72,6 +82,13 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
[PC98]: http://en.wikipedia.org/wiki/NEC_PC-9801
[Sun]: http://en.wikipedia.org/wiki/Sun-3
[IIGS]: http://en.wikipedia.org/wiki/Apple_IIGS
[Infinity]: https://www.massdrop.com/buy/infinity-keyboard-kit
[ghost_squid]: http://deskthority.net/wiki/Costar_replacement_controllers#The_Ghost_Squid
[cmxt]: http://gaming.coolermaster.com/en/products/keyboards/quickfirext/
[ergodox_org]: http://ergodox.org/
[cub-uanic]: https://github.com/cub-uanic/tmk_keyboard/tree/master/keyboard/ergodox
[mcdox]: https://github.com/DavidMcEwan/mcdox
[mcdox_tmk]: https://github.com/DavidMcEwan/tmk_keyboard/tree/master/keyboard/mcdox
@ -276,4 +293,4 @@ Coding Style
Other Keyboard Firmware Projects
------------------
See [doc/other_projects.md](doc/other_projects.md).
You can learn a lot about keyboard firmware from these. See [doc/other_projects.md](doc/other_projects.md).

View File

@ -8,6 +8,7 @@
#include "softpwm_led.h"
#include "suspend_avr.h"
#include "suspend.h"
#include "timer.h"
#ifdef PROTOCOL_LUFA
#include "lufa.h"
#endif
@ -52,11 +53,13 @@ void suspend_idle(uint8_t time)
* WDTO_4S
* WDTO_8S
*/
void suspend_power_down(uint8_t wdto)
static uint8_t wdt_timeout = 0;
static void power_down(uint8_t wdto)
{
#ifdef PROTOCOL_LUFA
if (USB_DeviceState == DEVICE_STATE_Configured) return;
#endif
wdt_timeout = wdto;
// Watchdog Interrupt Mode
wdt_intr_enable(wdto);
@ -86,6 +89,11 @@ void suspend_power_down(uint8_t wdto)
wdt_disable();
}
void suspend_power_down(void)
{
power_down(WDTO_15MS);
}
bool suspend_wakeup_condition(void)
{
matrix_power_up();
@ -114,16 +122,14 @@ void suspend_wakeup_init(void)
/* watchdog timeout */
ISR(WDT_vect)
{
/* wakeup from MCU sleep mode */
/*
// blink LED
static uint8_t led_state = 0;
static uint8_t led_count = 0;
led_count++;
if ((led_count & 0x07) == 0) {
led_set((led_state ^= (1<<USB_LED_CAPS_LOCK)));
// compensate timer for sleep
switch (wdt_timeout) {
case WDTO_15MS:
timer_count += 15 + 2; // WDTO_15MS + 2(from observation)
break;
default:
;
}
*/
}
#endif

View File

@ -194,6 +194,7 @@ static bool command_common(uint8_t code)
case KC_CAPSLOCK:
if (host_get_driver()) {
host_driver = host_get_driver();
clear_keyboard();
host_set_driver(0);
print("Locked.\n");
} else {
@ -562,12 +563,12 @@ static void mousekey_console_help(void)
print("4: select mk_time_to_max\n");
print("5: select mk_wheel_max_speed\n");
print("6: select mk_wheel_time_to_max\n");
print("p: print prameters\n");
print("p: print parameters\n");
print("d: set default values\n");
print("up: increase prameters(+1)\n");
print("down: decrease prameters(-1)\n");
print("pgup: increase prameters(+10)\n");
print("pgdown: decrease prameters(-10)\n");
print("up: increase parameters(+1)\n");
print("down: decrease parameters(-1)\n");
print("pgup: increase parameters(+10)\n");
print("pgdown: decrease parameters(-10)\n");
print("\nspeed = delta * max_speed * (repeat / time_to_max)\n");
print("where delta: cursor="); pdec(MOUSEKEY_MOVE_DELTA);
print(", wheel="); pdec(MOUSEKEY_WHEEL_DELTA); print("\n");

View File

@ -140,6 +140,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KC_VOLD KC_AUDIO_VOL_DOWN
#define KC_MNXT KC_MEDIA_NEXT_TRACK
#define KC_MPRV KC_MEDIA_PREV_TRACK
#define KC_MFFD KC_MEDIA_FAST_FORWARD
#define KC_MRWD KC_MEDIA_REWIND
#define KC_MSTP KC_MEDIA_STOP
#define KC_MPLY KC_MEDIA_PLAY_PAUSE
#define KC_MSEL KC_MEDIA_SELECT
@ -420,7 +422,9 @@ enum internal_special_keycodes {
KC_WWW_FORWARD,
KC_WWW_STOP,
KC_WWW_REFRESH,
KC_WWW_FAVORITES, /* 0xBA */
KC_WWW_FAVORITES,
KC_MEDIA_FAST_FORWARD,
KC_MEDIA_REWIND, /* 0xBC */
/* Fn key */
KC_FN0 = 0xC0,

View File

@ -35,6 +35,10 @@ typedef uint32_t matrix_row_t;
#define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1<<col))
#ifdef __cplusplus
extern "C" {
#endif
/* number of matrix rows */
uint8_t matrix_rows(void);
/* number of matrix columns */
@ -57,5 +61,8 @@ void matrix_print(void);
void matrix_power_up(void);
void matrix_power_down(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -6,6 +6,10 @@
#define STRING_STACK_LIMIT 120
//TODO
int xprintf(const char* format, ...) { return 0; }
#if 0
/* mbed Serial */
Serial ser(UART_TX, UART_RX);
@ -44,3 +48,4 @@ int xprintf(const char* format, ...)
return r;
*/
}
#endif

View File

@ -22,13 +22,14 @@
* THE SOFTWARE.
*/
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <stdint.h>
#include "print.h"
#ifndef NO_PRINT
#if defined(__AVR__)
#define sendchar(c) xputc(c)
@ -37,4 +38,11 @@ void print_set_sendchar(int8_t (*sendchar_func)(uint8_t))
xdev_out(sendchar_func);
}
#elif defined(__arm__)
// TODO
//void print_set_sendchar(int8_t (*sendchar_func)(uint8_t)) { }
#endif
#endif

View File

@ -38,12 +38,7 @@
#if defined(__AVR__)
#include "avr/xprintf.h"
// TODO: avoid collision with arduino/Print.h
#ifndef __cplusplus
#define print(s) xputs(PSTR(s))
#endif
#define println(s) xputs(PSTR(s "\r\n"))
#ifdef __cplusplus

View File

@ -61,6 +61,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* supplement for Bluegiga iWRAP HID(not supported by Windows?) */
#define AL_LOCK 0x019E
#define TRANSPORT_RECORD 0x00B2
#define TRANSPORT_FAST_FORWARD 0x00B3
#define TRANSPORT_REWIND 0x00B4
#define TRANSPORT_EJECT 0x00B8
#define AC_MINIMIZE 0x0206
@ -158,6 +159,8 @@ typedef struct {
(key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \
(key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : \
(key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : \
(key == KC_MEDIA_FAST_FORWARD ? TRANSPORT_FAST_FORWARD : \
(key == KC_MEDIA_REWIND ? TRANSPORT_REWIND : \
(key == KC_MEDIA_STOP ? TRANSPORT_STOP : \
(key == KC_MEDIA_EJECT ? TRANSPORT_STOP_EJECT : \
(key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : \
@ -171,7 +174,7 @@ typedef struct {
(key == KC_WWW_FORWARD ? AC_FORWARD : \
(key == KC_WWW_STOP ? AC_STOP : \
(key == KC_WWW_REFRESH ? AC_REFRESH : \
(key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0)))))))))))))))))))
(key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0)))))))))))))))))))))
#ifdef __cplusplus
}

View File

@ -6,7 +6,7 @@
void suspend_idle(uint8_t timeout);
void suspend_power_down(uint8_t timeout);
void suspend_power_down(void);
bool suspend_wakeup_condition(void);
void suspend_wakeup_init(void);

View File

@ -81,7 +81,7 @@ KC_F12 45 Keyboard F12
KC_PSCREEN KC_PSCR 46 Keyboard PrintScreen1
KC_SCKLOCK KC_SLCK 47 Keyboard Scroll Lock11
KC_PAUSE KC_PAUS 48 Keyboard Pause1
KC_INSERT KC_INT 49 Keyboard Insert1
KC_INSERT KC_INS 49 Keyboard Insert1
KC_HOME 4A Keyboard Home1
KC_PGUP 4B Keyboard PageUp1
KC_DELETE KC_DELETE 4C Keyboard Delete Forward

View File

@ -29,6 +29,7 @@ Other Keyboard Firmware Projects
## ErgoDox[Ergo][Split][USB][AVR]
- <http://geekhack.org/index.php?topic=22780.0>
- <https://github.com/benblazak/ergodox-firmware>
- <https://github.com/cub-uanic/tmk_keyboard>
## Suka's keyboard collection[Ergo][Split][3DPrinting][USB][AVR]
- <http://deskthority.net/workshop-f7/my-diy-keyboard-collection-or-how-i-became-a-kb-geek-t2534.html>

View File

@ -15,11 +15,13 @@ endif
ifdef PS2_USE_INT
SRC += protocol/ps2_interrupt.c
SRC += protocol/ps2_io_avr.c
OPT_DEFS += -DPS2_USE_INT
endif
ifdef PS2_USE_USART
SRC += protocol/ps2_usart.c
SRC += protocol/ps2_io_avr.c
OPT_DEFS += -DPS2_USE_USART
endif

View File

@ -360,7 +360,7 @@ Commands
3: mice
Registers:
0: application(keyobard uses this to store its data.)
0: application(keyboard uses this to store its data.)
1: application
2: application(keyboard uses this for LEDs and state of modifiers)
3: status and command

View File

@ -36,7 +36,7 @@ static void bluefruit_serial_send(uint8_t);
void bluefruit_keyboard_print_report(report_keyboard_t *report)
{
if (!debug_keyboard) return;
dprintf("keys: "); for (int i = 0; i < REPORT_KEYS; i++) { debug_hex8(report->keys[i]); dprintf(" "); }
dprintf("keys: "); for (int i = 0; i < KEYBOARD_REPORT_KEYS; i++) { debug_hex8(report->keys[i]); dprintf(" "); }
dprintf(" mods: "); debug_hex8(report->mods);
dprintf(" reserved: "); debug_hex8(report->reserved);
dprintf("\n");
@ -99,7 +99,7 @@ static void send_keyboard(report_keyboard_t *report)
bluefruit_trace_header();
#endif
bluefruit_serial_send(0xFD);
for (uint8_t i = 0; i < REPORT_SIZE; i++) {
for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) {
bluefruit_serial_send(report->raw[i]);
}
#ifdef BLUEFRUIT_TRACE_SERIAL

View File

@ -148,8 +148,10 @@ static void Console_Task(void)
*/
void EVENT_USB_Device_Connect(void)
{
print("[C]");
/* For battery powered device */
if (!USB_IsInitialized) {
USB_Disable();
USB_Init();
USB_Device_EnableSOFEvents();
}
@ -157,7 +159,9 @@ void EVENT_USB_Device_Connect(void)
void EVENT_USB_Device_Disconnect(void)
{
print("[D]");
/* For battery powered device */
USB_IsInitialized = false;
/* TODO: This doesn't work. After several plug in/outs can not be enumerated.
if (USB_IsInitialized) {
USB_Disable(); // Disable all interrupts
@ -169,10 +173,13 @@ void EVENT_USB_Device_Disconnect(void)
void EVENT_USB_Device_Reset(void)
{
print("[R]");
}
void EVENT_USB_Device_Suspend()
{
print("[S]");
matrix_power_down();
#ifdef SLEEP_LED_ENABLE
sleep_led_enable();
#endif
@ -180,6 +187,7 @@ void EVENT_USB_Device_Suspend()
void EVENT_USB_Device_WakeUp()
{
print("[W]");
suspend_wakeup_init();
#ifdef SLEEP_LED_ENABLE
@ -489,37 +497,28 @@ int8_t sendchar(uint8_t c)
uint8_t ep = Endpoint_GetCurrentEndpoint();
Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM);
if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) {
Endpoint_SelectEndpoint(ep);
return -1;
goto ERROR_EXIT;
}
if (timeouted && !Endpoint_IsReadWriteAllowed()) {
Endpoint_SelectEndpoint(ep);
return - 1;
goto ERROR_EXIT;
}
timeouted = false;
uint8_t timeout = SEND_TIMEOUT;
uint16_t prevFN = USB_Device_GetFrameNumber();
while (!Endpoint_IsReadWriteAllowed()) {
switch (USB_DeviceState) {
case DEVICE_STATE_Unattached:
case DEVICE_STATE_Suspended:
return -1;
if (USB_DeviceState != DEVICE_STATE_Configured) {
goto ERROR_EXIT;
}
if (Endpoint_IsStalled()) {
Endpoint_SelectEndpoint(ep);
return -1;
goto ERROR_EXIT;
}
if (prevFN != USB_Device_GetFrameNumber()) {
if (!(timeout--)) {
timeouted = true;
Endpoint_SelectEndpoint(ep);
return -1;
}
prevFN = USB_Device_GetFrameNumber();
goto ERROR_EXIT;
}
_delay_ms(1);
}
Endpoint_Write_8(c);
@ -530,6 +529,9 @@ int8_t sendchar(uint8_t c)
Endpoint_SelectEndpoint(ep);
return 0;
ERROR_EXIT:
Endpoint_SelectEndpoint(ep);
return -1;
}
#else
int8_t sendchar(uint8_t c)
@ -587,7 +589,8 @@ int main(void)
print("Keyboard start.\n");
while (1) {
while (USB_DeviceState == DEVICE_STATE_Suspended) {
suspend_power_down(WDTO_120MS);
print("[s]");
suspend_power_down();
if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
USB_Device_SendRemoteWakeup();
}

View File

@ -502,8 +502,10 @@ MODEL NUMBER:
Scan Code
---------
m0110_recv_key() function returns following scan codes instead of raw key events.
Scan codes are 1 byte long and MSB(bit7) is set when key is released.
m0110_recv_key() function returns following scan codes instead of M0110 raw codes.
Scan codes are 1 byte size and MSB(bit7) is set when key is released.
scancode = ((raw&0x80) | ((raw&0x7F)>>1))
M0110 M0120
,---------------------------------------------------------. ,---------------.
@ -529,6 +531,19 @@ Scan Code
| 3A| 37| 31 | 34| 3A| | 52| 41| |
`------------------------------------------------' `---------------'
International keyboard(See page 22 of "Technical Info for 128K/512K")
,---------------------------------------------------------.
| 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33|
|---------------------------------------------------------|
| 30| 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| 2A|
|------------------------------------------------------ |
| 39| 00| 01| 02| 03| 05| 04| 26| 28| 25| 29| 27| 24| |
|---------------------------------------------------------|
| 38| 06| 07| 08| 09| 0B| 2D| 2E| 2B| 2F| 2C| 0A| 38|
`---------------------------------------------------------'
| 3A| 37| 34 | 31| 3A|
`------------------------------------------------'
M0110A
,---------------------------------------------------------. ,---------------.
| `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Bcksp| |Clr| =| /| *|
@ -568,7 +583,7 @@ Connector:
Signaling:
http://www.kbdbabel.org/signaling/kbd_signaling_mac.png
http://typematic.blog.shinobi.jp/Entry/14/
Scan Codes:
M0110 raw scan codes:
Page 22 of Tech Info for 128K/512K
Page 07 of Tech Info for Plus
http://m0115.web.fc2.com/m0110.jpg

25
protocol/pjrc/MEMO.txt Normal file
View File

@ -0,0 +1,25 @@
Endpoint configuration
----------------------
0 Control endpoint
1 keyboard
2 mouse
3 debug
4 extra key(consumer/system)
5 nkro keyboard(supported only on ATmega32U4/16U4 and AT90USB64/128)
ATmega32U4/16U4, AT90USB64/128
• Endpoint 0:programmable size FIFO up to 64 bytes, default control endpoint
• Endpoints 1 programmable size FIFO up to 256 bytes in ping-pong mode.
• Endpoints 2 to 6: programmable size FIFO up to 64 bytes in ping-pong mode.
AT90USB82/162, ATmega8U2/16U2/32U2
• Endpoint 0:programmable size FIFO up to 64 bytes, default control endpoint
• Endpoints 1 and 2: programmable size FIFO up to 64 bytes.
• Endpoints 3 and 4: programmable size FIFO up to 64 bytes with ping-pong mode.
ping-pong mode means double buffer feature.
NOTE: ATmega8U2/16U2/32U2 is not supported with PJRC stack at this time.
TODO: Macro definition for ATmega8U2/16U2/32U2 in usb.h

View File

@ -24,6 +24,7 @@
#include <stdbool.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <util/delay.h>
#include "keyboard.h"
#include "usb.h"

View File

@ -122,7 +122,7 @@ void usb_remote_wakeup(void);
#define KBD_INTERFACE 0
#define KBD_ENDPOINT 1
#define KBD_SIZE 8
#define KBD_BUFFER EP_DOUBLE_BUFFER
#define KBD_BUFFER EP_SINGLE_BUFFER
#define KBD_REPORT_KEYS (KBD_SIZE - 2)
// secondary keyboard

View File

@ -74,7 +74,7 @@ void usb_keyboard_print_report(report_keyboard_t *report)
{
if (!debug_keyboard) return;
print("keys: ");
for (int i = 0; i < REPORT_KEYS; i++) { phex(report->keys[i]); print(" "); }
for (int i = 0; i < KEYBOARD_REPORT_KEYS; i++) { phex(report->keys[i]); print(" "); }
print(" mods: "); phex(report->mods); print("\n");
}

View File

@ -32,7 +32,7 @@
#define MOUSE_INTERFACE 1
#define MOUSE_ENDPOINT 2
#define MOUSE_SIZE 8
#define MOUSE_BUFFER EP_DOUBLE_BUFFER
#define MOUSE_BUFFER EP_SINGLE_BUFFER
#define MOUSE_BTN1 (1<<0)
#define MOUSE_BTN2 (1<<1)

View File

@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <avr/interrupt.h>
#include <util/delay.h>
#include "ps2.h"
#include "ps2_io.h"
#include "print.h"

View File

@ -1,4 +1,5 @@
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
/* Check port settings for clock and data line */

View File

@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <avr/interrupt.h>
#include <util/delay.h>
#include "ps2.h"
#include "ps2_io.h"
#include "print.h"

View File

@ -8,6 +8,7 @@ USB_HOST_SHIELD_DIR = $(USB_HID_DIR)/USB_Host_Shield_2.0
USB_HOST_SHIELD_SRC = \
$(USB_HOST_SHIELD_DIR)/Usb.cpp \
$(USB_HOST_SHIELD_DIR)/hid.cpp \
$(USB_HOST_SHIELD_DIR)/usbhub.cpp \
$(USB_HOST_SHIELD_DIR)/parsetools.cpp \
$(USB_HOST_SHIELD_DIR)/message.cpp
@ -42,7 +43,7 @@ SRC += $(USB_HID_DIR)/override_Serial.cpp
# replace arduino/wiring.c
SRC += $(USB_HID_DIR)/override_wiring.c
SRC += common/timer.c
SRC += common/avr/timer.c
SRC += $(USB_HOST_SHIELD_SRC)
SRC += $(ARDUINO_CORES_SRC)

@ -1 +1 @@
Subproject commit 8bb790f83af298b5f3e5516259c9d8ec27efe522
Subproject commit 2b4a56de3d090686f62d25ea34042759dc4352d6

View File

@ -419,6 +419,11 @@ flip: $(TARGET).hex
batchisp -hardware usb -device $(MCU) -operation start reset 0
dfu: $(TARGET).hex
ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1)))
dfu-programmer $(MCU) erase --force
else
dfu-programmer $(MCU) erase
endif
dfu-programmer $(MCU) erase
dfu-programmer $(MCU) flash $(TARGET).hex
dfu-programmer $(MCU) reset

View File

@ -7,6 +7,8 @@ OBJECTS += \
$(OBJDIR)/common/host.o \
$(OBJDIR)/common/keymap.o \
$(OBJDIR)/common/keyboard.o \
$(OBJDIR)/common/print.o \
$(OBJDIR)/common/debug.o \
$(OBJDIR)/common/util.o \
$(OBJDIR)/common/mbed/suspend.o \
$(OBJDIR)/common/mbed/timer.o \

View File

@ -1,4 +1,6 @@
###############################################################################
# based on Makefile exported form mbed.org
# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
GCC_BIN =
AS = $(GCC_BIN)arm-none-eabi-as
CC = $(GCC_BIN)arm-none-eabi-gcc
@ -9,13 +11,21 @@ OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump
SIZE = $(GCC_BIN)arm-none-eabi-size
CHKSUM = $(TMK_DIR)/tool/mbed/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 \
-fomit-frame-pointer
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 = $(CPU) -Wl,--gc-sections --specs=nano.specs
#LD_FLAGS += -u _printf_float -u _scanf_float
LD_FLAGS += -Wl,-Map=$(OBJDIR)/$(PROJECT).map,--cref
LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
@ -25,7 +35,7 @@ else
CC_FLAGS += -DNDEBUG -Os
endif
all: $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).hex size
all: $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).hex
clean:
rm -f $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).elf $(OBJDIR)/$(PROJECT).hex $(OBJDIR)/$(PROJECT).map $(OBJDIR)/$(PROJECT).lst $(OBJECTS) $(DEPS)
@ -41,22 +51,21 @@ $(OBJDIR)/%.o: %.c
$(OBJDIR)/%.o: %.cpp
mkdir -p $(@D)
$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 $(INCLUDE_PATHS) -o $@ $<
$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(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 ""
$(SIZE) $@
$(OBJDIR)/$(PROJECT).bin: $(OBJDIR)/$(PROJECT).elf
@$(OBJCOPY) -O binary $< $@
@echo "Writing vector checksum value into $@ ..."
ifneq (,$(findstring TARGET_NXP,$(CC_SYMBOLS)))
@echo
@echo "For NXP writing vector checksum value into $@ ..."
@$(CHKSUM) $@
@echo
endif
$(OBJDIR)/$(PROJECT).hex: $(OBJDIR)/$(PROJECT).elf
@$(OBJCOPY) -O ihex $< $@

50
tool/mbed/lpc11u35_501.mk Normal file
View File

@ -0,0 +1,50 @@
# based on Makefile exported form mbed.org
# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
CPU = -mcpu=cortex-m0 -mthumb
CC_SYMBOLS = \
-DTARGET_LPC11U35_501 \
-DTARGET_M0 \
-DTARGET_CORTEX_M \
-DTARGET_NXP \
-DTARGET_LPC11UXX \
-DTARGET_MCU_LPC11U35_501 \
-DTOOLCHAIN_GCC_ARM \
-DTOOLCHAIN_GCC \
-D__CORTEX_M0 \
-DARM_MATH_CM0 \
-D__MBED__=1
OBJECTS += \
$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC11U.o \
$(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/TARGET_MCU_LPC11U35_501/PeripheralPins.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/i2c_api.o \
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.o \
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/port_api.o \
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.o \
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/serial_api.o \
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/sleep.o \
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/spi_api.o \
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/us_ticker.o
INCLUDE_PATHS += \
-I$(MBED_DIR)/libraries/mbed/targets \
-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_501 \
-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_MCU_LPC11U35_501 \
-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_MCU_LPC11U35_501/TARGET_LPC11U35_501
LINKER_SCRIPT = $(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_501/LPC11U35.ld

View File

@ -1,99 +1,85 @@
# based on Makefile exported form mbed.org
# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
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/us_ticker_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
$(OBJDIR)/libraries/USBDevice/USBDevice/USBDevice.o
# $(OBJDIR)/libraries/mbed/common/assert.o \
# $(OBJDIR)/libraries/mbed/common/board.o \
# $(OBJDIR)/libraries/mbed/common/BusIn.o \
# $(OBJDIR)/libraries/mbed/common/BusInOut.o \
# $(OBJDIR)/libraries/mbed/common/BusOut.o \
# $(OBJDIR)/libraries/mbed/common/CallChain.o \
# $(OBJDIR)/libraries/mbed/common/CAN.o \
# $(OBJDIR)/libraries/mbed/common/error.o \
# $(OBJDIR)/libraries/mbed/common/Ethernet.o \
# $(OBJDIR)/libraries/mbed/common/exit.o \
# $(OBJDIR)/libraries/mbed/common/FileBase.o \
# $(OBJDIR)/libraries/mbed/common/FileLike.o \
# $(OBJDIR)/libraries/mbed/common/FilePath.o \
# $(OBJDIR)/libraries/mbed/common/FileSystemLike.o \
# $(OBJDIR)/libraries/mbed/common/FunctionPointer.o \
# $(OBJDIR)/libraries/mbed/common/gpio.o \
# $(OBJDIR)/libraries/mbed/common/I2C.o \
# $(OBJDIR)/libraries/mbed/common/I2CSlave.o \
# $(OBJDIR)/libraries/mbed/common/InterruptIn.o \
# $(OBJDIR)/libraries/mbed/common/InterruptManager.o \
# $(OBJDIR)/libraries/mbed/common/LocalFileSystem.o \
# $(OBJDIR)/libraries/mbed/common/mbed_interface.o \
# $(OBJDIR)/libraries/mbed/common/pinmap_common.o \
# $(OBJDIR)/libraries/mbed/common/RawSerial.o \
# $(OBJDIR)/libraries/mbed/common/retarget.o \
# $(OBJDIR)/libraries/mbed/common/rtc_time.o \
# $(OBJDIR)/libraries/mbed/common/semihost_api.o \
# $(OBJDIR)/libraries/mbed/common/SerialBase.o \
# $(OBJDIR)/libraries/mbed/common/Serial.o \
# $(OBJDIR)/libraries/mbed/common/SPI.o \
# $(OBJDIR)/libraries/mbed/common/SPISlave.o \
# $(OBJDIR)/libraries/mbed/common/Stream.o \
# $(OBJDIR)/libraries/mbed/common/Ticker.o \
# $(OBJDIR)/libraries/mbed/common/Timeout.o \
# $(OBJDIR)/libraries/mbed/common/TimerEvent.o \
# $(OBJDIR)/libraries/mbed/common/Timer.o \
# $(OBJDIR)/libraries/mbed/common/us_ticker_api.o \
# $(OBJDIR)/libraries/mbed/common/wait_api.o \
# $(OBJDIR)/libraries/USBDevice/USBAudio/USBAudio.o \
# $(OBJDIR)/libraries/USBDevice/USBDevice/USBDevice.o \
# $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_KL25Z.o \
# $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC11U.o \
# $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC17.o \
# $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC40.o \
# $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_RZ_A1H.o \
# $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_STM32F4.o \
# $(OBJDIR)/libraries/USBDevice/USBHID/USBHID.o \
# $(OBJDIR)/libraries/USBDevice/USBHID/USBKeyboard.o \
# $(OBJDIR)/libraries/USBDevice/USBHID/USBMouseKeyboard.o \
# $(OBJDIR)/libraries/USBDevice/USBHID/USBMouse.o \
# $(OBJDIR)/libraries/USBDevice/USBMIDI/USBMIDI.o \
# $(OBJDIR)/libraries/USBDevice/USBMSD/USBMSD.o \
# $(OBJDIR)/libraries/USBDevice/USBSerial/USBCDC.o \
# $(OBJDIR)/libraries/USBDevice/USBSerial/USBSerial.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/mbed/hal \
-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/USBDevice \
-I$(MBED_DIR)/libraries/USBDevice/USBHID \
-I$(MBED_DIR)/libraries/USBDevice/USBMIDI \
-I$(MBED_DIR)/libraries/USBDevice/USBMSD \
-I$(MBED_DIR)/libraries/USBDevice/USBMIDI
-I$(MBED_DIR)/libraries/USBDevice/USBSerial
# TMK mbed protocol
OBJECTS += \
$(OBJDIR)/protocol/mbed/mbed_driver.o \
$(OBJDIR)/protocol/mbed/HIDKeyboard.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