diff options
author | James Young <xxiinophobia@yahoo.com> | 2020-02-29 12:00:00 -0800 |
---|---|---|
committer | James Young <xxiinophobia@yahoo.com> | 2020-02-29 11:59:30 -0800 |
commit | 26eef35f07698d23aafae90e1c230b52e100a334 (patch) | |
tree | eb8e43fc58ca55788e6e89430af0db55ea79e324 /tmk_core/common | |
parent | 85041ff05bf0e5f4ff4535caf6e638491a5614c8 (diff) | |
download | qmk_firmware-26eef35f07698d23aafae90e1c230b52e100a334.tar.gz qmk_firmware-26eef35f07698d23aafae90e1c230b52e100a334.zip |
2020 February 29 Breaking Changes Update (#8064)
Diffstat (limited to 'tmk_core/common')
-rw-r--r-- | tmk_core/common/action.c | 26 | ||||
-rw-r--r-- | tmk_core/common/action_code.h | 33 | ||||
-rw-r--r-- | tmk_core/common/chibios/timer.c | 44 | ||||
-rw-r--r-- | tmk_core/common/command.c | 6 | ||||
-rw-r--r-- | tmk_core/common/timer.h | 5 |
5 files changed, 41 insertions, 73 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index d572b7056..0ec4a43ee 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
@@ -562,32 +562,6 @@ void process_action(keyrecord_t *record, action_t action) { | |||
562 | action_macro_play(action_get_macro(record, action.func.id, action.func.opt)); | 562 | action_macro_play(action_get_macro(record, action.func.id, action.func.opt)); |
563 | break; | 563 | break; |
564 | #endif | 564 | #endif |
565 | #if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE) | ||
566 | case ACT_BACKLIGHT: | ||
567 | if (!event.pressed) { | ||
568 | switch (action.backlight.opt) { | ||
569 | case BACKLIGHT_INCREASE: | ||
570 | backlight_increase(); | ||
571 | break; | ||
572 | case BACKLIGHT_DECREASE: | ||
573 | backlight_decrease(); | ||
574 | break; | ||
575 | case BACKLIGHT_TOGGLE: | ||
576 | backlight_toggle(); | ||
577 | break; | ||
578 | case BACKLIGHT_STEP: | ||
579 | backlight_step(); | ||
580 | break; | ||
581 | case BACKLIGHT_ON: | ||
582 | backlight_level(BACKLIGHT_LEVELS); | ||
583 | break; | ||
584 | case BACKLIGHT_OFF: | ||
585 | backlight_level(0); | ||
586 | break; | ||
587 | } | ||
588 | } | ||
589 | break; | ||
590 | #endif | ||
591 | case ACT_COMMAND: | 565 | case ACT_COMMAND: |
592 | break; | 566 | break; |
593 | #ifdef SWAP_HANDS_ENABLE | 567 | #ifdef SWAP_HANDS_ENABLE |
diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h index 03fcb3382..6c005b76d 100644 --- a/tmk_core/common/action_code.h +++ b/tmk_core/common/action_code.h | |||
@@ -86,8 +86,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
86 | * 1100|opt | id(8) Macro play? | 86 | * 1100|opt | id(8) Macro play? |
87 | * 1100|1111| id(8) Macro record? | 87 | * 1100|1111| id(8) Macro record? |
88 | * | 88 | * |
89 | * ACT_BACKLIGHT(1101): | 89 | * 1101|xxxx xxxx xxxx (reserved) |
90 | * 1101|opt |level(8) Backlight commands | ||
91 | * | 90 | * |
92 | * ACT_COMMAND(1110): | 91 | * ACT_COMMAND(1110): |
93 | * 1110|opt | id(8) Built-in Command exec | 92 | * 1110|opt | id(8) Built-in Command exec |
@@ -115,10 +114,9 @@ enum action_kind_id { | |||
115 | ACT_LAYER_TAP = 0b1010, /* Layer 0-15 */ | 114 | ACT_LAYER_TAP = 0b1010, /* Layer 0-15 */ |
116 | ACT_LAYER_TAP_EXT = 0b1011, /* Layer 16-31 */ | 115 | ACT_LAYER_TAP_EXT = 0b1011, /* Layer 16-31 */ |
117 | /* Extensions */ | 116 | /* Extensions */ |
118 | ACT_MACRO = 0b1100, | 117 | ACT_MACRO = 0b1100, |
119 | ACT_BACKLIGHT = 0b1101, | 118 | ACT_COMMAND = 0b1110, |
120 | ACT_COMMAND = 0b1110, | 119 | ACT_FUNCTION = 0b1111 |
121 | ACT_FUNCTION = 0b1111 | ||
122 | }; | 120 | }; |
123 | 121 | ||
124 | /** \brief Action Code Struct | 122 | /** \brief Action Code Struct |
@@ -169,11 +167,6 @@ typedef union { | |||
169 | uint8_t page : 2; | 167 | uint8_t page : 2; |
170 | uint8_t kind : 4; | 168 | uint8_t kind : 4; |
171 | } usage; | 169 | } usage; |
172 | struct action_backlight { | ||
173 | uint8_t level : 8; | ||
174 | uint8_t opt : 4; | ||
175 | uint8_t kind : 4; | ||
176 | } backlight; | ||
177 | struct action_command { | 170 | struct action_command { |
178 | uint8_t id : 8; | 171 | uint8_t id : 8; |
179 | uint8_t opt : 4; | 172 | uint8_t opt : 4; |
@@ -290,28 +283,10 @@ enum layer_param_tap_op { | |||
290 | #define ACTION_DEFAULT_LAYER_BIT_XOR(part, bits) ACTION_LAYER_BITOP(OP_BIT_XOR, (part), (bits), 0) | 283 | #define ACTION_DEFAULT_LAYER_BIT_XOR(part, bits) ACTION_LAYER_BITOP(OP_BIT_XOR, (part), (bits), 0) |
291 | #define ACTION_DEFAULT_LAYER_BIT_SET(part, bits) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), 0) | 284 | #define ACTION_DEFAULT_LAYER_BIT_SET(part, bits) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), 0) |
292 | 285 | ||
293 | /** \brief Extensions | ||
294 | */ | ||
295 | enum backlight_opt { | ||
296 | BACKLIGHT_INCREASE = 0, | ||
297 | BACKLIGHT_DECREASE = 1, | ||
298 | BACKLIGHT_TOGGLE = 2, | ||
299 | BACKLIGHT_STEP = 3, | ||
300 | BACKLIGHT_ON = 4, | ||
301 | BACKLIGHT_OFF = 5, | ||
302 | }; | ||
303 | |||
304 | /* Macro */ | 286 | /* Macro */ |
305 | #define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) | 287 | #define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) |
306 | #define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP << 8 | (id)) | 288 | #define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP << 8 | (id)) |
307 | #define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt) << 8 | (id)) | 289 | #define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt) << 8 | (id)) |
308 | /* Backlight */ | ||
309 | #define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE << 8) | ||
310 | #define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8) | ||
311 | #define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8) | ||
312 | #define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8) | ||
313 | #define ACTION_BACKLIGHT_ON() ACTION(ACT_BACKLIGHT, BACKLIGHT_ON << 8) | ||
314 | #define ACTION_BACKLIGHT_OFF() ACTION(ACT_BACKLIGHT, BACKLIGHT_OFF << 8) | ||
315 | /* Command */ | 290 | /* Command */ |
316 | #define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt) << 8 | (id)) | 291 | #define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt) << 8 | (id)) |
317 | /* Function */ | 292 | /* Function */ |
diff --git a/tmk_core/common/chibios/timer.c b/tmk_core/common/chibios/timer.c index ed5cfe1b0..ac5a5af63 100644 --- a/tmk_core/common/chibios/timer.c +++ b/tmk_core/common/chibios/timer.c | |||
@@ -2,30 +2,44 @@ | |||
2 | 2 | ||
3 | #include "timer.h" | 3 | #include "timer.h" |
4 | 4 | ||
5 | static systime_t last_systime = 0; | 5 | static uint32_t reset_point = 0; |
6 | static systime_t overflow = 0; | 6 | #if CH_CFG_ST_RESOLUTION < 32 |
7 | static uint32_t current_time_ms = 0; | 7 | static uint32_t last_systime = 0; |
8 | static uint32_t overflow = 0; | ||
9 | #endif | ||
8 | 10 | ||
9 | void timer_init(void) { timer_clear(); } | 11 | void timer_init(void) { timer_clear(); } |
10 | 12 | ||
11 | void timer_clear(void) { | 13 | void timer_clear(void) { |
12 | last_systime = chVTGetSystemTime(); | 14 | reset_point = (uint32_t)chVTGetSystemTime(); |
13 | overflow = 0; | 15 | #if CH_CFG_ST_RESOLUTION < 32 |
14 | current_time_ms = 0; | 16 | last_systime = reset_point; |
17 | overflow = 0; | ||
18 | #endif | ||
15 | } | 19 | } |
16 | 20 | ||
17 | uint16_t timer_read(void) { return (uint16_t)timer_read32(); } | 21 | uint16_t timer_read(void) { return (uint16_t)timer_read32(); } |
18 | 22 | ||
19 | uint32_t timer_read32(void) { | 23 | uint32_t timer_read32(void) { |
20 | // Note: We assume that the timer update is called at least once betweeen every wrap around of the system time | 24 | uint32_t systime = (uint32_t)chVTGetSystemTime(); |
21 | systime_t current_systime = chVTGetSystemTime(); | 25 | |
22 | systime_t elapsed = current_systime - last_systime + overflow; | 26 | #if CH_CFG_ST_RESOLUTION < 32 |
23 | uint32_t elapsed_ms = ST2MS(elapsed); | 27 | // If/when we need to support 64-bit chips, this may need to be modified to match the native bit-ness of the MCU. |
24 | current_time_ms += elapsed_ms; | 28 | // At this point, the only SysTick resolution allowed other than 32 is 16 bit. |
25 | overflow = elapsed - MS2ST(elapsed_ms); | 29 | // In the 16-bit case, at: |
26 | last_systime = current_systime; | 30 | // - CH_CFG_ST_FREQUENCY = 100000, overflow will occur every ~0.65 seconds |
27 | 31 | // - CH_CFG_ST_FREQUENCY = 10000, overflow will occur every ~6.5 seconds | |
28 | return current_time_ms; | 32 | // - CH_CFG_ST_FREQUENCY = 1000, overflow will occur every ~65 seconds |
33 | // With this implementation, as long as we ensure a timer read happens at least once during the overflow period, timing should be accurate. | ||
34 | if (systime < last_systime) { | ||
35 | overflow += ((uint32_t)1) << CH_CFG_ST_RESOLUTION; | ||
36 | } | ||
37 | |||
38 | last_systime = systime; | ||
39 | return (uint32_t)TIME_I2MS(systime - reset_point + overflow); | ||
40 | #else | ||
41 | return (uint32_t)TIME_I2MS(systime - reset_point); | ||
42 | #endif | ||
29 | } | 43 | } |
30 | 44 | ||
31 | uint16_t timer_elapsed(uint16_t last) { return TIMER_DIFF_16(timer_read(), last); } | 45 | uint16_t timer_elapsed(uint16_t last) { return TIMER_DIFF_16(timer_read(), last); } |
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index 900de5410..77a205eac 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c | |||
@@ -153,6 +153,9 @@ static void print_version(void) { | |||
153 | print("BUILD: (" __DATE__ ")\n"); | 153 | print("BUILD: (" __DATE__ ")\n"); |
154 | #else | 154 | #else |
155 | print("BUILD: " STR(QMK_VERSION) " (" __TIME__ " " __DATE__ ")\n"); | 155 | print("BUILD: " STR(QMK_VERSION) " (" __TIME__ " " __DATE__ ")\n"); |
156 | # ifdef PROTOCOL_CHIBIOS | ||
157 | print("CHIBIOS: " STR(CHIBIOS_VERSION) ", CONTRIB: " STR(CHIBIOS_CONTRIB_VERSION) "\n"); | ||
158 | # endif | ||
156 | #endif | 159 | #endif |
157 | 160 | ||
158 | /* build options */ | 161 | /* build options */ |
@@ -182,6 +185,9 @@ static void print_version(void) { | |||
182 | #ifdef NKRO_ENABLE | 185 | #ifdef NKRO_ENABLE |
183 | " NKRO" | 186 | " NKRO" |
184 | #endif | 187 | #endif |
188 | #ifdef LINK_TIME_OPTIMIZATION_ENABLE | ||
189 | " LTO" | ||
190 | #endif | ||
185 | 191 | ||
186 | " " STR(BOOTLOADER_SIZE) "\n"); | 192 | " " STR(BOOTLOADER_SIZE) "\n"); |
187 | 193 | ||
diff --git a/tmk_core/common/timer.h b/tmk_core/common/timer.h index 378cf7892..bbaae109d 100644 --- a/tmk_core/common/timer.h +++ b/tmk_core/common/timer.h | |||
@@ -45,9 +45,8 @@ uint16_t timer_elapsed(uint16_t last); | |||
45 | uint32_t timer_elapsed32(uint32_t last); | 45 | uint32_t timer_elapsed32(uint32_t last); |
46 | 46 | ||
47 | // Utility functions to check if a future time has expired & autmatically handle time wrapping if checked / reset frequently (half of max value) | 47 | // Utility functions to check if a future time has expired & autmatically handle time wrapping if checked / reset frequently (half of max value) |
48 | inline bool timer_expired(uint16_t current, uint16_t future) { return (uint16_t)(current - future) < 0x8000; } | 48 | #define timer_expired(current, future) (((uint16_t)current - (uint16_t)future) < 0x8000) |
49 | 49 | #define timer_expired32(current, future) (((uint32_t)current - (uint32_t)future) < 0x80000000) | |
50 | inline bool timer_expired32(uint32_t current, uint32_t future) { return (uint32_t)(current - future) < 0x80000000; } | ||
51 | 50 | ||
52 | #ifdef __cplusplus | 51 | #ifdef __cplusplus |
53 | } | 52 | } |