summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2023-10-14 22:21:20 +1100
committerGitHub <noreply@github.com>2023-10-14 13:21:20 +0200
commit1bff37781bda1d0c285aa5aa7102d6941ad64e7d (patch)
tree6348d64c7d7bba987e8bb386768fde33f33ace18
parent1da7c8c8d0c70c9f614ce898ee3380db0f04fa27 (diff)
Prep work for NKRO report separation (#22268)
* Clean up some keyboard/userspace code * Rename `KEYBOARD_REPORT_BITS` -> `NKRO_REPORT_BITS` * Add some missing includes * Use `PACKED` define for report types * Fix incorrect function signatures for FlexRAM EEPROM driver
-rw-r--r--keyboards/annepro2/annepro2_ble.c2
-rw-r--r--keyboards/bioi/bluetooth_custom.c13
-rw-r--r--keyboards/sawnsprojects/okayu/stm32f072/config.h2
-rw-r--r--keyboards/sawnsprojects/okayu/stm32f103/config.h2
-rw-r--r--keyboards/sawnsprojects/okayu/stm32f303/config.h2
-rw-r--r--platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c8
-rw-r--r--quantum/eeconfig.h1
-rw-r--r--quantum/quantum.h2
-rw-r--r--tmk_core/protocol/report.c8
-rw-r--r--tmk_core/protocol/report.h19
-rw-r--r--tmk_core/protocol/usb_descriptor.c4
-rw-r--r--users/brandonschlack/brandonschlack.c8
12 files changed, 35 insertions, 36 deletions
diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c
index 375f551cc2..b04929e958 100644
--- a/keyboards/annepro2/annepro2_ble.c
+++ b/keyboards/annepro2/annepro2_ble.c
@@ -167,5 +167,5 @@ static void ap2_ble_extra(report_extra_t *report) {
167static void ap2_ble_keyboard(report_keyboard_t *report) { 167static void ap2_ble_keyboard(report_keyboard_t *report) {
168 sdPut(&SD1, 0x0); 168 sdPut(&SD1, 0x0);
169 sdWrite(&SD1, ble_mcu_send_report, sizeof(ble_mcu_send_report)); 169 sdWrite(&SD1, ble_mcu_send_report, sizeof(ble_mcu_send_report));
170 sdWrite(&SD1, &report->raw[0], KEYBOARD_REPORT_SIZE); 170 sdWrite(&SD1, (uint8_t *)report, KEYBOARD_REPORT_SIZE);
171} 171}
diff --git a/keyboards/bioi/bluetooth_custom.c b/keyboards/bioi/bluetooth_custom.c
index 7d88a837d1..4ea277f731 100644
--- a/keyboards/bioi/bluetooth_custom.c
+++ b/keyboards/bioi/bluetooth_custom.c
@@ -86,13 +86,12 @@ void bluetooth_send_keyboard(report_keyboard_t *report)
86 86
87 send_str(PSTR("AT+BLEKEYBOARDCODE=")); 87 send_str(PSTR("AT+BLEKEYBOARDCODE="));
88 88
89 for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) 89 send_bytes(report->mods);
90 { 90 send_str(PSTR("-"));
91 send_bytes(report->raw[i]); 91 send_bytes(0);
92 if (i < (KEYBOARD_EPSIZE - 1)) 92 for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
93 { 93 send_str(PSTR("-"));
94 send_str(PSTR("-")); 94 send_bytes(report->keys[i]);
95 }
96 } 95 }
97 96
98 send_str(PSTR("\r\n")); 97 send_str(PSTR("\r\n"));
diff --git a/keyboards/sawnsprojects/okayu/stm32f072/config.h b/keyboards/sawnsprojects/okayu/stm32f072/config.h
index c47f1928c8..41bb0d1fdb 100644
--- a/keyboards/sawnsprojects/okayu/stm32f072/config.h
+++ b/keyboards/sawnsprojects/okayu/stm32f072/config.h
@@ -2,7 +2,7 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3#pragma once 3#pragma once
4 4
5#define WS2812_SPI SPID1 5#define WS2812_SPI_DRIVER SPID1
6#define WS2812_SPI_MOSI_PAL_MODE 5 6#define WS2812_SPI_MOSI_PAL_MODE 5
7#define WS2812_SPI_SCK_PIN B13 7#define WS2812_SPI_SCK_PIN B13
8#define WS2812_SPI_SCK_PAL_MODE 5 \ No newline at end of file 8#define WS2812_SPI_SCK_PAL_MODE 5 \ No newline at end of file
diff --git a/keyboards/sawnsprojects/okayu/stm32f103/config.h b/keyboards/sawnsprojects/okayu/stm32f103/config.h
index eff3605470..9024616477 100644
--- a/keyboards/sawnsprojects/okayu/stm32f103/config.h
+++ b/keyboards/sawnsprojects/okayu/stm32f103/config.h
@@ -2,7 +2,7 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3#pragma once 3#pragma once
4 4
5#define WS2812_SPI SPID2 5#define WS2812_SPI_DRIVER SPID2
6#define WS2812_SPI_MOSI_PAL_MODE 5 6#define WS2812_SPI_MOSI_PAL_MODE 5
7#define WS2812_SPI_SCK_PIN B13 7#define WS2812_SPI_SCK_PIN B13
8#define WS2812_SPI_SCK_PAL_MODE 5 \ No newline at end of file 8#define WS2812_SPI_SCK_PAL_MODE 5 \ No newline at end of file
diff --git a/keyboards/sawnsprojects/okayu/stm32f303/config.h b/keyboards/sawnsprojects/okayu/stm32f303/config.h
index c47f1928c8..41bb0d1fdb 100644
--- a/keyboards/sawnsprojects/okayu/stm32f303/config.h
+++ b/keyboards/sawnsprojects/okayu/stm32f303/config.h
@@ -2,7 +2,7 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3#pragma once 3#pragma once
4 4
5#define WS2812_SPI SPID1 5#define WS2812_SPI_DRIVER SPID1
6#define WS2812_SPI_MOSI_PAL_MODE 5 6#define WS2812_SPI_MOSI_PAL_MODE 5
7#define WS2812_SPI_SCK_PIN B13 7#define WS2812_SPI_SCK_PIN B13
8#define WS2812_SPI_SCK_PAL_MODE 5 \ No newline at end of file 8#define WS2812_SPI_SCK_PAL_MODE 5 \ No newline at end of file
diff --git a/platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c b/platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c
index 6468cbf3fa..9cf956b2f7 100644
--- a/platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c
+++ b/platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c
@@ -146,7 +146,7 @@ uint32_t eeprom_read_dword(const uint32_t *addr) {
146 * 146 *
147 * FIXME: needs doc 147 * FIXME: needs doc
148 */ 148 */
149void eeprom_read_block(void *buf, const void *addr, uint32_t len) { 149void eeprom_read_block(void *buf, const void *addr, size_t len) {
150 uint32_t offset = (uint32_t)addr; 150 uint32_t offset = (uint32_t)addr;
151 uint8_t *dest = (uint8_t *)buf; 151 uint8_t *dest = (uint8_t *)buf;
152 uint32_t end = offset + len; 152 uint32_t end = offset + len;
@@ -271,7 +271,7 @@ void eeprom_write_dword(uint32_t *addr, uint32_t value) {
271 * 271 *
272 * FIXME: needs doc 272 * FIXME: needs doc
273 */ 273 */
274void eeprom_write_block(const void *buf, void *addr, uint32_t len) { 274void eeprom_write_block(const void *buf, void *addr, size_t len) {
275 uint32_t offset = (uint32_t)addr; 275 uint32_t offset = (uint32_t)addr;
276 const uint8_t *src = (const uint8_t *)buf; 276 const uint8_t *src = (const uint8_t *)buf;
277 277
@@ -480,7 +480,7 @@ uint32_t eeprom_read_dword(const uint32_t *addr) {
480 return eeprom_read_byte(p) | (eeprom_read_byte(p + 1) << 8) | (eeprom_read_byte(p + 2) << 16) | (eeprom_read_byte(p + 3) << 24); 480 return eeprom_read_byte(p) | (eeprom_read_byte(p + 1) << 8) | (eeprom_read_byte(p + 2) << 16) | (eeprom_read_byte(p + 3) << 24);
481} 481}
482 482
483void eeprom_read_block(void *buf, const void *addr, uint32_t len) { 483void eeprom_read_block(void *buf, const void *addr, size_t len) {
484 const uint8_t *p = (const uint8_t *)addr; 484 const uint8_t *p = (const uint8_t *)addr;
485 uint8_t * dest = (uint8_t *)buf; 485 uint8_t * dest = (uint8_t *)buf;
486 while (len--) { 486 while (len--) {
@@ -506,7 +506,7 @@ void eeprom_write_dword(uint32_t *addr, uint32_t value) {
506 eeprom_write_byte(p, value >> 24); 506 eeprom_write_byte(p, value >> 24);
507} 507}
508 508
509void eeprom_write_block(const void *buf, void *addr, uint32_t len) { 509void eeprom_write_block(const void *buf, void *addr, size_t len) {
510 uint8_t * p = (uint8_t *)addr; 510 uint8_t * p = (uint8_t *)addr;
511 const uint8_t *src = (const uint8_t *)buf; 511 const uint8_t *src = (const uint8_t *)buf;
512 while (len--) { 512 while (len--) {
diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h
index 34d85cb91e..d7cce166bd 100644
--- a/quantum/eeconfig.h
+++ b/quantum/eeconfig.h
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20#include <stdint.h> 20#include <stdint.h>
21#include <stdbool.h> 21#include <stdbool.h>
22#include "eeprom.h"
22 23
23#ifndef EECONFIG_MAGIC_NUMBER 24#ifndef EECONFIG_MAGIC_NUMBER
24# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE6 // When changing, decrement this value to avoid future re-init issues 25# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE6 // When changing, decrement this value to avoid future re-init issues
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 66e4569991..e41542e4af 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -56,6 +56,8 @@
56#include "suspend.h" 56#include "suspend.h"
57#include <stddef.h> 57#include <stddef.h>
58#include <stdlib.h> 58#include <stdlib.h>
59#include <stdio.h>
60#include <string.h>
59 61
60#ifdef DEFERRED_EXEC_ENABLE 62#ifdef DEFERRED_EXEC_ENABLE
61# include "deferred_exec.h" 63# include "deferred_exec.h"
diff --git a/tmk_core/protocol/report.c b/tmk_core/protocol/report.c
index 1ba3be4604..27d267abae 100644
--- a/tmk_core/protocol/report.c
+++ b/tmk_core/protocol/report.c
@@ -59,7 +59,7 @@ uint8_t get_first_key(report_keyboard_t* keyboard_report) {
59#ifdef NKRO_ENABLE 59#ifdef NKRO_ENABLE
60 if (keyboard_protocol && keymap_config.nkro) { 60 if (keyboard_protocol && keymap_config.nkro) {
61 uint8_t i = 0; 61 uint8_t i = 0;
62 for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) 62 for (; i < NKRO_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++)
63 ; 63 ;
64 return i << 3 | biton(keyboard_report->nkro.bits[i]); 64 return i << 3 | biton(keyboard_report->nkro.bits[i]);
65 } 65 }
@@ -89,7 +89,7 @@ bool is_key_pressed(report_keyboard_t* keyboard_report, uint8_t key) {
89 } 89 }
90#ifdef NKRO_ENABLE 90#ifdef NKRO_ENABLE
91 if (keyboard_protocol && keymap_config.nkro) { 91 if (keyboard_protocol && keymap_config.nkro) {
92 if ((key >> 3) < KEYBOARD_REPORT_BITS) { 92 if ((key >> 3) < NKRO_REPORT_BITS) {
93 return keyboard_report->nkro.bits[key >> 3] & 1 << (key & 7); 93 return keyboard_report->nkro.bits[key >> 3] & 1 << (key & 7);
94 } else { 94 } else {
95 return false; 95 return false;
@@ -216,7 +216,7 @@ void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code) {
216 * FIXME: Needs doc 216 * FIXME: Needs doc
217 */ 217 */
218void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) { 218void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) {
219 if ((code >> 3) < KEYBOARD_REPORT_BITS) { 219 if ((code >> 3) < NKRO_REPORT_BITS) {
220 keyboard_report->nkro.bits[code >> 3] |= 1 << (code & 7); 220 keyboard_report->nkro.bits[code >> 3] |= 1 << (code & 7);
221 } else { 221 } else {
222 dprintf("add_key_bit: can't add: %02X\n", code); 222 dprintf("add_key_bit: can't add: %02X\n", code);
@@ -228,7 +228,7 @@ void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) {
228 * FIXME: Needs doc 228 * FIXME: Needs doc
229 */ 229 */
230void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code) { 230void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code) {
231 if ((code >> 3) < KEYBOARD_REPORT_BITS) { 231 if ((code >> 3) < NKRO_REPORT_BITS) {
232 keyboard_report->nkro.bits[code >> 3] &= ~(1 << (code & 7)); 232 keyboard_report->nkro.bits[code >> 3] &= ~(1 << (code & 7));
233 } else { 233 } else {
234 dprintf("del_key_bit: can't del: %02X\n", code); 234 dprintf("del_key_bit: can't del: %02X\n", code);
diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h
index 9d415a3bfd..dd3cee3df0 100644
--- a/tmk_core/protocol/report.h
+++ b/tmk_core/protocol/report.h
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20#include <stdint.h> 20#include <stdint.h>
21#include <stdbool.h> 21#include <stdbool.h>
22#include "keycode.h" 22#include "keycode.h"
23#include "util.h"
23 24
24// clang-format off 25// clang-format off
25 26
@@ -129,10 +130,10 @@ enum desktop_usages {
129#if defined(NKRO_ENABLE) 130#if defined(NKRO_ENABLE)
130# if defined(PROTOCOL_LUFA) || defined(PROTOCOL_CHIBIOS) 131# if defined(PROTOCOL_LUFA) || defined(PROTOCOL_CHIBIOS)
131# include "protocol/usb_descriptor.h" 132# include "protocol/usb_descriptor.h"
132# define KEYBOARD_REPORT_BITS (SHARED_EPSIZE - 2) 133# define NKRO_REPORT_BITS (SHARED_EPSIZE - 2)
133# elif defined(PROTOCOL_ARM_ATSAM) 134# elif defined(PROTOCOL_ARM_ATSAM)
134# include "protocol/arm_atsam/usb/udi_device_epsize.h" 135# include "protocol/arm_atsam/usb/udi_device_epsize.h"
135# define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1) 136# define NKRO_REPORT_BITS (NKRO_EPSIZE - 1)
136# undef NKRO_SHARED_EP 137# undef NKRO_SHARED_EP
137# undef MOUSE_SHARED_EP 138# undef MOUSE_SHARED_EP
138# else 139# else
@@ -188,20 +189,20 @@ typedef union {
188 uint8_t report_id; 189 uint8_t report_id;
189# endif 190# endif
190 uint8_t mods; 191 uint8_t mods;
191 uint8_t bits[KEYBOARD_REPORT_BITS]; 192 uint8_t bits[NKRO_REPORT_BITS];
192 } nkro; 193 } nkro;
193#endif 194#endif
194} __attribute__((packed)) report_keyboard_t; 195} PACKED report_keyboard_t;
195 196
196typedef struct { 197typedef struct {
197 uint8_t report_id; 198 uint8_t report_id;
198 uint16_t usage; 199 uint16_t usage;
199} __attribute__((packed)) report_extra_t; 200} PACKED report_extra_t;
200 201
201typedef struct { 202typedef struct {
202 uint8_t report_id; 203 uint8_t report_id;
203 uint32_t usage; 204 uint32_t usage;
204} __attribute__((packed)) report_programmable_button_t; 205} PACKED report_programmable_button_t;
205 206
206#ifdef MOUSE_EXTENDED_REPORT 207#ifdef MOUSE_EXTENDED_REPORT
207typedef int16_t mouse_xy_report_t; 208typedef int16_t mouse_xy_report_t;
@@ -222,7 +223,7 @@ typedef struct {
222 mouse_xy_report_t y; 223 mouse_xy_report_t y;
223 int8_t v; 224 int8_t v;
224 int8_t h; 225 int8_t h;
225} __attribute__((packed)) report_mouse_t; 226} PACKED report_mouse_t;
226 227
227typedef struct { 228typedef struct {
228#ifdef DIGITIZER_SHARED_EP 229#ifdef DIGITIZER_SHARED_EP
@@ -234,7 +235,7 @@ typedef struct {
234 uint8_t reserved : 5; 235 uint8_t reserved : 5;
235 uint16_t x; 236 uint16_t x;
236 uint16_t y; 237 uint16_t y;
237} __attribute__((packed)) report_digitizer_t; 238} PACKED report_digitizer_t;
238 239
239typedef struct { 240typedef struct {
240#ifdef JOYSTICK_SHARED_EP 241#ifdef JOYSTICK_SHARED_EP
@@ -251,7 +252,7 @@ typedef struct {
251#if JOYSTICK_BUTTON_COUNT > 0 252#if JOYSTICK_BUTTON_COUNT > 0
252 uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1]; 253 uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1];
253#endif 254#endif
254} __attribute__((packed)) report_joystick_t; 255} PACKED report_joystick_t;
255 256
256/* keycode to system usage */ 257/* keycode to system usage */
257static inline uint16_t KEYCODE2SYSTEM(uint8_t key) { 258static inline uint16_t KEYCODE2SYSTEM(uint8_t key) {
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index e215c90900..eb214c0492 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -359,10 +359,10 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
359 // Keycodes 359 // Keycodes
360 HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad 360 HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
361 HID_RI_USAGE_MINIMUM(8, 0x00), 361 HID_RI_USAGE_MINIMUM(8, 0x00),
362 HID_RI_USAGE_MAXIMUM(8, KEYBOARD_REPORT_BITS * 8 - 1), 362 HID_RI_USAGE_MAXIMUM(8, NKRO_REPORT_BITS * 8 - 1),
363 HID_RI_LOGICAL_MINIMUM(8, 0x00), 363 HID_RI_LOGICAL_MINIMUM(8, 0x00),
364 HID_RI_LOGICAL_MAXIMUM(8, 0x01), 364 HID_RI_LOGICAL_MAXIMUM(8, 0x01),
365 HID_RI_REPORT_COUNT(8, KEYBOARD_REPORT_BITS * 8), 365 HID_RI_REPORT_COUNT(8, NKRO_REPORT_BITS * 8),
366 HID_RI_REPORT_SIZE(8, 0x01), 366 HID_RI_REPORT_SIZE(8, 0x01),
367 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), 367 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
368 368
diff --git a/users/brandonschlack/brandonschlack.c b/users/brandonschlack/brandonschlack.c
index 1e52bd6452..6a9c04a73d 100644
--- a/users/brandonschlack/brandonschlack.c
+++ b/users/brandonschlack/brandonschlack.c
@@ -88,9 +88,7 @@ void suspend_power_down_keymap(void) {}
88 */ 88 */
89void suspend_power_down_user(void) { 89void suspend_power_down_user(void) {
90#ifdef RGB_MATRIX_ENABLE 90#ifdef RGB_MATRIX_ENABLE
91 if (!g_suspend_state) { 91 rgb_matrix_set_suspend_state(true);
92 rgb_matrix_set_suspend_state(true);
93 }
94#endif //RGB_MATRIX_ENABLE 92#endif //RGB_MATRIX_ENABLE
95 suspend_power_down_keymap(); 93 suspend_power_down_keymap();
96} 94}
@@ -103,9 +101,7 @@ void suspend_wakeup_init_keymap(void) {}
103 */ 101 */
104void suspend_wakeup_init_user(void) { 102void suspend_wakeup_init_user(void) {
105#ifdef RGB_MATRIX_ENABLE 103#ifdef RGB_MATRIX_ENABLE
106 if (g_suspend_state) { 104 rgb_matrix_set_suspend_state(false);
107 rgb_matrix_set_suspend_state(false);
108 }
109#endif //RGB_MATRIX_ENABLE 105#endif //RGB_MATRIX_ENABLE
110 suspend_wakeup_init_keymap(); 106 suspend_wakeup_init_keymap();
111} 107}