From f7462aaa613a08ba4b86dbb912ce26722cfccaff Mon Sep 17 00:00:00 2001 From: Luiz Ribeiro Date: Sat, 21 Jan 2017 12:30:06 -0500 Subject: Got ps2avrGB to work with the V-USB protocol --- tmk_core/protocol/vusb.mk | 7 ++++--- tmk_core/protocol/vusb/main.c | 6 +++++- tmk_core/protocol/vusb/vusb.c | 22 ++++++++++++++++++---- 3 files changed, 27 insertions(+), 8 deletions(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/vusb.mk b/tmk_core/protocol/vusb.mk index 3cba3f71a3..4d90510af5 100644 --- a/tmk_core/protocol/vusb.mk +++ b/tmk_core/protocol/vusb.mk @@ -2,7 +2,7 @@ VUSB_DIR = protocol/vusb OPT_DEFS += -DPROTOCOL_VUSB -SRC += $(VUSB_DIR)/main.c \ +SRC += $(VUSB_DIR)/main.c \ $(VUSB_DIR)/vusb.c \ $(VUSB_DIR)/usbdrv/usbdrv.c \ $(VUSB_DIR)/usbdrv/usbdrvasm.S \ @@ -16,6 +16,7 @@ SRC += $(COMMON_DIR)/sendchar_uart.c \ $(COMMON_DIR)/uart.c endif - # Search Path -VPATH += $(TMK_DIR)/protocol/vusb:$(TMK_DIR)/protocol/vusb/usbdrv +#VPATH += $(TMK_PATH)/$(VUSB_DIR) +VPATH += $(TMK_PATH)/$(VUSB_DIR) +VPATH += $(TMK_PATH)/$(VUSB_DIR)/usbdrv diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c index 8e4a266e9b..f6a0c7e9a4 100644 --- a/tmk_core/protocol/vusb/main.c +++ b/tmk_core/protocol/vusb/main.c @@ -48,8 +48,12 @@ int main(void) uint16_t last_timer = timer_read(); #endif +#ifdef CLKPR + // avoid unintentional changes of clock frequency in devices that have a + // clock prescaler CLKPR = 0x80, CLKPR = 0; -#ifndef PS2_USE_USART +#endif +#ifndef NO_UART uart_init(UART_BAUD_RATE); #endif diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index eaa1c512d8..a8c13b928a 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -15,6 +15,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include +#include #include #include "usbdrv.h" #include "usbconfig.h" @@ -24,6 +26,7 @@ along with this program. If not, see . #include "debug.h" #include "host_driver.h" #include "vusb.h" +#include "bootloader.h" static uint8_t vusb_keyboard_leds = 0; @@ -163,6 +166,7 @@ static struct { uint16_t len; enum { NONE, + BOOTLOADER, SET_LED } kind; } last_req; @@ -193,6 +197,11 @@ usbRequest_t *rq = (void *)data; debug("SET_LED: "); last_req.kind = SET_LED; last_req.len = rq->wLength.word; +#ifdef BOOTLOADER_SIZE + } else if(rq->wValue.word == 0x0301) { + last_req.kind = BOOTLOADER; + last_req.len = rq->wLength.word; +#endif } return USB_NO_MSG; // to get data in usbFunctionWrite } else { @@ -220,6 +229,11 @@ uchar usbFunctionWrite(uchar *data, uchar len) last_req.len = 0; return 1; break; + case BOOTLOADER: + usbDeviceDisconnect(); + bootloader_jump(); + return 1; + break; case NONE: default: return -1; @@ -266,7 +280,7 @@ const PROGMEM uchar keyboard_hid_report[] = { 0x95, 0x06, // Report Count (6), 0x75, 0x08, // Report Size (8), 0x15, 0x00, // Logical Minimum (0), - 0x25, 0xFF, 0x00 // Logical Maximum(255), + 0x25, 0xFF, 0x00, // Logical Maximum(255), 0x05, 0x07, // Usage Page (Key Codes), 0x19, 0x00, // Usage Minimum (0), 0x29, 0xFF, // Usage Maximum (255), @@ -336,7 +350,7 @@ const PROGMEM uchar mouse_hid_report[] = { 0xa1, 0x01, // COLLECTION (Application) 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) 0x15, 0x01, // LOGICAL_MINIMUM (0x1) - 0x25, 0xb7, 0x00 // LOGICAL_MAXIMUM (0xb7) + 0x25, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7) 0x19, 0x01, // USAGE_MINIMUM (0x1) 0x29, 0xb7, // USAGE_MAXIMUM (0xb7) 0x75, 0x10, // REPORT_SIZE (16) @@ -481,11 +495,11 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) /* interface index */ switch (rq->wIndex.word) { case 0: - usbMsgPtr = keyboard_hid_report; + usbMsgPtr = (unsigned char *)keyboard_hid_report; len = sizeof(keyboard_hid_report); break; case 1: - usbMsgPtr = mouse_hid_report; + usbMsgPtr = (unsigned char *)mouse_hid_report; len = sizeof(mouse_hid_report); break; } -- cgit v1.2.3