|
@@ -194,107 +194,107 @@ typedef struct {
|
|
|
|
|
|
#if STM32_USB_USE_OTG1
|
|
|
/* Reusable initialization structure - see USBEndpointConfig comment at top of file */
|
|
|
-#define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \
|
|
|
- { \
|
|
|
- .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \
|
|
|
- .inout_ep_config = \
|
|
|
- { \
|
|
|
- stream##_IN_MODE, /* Interrupt EP */ \
|
|
|
- NULL, /* SETUP packet notification callback */ \
|
|
|
- qmkusbDataTransmitted, /* IN notification callback */ \
|
|
|
- qmkusbDataReceived, /* OUT notification callback */ \
|
|
|
- stream##_EPSIZE, /* IN maximum packet size */ \
|
|
|
- stream##_EPSIZE, /* OUT maximum packet size */ \
|
|
|
- NULL, /* IN Endpoint state */ \
|
|
|
- NULL, /* OUT endpoint state */ \
|
|
|
- 2, /* IN multiplier */ \
|
|
|
- NULL /* SETUP buffer (not a SETUP endpoint) */ \
|
|
|
- }, \
|
|
|
- .int_ep_config = \
|
|
|
- { \
|
|
|
- USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ \
|
|
|
- NULL, /* SETUP packet notification callback */ \
|
|
|
- qmkusbInterruptTransmitted, /* IN notification callback */ \
|
|
|
- NULL, /* OUT notification callback */ \
|
|
|
- CDC_NOTIFICATION_EPSIZE, /* IN maximum packet size */ \
|
|
|
- 0, /* OUT maximum packet size */ \
|
|
|
- NULL, /* IN Endpoint state */ \
|
|
|
- NULL, /* OUT endpoint state */ \
|
|
|
- 2, /* IN multiplier */ \
|
|
|
- NULL, /* SETUP buffer (not a SETUP endpoint) */ \
|
|
|
- }, \
|
|
|
- .config = { \
|
|
|
- .usbp = &USB_DRIVER, \
|
|
|
- .bulk_in = stream##_IN_EPNUM, \
|
|
|
- .bulk_out = stream##_OUT_EPNUM, \
|
|
|
- .int_in = notification, \
|
|
|
- .in_buffers = stream##_IN_CAPACITY, \
|
|
|
- .out_buffers = stream##_OUT_CAPACITY, \
|
|
|
- .in_size = stream##_EPSIZE, \
|
|
|
- .out_size = stream##_EPSIZE, \
|
|
|
- .fixed_size = fixedsize, \
|
|
|
- .ib = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]){}, \
|
|
|
- .ob = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \
|
|
|
- } \
|
|
|
- }
|
|
|
+# define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \
|
|
|
+ { \
|
|
|
+ .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \
|
|
|
+ .inout_ep_config = \
|
|
|
+ { \
|
|
|
+ stream##_IN_MODE, /* Interrupt EP */ \
|
|
|
+ NULL, /* SETUP packet notification callback */ \
|
|
|
+ qmkusbDataTransmitted, /* IN notification callback */ \
|
|
|
+ qmkusbDataReceived, /* OUT notification callback */ \
|
|
|
+ stream##_EPSIZE, /* IN maximum packet size */ \
|
|
|
+ stream##_EPSIZE, /* OUT maximum packet size */ \
|
|
|
+ NULL, /* IN Endpoint state */ \
|
|
|
+ NULL, /* OUT endpoint state */ \
|
|
|
+ 2, /* IN multiplier */ \
|
|
|
+ NULL /* SETUP buffer (not a SETUP endpoint) */ \
|
|
|
+ }, \
|
|
|
+ .int_ep_config = \
|
|
|
+ { \
|
|
|
+ USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ \
|
|
|
+ NULL, /* SETUP packet notification callback */ \
|
|
|
+ qmkusbInterruptTransmitted, /* IN notification callback */ \
|
|
|
+ NULL, /* OUT notification callback */ \
|
|
|
+ CDC_NOTIFICATION_EPSIZE, /* IN maximum packet size */ \
|
|
|
+ 0, /* OUT maximum packet size */ \
|
|
|
+ NULL, /* IN Endpoint state */ \
|
|
|
+ NULL, /* OUT endpoint state */ \
|
|
|
+ 2, /* IN multiplier */ \
|
|
|
+ NULL, /* SETUP buffer (not a SETUP endpoint) */ \
|
|
|
+ }, \
|
|
|
+ .config = { \
|
|
|
+ .usbp = &USB_DRIVER, \
|
|
|
+ .bulk_in = stream##_IN_EPNUM, \
|
|
|
+ .bulk_out = stream##_OUT_EPNUM, \
|
|
|
+ .int_in = notification, \
|
|
|
+ .in_buffers = stream##_IN_CAPACITY, \
|
|
|
+ .out_buffers = stream##_OUT_CAPACITY, \
|
|
|
+ .in_size = stream##_EPSIZE, \
|
|
|
+ .out_size = stream##_EPSIZE, \
|
|
|
+ .fixed_size = fixedsize, \
|
|
|
+ .ib = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]){}, \
|
|
|
+ .ob = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \
|
|
|
+ } \
|
|
|
+ }
|
|
|
#else
|
|
|
/* Reusable initialization structure - see USBEndpointConfig comment at top of file */
|
|
|
-#define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \
|
|
|
- { \
|
|
|
- .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \
|
|
|
- .in_ep_config = \
|
|
|
- { \
|
|
|
- stream##_IN_MODE, /* Interrupt EP */ \
|
|
|
- NULL, /* SETUP packet notification callback */ \
|
|
|
- qmkusbDataTransmitted, /* IN notification callback */ \
|
|
|
- NULL, /* OUT notification callback */ \
|
|
|
- stream##_EPSIZE, /* IN maximum packet size */ \
|
|
|
- 0, /* OUT maximum packet size */ \
|
|
|
- NULL, /* IN Endpoint state */ \
|
|
|
- NULL, /* OUT endpoint state */ \
|
|
|
- 2, /* IN multiplier */ \
|
|
|
- NULL /* SETUP buffer (not a SETUP endpoint) */ \
|
|
|
- }, \
|
|
|
- .out_ep_config = \
|
|
|
- { \
|
|
|
- stream##_OUT_MODE, /* Interrupt EP */ \
|
|
|
- NULL, /* SETUP packet notification callback */ \
|
|
|
- NULL, /* IN notification callback */ \
|
|
|
- qmkusbDataReceived, /* OUT notification callback */ \
|
|
|
- 0, /* IN maximum packet size */ \
|
|
|
- stream##_EPSIZE, /* OUT maximum packet size */ \
|
|
|
- NULL, /* IN Endpoint state */ \
|
|
|
- NULL, /* OUT endpoint state */ \
|
|
|
- 2, /* IN multiplier */ \
|
|
|
- NULL, /* SETUP buffer (not a SETUP endpoint) */ \
|
|
|
- }, \
|
|
|
- .int_ep_config = \
|
|
|
- { \
|
|
|
- USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ \
|
|
|
- NULL, /* SETUP packet notification callback */ \
|
|
|
- qmkusbInterruptTransmitted, /* IN notification callback */ \
|
|
|
- NULL, /* OUT notification callback */ \
|
|
|
- CDC_NOTIFICATION_EPSIZE, /* IN maximum packet size */ \
|
|
|
- 0, /* OUT maximum packet size */ \
|
|
|
- NULL, /* IN Endpoint state */ \
|
|
|
- NULL, /* OUT endpoint state */ \
|
|
|
- 2, /* IN multiplier */ \
|
|
|
- NULL, /* SETUP buffer (not a SETUP endpoint) */ \
|
|
|
- }, \
|
|
|
- .config = { \
|
|
|
- .usbp = &USB_DRIVER, \
|
|
|
- .bulk_in = stream##_IN_EPNUM, \
|
|
|
- .bulk_out = stream##_OUT_EPNUM, \
|
|
|
- .int_in = notification, \
|
|
|
- .in_buffers = stream##_IN_CAPACITY, \
|
|
|
- .out_buffers = stream##_OUT_CAPACITY, \
|
|
|
- .in_size = stream##_EPSIZE, \
|
|
|
- .out_size = stream##_EPSIZE, \
|
|
|
- .fixed_size = fixedsize, \
|
|
|
- .ib = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]){}, \
|
|
|
- .ob = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \
|
|
|
- } \
|
|
|
- }
|
|
|
+# define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \
|
|
|
+ { \
|
|
|
+ .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \
|
|
|
+ .in_ep_config = \
|
|
|
+ { \
|
|
|
+ stream##_IN_MODE, /* Interrupt EP */ \
|
|
|
+ NULL, /* SETUP packet notification callback */ \
|
|
|
+ qmkusbDataTransmitted, /* IN notification callback */ \
|
|
|
+ NULL, /* OUT notification callback */ \
|
|
|
+ stream##_EPSIZE, /* IN maximum packet size */ \
|
|
|
+ 0, /* OUT maximum packet size */ \
|
|
|
+ NULL, /* IN Endpoint state */ \
|
|
|
+ NULL, /* OUT endpoint state */ \
|
|
|
+ 2, /* IN multiplier */ \
|
|
|
+ NULL /* SETUP buffer (not a SETUP endpoint) */ \
|
|
|
+ }, \
|
|
|
+ .out_ep_config = \
|
|
|
+ { \
|
|
|
+ stream##_OUT_MODE, /* Interrupt EP */ \
|
|
|
+ NULL, /* SETUP packet notification callback */ \
|
|
|
+ NULL, /* IN notification callback */ \
|
|
|
+ qmkusbDataReceived, /* OUT notification callback */ \
|
|
|
+ 0, /* IN maximum packet size */ \
|
|
|
+ stream##_EPSIZE, /* OUT maximum packet size */ \
|
|
|
+ NULL, /* IN Endpoint state */ \
|
|
|
+ NULL, /* OUT endpoint state */ \
|
|
|
+ 2, /* IN multiplier */ \
|
|
|
+ NULL, /* SETUP buffer (not a SETUP endpoint) */ \
|
|
|
+ }, \
|
|
|
+ .int_ep_config = \
|
|
|
+ { \
|
|
|
+ USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ \
|
|
|
+ NULL, /* SETUP packet notification callback */ \
|
|
|
+ qmkusbInterruptTransmitted, /* IN notification callback */ \
|
|
|
+ NULL, /* OUT notification callback */ \
|
|
|
+ CDC_NOTIFICATION_EPSIZE, /* IN maximum packet size */ \
|
|
|
+ 0, /* OUT maximum packet size */ \
|
|
|
+ NULL, /* IN Endpoint state */ \
|
|
|
+ NULL, /* OUT endpoint state */ \
|
|
|
+ 2, /* IN multiplier */ \
|
|
|
+ NULL, /* SETUP buffer (not a SETUP endpoint) */ \
|
|
|
+ }, \
|
|
|
+ .config = { \
|
|
|
+ .usbp = &USB_DRIVER, \
|
|
|
+ .bulk_in = stream##_IN_EPNUM, \
|
|
|
+ .bulk_out = stream##_OUT_EPNUM, \
|
|
|
+ .int_in = notification, \
|
|
|
+ .in_buffers = stream##_IN_CAPACITY, \
|
|
|
+ .out_buffers = stream##_OUT_CAPACITY, \
|
|
|
+ .in_size = stream##_EPSIZE, \
|
|
|
+ .out_size = stream##_EPSIZE, \
|
|
|
+ .fixed_size = fixedsize, \
|
|
|
+ .ib = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]){}, \
|
|
|
+ .ob = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \
|
|
|
+ } \
|
|
|
+ }
|
|
|
#endif
|
|
|
|
|
|
typedef struct {
|
|
@@ -388,12 +388,12 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
|
|
|
usbInitEndpointI(usbp, SHARED_IN_EPNUM, &shared_ep_config);
|
|
|
#endif
|
|
|
for (int i = 0; i < NUM_USB_DRIVERS; i++) {
|
|
|
- #if STM32_USB_USE_OTG1
|
|
|
+#if STM32_USB_USE_OTG1
|
|
|
usbInitEndpointI(usbp, drivers.array[i].config.bulk_in, &drivers.array[i].inout_ep_config);
|
|
|
- #else
|
|
|
+#else
|
|
|
usbInitEndpointI(usbp, drivers.array[i].config.bulk_in, &drivers.array[i].in_ep_config);
|
|
|
usbInitEndpointI(usbp, drivers.array[i].config.bulk_out, &drivers.array[i].out_ep_config);
|
|
|
- #endif
|
|
|
+#endif
|
|
|
if (drivers.array[i].config.int_in) {
|
|
|
usbInitEndpointI(usbp, drivers.array[i].config.int_in, &drivers.array[i].int_ep_config);
|
|
|
}
|
|
@@ -544,7 +544,7 @@ static bool usb_request_hook_cb(USBDriver *usbp) {
|
|
|
#ifdef NKRO_ENABLE
|
|
|
keymap_config.nkro = !!keyboard_protocol;
|
|
|
if (!keymap_config.nkro && keyboard_idle) {
|
|
|
-#else /* NKRO_ENABLE */
|
|
|
+#else /* NKRO_ENABLE */
|
|
|
if (keyboard_idle) {
|
|
|
#endif /* NKRO_ENABLE */
|
|
|
/* arm the idle timer if boot protocol & idle */
|
|
@@ -562,7 +562,7 @@ static bool usb_request_hook_cb(USBDriver *usbp) {
|
|
|
/* arm the timer */
|
|
|
#ifdef NKRO_ENABLE
|
|
|
if (!keymap_config.nkro && keyboard_idle) {
|
|
|
-#else /* NKRO_ENABLE */
|
|
|
+#else /* NKRO_ENABLE */
|
|
|
if (keyboard_idle) {
|
|
|
#endif /* NKRO_ENABLE */
|
|
|
osalSysLockFromISR();
|
|
@@ -618,21 +618,21 @@ static const USBConfig usbcfg = {
|
|
|
*/
|
|
|
void init_usb_driver(USBDriver *usbp) {
|
|
|
for (int i = 0; i < NUM_USB_DRIVERS; i++) {
|
|
|
- #if STM32_USB_USE_OTG1
|
|
|
+#if STM32_USB_USE_OTG1
|
|
|
QMKUSBDriver *driver = &drivers.array[i].driver;
|
|
|
drivers.array[i].inout_ep_config.in_state = &drivers.array[i].in_ep_state;
|
|
|
drivers.array[i].inout_ep_config.out_state = &drivers.array[i].out_ep_state;
|
|
|
drivers.array[i].int_ep_config.in_state = &drivers.array[i].int_ep_state;
|
|
|
qmkusbObjectInit(driver, &drivers.array[i].config);
|
|
|
qmkusbStart(driver, &drivers.array[i].config);
|
|
|
- #else
|
|
|
+#else
|
|
|
QMKUSBDriver *driver = &drivers.array[i].driver;
|
|
|
drivers.array[i].in_ep_config.in_state = &drivers.array[i].in_ep_state;
|
|
|
drivers.array[i].out_ep_config.out_state = &drivers.array[i].out_ep_state;
|
|
|
drivers.array[i].int_ep_config.in_state = &drivers.array[i].int_ep_state;
|
|
|
qmkusbObjectInit(driver, &drivers.array[i].config);
|
|
|
qmkusbStart(driver, &drivers.array[i].config);
|
|
|
- #endif
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -689,7 +689,7 @@ static void keyboard_idle_timer_cb(void *arg) {
|
|
|
|
|
|
#ifdef NKRO_ENABLE
|
|
|
if (!keymap_config.nkro && keyboard_idle && keyboard_protocol) {
|
|
|
-#else /* NKRO_ENABLE */
|
|
|
+#else /* NKRO_ENABLE */
|
|
|
if (keyboard_idle && keyboard_protocol) {
|
|
|
#endif /* NKRO_ENABLE */
|
|
|
/* TODO: are we sure we want the KBD_ENDPOINT? */
|
|
@@ -738,7 +738,7 @@ void send_keyboard(report_keyboard_t *report) {
|
|
|
usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)report, sizeof(struct nkro_report));
|
|
|
} else
|
|
|
#endif /* NKRO_ENABLE */
|
|
|
- { /* regular protocol */
|
|
|
+ { /* regular protocol */
|
|
|
/* need to wait until the previous packet has made it through */
|
|
|
/* busy wait, should be short and not very common */
|
|
|
if (usbGetTransmitStatusI(&USB_DRIVER, KEYBOARD_IN_EPNUM)) {
|
|
@@ -805,7 +805,7 @@ void send_mouse(report_mouse_t *report) {
|
|
|
osalSysUnlock();
|
|
|
}
|
|
|
|
|
|
-#else /* MOUSE_ENABLE */
|
|
|
+#else /* MOUSE_ENABLE */
|
|
|
void send_mouse(report_mouse_t *report) { (void)report; }
|
|
|
#endif /* MOUSE_ENABLE */
|
|
|
|
|
@@ -885,7 +885,7 @@ void console_task(void) {
|
|
|
} while (size > 0);
|
|
|
}
|
|
|
|
|
|
-#else /* CONSOLE_ENABLE */
|
|
|
+#else /* CONSOLE_ENABLE */
|
|
|
int8_t sendchar(uint8_t c) {
|
|
|
(void)c;
|
|
|
return 0;
|