Got ps2avrGB to work with the V-USB protocol
This commit is contained in:
		
							parent
							
								
									10ff962321
								
							
						
					
					
						commit
						f7462aaa61
					
				
					 19 changed files with 886 additions and 17 deletions
				
			
		|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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; | ||||
|             } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Luiz Ribeiro
						Luiz Ribeiro