From b624f32f944acdc59dcb130674c09090c5c404cb Mon Sep 17 00:00:00 2001 From: skullY Date: Fri, 30 Aug 2019 11:19:03 -0700 Subject: clang-format changes --- tmk_core/protocol/chibios/usb_main.c | 1048 ++++++++++++++++------------------ 1 file changed, 507 insertions(+), 541 deletions(-) (limited to 'tmk_core/protocol/chibios/usb_main.c') diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 8223d97228..c8a6bbb43f 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -24,17 +24,17 @@ #include "debug.h" #include "suspend.h" #ifdef SLEEP_LED_ENABLE -#include "sleep_led.h" -#include "led.h" +# include "sleep_led.h" +# include "led.h" #endif #include "wait.h" #include "usb_descriptor.h" #include "usb_driver.h" #ifdef NKRO_ENABLE - #include "keycode_config.h" +# include "keycode_config.h" - extern keymap_config_t keymap_config; +extern keymap_config_t keymap_config; #endif /* --------------------------------------------------------- @@ -43,19 +43,19 @@ */ #ifndef usb_lld_connect_bus - #define usb_lld_connect_bus(usbp) +# define usb_lld_connect_bus(usbp) #endif #ifndef usb_lld_disconnect_bus - #define usb_lld_disconnect_bus(usbp) +# define usb_lld_disconnect_bus(usbp) #endif -uint8_t keyboard_idle __attribute__((aligned(2))) = 0; -uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; -uint16_t keyboard_led_stats __attribute__((aligned(2))) = 0; -volatile uint16_t keyboard_idle_count = 0; +uint8_t keyboard_idle __attribute__((aligned(2))) = 0; +uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; +uint16_t keyboard_led_stats __attribute__((aligned(2))) = 0; +volatile uint16_t keyboard_idle_count = 0; static virtual_timer_t keyboard_idle_timer; -static void keyboard_idle_timer_cb(void *arg); +static void keyboard_idle_timer_cb(void *arg); report_keyboard_t keyboard_report_sent = {{0}}; #ifdef MOUSE_ENABLE @@ -84,15 +84,15 @@ uint8_t extra_report_blank[3] = {0}; * Returns the proper descriptor */ static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype, uint8_t dindex, uint16_t wIndex) { - (void)usbp; - static USBDescriptor desc; - uint16_t wValue = ((uint16_t)dtype << 8) | dindex; - desc.ud_string = NULL; - desc.ud_size = get_usb_descriptor(wValue, wIndex, (const void** const)&desc.ud_string); - if (desc.ud_string == NULL) - return NULL; - else - return &desc; + (void)usbp; + static USBDescriptor desc; + uint16_t wValue = ((uint16_t)dtype << 8) | dindex; + desc.ud_string = NULL; + desc.ud_size = get_usb_descriptor(wValue, wIndex, (const void **const) & desc.ud_string); + if (desc.ud_string == NULL) + return NULL; + else + return &desc; } #ifndef KEYBOARD_SHARED_EP @@ -100,16 +100,16 @@ static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype static USBInEndpointState kbd_ep_state; /* keyboard endpoint initialization structure (IN) */ static const USBEndpointConfig kbd_ep_config = { - USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ - NULL, /* SETUP packet notification callback */ - kbd_in_cb, /* IN notification callback */ - NULL, /* OUT notification callback */ - KEYBOARD_EPSIZE, /* IN maximum packet size */ - 0, /* OUT maximum packet size */ - &kbd_ep_state, /* IN Endpoint state */ - NULL, /* OUT endpoint state */ - 2, /* IN multiplier */ - NULL /* SETUP buffer (not a SETUP endpoint) */ + USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ + NULL, /* SETUP packet notification callback */ + kbd_in_cb, /* IN notification callback */ + NULL, /* OUT notification callback */ + KEYBOARD_EPSIZE, /* IN maximum packet size */ + 0, /* OUT maximum packet size */ + &kbd_ep_state, /* IN Endpoint state */ + NULL, /* OUT endpoint state */ + 2, /* IN multiplier */ + NULL /* SETUP buffer (not a SETUP endpoint) */ }; #endif @@ -119,16 +119,16 @@ static USBInEndpointState mouse_ep_state; /* mouse endpoint initialization structure (IN) */ static const USBEndpointConfig mouse_ep_config = { - USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ - NULL, /* SETUP packet notification callback */ - mouse_in_cb, /* IN notification callback */ - NULL, /* OUT notification callback */ - MOUSE_EPSIZE, /* IN maximum packet size */ - 0, /* OUT maximum packet size */ - &mouse_ep_state, /* IN Endpoint state */ - NULL, /* OUT endpoint state */ - 2, /* IN multiplier */ - NULL /* SETUP buffer (not a SETUP endpoint) */ + USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ + NULL, /* SETUP packet notification callback */ + mouse_in_cb, /* IN notification callback */ + NULL, /* OUT notification callback */ + MOUSE_EPSIZE, /* IN maximum packet size */ + 0, /* OUT maximum packet size */ + &mouse_ep_state, /* IN Endpoint state */ + NULL, /* OUT endpoint state */ + 2, /* IN multiplier */ + NULL /* SETUP buffer (not a SETUP endpoint) */ }; #endif @@ -138,145 +138,141 @@ static USBInEndpointState shared_ep_state; /* shared endpoint initialization structure (IN) */ static const USBEndpointConfig shared_ep_config = { - USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ - NULL, /* SETUP packet notification callback */ - shared_in_cb, /* IN notification callback */ - NULL, /* OUT notification callback */ - SHARED_EPSIZE, /* IN maximum packet size */ - 0, /* OUT maximum packet size */ - &shared_ep_state, /* IN Endpoint state */ - NULL, /* OUT endpoint state */ - 2, /* IN multiplier */ - NULL /* SETUP buffer (not a SETUP endpoint) */ + USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ + NULL, /* SETUP packet notification callback */ + shared_in_cb, /* IN notification callback */ + NULL, /* OUT notification callback */ + SHARED_EPSIZE, /* IN maximum packet size */ + 0, /* OUT maximum packet size */ + &shared_ep_state, /* IN Endpoint state */ + NULL, /* OUT endpoint state */ + 2, /* IN multiplier */ + NULL /* SETUP buffer (not a SETUP endpoint) */ }; #endif typedef struct { - size_t queue_capacity_in; - size_t queue_capacity_out; - USBInEndpointState in_ep_state; - USBOutEndpointState out_ep_state; - USBInEndpointState int_ep_state; - USBEndpointConfig in_ep_config; - USBEndpointConfig out_ep_config; - USBEndpointConfig int_ep_config; - const QMKUSBConfig config; - QMKUSBDriver driver; + size_t queue_capacity_in; + size_t queue_capacity_out; + USBInEndpointState in_ep_state; + USBOutEndpointState out_ep_state; + USBInEndpointState int_ep_state; + USBEndpointConfig in_ep_config; + USBEndpointConfig out_ep_config; + USBEndpointConfig int_ep_config; + const QMKUSBConfig config; + QMKUSBDriver driver; } usb_driver_config_t; -#define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) { \ - .queue_capacity_in = stream##_IN_CAPACITY, \ - .queue_capacity_out = stream##_OUT_CAPACITY, \ - .in_ep_config = { \ - .ep_mode = stream##_IN_MODE, \ - .setup_cb = NULL, \ - .in_cb = qmkusbDataTransmitted, \ - .out_cb = NULL, \ - .in_maxsize = stream##_EPSIZE, \ - .out_maxsize = 0, \ - /* The pointer to the states will be filled during initialization */ \ - .in_state = NULL, \ - .out_state = NULL, \ - .ep_buffers = 2, \ - .setup_buf = NULL \ - }, \ - .out_ep_config = { \ - .ep_mode = stream##_OUT_MODE, \ - .setup_cb = NULL, \ - .in_cb = NULL, \ - .out_cb = qmkusbDataReceived, \ - .in_maxsize = 0, \ - .out_maxsize = stream##_EPSIZE, \ - /* The pointer to the states will be filled during initialization */ \ - .in_state = NULL, \ - .out_state = NULL, \ - .ep_buffers = 2, \ - .setup_buf = NULL, \ - }, \ - .int_ep_config = { \ - .ep_mode = USB_EP_MODE_TYPE_INTR, \ - .setup_cb = NULL, \ - .in_cb = qmkusbInterruptTransmitted, \ - .out_cb = NULL, \ - .in_maxsize = CDC_NOTIFICATION_EPSIZE, \ - .out_maxsize = 0, \ - /* The pointer to the states will be filled during initialization */ \ - .in_state = NULL, \ - .out_state = NULL, \ - .ep_buffers = 2, \ - .setup_buf = NULL, \ - }, \ - .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 = (uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]) {}, \ - .ob = (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 = {.ep_mode = stream##_IN_MODE, \ + .setup_cb = NULL, \ + .in_cb = qmkusbDataTransmitted, \ + .out_cb = NULL, \ + .in_maxsize = stream##_EPSIZE, \ + .out_maxsize = 0, /* The pointer to the states will be filled during initialization */ \ + .in_state = NULL, \ + .out_state = NULL, \ + .ep_buffers = 2, \ + .setup_buf = NULL}, \ + .out_ep_config = \ + { \ + .ep_mode = stream##_OUT_MODE, \ + .setup_cb = NULL, \ + .in_cb = NULL, \ + .out_cb = qmkusbDataReceived, \ + .in_maxsize = 0, \ + .out_maxsize = stream##_EPSIZE, /* The pointer to the states will be filled during initialization */ \ + .in_state = NULL, \ + .out_state = NULL, \ + .ep_buffers = 2, \ + .setup_buf = NULL, \ + }, \ + .int_ep_config = \ + { \ + .ep_mode = USB_EP_MODE_TYPE_INTR, \ + .setup_cb = NULL, \ + .in_cb = qmkusbInterruptTransmitted, \ + .out_cb = NULL, \ + .in_maxsize = CDC_NOTIFICATION_EPSIZE, \ + .out_maxsize = 0, /* The pointer to the states will be filled during initialization */ \ + .in_state = NULL, \ + .out_state = NULL, \ + .ep_buffers = 2, \ + .setup_buf = NULL, \ + }, \ + .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 = (uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]){}, \ + .ob = (uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \ + } \ + } typedef struct { - union { - struct { + union { + struct { #ifdef CONSOLE_ENABLE - usb_driver_config_t console_driver; + usb_driver_config_t console_driver; #endif #ifdef RAW_ENABLE - usb_driver_config_t raw_driver; + usb_driver_config_t raw_driver; #endif #ifdef MIDI_ENABLE - usb_driver_config_t midi_driver; + usb_driver_config_t midi_driver; #endif #ifdef VIRTSER_ENABLE - usb_driver_config_t serial_driver; + usb_driver_config_t serial_driver; #endif + }; + usb_driver_config_t array[0]; }; - usb_driver_config_t array[0]; - }; } usb_driver_configs_t; static usb_driver_configs_t drivers = { #ifdef CONSOLE_ENABLE - #define CONSOLE_IN_CAPACITY 4 - #define CONSOLE_OUT_CAPACITY 4 - #define CONSOLE_IN_MODE USB_EP_MODE_TYPE_INTR - #define CONSOLE_OUT_MODE USB_EP_MODE_TYPE_INTR - .console_driver = QMK_USB_DRIVER_CONFIG(CONSOLE, 0, true), +# define CONSOLE_IN_CAPACITY 4 +# define CONSOLE_OUT_CAPACITY 4 +# define CONSOLE_IN_MODE USB_EP_MODE_TYPE_INTR +# define CONSOLE_OUT_MODE USB_EP_MODE_TYPE_INTR + .console_driver = QMK_USB_DRIVER_CONFIG(CONSOLE, 0, true), #endif #ifdef RAW_ENABLE - #define RAW_IN_CAPACITY 4 - #define RAW_OUT_CAPACITY 4 - #define RAW_IN_MODE USB_EP_MODE_TYPE_INTR - #define RAW_OUT_MODE USB_EP_MODE_TYPE_INTR - .raw_driver = QMK_USB_DRIVER_CONFIG(RAW, 0, false), +# define RAW_IN_CAPACITY 4 +# define RAW_OUT_CAPACITY 4 +# define RAW_IN_MODE USB_EP_MODE_TYPE_INTR +# define RAW_OUT_MODE USB_EP_MODE_TYPE_INTR + .raw_driver = QMK_USB_DRIVER_CONFIG(RAW, 0, false), #endif #ifdef MIDI_ENABLE - #define MIDI_STREAM_IN_CAPACITY 4 - #define MIDI_STREAM_OUT_CAPACITY 4 - #define MIDI_STREAM_IN_MODE USB_EP_MODE_TYPE_BULK - #define MIDI_STREAM_OUT_MODE USB_EP_MODE_TYPE_BULK - .midi_driver = QMK_USB_DRIVER_CONFIG(MIDI_STREAM, 0, false), +# define MIDI_STREAM_IN_CAPACITY 4 +# define MIDI_STREAM_OUT_CAPACITY 4 +# define MIDI_STREAM_IN_MODE USB_EP_MODE_TYPE_BULK +# define MIDI_STREAM_OUT_MODE USB_EP_MODE_TYPE_BULK + .midi_driver = QMK_USB_DRIVER_CONFIG(MIDI_STREAM, 0, false), #endif #ifdef VIRTSER_ENABLE - #define CDC_IN_CAPACITY 4 - #define CDC_OUT_CAPACITY 4 - #define CDC_IN_MODE USB_EP_MODE_TYPE_BULK - #define CDC_OUT_MODE USB_EP_MODE_TYPE_BULK - .serial_driver = QMK_USB_DRIVER_CONFIG(CDC, CDC_NOTIFICATION_EPNUM, false), +# define CDC_IN_CAPACITY 4 +# define CDC_OUT_CAPACITY 4 +# define CDC_IN_MODE USB_EP_MODE_TYPE_BULK +# define CDC_OUT_MODE USB_EP_MODE_TYPE_BULK + .serial_driver = QMK_USB_DRIVER_CONFIG(CDC, CDC_NOTIFICATION_EPNUM, false), #endif }; #define NUM_USB_DRIVERS (sizeof(drivers) / sizeof(usb_driver_config_t)) - /* --------------------------------------------------------- * USB driver functions * --------------------------------------------------------- @@ -285,77 +281,77 @@ static usb_driver_configs_t drivers = { /* Handles the USB driver global events * TODO: maybe disable some things when connection is lost? */ static void usb_event_cb(USBDriver *usbp, usbevent_t event) { - switch(event) { - case USB_EVENT_ADDRESS: - return; + switch (event) { + case USB_EVENT_ADDRESS: + return; - case USB_EVENT_CONFIGURED: - osalSysLockFromISR(); - /* Enable the endpoints specified into the configuration. */ + case USB_EVENT_CONFIGURED: + osalSysLockFromISR(); + /* Enable the endpoints specified into the configuration. */ #ifndef KEYBOARD_SHARED_EP - usbInitEndpointI(usbp, KEYBOARD_IN_EPNUM, &kbd_ep_config); + usbInitEndpointI(usbp, KEYBOARD_IN_EPNUM, &kbd_ep_config); #endif #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) - usbInitEndpointI(usbp, MOUSE_IN_EPNUM, &mouse_ep_config); + usbInitEndpointI(usbp, MOUSE_IN_EPNUM, &mouse_ep_config); #endif #ifdef SHARED_EP_ENABLE - usbInitEndpointI(usbp, SHARED_IN_EPNUM, &shared_ep_config); + usbInitEndpointI(usbp, SHARED_IN_EPNUM, &shared_ep_config); #endif - for (int i=0;isetup fields: - * 0: bmRequestType (bitmask) - * 1: bRequest - * 2,3: (LSB,MSB) wValue - * 4,5: (LSB,MSB) wIndex - * 6,7: (LSB,MSB) wLength (number of bytes to transfer if there is a data phase) */ - - /* Handle HID class specific requests */ - if(((usbp->setup[0] & USB_RTYPE_TYPE_MASK) == USB_RTYPE_TYPE_CLASS) && - ((usbp->setup[0] & USB_RTYPE_RECIPIENT_MASK) == USB_RTYPE_RECIPIENT_INTERFACE)) { - switch(usbp->setup[0] & USB_RTYPE_DIR_MASK) { - case USB_RTYPE_DIR_DEV2HOST: - switch(usbp->setup[1]) { /* bRequest */ - case HID_GET_REPORT: - switch(usbp->setup[4]) { /* LSB(wIndex) (check MSB==0?) */ - case KEYBOARD_INTERFACE: - usbSetupTransfer(usbp, (uint8_t *)&keyboard_report_sent, sizeof(keyboard_report_sent), NULL); - return TRUE; - break; + const USBDescriptor *dp; + int has_report_id; + + /* usbp->setup fields: + * 0: bmRequestType (bitmask) + * 1: bRequest + * 2,3: (LSB,MSB) wValue + * 4,5: (LSB,MSB) wIndex + * 6,7: (LSB,MSB) wLength (number of bytes to transfer if there is a data phase) */ + + /* Handle HID class specific requests */ + if (((usbp->setup[0] & USB_RTYPE_TYPE_MASK) == USB_RTYPE_TYPE_CLASS) && ((usbp->setup[0] & USB_RTYPE_RECIPIENT_MASK) == USB_RTYPE_RECIPIENT_INTERFACE)) { + switch (usbp->setup[0] & USB_RTYPE_DIR_MASK) { + case USB_RTYPE_DIR_DEV2HOST: + switch (usbp->setup[1]) { /* bRequest */ + case HID_GET_REPORT: + switch (usbp->setup[4]) { /* LSB(wIndex) (check MSB==0?) */ + case KEYBOARD_INTERFACE: + usbSetupTransfer(usbp, (uint8_t *)&keyboard_report_sent, sizeof(keyboard_report_sent), NULL); + return TRUE; + break; #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) - case MOUSE_INTERFACE: - usbSetupTransfer(usbp, (uint8_t *)&mouse_report_blank, sizeof(mouse_report_blank), NULL); - return TRUE; - break; + case MOUSE_INTERFACE: + usbSetupTransfer(usbp, (uint8_t *)&mouse_report_blank, sizeof(mouse_report_blank), NULL); + return TRUE; + break; #endif - default: - usbSetupTransfer(usbp, NULL, 0, NULL); - return TRUE; - break; - } - break; - - case HID_GET_PROTOCOL: - if((usbp->setup[4] == KEYBOARD_INTERFACE) && (usbp->setup[5] == 0)) { /* wIndex */ - usbSetupTransfer(usbp, &keyboard_protocol, 1, NULL); - return TRUE; - } - break; - - case HID_GET_IDLE: - usbSetupTransfer(usbp, &keyboard_idle, 1, NULL); - return TRUE; - break; - } - break; - - case USB_RTYPE_DIR_HOST2DEV: - switch(usbp->setup[1]) { /* bRequest */ - case HID_SET_REPORT: - switch(usbp->setup[4]) { /* LSB(wIndex) (check MSB==0 and wLength==1?) */ - case KEYBOARD_INTERFACE: + default: + usbSetupTransfer(usbp, NULL, 0, NULL); + return TRUE; + break; + } + break; + + case HID_GET_PROTOCOL: + if ((usbp->setup[4] == KEYBOARD_INTERFACE) && (usbp->setup[5] == 0)) { /* wIndex */ + usbSetupTransfer(usbp, &keyboard_protocol, 1, NULL); + return TRUE; + } + break; + + case HID_GET_IDLE: + usbSetupTransfer(usbp, &keyboard_idle, 1, NULL); + return TRUE; + break; + } + break; + + case USB_RTYPE_DIR_HOST2DEV: + switch (usbp->setup[1]) { /* bRequest */ + case HID_SET_REPORT: + switch (usbp->setup[4]) { /* LSB(wIndex) (check MSB==0 and wLength==1?) */ + case KEYBOARD_INTERFACE: #if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP) - case SHARED_INTERFACE: + case SHARED_INTERFACE: #endif - /* keyboard_led_stats = - * keyboard_led_stats needs be word (or dword), otherwise we get an exception on F0 */ - has_report_id = 0; + /* keyboard_led_stats = + * keyboard_led_stats needs be word (or dword), otherwise we get an exception on F0 */ + has_report_id = 0; #if defined(SHARED_EP_ENABLE) - if (usbp->setup[4] == SHARED_INTERFACE) { - has_report_id = 1; - } + if (usbp->setup[4] == SHARED_INTERFACE) { + has_report_id = 1; + } #endif - if (usbp->setup[4] == KEYBOARD_INTERFACE && !keyboard_protocol) { - has_report_id = 0; - } - if (has_report_id) { - usbSetupTransfer(usbp, set_report_buf, sizeof(set_report_buf), set_led_transfer_cb); - } else { - usbSetupTransfer(usbp, (uint8_t *)&keyboard_led_stats, 1, NULL); - } - return TRUE; - break; - } - break; - - case HID_SET_PROTOCOL: - if((usbp->setup[4] == KEYBOARD_INTERFACE) && (usbp->setup[5] == 0)) { /* wIndex */ - keyboard_protocol = ((usbp->setup[2]) != 0x00); /* LSB(wValue) */ + if (usbp->setup[4] == KEYBOARD_INTERFACE && !keyboard_protocol) { + has_report_id = 0; + } + if (has_report_id) { + usbSetupTransfer(usbp, set_report_buf, sizeof(set_report_buf), set_led_transfer_cb); + } else { + usbSetupTransfer(usbp, (uint8_t *)&keyboard_led_stats, 1, NULL); + } + return TRUE; + break; + } + break; + + case HID_SET_PROTOCOL: + if ((usbp->setup[4] == KEYBOARD_INTERFACE) && (usbp->setup[5] == 0)) { /* wIndex */ + keyboard_protocol = ((usbp->setup[2]) != 0x00); /* LSB(wValue) */ #ifdef NKRO_ENABLE - keymap_config.nkro = !!keyboard_protocol; - if(!keymap_config.nkro && keyboard_idle) { -#else /* NKRO_ENABLE */ - if(keyboard_idle) { -#endif /* NKRO_ENABLE */ - /* arm the idle timer if boot protocol & idle */ - osalSysLockFromISR(); - chVTSetI(&keyboard_idle_timer, 4*MS2ST(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); - osalSysUnlockFromISR(); - } - } - usbSetupTransfer(usbp, NULL, 0, NULL); - return TRUE; - break; - - case HID_SET_IDLE: - keyboard_idle = usbp->setup[3]; /* MSB(wValue) */ - /* arm the timer */ + keymap_config.nkro = !!keyboard_protocol; + if (!keymap_config.nkro && keyboard_idle) { +#else /* NKRO_ENABLE */ + if (keyboard_idle) { +#endif /* NKRO_ENABLE */ + /* arm the idle timer if boot protocol & idle */ + osalSysLockFromISR(); + chVTSetI(&keyboard_idle_timer, 4 * MS2ST(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); + osalSysUnlockFromISR(); + } + } + usbSetupTransfer(usbp, NULL, 0, NULL); + return TRUE; + break; + + case HID_SET_IDLE: + keyboard_idle = usbp->setup[3]; /* MSB(wValue) */ + /* arm the timer */ #ifdef NKRO_ENABLE - if(!keymap_config.nkro && keyboard_idle) { -#else /* NKRO_ENABLE */ - if(keyboard_idle) { + if (!keymap_config.nkro && keyboard_idle) { +#else /* NKRO_ENABLE */ + if (keyboard_idle) { #endif /* NKRO_ENABLE */ - osalSysLockFromISR(); - chVTSetI(&keyboard_idle_timer, 4*MS2ST(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); - osalSysUnlockFromISR(); + osalSysLockFromISR(); + chVTSetI(&keyboard_idle_timer, 4 * MS2ST(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); + osalSysUnlockFromISR(); + } + usbSetupTransfer(usbp, NULL, 0, NULL); + return TRUE; + break; + } + break; } - usbSetupTransfer(usbp, NULL, 0, NULL); + } + + /* Handle the Get_Descriptor Request for HID class (not handled by the default hook) */ + if ((usbp->setup[0] == 0x81) && (usbp->setup[1] == USB_REQ_GET_DESCRIPTOR)) { + dp = usbp->config->get_descriptor_cb(usbp, usbp->setup[3], usbp->setup[2], get_hword(&usbp->setup[4])); + if (dp == NULL) return FALSE; + usbSetupTransfer(usbp, (uint8_t *)dp->ud_string, dp->ud_size, NULL); return TRUE; - break; - } - break; } - } - - /* Handle the Get_Descriptor Request for HID class (not handled by the default hook) */ - if((usbp->setup[0] == 0x81) && (usbp->setup[1] == USB_REQ_GET_DESCRIPTOR)) { - dp = usbp->config->get_descriptor_cb(usbp, usbp->setup[3], usbp->setup[2], get_hword(&usbp->setup[4])); - if(dp == NULL) - return FALSE; - usbSetupTransfer(usbp, (uint8_t *)dp->ud_string, dp->ud_size, NULL); - return TRUE; - } - - for (int i=0;iepc[SHARED_IN_EPNUM]->in_state->thread); + if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { + osalSysUnlock(); + return; } - usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)report, sizeof(struct nkro_report)); osalSysUnlock(); - } else + +#ifdef NKRO_ENABLE + if (keymap_config.nkro && keyboard_protocol) { /* NKRO protocol */ + /* need to wait until the previous packet has made it through */ + /* can rewrite this using the synchronous API, then would wait + * until *after* the packet has been transmitted. I think + * this is more efficient */ + /* busy wait, should be short and not very common */ + osalSysLock(); + if (usbGetTransmitStatusI(&USB_DRIVER, SHARED_IN_EPNUM)) { + /* Need to either suspend, or loop and call unlock/lock during + * every iteration - otherwise the system will remain locked, + * no interrupts served, so USB not going through as well. + * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ + osalThreadSuspendS(&(&USB_DRIVER)->epc[SHARED_IN_EPNUM]->in_state->thread); + } + usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)report, sizeof(struct nkro_report)); + osalSysUnlock(); + } else #endif /* NKRO_ENABLE */ - { /* regular protocol */ - /* need to wait until the previous packet has made it through */ - /* busy wait, should be short and not very common */ - osalSysLock(); - if(usbGetTransmitStatusI(&USB_DRIVER, KEYBOARD_IN_EPNUM)) { - /* Need to either suspend, or loop and call unlock/lock during - * every iteration - otherwise the system will remain locked, - * no interrupts served, so USB not going through as well. - * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ - osalThreadSuspendS(&(&USB_DRIVER)->epc[KEYBOARD_IN_EPNUM]->in_state->thread); - } - uint8_t *data, size; - if (keyboard_protocol) { - data = (uint8_t*)report; - size = KEYBOARD_REPORT_SIZE; - } else { /* boot protocol */ - data = &report->mods; - size = 8; + { /* regular protocol */ + /* need to wait until the previous packet has made it through */ + /* busy wait, should be short and not very common */ + osalSysLock(); + if (usbGetTransmitStatusI(&USB_DRIVER, KEYBOARD_IN_EPNUM)) { + /* Need to either suspend, or loop and call unlock/lock during + * every iteration - otherwise the system will remain locked, + * no interrupts served, so USB not going through as well. + * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ + osalThreadSuspendS(&(&USB_DRIVER)->epc[KEYBOARD_IN_EPNUM]->in_state->thread); + } + uint8_t *data, size; + if (keyboard_protocol) { + data = (uint8_t *)report; + size = KEYBOARD_REPORT_SIZE; + } else { /* boot protocol */ + data = &report->mods; + size = 8; + } + usbStartTransmitI(&USB_DRIVER, KEYBOARD_IN_EPNUM, data, size); + osalSysUnlock(); } - usbStartTransmitI(&USB_DRIVER, KEYBOARD_IN_EPNUM, data, size); - osalSysUnlock(); - } - keyboard_report_sent = *report; + keyboard_report_sent = *report; } /* --------------------------------------------------------- @@ -684,39 +672,37 @@ void send_keyboard(report_keyboard_t *report) { #ifdef MOUSE_ENABLE -#ifndef MOUSE_SHARED_EP +# ifndef MOUSE_SHARED_EP /* mouse IN callback hander (a mouse report has made it IN) */ void mouse_in_cb(USBDriver *usbp, usbep_t ep) { - (void)usbp; - (void)ep; + (void)usbp; + (void)ep; } -#endif +# endif void send_mouse(report_mouse_t *report) { - osalSysLock(); - if(usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { - osalSysUnlock(); - return; - } - - if(usbGetTransmitStatusI(&USB_DRIVER, MOUSE_IN_EPNUM)) { - /* Need to either suspend, or loop and call unlock/lock during - * every iteration - otherwise the system will remain locked, - * no interrupts served, so USB not going through as well. - * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ - if (osalThreadSuspendTimeoutS(&(&USB_DRIVER)->epc[MOUSE_IN_EPNUM]->in_state->thread, MS2ST(10))==MSG_TIMEOUT) { - osalSysUnlock(); - return; + osalSysLock(); + if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { + osalSysUnlock(); + return; } - } - usbStartTransmitI(&USB_DRIVER, MOUSE_IN_EPNUM, (uint8_t *)report, sizeof(report_mouse_t)); - osalSysUnlock(); -} -#else /* MOUSE_ENABLE */ -void send_mouse(report_mouse_t *report) { - (void)report; + if (usbGetTransmitStatusI(&USB_DRIVER, MOUSE_IN_EPNUM)) { + /* Need to either suspend, or loop and call unlock/lock during + * every iteration - otherwise the system will remain locked, + * no interrupts served, so USB not going through as well. + * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ + if (osalThreadSuspendTimeoutS(&(&USB_DRIVER)->epc[MOUSE_IN_EPNUM]->in_state->thread, MS2ST(10)) == MSG_TIMEOUT) { + osalSysUnlock(); + return; + } + } + usbStartTransmitI(&USB_DRIVER, MOUSE_IN_EPNUM, (uint8_t *)report, sizeof(report_mouse_t)); + osalSysUnlock(); } + +#else /* MOUSE_ENABLE */ +void send_mouse(report_mouse_t *report) { (void)report; } #endif /* MOUSE_ENABLE */ /* --------------------------------------------------------- @@ -726,9 +712,9 @@ void send_mouse(report_mouse_t *report) { #ifdef SHARED_EP_ENABLE /* shared IN callback hander */ void shared_in_cb(USBDriver *usbp, usbep_t ep) { - /* STUB */ - (void)usbp; - (void)ep; + /* STUB */ + (void)usbp; + (void)ep; } #endif @@ -739,36 +725,25 @@ void shared_in_cb(USBDriver *usbp, usbep_t ep) { #ifdef EXTRAKEY_ENABLE static void send_extra_report(uint8_t report_id, uint16_t data) { - osalSysLock(); - if(usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { - osalSysUnlock(); - return; - } + osalSysLock(); + if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { + osalSysUnlock(); + return; + } - report_extra_t report = { - .report_id = report_id, - .usage = data - }; + report_extra_t report = {.report_id = report_id, .usage = data}; - usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t)); - osalSysUnlock(); + usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t)); + osalSysUnlock(); } -void send_system(uint16_t data) { - send_extra_report(REPORT_ID_SYSTEM, data); -} +void send_system(uint16_t data) { send_extra_report(REPORT_ID_SYSTEM, data); } -void send_consumer(uint16_t data) { - send_extra_report(REPORT_ID_CONSUMER, data); -} +void send_consumer(uint16_t data) { send_extra_report(REPORT_ID_CONSUMER, data); } -#else /* EXTRAKEY_ENABLE */ -void send_system(uint16_t data) { - (void)data; -} -void send_consumer(uint16_t data) { - (void)data; -} +#else /* EXTRAKEY_ENABLE */ +void send_system(uint16_t data) { (void)data; } +void send_consumer(uint16_t data) { (void)data; } #endif /* EXTRAKEY_ENABLE */ /* --------------------------------------------------------- @@ -779,106 +754,97 @@ void send_consumer(uint16_t data) { #ifdef CONSOLE_ENABLE int8_t sendchar(uint8_t c) { - // The previous implmentation had timeouts, but I think it's better to just slow down - // and make sure that everything is transferred, rather than dropping stuff - return chnWrite(&drivers.console_driver.driver, &c, 1); + // The previous implmentation had timeouts, but I think it's better to just slow down + // and make sure that everything is transferred, rather than dropping stuff + return chnWrite(&drivers.console_driver.driver, &c, 1); } // Just a dummy function for now, this could be exposed as a weak function // Or connected to the actual QMK console -static void console_receive( uint8_t *data, uint8_t length ) { - (void)data; - (void)length; +static void console_receive(uint8_t *data, uint8_t length) { + (void)data; + (void)length; } void console_task(void) { - uint8_t buffer[CONSOLE_EPSIZE]; - size_t size = 0; - do { - size_t size = chnReadTimeout(&drivers.console_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE); - if (size > 0) { - console_receive(buffer, size); - } - } while(size > 0); + uint8_t buffer[CONSOLE_EPSIZE]; + size_t size = 0; + do { + size_t size = chnReadTimeout(&drivers.console_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE); + if (size > 0) { + console_receive(buffer, size); + } + } while (size > 0); } -#else /* CONSOLE_ENABLE */ +#else /* CONSOLE_ENABLE */ int8_t sendchar(uint8_t c) { - (void)c; - return 0; + (void)c; + return 0; } #endif /* CONSOLE_ENABLE */ void sendchar_pf(void *p, char c) { - (void)p; - sendchar((uint8_t)c); + (void)p; + sendchar((uint8_t)c); } #ifdef RAW_ENABLE -void raw_hid_send( uint8_t *data, uint8_t length ) { - // TODO: implement variable size packet - if ( length != RAW_EPSIZE ) - { - return; - - } - chnWrite(&drivers.raw_driver.driver, data, length); +void raw_hid_send(uint8_t *data, uint8_t length) { + // TODO: implement variable size packet + if (length != RAW_EPSIZE) { + return; + } + chnWrite(&drivers.raw_driver.driver, data, length); } -__attribute__ ((weak)) -void raw_hid_receive( uint8_t *data, uint8_t length ) { - // Users should #include "raw_hid.h" in their own code - // and implement this function there. Leave this as weak linkage - // so users can opt to not handle data coming in. +__attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { + // Users should #include "raw_hid.h" in their own code + // and implement this function there. Leave this as weak linkage + // so users can opt to not handle data coming in. } void raw_hid_task(void) { - uint8_t buffer[RAW_EPSIZE]; - size_t size = 0; - do { - size_t size = chnReadTimeout(&drivers.raw_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE); - if (size > 0) { - raw_hid_receive(buffer, size); - } - } while(size > 0); + uint8_t buffer[RAW_EPSIZE]; + size_t size = 0; + do { + size_t size = chnReadTimeout(&drivers.raw_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE); + if (size > 0) { + raw_hid_receive(buffer, size); + } + } while (size > 0); } #endif #ifdef MIDI_ENABLE -void send_midi_packet(MIDI_EventPacket_t* event) { - chnWrite(&drivers.midi_driver.driver, (uint8_t*)event, sizeof(MIDI_EventPacket_t)); -} +void send_midi_packet(MIDI_EventPacket_t *event) { chnWrite(&drivers.midi_driver.driver, (uint8_t *)event, sizeof(MIDI_EventPacket_t)); } -bool recv_midi_packet(MIDI_EventPacket_t* const event) { - size_t size = chnReadTimeout(&drivers.midi_driver.driver, (uint8_t*)event, sizeof(MIDI_EventPacket_t), TIME_IMMEDIATE); - return size == sizeof(MIDI_EventPacket_t); +bool recv_midi_packet(MIDI_EventPacket_t *const event) { + size_t size = chnReadTimeout(&drivers.midi_driver.driver, (uint8_t *)event, sizeof(MIDI_EventPacket_t), TIME_IMMEDIATE); + return size == sizeof(MIDI_EventPacket_t); } #endif #ifdef VIRTSER_ENABLE -void virtser_send(const uint8_t byte) { - chnWrite(&drivers.serial_driver.driver, &byte, 1); -} +void virtser_send(const uint8_t byte) { chnWrite(&drivers.serial_driver.driver, &byte, 1); } -__attribute__ ((weak)) -void virtser_recv(uint8_t c) -{ - // Ignore by default +__attribute__((weak)) void virtser_recv(uint8_t c) { + // Ignore by default } void virtser_task(void) { - uint8_t numBytesReceived = 0; - uint8_t buffer[16]; - do { - numBytesReceived = chnReadTimeout(&drivers.serial_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE); - for (int i=0;i 0); + uint8_t numBytesReceived = 0; + uint8_t buffer[16]; + do { + numBytesReceived = chnReadTimeout(&drivers.serial_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE); + for (int i = 0; i < numBytesReceived; i++) { + virtser_recv(buffer[i]); + } + } while (numBytesReceived > 0); } #endif -- cgit v1.2.3 From 1d4287cb9535a8ba7ab5d2aa0846167f34fc5b67 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sun, 10 Nov 2019 17:02:46 +0000 Subject: Fix chibios when mouse and nkro disabled (#7312) --- tmk_core/protocol/chibios/usb_main.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'tmk_core/protocol/chibios/usb_main.c') diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index c8a6bbb43f..f7bfa20b2e 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -379,7 +379,6 @@ static void set_led_transfer_cb(USBDriver *usbp) { /* Callback for SETUP request on the endpoint 0 (control) */ static bool usb_request_hook_cb(USBDriver *usbp) { const USBDescriptor *dp; - int has_report_id; /* usbp->setup fields: * 0: bmRequestType (bitmask) @@ -432,26 +431,17 @@ static bool usb_request_hook_cb(USBDriver *usbp) { switch (usbp->setup[1]) { /* bRequest */ case HID_SET_REPORT: switch (usbp->setup[4]) { /* LSB(wIndex) (check MSB==0 and wLength==1?) */ - case KEYBOARD_INTERFACE: #if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP) case SHARED_INTERFACE: + usbSetupTransfer(usbp, set_report_buf, sizeof(set_report_buf), set_led_transfer_cb); + return TRUE; + break; #endif + + case KEYBOARD_INTERFACE: /* keyboard_led_stats = * keyboard_led_stats needs be word (or dword), otherwise we get an exception on F0 */ - has_report_id = 0; -#if defined(SHARED_EP_ENABLE) - if (usbp->setup[4] == SHARED_INTERFACE) { - has_report_id = 1; - } -#endif - if (usbp->setup[4] == KEYBOARD_INTERFACE && !keyboard_protocol) { - has_report_id = 0; - } - if (has_report_id) { - usbSetupTransfer(usbp, set_report_buf, sizeof(set_report_buf), set_led_transfer_cb); - } else { - usbSetupTransfer(usbp, (uint8_t *)&keyboard_led_stats, 1, NULL); - } + usbSetupTransfer(usbp, (uint8_t *)&keyboard_led_stats, 1, NULL); return TRUE; break; } -- cgit v1.2.3 From a91c0c476507cb8c12840abb59bff34ab0de3c03 Mon Sep 17 00:00:00 2001 From: zvecr Date: Sun, 17 Nov 2019 14:02:26 +0000 Subject: Run clang-format manually to fix recently changed files --- drivers/haptic/DRV2605L.c | 12 ++- drivers/haptic/haptic.c | 85 +++++++++++----------- drivers/haptic/haptic.h | 16 ++-- quantum/backlight/backlight_avr.c | 2 +- quantum/config_common.h | 39 +++++----- quantum/dip_switch.c | 37 ++++------ quantum/encoder.c | 8 +- quantum/keymap_extras/keymap_italian.h | 54 +++++++------- quantum/keymap_extras/keymap_italian_osx_ansi.h | 60 +++++++-------- quantum/keymap_extras/keymap_italian_osx_iso.h | 60 +++++++-------- quantum/process_keycode/process_tap_dance.h | 6 +- quantum/quantum.c | 2 +- quantum/quantum.h | 5 +- quantum/quantum_keycodes.h | 2 +- quantum/rgblight.c | 2 +- quantum/stm32/chconf.h | 39 ++++++---- tmk_core/common/arm_atsam/suspend.c | 3 +- tmk_core/common/eeconfig.c | 4 +- tmk_core/common/host.c | 2 +- tmk_core/common/led.h | 10 +-- tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h | 7 +- tmk_core/protocol/chibios/usb_main.c | 6 +- tmk_core/protocol/iwrap/iwrap.c | 3 +- tmk_core/protocol/lufa/adafruit_ble.cpp | 6 +- 24 files changed, 235 insertions(+), 235 deletions(-) (limited to 'tmk_core/protocol/chibios/usb_main.c') diff --git a/drivers/haptic/DRV2605L.c b/drivers/haptic/DRV2605L.c index 728554b01e..c40731913b 100644 --- a/drivers/haptic/DRV2605L.c +++ b/drivers/haptic/DRV2605L.c @@ -115,15 +115,13 @@ void DRV_init(void) { } void DRV_rtp_init(void) { - DRV_write(DRV_GO, 0x00); - DRV_write(DRV_RTP_INPUT, 20); //20 is the lowest value I've found where haptics can still be felt. - DRV_write(DRV_MODE, 0x05); - DRV_write(DRV_GO, 0x01); + DRV_write(DRV_GO, 0x00); + DRV_write(DRV_RTP_INPUT, 20); // 20 is the lowest value I've found where haptics can still be felt. + DRV_write(DRV_MODE, 0x05); + DRV_write(DRV_GO, 0x01); } -void DRV_amplitude(uint8_t amplitude) { - DRV_write(DRV_RTP_INPUT, amplitude); -} +void DRV_amplitude(uint8_t amplitude) { DRV_write(DRV_RTP_INPUT, amplitude); } void DRV_pulse(uint8_t sequence) { DRV_write(DRV_GO, 0x00); diff --git a/drivers/haptic/haptic.c b/drivers/haptic/haptic.c index 989970beee..2ce279b753 100644 --- a/drivers/haptic/haptic.c +++ b/drivers/haptic/haptic.c @@ -169,12 +169,12 @@ void haptic_set_mode(uint8_t mode) { } void haptic_set_amplitude(uint8_t amp) { - haptic_config.amplitude = amp; - eeconfig_update_haptic(haptic_config.raw); - xprintf("haptic_config.amplitude = %u\n", haptic_config.amplitude); - #ifdef DRV2605L - DRV_amplitude(amp); - #endif + haptic_config.amplitude = amp; + eeconfig_update_haptic(haptic_config.raw); + xprintf("haptic_config.amplitude = %u\n", haptic_config.amplitude); +#ifdef DRV2605L + DRV_amplitude(amp); +#endif } void haptic_set_buzz(uint8_t buzz) { @@ -211,52 +211,50 @@ uint8_t haptic_get_dwell(void) { } void haptic_enable_continuous(void) { - haptic_config.cont = 1; - xprintf("haptic_config.cont = %u\n", haptic_config.cont); - eeconfig_update_haptic(haptic_config.raw); - #ifdef DRV2605L - DRV_rtp_init(); - #endif + haptic_config.cont = 1; + xprintf("haptic_config.cont = %u\n", haptic_config.cont); + eeconfig_update_haptic(haptic_config.raw); +#ifdef DRV2605L + DRV_rtp_init(); +#endif } void haptic_disable_continuous(void) { - haptic_config.cont = 0; - xprintf("haptic_config.cont = %u\n", haptic_config.cont); - eeconfig_update_haptic(haptic_config.raw); - #ifdef DRV2605L - DRV_write(DRV_MODE,0x00); - #endif + haptic_config.cont = 0; + xprintf("haptic_config.cont = %u\n", haptic_config.cont); + eeconfig_update_haptic(haptic_config.raw); +#ifdef DRV2605L + DRV_write(DRV_MODE, 0x00); +#endif } void haptic_toggle_continuous(void) { #ifdef DRV2605L -if (haptic_config.cont) { - haptic_disable_continuous(); - } else { - haptic_enable_continuous(); - } - eeconfig_update_haptic(haptic_config.raw); + if (haptic_config.cont) { + haptic_disable_continuous(); + } else { + haptic_enable_continuous(); + } + eeconfig_update_haptic(haptic_config.raw); #endif } - void haptic_cont_increase(void) { - uint8_t amp = haptic_config.amplitude + 10; - if (haptic_config.amplitude >= 120) { - amp = 120; - } - haptic_set_amplitude(amp); + uint8_t amp = haptic_config.amplitude + 10; + if (haptic_config.amplitude >= 120) { + amp = 120; + } + haptic_set_amplitude(amp); } void haptic_cont_decrease(void) { - uint8_t amp = haptic_config.amplitude - 10; - if (haptic_config.amplitude < 20) { - amp = 20; - } - haptic_set_amplitude(amp); + uint8_t amp = haptic_config.amplitude - 10; + if (haptic_config.amplitude < 20) { + amp = 20; + } + haptic_set_amplitude(amp); } - void haptic_play(void) { #ifdef DRV2605L uint8_t play_eff = 0; @@ -269,7 +267,6 @@ void haptic_play(void) { } bool process_haptic(uint16_t keycode, keyrecord_t *record) { - if (keycode == HPT_ON && record->event.pressed) { haptic_enable(); } @@ -300,16 +297,16 @@ bool process_haptic(uint16_t keycode, keyrecord_t *record) { if (keycode == HPT_DWLD && record->event.pressed) { haptic_dwell_decrease(); } - if (keycode == HPT_CONT && record->event.pressed) { - haptic_toggle_continuous(); + if (keycode == HPT_CONT && record->event.pressed) { + haptic_toggle_continuous(); } - if (keycode == HPT_CONI && record->event.pressed) { - haptic_cont_increase(); + if (keycode == HPT_CONI && record->event.pressed) { + haptic_cont_increase(); } - if (keycode == HPT_COND && record->event.pressed) { - haptic_cont_decrease(); + if (keycode == HPT_COND && record->event.pressed) { + haptic_cont_decrease(); } - + if (haptic_config.enable) { if (record->event.pressed) { // keypress diff --git a/drivers/haptic/haptic.h b/drivers/haptic/haptic.h index 2f6eb31fc2..5d3bd1c310 100644 --- a/drivers/haptic/haptic.h +++ b/drivers/haptic/haptic.h @@ -34,14 +34,14 @@ typedef union { uint32_t raw; struct { - bool enable :1; - uint8_t feedback :2; - uint8_t mode :7; - bool buzz :1; - uint8_t dwell :7; - bool cont :1; - uint8_t amplitude :8; - uint16_t reserved :7; + bool enable : 1; + uint8_t feedback : 2; + uint8_t mode : 7; + bool buzz : 1; + uint8_t dwell : 7; + bool cont : 1; + uint8_t amplitude : 8; + uint16_t reserved : 7; }; } haptic_config_t; diff --git a/quantum/backlight/backlight_avr.c b/quantum/backlight/backlight_avr.c index 648a37adf3..edda6ea0b6 100644 --- a/quantum/backlight/backlight_avr.c +++ b/quantum/backlight/backlight_avr.c @@ -191,7 +191,7 @@ void backlight_off(pin_t backlight_pin) { # define FOR_EACH_LED(x) \ for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) { \ - pin_t backlight_pin = backlight_pins[i]; \ + pin_t backlight_pin = backlight_pins[i]; \ { x } \ } diff --git a/quantum/config_common.h b/quantum/config_common.h index f42df6357d..c1c1d4bd42 100644 --- a/quantum/config_common.h +++ b/quantum/config_common.h @@ -303,25 +303,26 @@ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ sei(); \ } while (0) -# elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) -# define SERIAL_UART_BAUD 115200 -# define SERIAL_UART_DATA UDR1 - /* UBRR should result in ~16 and set UCSR1A = _BV(U2X1) as per rn42 documentation. HC05 needs baudrate configured accordingly */ -# define SERIAL_UART_UBRR (F_CPU / (8UL * SERIAL_UART_BAUD) - 1) -# define SERIAL_UART_RXD_VECT USART1_RX_vect -# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) -# define SERIAL_UART_INIT() do { \ - UCSR1A = _BV(U2X1); \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX */ \ - UCSR1B = _BV(TXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - sei(); \ - } while(0) +# elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) +# define SERIAL_UART_BAUD 115200 +# define SERIAL_UART_DATA UDR1 +/* UBRR should result in ~16 and set UCSR1A = _BV(U2X1) as per rn42 documentation. HC05 needs baudrate configured accordingly */ +# define SERIAL_UART_UBRR (F_CPU / (8UL * SERIAL_UART_BAUD) - 1) +# define SERIAL_UART_RXD_VECT USART1_RX_vect +# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) +# define SERIAL_UART_INIT() \ + do { \ + UCSR1A = _BV(U2X1); \ + /* baud rate */ \ + UBRR1L = SERIAL_UART_UBRR; \ + /* baud rate */ \ + UBRR1H = SERIAL_UART_UBRR >> 8; \ + /* enable TX */ \ + UCSR1B = _BV(TXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ + sei(); \ + } while (0) # else # error "USART configuration is needed." # endif diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c index 3b5a8dadc9..ab74222d10 100644 --- a/quantum/dip_switch.c +++ b/quantum/dip_switch.c @@ -21,40 +21,33 @@ // for memcpy #include - #if !defined(DIP_SWITCH_PINS) -# error "No DIP switch pads defined by DIP_SWITCH_PINS" +# error "No DIP switch pads defined by DIP_SWITCH_PINS" #endif -#define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad)/sizeof(pin_t)) -static pin_t dip_switch_pad[] = DIP_SWITCH_PINS; -static bool dip_switch_state[NUMBER_OF_DIP_SWITCHES] = { 0 }; -static bool last_dip_switch_state[NUMBER_OF_DIP_SWITCHES] = { 0 }; - +#define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(pin_t)) +static pin_t dip_switch_pad[] = DIP_SWITCH_PINS; +static bool dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0}; +static bool last_dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0}; -__attribute__((weak)) -void dip_switch_update_user(uint8_t index, bool active) {} +__attribute__((weak)) void dip_switch_update_user(uint8_t index, bool active) {} -__attribute__((weak)) -void dip_switch_update_kb(uint8_t index, bool active) { dip_switch_update_user(index, active); } +__attribute__((weak)) void dip_switch_update_kb(uint8_t index, bool active) { dip_switch_update_user(index, active); } -__attribute__((weak)) -void dip_switch_update_mask_user(uint32_t state) {} +__attribute__((weak)) void dip_switch_update_mask_user(uint32_t state) {} -__attribute__((weak)) -void dip_switch_update_mask_kb(uint32_t state) { dip_switch_update_mask_user(state); } +__attribute__((weak)) void dip_switch_update_mask_kb(uint32_t state) { dip_switch_update_mask_user(state); } void dip_switch_init(void) { - for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) { - setPinInputHigh(dip_switch_pad[i]); - } - dip_switch_read(true); + for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) { + setPinInputHigh(dip_switch_pad[i]); + } + dip_switch_read(true); } - void dip_switch_read(bool forced) { - bool has_dip_state_changed = false; - uint32_t dip_switch_mask = 0; + bool has_dip_state_changed = false; + uint32_t dip_switch_mask = 0; for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) { dip_switch_state[i] = !readPin(dip_switch_pad[i]); diff --git a/quantum/encoder.c b/quantum/encoder.c index e86a0045c6..4aeb3d0cde 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -37,8 +37,8 @@ static pin_t encoders_pad_b[] = ENCODERS_PAD_B; static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0}; -static uint8_t encoder_state[NUMBER_OF_ENCODERS] = {0}; -static int8_t encoder_pulses[NUMBER_OF_ENCODERS] = {0}; +static uint8_t encoder_state[NUMBER_OF_ENCODERS] = {0}; +static int8_t encoder_pulses[NUMBER_OF_ENCODERS] = {0}; #ifdef SPLIT_KEYBOARD // right half encoders come over as second set of encoders @@ -84,7 +84,7 @@ static void encoder_update(int8_t index, uint8_t state) { encoder_value[index]++; encoder_update_kb(index, true); } - if (encoder_pulses[index] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise + if (encoder_pulses[index] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise encoder_value[index]--; encoder_update_kb(index, false); } @@ -109,7 +109,7 @@ void encoder_state_raw(uint8_t* slave_state) { memcpy(slave_state, &encoder_valu void encoder_update_raw(uint8_t* slave_state) { for (int i = 0; i < NUMBER_OF_ENCODERS; i++) { uint8_t index = i + thatHand; - int8_t delta = slave_state[i] - encoder_value[index]; + int8_t delta = slave_state[i] - encoder_value[index]; while (delta > 0) { delta--; encoder_value[index]++; diff --git a/quantum/keymap_extras/keymap_italian.h b/quantum/keymap_extras/keymap_italian.h index a8c03b884f..063700aa0b 100644 --- a/quantum/keymap_extras/keymap_italian.h +++ b/quantum/keymap_extras/keymap_italian.h @@ -78,36 +78,36 @@ #define IT_MINS KC_SLSH // - and _ // shifted characters -#define IT_DEGR LSFT(IT_AACC) // ° -#define IT_EXLM LSFT(KC_1) // ! -#define IT_DQOT LSFT(KC_2) // " -#define IT_STRL LSFT(KC_3) // £ -#define IT_DLR LSFT(KC_4) // $ -#define IT_PERC LSFT(KC_5) // % -#define IT_AMPR LSFT(KC_6) // & -#define IT_SLSH LSFT(KC_7) // / -#define IT_LPRN LSFT(KC_8) // ( -#define IT_RPRN LSFT(KC_9) // ) -#define IT_EQL LSFT(KC_0) // = -#define IT_QST LSFT(IT_APOS) // ? -#define IT_CRC LSFT(IT_IACC) // ^ -#define IT_ASTR LSFT(IT_PLUS) // * -#define IT_MORE LSFT(IT_LESS) // > -#define IT_COLN LSFT(IT_DOT) // : -#define IT_SCLN LSFT(IT_COMM) // ; -#define IT_UNDS LSFT(IT_MINS) // _ +#define IT_DEGR LSFT(IT_AACC) // ° +#define IT_EXLM LSFT(KC_1) // ! +#define IT_DQOT LSFT(KC_2) // " +#define IT_STRL LSFT(KC_3) // £ +#define IT_DLR LSFT(KC_4) // $ +#define IT_PERC LSFT(KC_5) // % +#define IT_AMPR LSFT(KC_6) // & +#define IT_SLSH LSFT(KC_7) // / +#define IT_LPRN LSFT(KC_8) // ( +#define IT_RPRN LSFT(KC_9) // ) +#define IT_EQL LSFT(KC_0) // = +#define IT_QST LSFT(IT_APOS) // ? +#define IT_CRC LSFT(IT_IACC) // ^ +#define IT_ASTR LSFT(IT_PLUS) // * +#define IT_MORE LSFT(IT_LESS) // > +#define IT_COLN LSFT(IT_DOT) // : +#define IT_SCLN LSFT(IT_COMM) // ; +#define IT_UNDS LSFT(IT_MINS) // _ // Alt Gr-ed characters -#define IT_LCBR ALGR(KC_7) // { -#define IT_LBRC ALGR(IT_EACC) // [ -#define IT_RBRC ALGR(IT_PLUS) // ] -#define IT_RCBR ALGR(KC_0) // } -#define IT_AT ALGR(IT_OACC) // @ -#define IT_EURO ALGR(KC_E) // € -#define IT_PIPE LSFT(IT_BSLS) // | -#define IT_SHRP ALGR(IT_AACC) // # +#define IT_LCBR ALGR(KC_7) // { +#define IT_LBRC ALGR(IT_EACC) // [ +#define IT_RBRC ALGR(IT_PLUS) // ] +#define IT_RCBR ALGR(KC_0) // } +#define IT_AT ALGR(IT_OACC) // @ +#define IT_EURO ALGR(KC_E) // € +#define IT_PIPE LSFT(IT_BSLS) // | +#define IT_SHRP ALGR(IT_AACC) // # // Deprecated -#define IT_X_PLUS X_RBRACKET // # +#define IT_X_PLUS X_RBRACKET // # #endif diff --git a/quantum/keymap_extras/keymap_italian_osx_ansi.h b/quantum/keymap_extras/keymap_italian_osx_ansi.h index 2b7160ff33..fa12d05dce 100644 --- a/quantum/keymap_extras/keymap_italian_osx_ansi.h +++ b/quantum/keymap_extras/keymap_italian_osx_ansi.h @@ -65,7 +65,7 @@ #define IT_COMM KC_COMM // , and ; #define IT_APOS KC_MINS // ' and ? #define IT_BSLS KC_NUBS // \ and | -#define IT_LESS KC_GRV // < and > +#define IT_LESS KC_GRV // < and > #define IT_MINS KC_SLSH // - and _ // accented vowels (regular, with shift, with option, with option and shift) @@ -77,37 +77,37 @@ #define IT_IACC KC_EQL // ì, ^, ˆ, ± // shifted characters -#define IT_EXLM LSFT(KC_1) // ! -#define IT_DQOT LSFT(KC_2) // " -#define IT_STRL LSFT(KC_3) // £ -#define IT_DLR LSFT(KC_4) // $ -#define IT_PERC LSFT(KC_5) // % -#define IT_AMPR LSFT(KC_6) // & -#define IT_SLSH LSFT(KC_7) // / -#define IT_LPRN LSFT(KC_8) // ( -#define IT_RPRN LSFT(KC_9) // ) -#define IT_EQL LSFT(KC_0) // = -#define IT_DEGR LSFT(IT_AACC) // ° -#define IT_QST LSFT(IT_APOS) // ? -#define IT_CRC LSFT(IT_IACC) // ^ -#define IT_ASTR LSFT(IT_PLUS) // * -#define IT_MORE LSFT(IT_LESS) // > -#define IT_COLN LSFT(IT_DOT) // : -#define IT_SCLN LSFT(IT_COMM) // ; -#define IT_UNDS LSFT(IT_MINS) // _ -#define IT_LCBR LSFT(IT_LBRC) // { -#define IT_RCBR LSFT(IT_RBRC) // } -#define IT_PIPE LSFT(IT_BSLS) // | +#define IT_EXLM LSFT(KC_1) // ! +#define IT_DQOT LSFT(KC_2) // " +#define IT_STRL LSFT(KC_3) // £ +#define IT_DLR LSFT(KC_4) // $ +#define IT_PERC LSFT(KC_5) // % +#define IT_AMPR LSFT(KC_6) // & +#define IT_SLSH LSFT(KC_7) // / +#define IT_LPRN LSFT(KC_8) // ( +#define IT_RPRN LSFT(KC_9) // ) +#define IT_EQL LSFT(KC_0) // = +#define IT_DEGR LSFT(IT_AACC) // ° +#define IT_QST LSFT(IT_APOS) // ? +#define IT_CRC LSFT(IT_IACC) // ^ +#define IT_ASTR LSFT(IT_PLUS) // * +#define IT_MORE LSFT(IT_LESS) // > +#define IT_COLN LSFT(IT_DOT) // : +#define IT_SCLN LSFT(IT_COMM) // ; +#define IT_UNDS LSFT(IT_MINS) // _ +#define IT_LCBR LSFT(IT_LBRC) // { +#define IT_RCBR LSFT(IT_RBRC) // } +#define IT_PIPE LSFT(IT_BSLS) // | // Alt -ed characters -#define IT_LBRC LALT(IT_EACC) // [ -#define IT_RBRC LALT(IT_PLUS) // ] -#define IT_AT LALT(IT_OACC) // @ -#define IT_EURO LALT(KC_E) // € -#define IT_SHRP LALT(IT_AACC ) // # -#define IT_ACUT LALT(KC_8) // ´ -#define IT_GRAVE LALT(KC_9) // ` -#define IT_TILDE LALT(KC_5) // ~ +#define IT_LBRC LALT(IT_EACC) // [ +#define IT_RBRC LALT(IT_PLUS) // ] +#define IT_AT LALT(IT_OACC) // @ +#define IT_EURO LALT(KC_E) // € +#define IT_SHRP LALT(IT_AACC) // # +#define IT_ACUT LALT(KC_8) // ´ +#define IT_GRAVE LALT(KC_9) // ` +#define IT_TILDE LALT(KC_5) // ~ #define IT_PLMN LALT(LSFT(IT_IACC)) // ± #endif diff --git a/quantum/keymap_extras/keymap_italian_osx_iso.h b/quantum/keymap_extras/keymap_italian_osx_iso.h index 5c920014a1..a9b36f16e6 100644 --- a/quantum/keymap_extras/keymap_italian_osx_iso.h +++ b/quantum/keymap_extras/keymap_italian_osx_iso.h @@ -65,7 +65,7 @@ #define IT_COMM KC_COMM // , and ; #define IT_APOS KC_MINS // ' and ? #define IT_BSLS KC_GRV // \ and | -#define IT_LESS KC_NUBS// < and > +#define IT_LESS KC_NUBS // < and > #define IT_MINS KC_SLSH // - and _ // accented vowels (regular, with shift, with option, with option and shift) @@ -77,37 +77,37 @@ #define IT_IACC KC_EQL // ì, ^, ˆ, ± // shifted characters -#define IT_EXLM LSFT(KC_1) // ! -#define IT_DQOT LSFT(KC_2) // " -#define IT_STRL LSFT(KC_3) // £ -#define IT_DLR LSFT(KC_4) // $ -#define IT_PERC LSFT(KC_5) // % -#define IT_AMPR LSFT(KC_6) // & -#define IT_SLSH LSFT(KC_7) // / -#define IT_LPRN LSFT(KC_8) // ( -#define IT_RPRN LSFT(KC_9) // ) -#define IT_EQL LSFT(KC_0) // = -#define IT_DEGR LSFT(IT_AACC) // ° -#define IT_QST LSFT(IT_APOS) // ? -#define IT_CRC LSFT(IT_IACC) // ^ -#define IT_ASTR LSFT(IT_PLUS) // * -#define IT_MORE LSFT(IT_LESS) // > -#define IT_COLN LSFT(IT_DOT) // : -#define IT_SCLN LSFT(IT_COMM) // ; -#define IT_UNDS LSFT(IT_MINS) // _ -#define IT_LCBR LSFT(IT_LBRC) // { -#define IT_RCBR LSFT(IT_RBRC) // } -#define IT_PIPE LSFT(IT_BSLS) // | +#define IT_EXLM LSFT(KC_1) // ! +#define IT_DQOT LSFT(KC_2) // " +#define IT_STRL LSFT(KC_3) // £ +#define IT_DLR LSFT(KC_4) // $ +#define IT_PERC LSFT(KC_5) // % +#define IT_AMPR LSFT(KC_6) // & +#define IT_SLSH LSFT(KC_7) // / +#define IT_LPRN LSFT(KC_8) // ( +#define IT_RPRN LSFT(KC_9) // ) +#define IT_EQL LSFT(KC_0) // = +#define IT_DEGR LSFT(IT_AACC) // ° +#define IT_QST LSFT(IT_APOS) // ? +#define IT_CRC LSFT(IT_IACC) // ^ +#define IT_ASTR LSFT(IT_PLUS) // * +#define IT_MORE LSFT(IT_LESS) // > +#define IT_COLN LSFT(IT_DOT) // : +#define IT_SCLN LSFT(IT_COMM) // ; +#define IT_UNDS LSFT(IT_MINS) // _ +#define IT_LCBR LSFT(IT_LBRC) // { +#define IT_RCBR LSFT(IT_RBRC) // } +#define IT_PIPE LSFT(IT_BSLS) // | // Alt -ed characters -#define IT_LBRC LALT(IT_EACC) // [ -#define IT_RBRC LALT(IT_PLUS) // ] -#define IT_AT LALT(IT_OACC) // @ -#define IT_EURO LALT(KC_E) // € -#define IT_SHRP LALT(IT_AACC ) // # -#define IT_ACUT LALT(KC_8) // ´ -#define IT_GRAVE LALT(KC_9) // ` -#define IT_TILDE LALT(KC_5) // ~ +#define IT_LBRC LALT(IT_EACC) // [ +#define IT_RBRC LALT(IT_PLUS) // ] +#define IT_AT LALT(IT_OACC) // @ +#define IT_EURO LALT(KC_E) // € +#define IT_SHRP LALT(IT_AACC) // # +#define IT_ACUT LALT(KC_8) // ´ +#define IT_GRAVE LALT(KC_9) // ` +#define IT_TILDE LALT(KC_5) // ~ #define IT_PLMN LALT(LSFT(IT_IACC)) // ± #endif diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h index 8f3f3ff3c6..09ceef74d8 100644 --- a/quantum/process_keycode/process_tap_dance.h +++ b/quantum/process_keycode/process_tap_dance.h @@ -63,10 +63,10 @@ typedef struct { { .fn = {qk_tap_dance_pair_on_each_tap, qk_tap_dance_pair_finished, qk_tap_dance_pair_reset}, .user_data = (void *)&((qk_tap_dance_pair_t){kc1, kc2}), } # define ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) \ - { .fn = { qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset }, .user_data = (void *)&((qk_tap_dance_dual_role_t) { kc, layer, layer_move }), } + { .fn = {qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_move}), } # define ACTION_TAP_DANCE_LAYER_TOGGLE(kc, layer) \ - { .fn = { NULL, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset }, .user_data = (void *)&((qk_tap_dance_dual_role_t) { kc, layer, layer_invert }), } + { .fn = {NULL, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_invert}), } # define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) @@ -79,8 +79,6 @@ typedef struct { # define ACTION_TAP_DANCE_FN_ADVANCED_TIME(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, tap_specific_tapping_term) \ { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = NULL, .custom_tapping_term = tap_specific_tapping_term, } - - extern qk_tap_dance_action_t tap_dance_actions[]; /* To be used internally */ diff --git a/quantum/quantum.c b/quantum/quantum.c index c27c3aba61..2e5e6376b7 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -1116,7 +1116,7 @@ __attribute__((weak)) void led_set(uint8_t usb_led) { #endif led_set_kb(usb_led); - led_update_kb((led_t) usb_led); + led_update_kb((led_t)usb_led); } //------------------------------------------------------------------------------ diff --git a/quantum/quantum.h b/quantum/quantum.h index 7988c58788..6beab65a32 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -146,14 +146,13 @@ extern layer_state_t layer_state; #endif #ifdef DIP_SWITCH_ENABLE - #include "dip_switch.h" +# include "dip_switch.h" #endif #ifdef DYNAMIC_MACRO_ENABLE - #include "process_dynamic_macro.h" +# include "process_dynamic_macro.h" #endif - // Function substitutions to ease GPIO manipulation #if defined(__AVR__) typedef uint8_t pin_t; diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 51a7e290fa..66a3c66e85 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -771,4 +771,4 @@ enum quantum_keycodes { #define DM_PLY1 DYN_MACRO_PLAY1 #define DM_PLY2 DYN_MACRO_PLAY2 -#endif // QUANTUM_KEYCODES_H +#endif // QUANTUM_KEYCODES_H diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 80f276139c..7949bb688e 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -919,7 +919,7 @@ void rgblight_effect_snake(animation_status_t *anim) { ledp->g = 0; ledp->b = 0; # ifdef RGBW - ledp->w = 0; + ledp->w = 0; # endif for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) { k = pos + j * increment; diff --git a/quantum/stm32/chconf.h b/quantum/stm32/chconf.h index f7b1b077d3..6b691950a6 100644 --- a/quantum/stm32/chconf.h +++ b/quantum/stm32/chconf.h @@ -419,34 +419,39 @@ * @note It is invoked from within @p chThdInit() and implicitly from all * the threads creation APIs. */ -# define CH_CFG_THREAD_INIT_HOOK(tp) \ - { /* Add threads initialization code here.*/ } +# define CH_CFG_THREAD_INIT_HOOK(tp) \ + { /* Add threads initialization code here.*/ \ + } /** * @brief Threads finalization hook. * @details User finalization code added to the @p chThdExit() API. */ -# define CH_CFG_THREAD_EXIT_HOOK(tp) \ - { /* Add threads finalization code here.*/ } +# define CH_CFG_THREAD_EXIT_HOOK(tp) \ + { /* Add threads finalization code here.*/ \ + } /** * @brief Context switch hook. * @details This hook is invoked just before switching between threads. */ # define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) \ - { /* Context switch code here.*/ } + { /* Context switch code here.*/ \ + } /** * @brief ISR enter hook. */ # define CH_CFG_IRQ_PROLOGUE_HOOK() \ - { /* IRQ prologue code here.*/ } + { /* IRQ prologue code here.*/ \ + } /** * @brief ISR exit hook. */ # define CH_CFG_IRQ_EPILOGUE_HOOK() \ - { /* IRQ epilogue code here.*/ } + { /* IRQ epilogue code here.*/ \ + } /** * @brief Idle thread enter hook. @@ -455,7 +460,8 @@ * @note This macro can be used to activate a power saving mode. */ # define CH_CFG_IDLE_ENTER_HOOK() \ - { /* Idle-enter code here.*/ } + { /* Idle-enter code here.*/ \ + } /** * @brief Idle thread leave hook. @@ -464,22 +470,25 @@ * @note This macro can be used to deactivate a power saving mode. */ # define CH_CFG_IDLE_LEAVE_HOOK() \ - { /* Idle-leave code here.*/ } + { /* Idle-leave code here.*/ \ + } /** * @brief Idle Loop hook. * @details This hook is continuously invoked by the idle thread loop. */ # define CH_CFG_IDLE_LOOP_HOOK() \ - { /* Idle loop code here.*/ } + { /* Idle loop code here.*/ \ + } /** * @brief System tick event hook. * @details This hook is invoked in the system tick handler immediately * after processing the virtual timers queue. */ -# define CH_CFG_SYSTEM_TICK_HOOK() \ - { /* System tick event code here.*/ } +# define CH_CFG_SYSTEM_TICK_HOOK() \ + { /* System tick event code here.*/ \ + } /** * @brief System halt hook. @@ -487,7 +496,8 @@ * the system is halted. */ # define CH_CFG_SYSTEM_HALT_HOOK(reason) \ - { /* System halt code here.*/ } + { /* System halt code here.*/ \ + } /** * @brief Trace hook. @@ -495,7 +505,8 @@ * trace buffer. */ # define CH_CFG_TRACE_HOOK(tep) \ - { /* Trace code here.*/ } + { /* Trace code here.*/ \ + } /** @} */ diff --git a/tmk_core/common/arm_atsam/suspend.c b/tmk_core/common/arm_atsam/suspend.c index 2dad005706..d1077be4c2 100644 --- a/tmk_core/common/arm_atsam/suspend.c +++ b/tmk_core/common/arm_atsam/suspend.c @@ -7,7 +7,8 @@ * * FIXME: needs doc */ -void suspend_idle(uint8_t time) { /* Note: Not used anywhere currently */ } +void suspend_idle(uint8_t time) { /* Note: Not used anywhere currently */ +} /** \brief Run user level Power down * diff --git a/tmk_core/common/eeconfig.c b/tmk_core/common/eeconfig.c index 72f198d6ce..7cec4bd7df 100644 --- a/tmk_core/common/eeconfig.c +++ b/tmk_core/common/eeconfig.c @@ -51,10 +51,10 @@ void eeconfig_init_quantum(void) { // TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS // within the emulated eeprom via dfu-util or another tool #if defined INIT_EE_HANDS_LEFT - #pragma message "Faking EE_HANDS for left hand" +# pragma message "Faking EE_HANDS for left hand" eeprom_update_byte(EECONFIG_HANDEDNESS, 1); #elif defined INIT_EE_HANDS_RIGHT - #pragma message "Faking EE_HANDS for right hand" +# pragma message "Faking EE_HANDS for right hand" eeprom_update_byte(EECONFIG_HANDEDNESS, 0); #endif diff --git a/tmk_core/common/host.c b/tmk_core/common/host.c index 713b0d9456..e7d92cfac6 100644 --- a/tmk_core/common/host.c +++ b/tmk_core/common/host.c @@ -41,7 +41,7 @@ uint8_t host_keyboard_leds(void) { } led_t host_keyboard_led_state(void) { - if (!driver) return (led_t) {0}; + if (!driver) return (led_t){0}; return (led_t)((*driver->keyboard_leds)()); } diff --git a/tmk_core/common/led.h b/tmk_core/common/led.h index daf974bed4..990282862b 100644 --- a/tmk_core/common/led.h +++ b/tmk_core/common/led.h @@ -36,11 +36,11 @@ extern "C" { typedef union { uint8_t raw; struct { - bool num_lock : 1; - bool caps_lock : 1; - bool scroll_lock : 1; - bool compose : 1; - bool kana : 1; + bool num_lock : 1; + bool caps_lock : 1; + bool scroll_lock : 1; + bool compose : 1; + bool kana : 1; uint8_t reserved : 3; }; } led_t; diff --git a/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h b/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h index 2f8a39bdd8..fb97f63cef 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h +++ b/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h @@ -186,9 +186,10 @@ COMPILER_PACK_RESET() #define USB_HID_COUNTRY_UK 32 // UK #define USB_HID_COUNTRY_US 33 // US #define USB_HID_COUNTRY_YUGOSLAVIA 34 // Yugoslavia -#define USB_HID_COUNTRY_TURKISH_F 35 // Turkish-F - //! @} - //! @} +#define USB_HID_COUNTRY_TURKISH_F \ + 35 // Turkish-F + //! @} + //! @} //! @} //! \name HID KEYS values diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index f7bfa20b2e..b90bcd0372 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -310,7 +310,7 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) { case USB_EVENT_SUSPEND: #ifdef SLEEP_LED_ENABLE sleep_led_enable(); -#endif /* SLEEP_LED_ENABLE */ +#endif /* SLEEP_LED_ENABLE */ /* Falls into.*/ case USB_EVENT_UNCONFIGURED: /* Falls into.*/ @@ -453,9 +453,9 @@ 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 */ +#endif /* NKRO_ENABLE */ /* arm the idle timer if boot protocol & idle */ osalSysLockFromISR(); chVTSetI(&keyboard_idle_timer, 4 * MS2ST(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); diff --git a/tmk_core/protocol/iwrap/iwrap.c b/tmk_core/protocol/iwrap/iwrap.c index 05e632da38..4d0ca5756b 100644 --- a/tmk_core/protocol/iwrap/iwrap.c +++ b/tmk_core/protocol/iwrap/iwrap.c @@ -320,7 +320,8 @@ static void send_mouse(report_mouse_t *report) { #endif } -static void send_system(uint16_t data) { /* not supported */ } +static void send_system(uint16_t data) { /* not supported */ +} static void send_consumer(uint16_t data) { #ifdef EXTRAKEY_ENABLE diff --git a/tmk_core/protocol/lufa/adafruit_ble.cpp b/tmk_core/protocol/lufa/adafruit_ble.cpp index 505794a80c..7b3ffdef7a 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.cpp +++ b/tmk_core/protocol/lufa/adafruit_ble.cpp @@ -31,9 +31,9 @@ #define ConnectionUpdateInterval 1000 /* milliseconds */ #ifdef SAMPLE_BATTERY -#ifndef BATTERY_LEVEL_PIN -# define BATTERY_LEVEL_PIN 7 -#endif +# ifndef BATTERY_LEVEL_PIN +# define BATTERY_LEVEL_PIN 7 +# endif #endif static struct { -- cgit v1.2.3