-
-
Notifications
You must be signed in to change notification settings - Fork 40.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow some usbconfig.h overrides at the keyboard level #8647
Conversation
Why not wrap them in |
This was just a short term, lightest touch bodge to get be back up and running since I rebased and picked up #8584. If we want the longer term solution I can prepare that instead. |
The only things I can really see needing configurability are |
Currently the patch looks like: diff --git a/tmk_core/protocol/vusb/usbconfig.h b/tmk_core/protocol/vusb/usbconfig.h
index f15616351..88d29ac94 100644
--- a/tmk_core/protocol/vusb/usbconfig.h
+++ b/tmk_core/protocol/vusb/usbconfig.h
@@ -23,16 +23,22 @@ section at the end of this file).
*/
/* ---------------------------- Hardware Config ---------------------------- */
-
+#ifndef USB_CFG_IOPORTNAME
#define USB_CFG_IOPORTNAME D
+#endif
+
/* This is the port where the USB bus is connected. When you configure it to
* "B", the registers PORTB, PINB and DDRB will be used.
*/
+#ifndef USB_CFG_DMINUS_BIT
#define USB_CFG_DMINUS_BIT 3
+#endif
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
* This may be any bit in the port.
*/
+#ifndef USB_CFG_DPLUS_BIT
#define USB_CFG_DPLUS_BIT 2
+#endif
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
* This may be any bit in the port. Please note that D+ must also be connected
* to interrupt pin INT0! [You can also use other interrupts, see section
@@ -78,7 +84,9 @@ section at the end of this file).
* default control endpoint 0 and an interrupt-in endpoint (any other endpoint
* number).
*/
+#ifndef USB_CFG_HAVE_INTRIN_ENDPOINT3
#define USB_CFG_HAVE_INTRIN_ENDPOINT3 1
+#endif
/* Define this to 1 if you want to compile a version with three endpoints: The
* default control endpoint 0, an interrupt-in endpoint 3 (or the number
* configured below) and a catch-all default interrupt-in endpoint as above.
@@ -123,7 +131,9 @@ section at the end of this file).
* data from a static buffer, set it to 0 and return the data from
* usbFunctionSetup(). This saves a couple of bytes.
*/
+#ifndef USB_CFG_IMPLEMENT_FN_WRITEOUT
#define USB_CFG_IMPLEMENT_FN_WRITEOUT 1
+#endif
/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints.
* You must implement the function usbFunctionWriteOut() which receives all
* interrupt/bulk data sent to any endpoint other than 0. The endpoint number
@@ -160,7 +170,9 @@ section at the end of this file).
/* This macro (if defined) is executed when a USB SET_ADDRESS request was
* received.
*/
+#ifndef USB_COUNT_SOF
#define USB_COUNT_SOF 1
+#endif
/* define this macro to 1 if you need the global variable "usbSofCount" which
* counts SOF packets. This feature requires that the hardware interrupt is
* connected to D- instead of D+.
@@ -342,11 +354,23 @@ section at the end of this file).
/* #define USB_INTR_VECTOR INT0_vect */
/* Set INT1 for D- falling edge to count SOF */
+#ifndef USB_INTR_CFG
/* #define USB_INTR_CFG EICRA */
+#endif
+#ifndef USB_INTR_CFG_SET
#define USB_INTR_CFG_SET ((1 << ISC11) | (0 << ISC10))
+#endif
/* #define USB_INTR_CFG_CLR 0 */
/* #define USB_INTR_ENABLE EIMSK */
+#ifndef USB_INTR_ENABLE_BIT
#define USB_INTR_ENABLE_BIT INT1
+#endif
/* #define USB_INTR_PENDING EIFR */
+#ifndef USB_INTR_PENDING_BIT
#define USB_INTR_PENDING_BIT INTF1
+#endif
+#ifndef USB_INTR_VECTOR
#define USB_INTR_VECTOR INT1_vect
+#endif
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 9ecbe0c7a..00314ebe8 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <avr/wdt.h>
#include <stdint.h>
#include "usbdrv.h"
-#include <usbconfig.h>
+#include "usbconfig.h"
#include "host.h"
#include "report.h"
#include "print.h" Ive also seen https://codeandlife.com/2012/02/22/v-usb-with-attiny45-attiny85-without-a-crystal/ override some extra config to do with clock configuration but ive not needed it yet. |
2ac1932
to
6d7ebc8
Compare
Updated with the proposed longer term changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Currently there is no way to override options within
usbconfig.h
, which is fine till you need to use different pins for the usb port.If you add an override file at the keyboard level(as a short term workaround), it produces the following sort of errors:
Types of Changes
Checklist