From e82f32d367444be1cf0292b47eb9bd6d3f647e92 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Thu, 28 Aug 2014 11:33:46 +0900 Subject: [PATCH] Enable PS/2 mouse for TentaPad --- common/keyboard.c | 5 ++-- keyboard/tentapad/Makefile | 4 ++- keyboard/tentapad/Makefile.pjrc | 1 + keyboard/tentapad/Makefile_gh60 | 1 + keyboard/tentapad/Makefile_gh60.pjrc | 1 + keyboard/tentapad/config.h | 43 +++++++++++++++++++++++----- keyboard/tentapad/matrix.c | 20 ++++++------- protocol/ps2.h | 1 - 8 files changed, 53 insertions(+), 23 deletions(-) diff --git a/common/keyboard.c b/common/keyboard.c index f989dc1f..312f6e53 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -66,6 +66,7 @@ static bool has_ghost_in_row(uint8_t row) } #endif +extern uint8_t ps2_mouse_enabled; void keyboard_init(void) { @@ -77,7 +78,7 @@ void keyboard_init(void) #endif #ifdef PS2_MOUSE_ENABLE - if (ps2_enabled()) { + if (ps2_mouse_enabled) { ps2_mouse_init(); } #endif @@ -163,7 +164,7 @@ MATRIX_LOOP_END: #endif #ifdef PS2_MOUSE_ENABLE - if (ps2_enabled()) { + if (ps2_mouse_enabled) { ps2_mouse_task(); } #endif diff --git a/keyboard/tentapad/Makefile b/keyboard/tentapad/Makefile index 610e78c2..c6aad9a5 100644 --- a/keyboard/tentapad/Makefile +++ b/keyboard/tentapad/Makefile @@ -130,11 +130,13 @@ COMMAND_ENABLE = yes # Commands for debug and configuration #NKRO_ENABLE = yes # USB Nkey Rollover #USB_6KRO_ENABLE = yes # USB 6key Rollover PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support -PS2_USE_BUSYWAIT = yes +PS2_USE_USART= yes +#PS2_USE_BUSYWAIT = yes BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom #KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor SOFTPWM_LED_ENABLE = yes # Enable SoftPWM to drive backlight +FADING_LED_ENABLE = yes # Enable fading backlight BREATHING_LED_ENABLE = yes # Enable breathing backlight #LEDMAP_ENABLE = yes # Enable LED mapping #LEDMAP_IN_EEPROM_ENABLE = yes # Read LED mapping from eeprom diff --git a/keyboard/tentapad/Makefile.pjrc b/keyboard/tentapad/Makefile.pjrc index 9cbdce7b..9975a614 100644 --- a/keyboard/tentapad/Makefile.pjrc +++ b/keyboard/tentapad/Makefile.pjrc @@ -105,6 +105,7 @@ BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom #KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor SOFTPWM_LED_ENABLE = yes # Enable SoftPWM to drive backlight +FADING_LED_ENABLE = yes # Enable fading backlight BREATHING_LED_ENABLE = yes # Enable breathing backlight #LEDMAP_ENABLE = yes # Enable LED mapping #LEDMAP_IN_EEPROM_ENABLE = yes # Read LED mapping from eeprom diff --git a/keyboard/tentapad/Makefile_gh60 b/keyboard/tentapad/Makefile_gh60 index 33f87de8..717dc33d 100644 --- a/keyboard/tentapad/Makefile_gh60 +++ b/keyboard/tentapad/Makefile_gh60 @@ -135,6 +135,7 @@ BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom #KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor SOFTPWM_LED_ENABLE = yes # Enable SoftPWM to drive backlight +FADING_LED_ENABLE = yes # Enable fading backlight BREATHING_LED_ENABLE = yes # Enable breathing backlight #LEDMAP_ENABLE = yes # Enable LED mapping #LEDMAP_IN_EEPROM_ENABLE = yes # Read LED mapping from eeprom diff --git a/keyboard/tentapad/Makefile_gh60.pjrc b/keyboard/tentapad/Makefile_gh60.pjrc index 3dd80178..dae1da9e 100644 --- a/keyboard/tentapad/Makefile_gh60.pjrc +++ b/keyboard/tentapad/Makefile_gh60.pjrc @@ -105,6 +105,7 @@ BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom #KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor SOFTPWM_LED_ENABLE = yes # Enable SoftPWM to drive backlight +FADING_LED_ENABLE = yes # Enable fading backlight BREATHING_LED_ENABLE = yes # Enable breathing backlight #LEDMAP_ENABLE = yes # Enable LED mapping #LEDMAP_IN_EEPROM_ENABLE = yes # Read LED mapping from eeprom diff --git a/keyboard/tentapad/config.h b/keyboard/tentapad/config.h index ce986978..847097b5 100644 --- a/keyboard/tentapad/config.h +++ b/keyboard/tentapad/config.h @@ -42,11 +42,7 @@ along with this program. If not, see . #define DEBOUNCE 5 /* number of backlight levels */ -#ifdef BREATHING_LED_ENABLE -#define BACKLIGHT_LEVELS 6 -#else -#define BACKLIGHT_LEVELS 3 -#endif +#define BACKLIGHT_LEVELS 8 /* number of LEDs */ #define LED_COUNT 4 @@ -64,15 +60,48 @@ along with this program. If not, see . /* PS2 mouse support */ #ifdef PS2_MOUSE_ENABLE + #define PS2_CLOCK_PORT PORTD #define PS2_CLOCK_PIN PIND #define PS2_CLOCK_DDR DDRD -#define PS2_CLOCK_BIT PD3 +#define PS2_CLOCK_BIT PD5 #define PS2_DATA_PORT PORTD #define PS2_DATA_PIN PIND #define PS2_DATA_DDR DDRD -#define PS2_DATA_BIT PD4 +#define PS2_DATA_BIT PD2 + +#ifdef PS2_USE_USART +#define PS2_USART_INIT() do { \ + PS2_CLOCK_DDR &= ~(1<