Merge branch 'master' into chibios

This commit is contained in:
flabbergast 2015-10-12 06:55:37 +01:00
commit b388269407
21 changed files with 148 additions and 39 deletions

View file

@ -266,7 +266,7 @@ enum layer_pram_tap_op {
#define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF)
#define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON)
#define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR)
#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xe0 | (mods)&0x0f)
#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xe0 | ((mods)&0x0f))
/* With Tapping */
#define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key))
#define ACTION_LAYER_TAP_TOGGLE(layer) ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE)

View file

@ -42,6 +42,7 @@ void action_macro_play(const macro_t *macro_p)
dprintf("KEY_DOWN(%02X)\n", macro);
if (IS_MOD(macro)) {
add_weak_mods(MOD_BIT(macro));
send_keyboard_report();
} else {
register_code(macro);
}
@ -51,6 +52,7 @@ void action_macro_play(const macro_t *macro_p)
dprintf("KEY_UP(%02X)\n", macro);
if (IS_MOD(macro)) {
del_weak_mods(MOD_BIT(macro));
send_keyboard_report();
} else {
unregister_code(macro);
}

View file

@ -76,7 +76,7 @@ void send_keyboard_report(void) {
void add_key(uint8_t key)
{
#ifdef NKRO_ENABLE
if (keyboard_nkro) {
if (keyboard_protocol && keyboard_nkro) {
add_key_bit(key);
return;
}
@ -87,7 +87,7 @@ void add_key(uint8_t key)
void del_key(uint8_t key)
{
#ifdef NKRO_ENABLE
if (keyboard_nkro) {
if (keyboard_protocol && keyboard_nkro) {
del_key_bit(key);
return;
}
@ -160,7 +160,7 @@ uint8_t has_anymod(void)
uint8_t get_first_key(void)
{
#ifdef NKRO_ENABLE
if (keyboard_nkro) {
if (keyboard_protocol && keyboard_nkro) {
uint8_t i = 0;
for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++)
;

View file

@ -232,13 +232,13 @@ static bool command_common(uint8_t code)
break;
case KC_D:
if (debug_enable) {
print("\ndebug: on\n");
print("\ndebug: off\n");
debug_matrix = false;
debug_keyboard = false;
debug_mouse = false;
debug_enable = false;
} else {
print("\ndebug: off\n");
print("\ndebug: on\n");
debug_enable = true;
}
break;
@ -327,6 +327,9 @@ static bool command_common(uint8_t code)
print_val_hex8(host_keyboard_leds());
print_val_hex8(keyboard_protocol);
print_val_hex8(keyboard_idle);
#ifdef NKRO_ENABLE
print_val_hex8(keyboard_nkro);
#endif
print_val_hex32(timer_read32());
#ifdef PROTOCOL_PJRC

View file

@ -156,6 +156,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KC_WSTP KC_WWW_STOP
#define KC_WREF KC_WWW_REFRESH
#define KC_WFAV KC_WWW_FAVORITES
/* Jump to bootloader */
#define KC_BTLD KC_BOOTLOADER
/* Transparent */
#define KC_TRANSPARENT 1
#define KC_TRNS KC_TRANSPARENT
@ -426,6 +428,9 @@ enum internal_special_keycodes {
KC_MEDIA_FAST_FORWARD,
KC_MEDIA_REWIND, /* 0xBC */
/* Jump to bootloader */
KC_BOOTLOADER = 0xBF,
/* Fn key */
KC_FN0 = 0xC0,
KC_FN1,

View file

@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action_layer.h"
#include "action.h"
#include "action_macro.h"
#include "wait.h"
#include "debug.h"
@ -146,6 +147,11 @@ static action_t keycode_to_action(uint8_t keycode)
case KC_TRNS:
action.code = ACTION_TRANSPARENT;
break;
case KC_BOOTLOADER:
clear_keyboard();
wait_ms(50);
bootloader_jump(); // not return
break;
default:
action.code = ACTION_NO;
break;

View file

@ -53,6 +53,7 @@
#include "lufa.h"
uint8_t keyboard_idle = 0;
/* 0: Boot Protocol, 1: Report Protocol(default) */
uint8_t keyboard_protocol = 1;
static uint8_t keyboard_led_stats = 0;
@ -217,6 +218,9 @@ void EVENT_USB_Device_StartOfFrame(void)
/** Event handler for the USB_ConfigurationChanged event.
* This is fired when the host sets the current configuration of the USB device after enumeration.
*
* ATMega32u2 supports dual bank(ping-pong mode) only on endpoint 3 and 4,
* it is safe to use singl bank for all endpoints.
*/
void EVENT_USB_Device_ConfigurationChanged(void)
{
@ -241,7 +245,7 @@ void EVENT_USB_Device_ConfigurationChanged(void)
#ifdef CONSOLE_ENABLE
/* Setup Console HID Report Endpoints */
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
CONSOLE_EPSIZE, ENDPOINT_BANK_DOUBLE);
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
#if 0
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT,
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
@ -346,10 +350,7 @@ void EVENT_USB_Device_ControlRequest(void)
Endpoint_ClearSETUP();
Endpoint_ClearStatusStage();
keyboard_protocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00);
#ifdef NKRO_ENABLE
keyboard_nkro = !!keyboard_protocol;
#endif
keyboard_protocol = (USB_ControlRequest.wValue & 0xFF);
clear_keyboard();
}
}
@ -396,7 +397,7 @@ static void send_keyboard(report_keyboard_t *report)
/* Select the Keyboard Report Endpoint */
#ifdef NKRO_ENABLE
if (keyboard_nkro) {
if (keyboard_protocol && keyboard_nkro) {
/* Report protocol - NKRO */
Endpoint_SelectEndpoint(NKRO_IN_EPNUM);

View file

@ -59,10 +59,16 @@ static inline void query(void);
static inline void reset(void);
static inline uint32_t response(void);
#define out_hi_delay(intervals) do { out_hi(); _delay_us(NEXT_KBD_TIMING * intervals); } while (0);
#define out_lo_delay(intervals) do { out_lo(); _delay_us(NEXT_KBD_TIMING * intervals); } while (0);
#define query_delay(intervals) do { query(); _delay_us(NEXT_KBD_TIMING * intervals); } while (0);
#define reset_delay(intervals) do { reset(); _delay_us(NEXT_KBD_TIMING * intervals); } while (0);
/* The keyboard sends signal with 50us pulse width on OUT line
* while it seems to miss the 50us pulse on In line.
* next_kbd_set_leds() often fails to sync LED status with 50us
* but it works well with 51us(+1us) on TMK converter(ATMeaga32u2) at least.
* TODO: test on Teensy and Pro Micro configuration
*/
#define out_hi_delay(intervals) do { out_hi(); _delay_us((NEXT_KBD_TIMING+1) * intervals); } while (0);
#define out_lo_delay(intervals) do { out_lo(); _delay_us((NEXT_KBD_TIMING+1) * intervals); } while (0);
#define query_delay(intervals) do { query(); _delay_us((NEXT_KBD_TIMING+1) * intervals); } while (0);
#define reset_delay(intervals) do { reset(); _delay_us((NEXT_KBD_TIMING+1) * intervals); } while (0);
void next_kbd_init(void)
{
@ -79,6 +85,7 @@ void next_kbd_init(void)
void next_kbd_set_leds(bool left, bool right)
{
cli();
out_lo_delay(9);
out_hi_delay(3);
@ -98,6 +105,7 @@ void next_kbd_set_leds(bool left, bool right)
out_lo_delay(7);
out_hi();
sei();
}
#define NEXT_KBD_READ (NEXT_KBD_IN_PIN&(1<<NEXT_KBD_IN_BIT))

@ -1 +0,0 @@
Subproject commit 94c560c854c7a1dfc35e9de9db05de1b202de6c6

@ -1 +0,0 @@
Subproject commit c30fcdf1f112de581de7b145a97630539e5cff44

@ -1 +0,0 @@
Subproject commit 77762338286535dabb9c94b87060e33e487ff0f3

@ -1 +0,0 @@
Subproject commit 77b033420485f7d3d35430c0e8d4d844aa894834