From 446f87f9e82e57fdc255cab3051a4b598fa4da75 Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 4 Mar 2012 01:12:35 +0900 Subject: [PATCH] Fiexed AT90USB162 compatibility.(different number of endpoint) --- pjrc/usb.c | 4 ++-- pjrc/usb.h | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pjrc/usb.c b/pjrc/usb.c index 20afc1b8..2b69b6a7 100644 --- a/pjrc/usb.c +++ b/pjrc/usb.c @@ -785,7 +785,7 @@ ISR(USB_COM_vect) usb_configuration = wValue; usb_send_in(); cfg = endpoint_config_table; - for (i=1; i<=6; i++) { + for (i=1; i<=MAX_ENDPOINT; i++) { UENUM = i; en = pgm_read_byte(cfg++); if (en) { @@ -796,7 +796,7 @@ ISR(USB_COM_vect) UECONX = 0; } } - UERST = 0x7E; + UERST = UERST_MASK; UERST = 0; return; } diff --git a/pjrc/usb.h b/pjrc/usb.h index 82e18f17..0eb58fc3 100644 --- a/pjrc/usb.h +++ b/pjrc/usb.h @@ -53,7 +53,13 @@ void usb_remote_wakeup(void); ((s) == 16 ? 0x10 : \ 0x00))) -#define MAX_ENDPOINT 4 +#if defined (__AVR_AT90USB162__) || defined (__AVR_AT90USB82__) +# define MAX_ENDPOINT 4 +# define UERST_MASK 0x1E +#else +# define MAX_ENDPOINT 6 +# define UERST_MASK 0x7E +#endif #define LSB(n) (n & 255) #define MSB(n) ((n >> 8) & 255) -- 2.39.3