From a9a3610dd4a168e473d2d6a2eb3fbc37aabb46c9 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 28 Jun 2012 16:51:56 +0900 Subject: Add LUFA mouse feature and fix mouse report. - add LUFA boot mouse feature - remove report_id from mouse report - fix LUFA descriptor --- common/report.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/report.h b/common/report.h index b85b86c5f8..45f5c0b881 100644 --- a/common/report.h +++ b/common/report.h @@ -82,15 +82,14 @@ typedef struct { uint8_t mods; uint8_t rserved; uint8_t keys[REPORT_KEYS]; -} report_keyboard_t; +} __attribute__ ((packed)) report_keyboard_t; typedef struct { - uint8_t report_id; uint8_t buttons; int8_t x; int8_t y; int8_t v; int8_t h; -} report_mouse_t; +} __attribute__ ((packed)) report_mouse_t; #endif -- cgit v1.2.3 From 3d81d5221eac9ca9620ba9043a250dcb8371b22e Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 28 Jun 2012 20:15:56 +0900 Subject: Add consumer/system control feature to LUFA. --- common/keyboard.c | 17 +++++------------ common/mousekey.c | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) (limited to 'common') diff --git a/common/keyboard.c b/common/keyboard.c index 5c2643c951..25f32eb02f 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -49,6 +49,7 @@ void keyboard_proc(void) uint8_t fn_bits = 0; #ifdef EXTRAKEY_ENABLE uint16_t consumer_code = 0; + uint16_t system_code = 0; #endif matrix_scan(); @@ -89,22 +90,13 @@ void keyboard_proc(void) #ifdef HOST_PJRC if (suspend && remote_wakeup) { usb_remote_wakeup(); - } else { - host_system_send(SYSTEM_POWER_DOWN); } -#else - host_system_send(SYSTEM_POWER_DOWN); #endif - host_system_send(0); - _delay_ms(500); + system_code = SYSTEM_POWER_DOWN; } else if (code == KB_SYSTEM_SLEEP) { - host_system_send(SYSTEM_SLEEP); - host_system_send(0); - _delay_ms(500); + system_code = SYSTEM_SLEEP; } else if (code == KB_SYSTEM_WAKE) { - host_system_send(SYSTEM_WAKE_UP); - host_system_send(0); - _delay_ms(500); + system_code = SYSTEM_WAKE_UP; } // Consumer Page else if (code == KB_AUDIO_MUTE) { @@ -173,6 +165,7 @@ void keyboard_proc(void) host_send_keyboard_report(); #ifdef EXTRAKEY_ENABLE host_consumer_send(consumer_code); + host_system_send(system_code); #endif #ifdef DEBUG_LED // LED flash for debug diff --git a/common/mousekey.c b/common/mousekey.c index 76bd0fd363..1d35355b49 100644 --- a/common/mousekey.c +++ b/common/mousekey.c @@ -121,12 +121,12 @@ void mousekey_clear_report(void) static void mousekey_debug(void) { if (!debug_mouse) return; - print("mousekey[btn|x y v h]: "); + print("mousekey [btn|x y v h]rep: ["); phex(report.buttons); print("|"); phex(report.x); print(" "); phex(report.y); print(" "); phex(report.v); print(" "); - phex(report.h); + phex(report.h); print("]"); phex(mousekey_repeat); print("\n"); } -- cgit v1.2.3 From a112f3614e0e3204ce35dcdfbf2723c3382c4c35 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 29 Jun 2012 16:48:36 +0900 Subject: confirm SetReport LED. --- common/command.c | 1 + common/host.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/command.c b/common/command.c index e325a5d847..13d37242d9 100644 --- a/common/command.c +++ b/common/command.c @@ -138,6 +138,7 @@ static uint8_t command_common(void) } break; case KB_S: + print("host_keyboard_leds:"); phex(host_keyboard_leds()); print("\n"); #ifdef HOST_PJRC print("UDCON: "); phex(UDCON); print("\n"); print("UDIEN: "); phex(UDIEN); print("\n"); diff --git a/common/host.c b/common/host.c index cc26d55c22..8dd2abbee8 100644 --- a/common/host.c +++ b/common/host.c @@ -168,13 +168,16 @@ void host_mouse_send(report_mouse_t *report) void host_system_send(uint16_t data) { + static uint16_t last_data = 0; + if (data == last_data) return; + last_data = data; + if (!driver) return; (*driver->send_system)(data); } void host_consumer_send(uint16_t data) { - // TODO: this is needed? static uint16_t last_data = 0; if (data == last_data) return; last_data = data; -- cgit v1.2.3 From f427529a30487de45ebfbe6fbba9c290738878ab Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 30 Jun 2012 11:19:07 +0900 Subject: Fix bootloader.c --- common/bootloader.c | 68 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 17 deletions(-) (limited to 'common') diff --git a/common/bootloader.c b/common/bootloader.c index 5cbfc72e5b..cb971c7043 100644 --- a/common/bootloader.c +++ b/common/bootloader.c @@ -1,22 +1,56 @@ -/* -Copyright 2011 Jun Wako - -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. +#include +#include +#include +#include "bootloader.h" -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. +/* Start Bootloader from Application + * See + * http://www.pjrc.com/teensy/jump_to_bootloader.html + * http://www.fourwalledcubicle.com/files/LUFA/Doc/120219/html/_page__software_bootloader_start.html + */ -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ +/* Boot Section Size in bytes + * Teensy halfKay 512 + * Atmel DFU loader 4096 + * LUFA bootloader 4096 + */ +#ifndef BOOT_SIZE +#define BOOT_SIZE 512 +#endif -#include "bootloader.h" +#define FLASH_SIZE (FLASHEND + 1) +#define BOOTLOADER_START (FLASHEND - BOOT_SIZE) +void bootloader_jump(void) { + cli(); + // disable watchdog, if enabled + // disable all peripherals + UDCON = 1; + USBCON = (1< Date: Sat, 30 Jun 2012 13:26:09 +0900 Subject: Add Makefile.lufa to keyboard/hhkb and hbkb. --- common/bootloader.c | 1 + 1 file changed, 1 insertion(+) (limited to 'common') diff --git a/common/bootloader.c b/common/bootloader.c index cb971c7043..e45295cd5f 100644 --- a/common/bootloader.c +++ b/common/bootloader.c @@ -9,6 +9,7 @@ * http://www.fourwalledcubicle.com/files/LUFA/Doc/120219/html/_page__software_bootloader_start.html */ +// TODO: support usbasp /* Boot Section Size in bytes * Teensy halfKay 512 * Atmel DFU loader 4096 -- cgit v1.2.3 From 6d79e6579f1b769f3547856b8af56bd357580adf Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 30 Jun 2012 14:44:14 +0900 Subject: Add support of USBasp bootloader. --- common/bootloader.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'common') diff --git a/common/bootloader.c b/common/bootloader.c index e45295cd5f..612b949648 100644 --- a/common/bootloader.c +++ b/common/bootloader.c @@ -24,12 +24,22 @@ void bootloader_jump(void) { cli(); + + // + //Teensy + // +#if defined(__AVR_AT90USB162__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) // disable watchdog, if enabled // disable all peripherals UDCON = 1; USBCON = (1<