diff options
Diffstat (limited to 'tmk_core/protocol/vusb')
| -rw-r--r-- | tmk_core/protocol/vusb/main.c | 6 | ||||
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 22 | 
2 files changed, 23 insertions, 5 deletions
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)      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 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  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */ +#include <avr/eeprom.h> +#include <avr/wdt.h>  #include <stdint.h>  #include "usbdrv.h"  #include "usbconfig.h" @@ -24,6 +26,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #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;              }  | 
