From bdb53e4c043d089279d9891b68bea77614cb97ee Mon Sep 17 00:00:00 2001 From: yiancar Date: Sun, 16 Aug 2020 01:07:21 +0100 Subject: Added 3rd endpoint (#1) * Added 3rd endpoint - Added 3rd endpoint check in asmcommon. This adds 2 extra cycles to the USB routine when enabled. With 16MHz clock (most if not all qmk build use that) the routine is still within spec. - Updated prototype.h file to add additional options. - Simulatanius changes in QMK to follow soon * Update usbdrv/usbdrv.c * Update usbdrv/usbdrv.c * Update usbdrv/usbdrv.c * Update usbdrv/usbdrv.c * Update usbdrv/usbdrvasm.S Accepted to keep changes minimal * Update usbdrv/usbdrvasm.S Accepted to keep changes minimal * Update usbdrv/usbdrvasm.S Accepted to keep changes minimal * Update usbdrv/usbdrvasm.S Accepted to keep changes minimal --- usbdrv/usbdrv.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'usbdrv/usbdrv.c') diff --git a/usbdrv/usbdrv.c b/usbdrv/usbdrv.c index 1d80ac6..b0cb565 100644 --- a/usbdrv/usbdrv.c +++ b/usbdrv/usbdrv.c @@ -37,6 +37,9 @@ usbTxStatus_t usbTxStatus1; # if USB_CFG_HAVE_INTRIN_ENDPOINT3 usbTxStatus_t usbTxStatus3; # endif +# if USB_CFG_HAVE_INTRIN_ENDPOINT4 +usbTxStatus_t usbTxStatus4; +# endif #endif #if USB_CFG_CHECK_DATA_TOGGLING uchar usbCurrentDataToken;/* when we check data toggling to ignore duplicate packets */ @@ -139,7 +142,7 @@ PROGMEM const char usbDescriptorDevice[] = { /* USB device descriptor */ PROGMEM const char usbDescriptorConfiguration[] = { /* USB configuration descriptor */ 9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */ USBDESCR_CONFIG, /* descriptor type */ - 18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 + + 18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT4 + (USB_CFG_DESCR_PROPS_HID & 0xff), 0, /* total length of data returned (including inlined descriptors) */ 1, /* number of interfaces in this configuration */ @@ -187,6 +190,14 @@ PROGMEM const char usbDescriptorConfiguration[] = { /* USB configuration desc 8, 0, /* maximum packet size */ USB_CFG_INTR_POLL_INTERVAL, /* in ms */ #endif +#if USB_CFG_HAVE_INTRIN_ENDPOINT4 /* endpoint descriptor for endpoint 4 */ + 7, /* sizeof(usbDescrEndpoint) */ + USBDESCR_ENDPOINT, /* descriptor type = endpoint */ + (char)(0x80 | USB_CFG_EP4_NUMBER), /* IN endpoint number 4 */ + 0x03, /* attrib: Interrupt endpoint */ + 8, 0, /* maximum packet size */ + USB_CFG_INTR_POLL_INTERVAL, /* in ms */ +#endif }; #endif @@ -199,6 +210,9 @@ static inline void usbResetDataToggling(void) # if USB_CFG_HAVE_INTRIN_ENDPOINT3 USB_SET_DATATOKEN3(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */ # endif +# if USB_CFG_HAVE_INTRIN_ENDPOINT4 + USB_SET_DATATOKEN4(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */ +# endif #endif } @@ -209,6 +223,9 @@ static inline void usbResetStall(void) #if USB_CFG_HAVE_INTRIN_ENDPOINT3 usbTxLen3 = USBPID_NAK; #endif +#if USB_CFG_HAVE_INTRIN_ENDPOINT4 + usbTxLen4 = USBPID_NAK; +#endif #endif } @@ -252,6 +269,13 @@ USB_PUBLIC void usbSetInterrupt3(uchar *data, uchar len) usbGenericSetInterrupt(data, len, &usbTxStatus3); } #endif + +#if USB_CFG_HAVE_INTRIN_ENDPOINT4 +USB_PUBLIC void usbSetInterrupt4(uchar *data, uchar len) +{ + usbGenericSetInterrupt(data, len, &usbTxStatus4); +} +#endif #endif /* USB_CFG_SUPPRESS_INTR_CODE */ /* ------------------ utilities for code following below ------------------- */ @@ -628,6 +652,9 @@ USB_PUBLIC void usbInit(void) #if USB_CFG_HAVE_INTRIN_ENDPOINT3 usbTxLen3 = USBPID_NAK; #endif +#if USB_CFG_HAVE_INTRIN_ENDPOINT4 + usbTxLen4 = USBPID_NAK; +#endif #endif } -- cgit v1.2.3