diff options
| author | Luiz Ribeiro <luizribeiro@gmail.com> | 2017-01-21 12:30:06 -0500 |
|---|---|---|
| committer | Luiz Ribeiro <luizribeiro@gmail.com> | 2017-01-21 12:55:19 -0500 |
| commit | f7462aaa613a08ba4b86dbb912ce26722cfccaff (patch) | |
| tree | cd7bd4b109fdb9d6f5253885138e1b34ee277e12 /tmk_core/protocol | |
| parent | 10ff9623214ee62935a17b3f68d5180756b7a27b (diff) | |
| download | qmk_firmware-f7462aaa613a08ba4b86dbb912ce26722cfccaff.tar.gz qmk_firmware-f7462aaa613a08ba4b86dbb912ce26722cfccaff.zip | |
Got ps2avrGB to work with the V-USB protocol
Diffstat (limited to 'tmk_core/protocol')
| -rw-r--r-- | tmk_core/protocol/vusb.mk | 7 | ||||
| -rw-r--r-- | tmk_core/protocol/vusb/main.c | 6 | ||||
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 22 |
3 files changed, 27 insertions, 8 deletions
diff --git a/tmk_core/protocol/vusb.mk b/tmk_core/protocol/vusb.mk index 3cba3f71a..4d90510af 100644 --- a/tmk_core/protocol/vusb.mk +++ b/tmk_core/protocol/vusb.mk | |||
| @@ -2,7 +2,7 @@ VUSB_DIR = protocol/vusb | |||
| 2 | 2 | ||
| 3 | OPT_DEFS += -DPROTOCOL_VUSB | 3 | OPT_DEFS += -DPROTOCOL_VUSB |
| 4 | 4 | ||
| 5 | SRC += $(VUSB_DIR)/main.c \ | 5 | SRC += $(VUSB_DIR)/main.c \ |
| 6 | $(VUSB_DIR)/vusb.c \ | 6 | $(VUSB_DIR)/vusb.c \ |
| 7 | $(VUSB_DIR)/usbdrv/usbdrv.c \ | 7 | $(VUSB_DIR)/usbdrv/usbdrv.c \ |
| 8 | $(VUSB_DIR)/usbdrv/usbdrvasm.S \ | 8 | $(VUSB_DIR)/usbdrv/usbdrvasm.S \ |
| @@ -16,6 +16,7 @@ SRC += $(COMMON_DIR)/sendchar_uart.c \ | |||
| 16 | $(COMMON_DIR)/uart.c | 16 | $(COMMON_DIR)/uart.c |
| 17 | endif | 17 | endif |
| 18 | 18 | ||
| 19 | |||
| 20 | # Search Path | 19 | # Search Path |
| 21 | VPATH += $(TMK_DIR)/protocol/vusb:$(TMK_DIR)/protocol/vusb/usbdrv | 20 | #VPATH += $(TMK_PATH)/$(VUSB_DIR) |
| 21 | VPATH += $(TMK_PATH)/$(VUSB_DIR) | ||
| 22 | VPATH += $(TMK_PATH)/$(VUSB_DIR)/usbdrv | ||
diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c index 8e4a266e9..f6a0c7e9a 100644 --- a/tmk_core/protocol/vusb/main.c +++ b/tmk_core/protocol/vusb/main.c | |||
| @@ -48,8 +48,12 @@ int main(void) | |||
| 48 | uint16_t last_timer = timer_read(); | 48 | uint16_t last_timer = timer_read(); |
| 49 | #endif | 49 | #endif |
| 50 | 50 | ||
| 51 | #ifdef CLKPR | ||
| 52 | // avoid unintentional changes of clock frequency in devices that have a | ||
| 53 | // clock prescaler | ||
| 51 | CLKPR = 0x80, CLKPR = 0; | 54 | CLKPR = 0x80, CLKPR = 0; |
| 52 | #ifndef PS2_USE_USART | 55 | #endif |
| 56 | #ifndef NO_UART | ||
| 53 | uart_init(UART_BAUD_RATE); | 57 | uart_init(UART_BAUD_RATE); |
| 54 | #endif | 58 | #endif |
| 55 | 59 | ||
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index eaa1c512d..a8c13b928 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 | |||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #include <avr/eeprom.h> | ||
| 19 | #include <avr/wdt.h> | ||
| 18 | #include <stdint.h> | 20 | #include <stdint.h> |
| 19 | #include "usbdrv.h" | 21 | #include "usbdrv.h" |
| 20 | #include "usbconfig.h" | 22 | #include "usbconfig.h" |
| @@ -24,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 24 | #include "debug.h" | 26 | #include "debug.h" |
| 25 | #include "host_driver.h" | 27 | #include "host_driver.h" |
| 26 | #include "vusb.h" | 28 | #include "vusb.h" |
| 29 | #include "bootloader.h" | ||
| 27 | 30 | ||
| 28 | 31 | ||
| 29 | static uint8_t vusb_keyboard_leds = 0; | 32 | static uint8_t vusb_keyboard_leds = 0; |
| @@ -163,6 +166,7 @@ static struct { | |||
| 163 | uint16_t len; | 166 | uint16_t len; |
| 164 | enum { | 167 | enum { |
| 165 | NONE, | 168 | NONE, |
| 169 | BOOTLOADER, | ||
| 166 | SET_LED | 170 | SET_LED |
| 167 | } kind; | 171 | } kind; |
| 168 | } last_req; | 172 | } last_req; |
| @@ -193,6 +197,11 @@ usbRequest_t *rq = (void *)data; | |||
| 193 | debug("SET_LED: "); | 197 | debug("SET_LED: "); |
| 194 | last_req.kind = SET_LED; | 198 | last_req.kind = SET_LED; |
| 195 | last_req.len = rq->wLength.word; | 199 | last_req.len = rq->wLength.word; |
| 200 | #ifdef BOOTLOADER_SIZE | ||
| 201 | } else if(rq->wValue.word == 0x0301) { | ||
| 202 | last_req.kind = BOOTLOADER; | ||
| 203 | last_req.len = rq->wLength.word; | ||
| 204 | #endif | ||
| 196 | } | 205 | } |
| 197 | return USB_NO_MSG; // to get data in usbFunctionWrite | 206 | return USB_NO_MSG; // to get data in usbFunctionWrite |
| 198 | } else { | 207 | } else { |
| @@ -220,6 +229,11 @@ uchar usbFunctionWrite(uchar *data, uchar len) | |||
| 220 | last_req.len = 0; | 229 | last_req.len = 0; |
| 221 | return 1; | 230 | return 1; |
| 222 | break; | 231 | break; |
| 232 | case BOOTLOADER: | ||
| 233 | usbDeviceDisconnect(); | ||
| 234 | bootloader_jump(); | ||
| 235 | return 1; | ||
| 236 | break; | ||
| 223 | case NONE: | 237 | case NONE: |
| 224 | default: | 238 | default: |
| 225 | return -1; | 239 | return -1; |
| @@ -266,7 +280,7 @@ const PROGMEM uchar keyboard_hid_report[] = { | |||
| 266 | 0x95, 0x06, // Report Count (6), | 280 | 0x95, 0x06, // Report Count (6), |
| 267 | 0x75, 0x08, // Report Size (8), | 281 | 0x75, 0x08, // Report Size (8), |
| 268 | 0x15, 0x00, // Logical Minimum (0), | 282 | 0x15, 0x00, // Logical Minimum (0), |
| 269 | 0x25, 0xFF, 0x00 // Logical Maximum(255), | 283 | 0x25, 0xFF, 0x00, // Logical Maximum(255), |
| 270 | 0x05, 0x07, // Usage Page (Key Codes), | 284 | 0x05, 0x07, // Usage Page (Key Codes), |
| 271 | 0x19, 0x00, // Usage Minimum (0), | 285 | 0x19, 0x00, // Usage Minimum (0), |
| 272 | 0x29, 0xFF, // Usage Maximum (255), | 286 | 0x29, 0xFF, // Usage Maximum (255), |
| @@ -336,7 +350,7 @@ const PROGMEM uchar mouse_hid_report[] = { | |||
| 336 | 0xa1, 0x01, // COLLECTION (Application) | 350 | 0xa1, 0x01, // COLLECTION (Application) |
| 337 | 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) | 351 | 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) |
| 338 | 0x15, 0x01, // LOGICAL_MINIMUM (0x1) | 352 | 0x15, 0x01, // LOGICAL_MINIMUM (0x1) |
| 339 | 0x25, 0xb7, 0x00 // LOGICAL_MAXIMUM (0xb7) | 353 | 0x25, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7) |
| 340 | 0x19, 0x01, // USAGE_MINIMUM (0x1) | 354 | 0x19, 0x01, // USAGE_MINIMUM (0x1) |
| 341 | 0x29, 0xb7, // USAGE_MAXIMUM (0xb7) | 355 | 0x29, 0xb7, // USAGE_MAXIMUM (0xb7) |
| 342 | 0x75, 0x10, // REPORT_SIZE (16) | 356 | 0x75, 0x10, // REPORT_SIZE (16) |
| @@ -481,11 +495,11 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) | |||
| 481 | /* interface index */ | 495 | /* interface index */ |
| 482 | switch (rq->wIndex.word) { | 496 | switch (rq->wIndex.word) { |
| 483 | case 0: | 497 | case 0: |
| 484 | usbMsgPtr = keyboard_hid_report; | 498 | usbMsgPtr = (unsigned char *)keyboard_hid_report; |
| 485 | len = sizeof(keyboard_hid_report); | 499 | len = sizeof(keyboard_hid_report); |
| 486 | break; | 500 | break; |
| 487 | case 1: | 501 | case 1: |
| 488 | usbMsgPtr = mouse_hid_report; | 502 | usbMsgPtr = (unsigned char *)mouse_hid_report; |
| 489 | len = sizeof(mouse_hid_report); | 503 | len = sizeof(mouse_hid_report); |
| 490 | break; | 504 | break; |
| 491 | } | 505 | } |
