aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol/vusb/vusb.c
diff options
context:
space:
mode:
authorLuiz Ribeiro <luizribeiro@gmail.com>2017-01-21 12:30:06 -0500
committerLuiz Ribeiro <luizribeiro@gmail.com>2017-01-21 12:55:19 -0500
commitf7462aaa613a08ba4b86dbb912ce26722cfccaff (patch)
treecd7bd4b109fdb9d6f5253885138e1b34ee277e12 /tmk_core/protocol/vusb/vusb.c
parent10ff9623214ee62935a17b3f68d5180756b7a27b (diff)
downloadqmk_firmware-f7462aaa613a08ba4b86dbb912ce26722cfccaff.tar.gz
qmk_firmware-f7462aaa613a08ba4b86dbb912ce26722cfccaff.zip
Got ps2avrGB to work with the V-USB protocol
Diffstat (limited to 'tmk_core/protocol/vusb/vusb.c')
-rw-r--r--tmk_core/protocol/vusb/vusb.c22
1 files changed, 18 insertions, 4 deletions
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
15along with this program. If not, see <http://www.gnu.org/licenses/>. 15along 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
29static uint8_t vusb_keyboard_leds = 0; 32static 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 }