summaryrefslogtreecommitdiff
path: root/tmk_core/common
diff options
context:
space:
mode:
authorJames Young <xxiinophobia@yahoo.com>2020-02-29 12:00:00 -0800
committerFlorian Didron <fdidron@users.noreply.github.com>2020-06-12 17:00:27 +0900
commitf01c45ef54039366b666c28747fd57136d81c472 (patch)
treea09c6a4e1f7f1b447fc508f4ca542d2640443e71 /tmk_core/common
parentae8641748e4b2adb5b4f091027975e3884e325c9 (diff)
2020 February 29 Breaking Changes Update (#8064)
Diffstat (limited to 'tmk_core/common')
-rw-r--r--tmk_core/common/action.c28
-rw-r--r--tmk_core/common/action_code.h33
-rw-r--r--tmk_core/common/chibios/timer.c44
-rw-r--r--tmk_core/common/command.c6
-rw-r--r--tmk_core/common/timer.h5
5 files changed, 41 insertions, 75 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index 001f0de13a..ab68681ded 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -562,34 +562,6 @@ void process_action(keyrecord_t *record, action_t action) {
action_macro_play(action_get_macro(record, action.func.id, action.func.opt));
break;
#endif
-#if defined(BACKLIGHT_ENABLE) | defined(LED_MATRIX_ENABLE)
- case ACT_BACKLIGHT:
- if (!event.pressed) {
- switch (action.backlight.opt) {
- case BACKLIGHT_INCREASE:
- backlight_increase();
- break;
- case BACKLIGHT_DECREASE:
- backlight_decrease();
- break;
- case BACKLIGHT_TOGGLE:
- backlight_toggle();
- break;
- case BACKLIGHT_STEP:
- backlight_step();
- break;
- case BACKLIGHT_ON:
- backlight_level(BACKLIGHT_LEVELS);
- break;
- case BACKLIGHT_OFF:
- backlight_level(0);
- break;
- }
- }
- break;
-#endif
- case ACT_COMMAND:
- break;
#ifdef SWAP_HANDS_ENABLE
case ACT_SWAP_HANDS:
switch (action.swap.code) {
diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h
index 03fcb3382b..6c005b76d1 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/>.
* 1100|opt | id(8) Macro play?
* 1100|1111| id(8) Macro record?
*
- * ACT_BACKLIGHT(1101):
- * 1101|opt |level(8) Backlight commands
+ * 1101|xxxx xxxx xxxx (reserved)
*
* ACT_COMMAND(1110):
* 1110|opt | id(8) Built-in Command exec
@@ -115,10 +114,9 @@ enum action_kind_id {
ACT_LAYER_TAP = 0b1010, /* Layer 0-15 */
ACT_LAYER_TAP_EXT = 0b1011, /* Layer 16-31 */
/* Extensions */
- ACT_MACRO = 0b1100,
- ACT_BACKLIGHT = 0b1101,
- ACT_COMMAND = 0b1110,
- ACT_FUNCTION = 0b1111
+ ACT_MACRO = 0b1100,
+ ACT_COMMAND = 0b1110,
+ ACT_FUNCTION = 0b1111
};
/** \brief Action Code Struct
@@ -169,11 +167,6 @@ typedef union {
uint8_t page : 2;
uint8_t kind : 4;
} usage;
- struct action_backlight {
- uint8_t level : 8;
- uint8_t opt : 4;
- uint8_t kind : 4;
- } backlight;
struct action_command {
uint8_t id : 8;
uint8_t opt : 4;
@@ -290,28 +283,10 @@ enum layer_param_tap_op {
#define ACTION_DEFAULT_LAYER_BIT_XOR(part, bits) ACTION_LAYER_BITOP(OP_BIT_XOR, (part), (bits), 0)
#define ACTION_DEFAULT_LAYER_BIT_SET(part, bits) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), 0)
-/** \brief Extensions
- */
-enum backlight_opt {
- BACKLIGHT_INCREASE = 0,
- BACKLIGHT_DECREASE = 1,
- BACKLIGHT_TOGGLE = 2,
- BACKLIGHT_STEP = 3,
- BACKLIGHT_ON = 4,
- BACKLIGHT_OFF = 5,
-};
-
/* Macro */
#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id))
#define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP << 8 | (id))
#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt) << 8 | (id))
-/* Backlight */
-#define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE << 8)
-#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8)
-#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8)
-#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8)
-#define ACTION_BACKLIGHT_ON() ACTION(ACT_BACKLIGHT, BACKLIGHT_ON << 8)
-#define ACTION_BACKLIGHT_OFF() ACTION(ACT_BACKLIGHT, BACKLIGHT_OFF << 8)
/* Command */
#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt) << 8 | (id))
/* Function */
diff --git a/tmk_core/common/chibios/timer.c b/tmk_core/common/chibios/timer.c
index ed5cfe1b05..ac5a5af638 100644
--- a/tmk_core/common/chibios/timer.c
+++ b/tmk_core/common/chibios/timer.c
@@ -2,30 +2,44 @@
#include "timer.h"
-static systime_t last_systime = 0;
-static systime_t overflow = 0;
-static uint32_t current_time_ms = 0;
+static uint32_t reset_point = 0;
+#if CH_CFG_ST_RESOLUTION < 32
+static uint32_t last_systime = 0;
+static uint32_t overflow = 0;
+#endif
void timer_init(void) { timer_clear(); }
void timer_clear(void) {
- last_systime = chVTGetSystemTime();
- overflow = 0;
- current_time_ms = 0;
+ reset_point = (uint32_t)chVTGetSystemTime();
+#if CH_CFG_ST_RESOLUTION < 32
+ last_systime = reset_point;
+ overflow = 0;
+#endif
}
uint16_t timer_read(void) { return (uint16_t)timer_read32(); }
uint32_t timer_read32(void) {
- // Note: We assume that the timer update is called at least once betweeen every wrap around of the system time
- systime_t current_systime = chVTGetSystemTime();
- systime_t elapsed = current_systime - last_systime + overflow;
- uint32_t elapsed_ms = ST2MS(elapsed);
- current_time_ms += elapsed_ms;
- overflow = elapsed - MS2ST(elapsed_ms);
- last_systime = current_systime;
-
- return current_time_ms;
+ uint32_t systime = (uint32_t)chVTGetSystemTime();
+
+#if CH_CFG_ST_RESOLUTION < 32
+ // If/when we need to support 64-bit chips, this may need to be modified to match the native bit-ness of the MCU.
+ // At this point, the only SysTick resolution allowed other than 32 is 16 bit.
+ // In the 16-bit case, at:
+ // - CH_CFG_ST_FREQUENCY = 100000, overflow will occur every ~0.65 seconds
+ // - CH_CFG_ST_FREQUENCY = 10000, overflow will occur every ~6.5 seconds
+ // - CH_CFG_ST_FREQUENCY = 1000, overflow will occur every ~65 seconds
+ // With this implementation, as long as we ensure a timer read happens at least once during the overflow period, timing should be accurate.
+ if (systime < last_systime) {
+ overflow += ((uint32_t)1) << CH_CFG_ST_RESOLUTION;
+ }
+
+ last_systime = systime;
+ return (uint32_t)TIME_I2MS(systime - reset_point + overflow);
+#else
+ return (uint32_t)TIME_I2MS(systime - reset_point);
+#endif
}
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 900de54103..77a205eac4 100644
--- a/tmk_core/common/command.c
+++ b/tmk_core/common/command.c
@@ -153,6 +153,9 @@ static void print_version(void) {
print("BUILD: (" __DATE__ ")\n");
#else
print("BUILD: " STR(QMK_VERSION) " (" __TIME__ " " __DATE__ ")\n");
+# ifdef PROTOCOL_CHIBIOS
+ print("CHIBIOS: " STR(CHIBIOS_VERSION) ", CONTRIB: " STR(CHIBIOS_CONTRIB_VERSION) "\n");
+# endif
#endif
/* build options */
@@ -182,6 +185,9 @@ static void print_version(void) {
#ifdef NKRO_ENABLE
" NKRO"
#endif
+#ifdef LINK_TIME_OPTIMIZATION_ENABLE
+ " LTO"
+#endif
" " STR(BOOTLOADER_SIZE) "\n");
diff --git a/tmk_core/common/timer.h b/tmk_core/common/timer.h
index 378cf7892c..bbaae109d0 100644
--- a/tmk_core/common/timer.h
+++ b/tmk_core/common/timer.h
@@ -45,9 +45,8 @@ uint16_t timer_elapsed(uint16_t last);
uint32_t timer_elapsed32(uint32_t last);
// Utility functions to check if a future time has expired & autmatically handle time wrapping if checked / reset frequently (half of max value)
-inline bool timer_expired(uint16_t current, uint16_t future) { return (uint16_t)(current - future) < 0x8000; }
-
-inline bool timer_expired32(uint32_t current, uint32_t future) { return (uint32_t)(current - future) < 0x80000000; }
+#define timer_expired(current, future) (((uint16_t)current - (uint16_t)future) < 0x8000)
+#define timer_expired32(current, future) (((uint32_t)current - (uint32_t)future) < 0x80000000)
#ifdef __cplusplus
}