diff options
| -rw-r--r-- | quantum/quantum.h | 1 | ||||
| -rw-r--r-- | quantum/rgb_matrix.c | 6 | ||||
| -rw-r--r-- | quantum/rgblight.c | 21 | ||||
| -rw-r--r-- | quantum/split_common/transport.c | 26 | ||||
| -rw-r--r-- | tmk_core/common.mk | 1 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.c | 2 | ||||
| -rw-r--r-- | tmk_core/common/sync_timer.c | 58 | ||||
| -rw-r--r-- | tmk_core/common/sync_timer.h | 54 |
8 files changed, 154 insertions, 15 deletions
diff --git a/quantum/quantum.h b/quantum/quantum.h index cb0af306a..59c3dd490 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -53,6 +53,7 @@ | |||
| 53 | #include "eeconfig.h" | 53 | #include "eeconfig.h" |
| 54 | #include "bootloader.h" | 54 | #include "bootloader.h" |
| 55 | #include "timer.h" | 55 | #include "timer.h" |
| 56 | #include "sync_timer.h" | ||
| 56 | #include "config_common.h" | 57 | #include "config_common.h" |
| 57 | #include "led.h" | 58 | #include "led.h" |
| 58 | #include "action_util.h" | 59 | #include "action_util.h" |
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index f239bd582..a3dd51f7b 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
| @@ -266,9 +266,9 @@ static bool rgb_matrix_none(effect_params_t *params) { | |||
| 266 | 266 | ||
| 267 | static void rgb_task_timers(void) { | 267 | static void rgb_task_timers(void) { |
| 268 | #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 | 268 | #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 |
| 269 | uint32_t deltaTime = timer_elapsed32(rgb_timer_buffer); | 269 | uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer); |
| 270 | #endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 | 270 | #endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 |
| 271 | rgb_timer_buffer = timer_read32(); | 271 | rgb_timer_buffer = sync_timer_read32(); |
| 272 | 272 | ||
| 273 | // Update double buffer timers | 273 | // Update double buffer timers |
| 274 | #if RGB_DISABLE_TIMEOUT > 0 | 274 | #if RGB_DISABLE_TIMEOUT > 0 |
| @@ -296,7 +296,7 @@ static void rgb_task_timers(void) { | |||
| 296 | 296 | ||
| 297 | static void rgb_task_sync(void) { | 297 | static void rgb_task_sync(void) { |
| 298 | // next task | 298 | // next task |
| 299 | if (timer_elapsed32(g_rgb_timer) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING; | 299 | if (sync_timer_elapsed32(g_rgb_timer) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING; |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | static void rgb_task_start(void) { | 302 | static void rgb_task_start(void) { |
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 7f9e330d3..65308572d 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -29,7 +29,7 @@ | |||
| 29 | #endif | 29 | #endif |
| 30 | #include "wait.h" | 30 | #include "wait.h" |
| 31 | #include "progmem.h" | 31 | #include "progmem.h" |
| 32 | #include "timer.h" | 32 | #include "sync_timer.h" |
| 33 | #include "rgblight.h" | 33 | #include "rgblight.h" |
| 34 | #include "color.h" | 34 | #include "color.h" |
| 35 | #include "debug.h" | 35 | #include "debug.h" |
| @@ -684,18 +684,16 @@ static void rgblight_layers_write(void) { | |||
| 684 | 684 | ||
| 685 | # ifdef RGBLIGHT_LAYER_BLINK | 685 | # ifdef RGBLIGHT_LAYER_BLINK |
| 686 | rgblight_layer_mask_t _blinked_layer_mask = 0; | 686 | rgblight_layer_mask_t _blinked_layer_mask = 0; |
| 687 | uint16_t _blink_duration = 0; | ||
| 688 | static uint16_t _blink_timer; | 687 | static uint16_t _blink_timer; |
| 689 | 688 | ||
| 690 | void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { | 689 | void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { |
| 691 | rgblight_set_layer_state(layer, true); | 690 | rgblight_set_layer_state(layer, true); |
| 692 | _blinked_layer_mask |= 1 << layer; | 691 | _blinked_layer_mask |= 1 << layer; |
| 693 | _blink_timer = timer_read(); | 692 | _blink_timer = sync_timer_read() + duration_ms; |
| 694 | _blink_duration = duration_ms; | ||
| 695 | } | 693 | } |
| 696 | 694 | ||
| 697 | void rgblight_unblink_layers(void) { | 695 | void rgblight_unblink_layers(void) { |
| 698 | if (_blinked_layer_mask != 0 && timer_elapsed(_blink_timer) > _blink_duration) { | 696 | if (_blinked_layer_mask != 0 && timer_expired(sync_timer_read(), _blink_timer)) { |
| 699 | for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) { | 697 | for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) { |
| 700 | if ((_blinked_layer_mask & 1 << layer) != 0) { | 698 | if ((_blinked_layer_mask & 1 << layer) != 0) { |
| 701 | rgblight_set_layer_state(layer, false); | 699 | rgblight_set_layer_state(layer, false); |
| @@ -799,7 +797,7 @@ void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom) { | |||
| 799 | animation_status.restart = true; | 797 | animation_status.restart = true; |
| 800 | } | 798 | } |
| 801 | # endif /* RGBLIGHT_SPLIT_NO_ANIMATION_SYNC */ | 799 | # endif /* RGBLIGHT_SPLIT_NO_ANIMATION_SYNC */ |
| 802 | # endif /* RGBLIGHT_USE_TIMER */ | 800 | # endif /* RGBLIGHT_USE_TIMER */ |
| 803 | } | 801 | } |
| 804 | #endif /* RGBLIGHT_SPLIT */ | 802 | #endif /* RGBLIGHT_SPLIT */ |
| 805 | 803 | ||
| @@ -832,7 +830,7 @@ void rgblight_timer_enable(void) { | |||
| 832 | if (!is_static_effect(rgblight_config.mode)) { | 830 | if (!is_static_effect(rgblight_config.mode)) { |
| 833 | rgblight_status.timer_enabled = true; | 831 | rgblight_status.timer_enabled = true; |
| 834 | } | 832 | } |
| 835 | animation_status.last_timer = timer_read(); | 833 | animation_status.last_timer = sync_timer_read(); |
| 836 | RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE; | 834 | RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE; |
| 837 | dprintf("rgblight timer enabled.\n"); | 835 | dprintf("rgblight timer enabled.\n"); |
| 838 | } | 836 | } |
| @@ -941,18 +939,19 @@ void rgblight_task(void) { | |||
| 941 | # endif | 939 | # endif |
| 942 | if (animation_status.restart) { | 940 | if (animation_status.restart) { |
| 943 | animation_status.restart = false; | 941 | animation_status.restart = false; |
| 944 | animation_status.last_timer = timer_read() - interval_time - 1; | 942 | animation_status.last_timer = sync_timer_read(); |
| 945 | animation_status.pos16 = 0; // restart signal to local each effect | 943 | animation_status.pos16 = 0; // restart signal to local each effect |
| 946 | } | 944 | } |
| 947 | if (timer_elapsed(animation_status.last_timer) >= interval_time) { | 945 | uint16_t now = sync_timer_read(); |
| 946 | if (timer_expired(now, animation_status.last_timer)) { | ||
| 948 | # if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) | 947 | # if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) |
| 949 | static uint16_t report_last_timer = 0; | 948 | static uint16_t report_last_timer = 0; |
| 950 | static bool tick_flag = false; | 949 | static bool tick_flag = false; |
| 951 | uint16_t oldpos16; | 950 | uint16_t oldpos16; |
| 952 | if (tick_flag) { | 951 | if (tick_flag) { |
| 953 | tick_flag = false; | 952 | tick_flag = false; |
| 954 | if (timer_elapsed(report_last_timer) >= 30000) { | 953 | if (timer_expired(now, report_last_timer)) { |
| 955 | report_last_timer = timer_read(); | 954 | report_last_timer += 30000; |
| 956 | dprintf("rgblight animation tick report to slave\n"); | 955 | dprintf("rgblight animation tick report to slave\n"); |
| 957 | RGBLIGHT_SPLIT_ANIMATION_TICK; | 956 | RGBLIGHT_SPLIT_ANIMATION_TICK; |
| 958 | } | 957 | } |
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c index 467ff81a9..6856b6055 100644 --- a/quantum/split_common/transport.c +++ b/quantum/split_common/transport.c | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "quantum.h" | 6 | #include "quantum.h" |
| 7 | 7 | ||
| 8 | #define ROWS_PER_HAND (MATRIX_ROWS / 2) | 8 | #define ROWS_PER_HAND (MATRIX_ROWS / 2) |
| 9 | #define SYNC_TIMER_OFFSET 2 | ||
| 9 | 10 | ||
| 10 | #ifdef RGBLIGHT_ENABLE | 11 | #ifdef RGBLIGHT_ENABLE |
| 11 | # include "rgblight.h" | 12 | # include "rgblight.h" |
| @@ -27,6 +28,9 @@ static pin_t encoders_pad[] = ENCODERS_PAD_A; | |||
| 27 | # include "i2c_slave.h" | 28 | # include "i2c_slave.h" |
| 28 | 29 | ||
| 29 | typedef struct _I2C_slave_buffer_t { | 30 | typedef struct _I2C_slave_buffer_t { |
| 31 | # ifndef DISABLE_SYNC_TIMER | ||
| 32 | uint32_t sync_timer; | ||
| 33 | # endif | ||
| 30 | matrix_row_t smatrix[ROWS_PER_HAND]; | 34 | matrix_row_t smatrix[ROWS_PER_HAND]; |
| 31 | uint8_t backlight_level; | 35 | uint8_t backlight_level; |
| 32 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 36 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
| @@ -44,6 +48,7 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re | |||
| 44 | 48 | ||
| 45 | # define I2C_BACKLIGHT_START offsetof(I2C_slave_buffer_t, backlight_level) | 49 | # define I2C_BACKLIGHT_START offsetof(I2C_slave_buffer_t, backlight_level) |
| 46 | # define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync) | 50 | # define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync) |
| 51 | # define I2C_SYNC_TIME_START offsetof(I2C_slave_buffer_t, sync_timer) | ||
| 47 | # define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix) | 52 | # define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix) |
| 48 | # define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state) | 53 | # define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state) |
| 49 | # define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm) | 54 | # define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm) |
| @@ -91,10 +96,18 @@ bool transport_master(matrix_row_t matrix[]) { | |||
| 91 | } | 96 | } |
| 92 | } | 97 | } |
| 93 | # endif | 98 | # endif |
| 99 | |||
| 100 | # ifndef DISABLE_SYNC_TIMER | ||
| 101 | i2c_buffer->sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; | ||
| 102 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_SYNC_TIME_START, (void *)&i2c_buffer->sync_timer, sizeof(i2c_buffer->sync_timer), TIMEOUT); | ||
| 103 | # endif | ||
| 94 | return true; | 104 | return true; |
| 95 | } | 105 | } |
| 96 | 106 | ||
| 97 | void transport_slave(matrix_row_t matrix[]) { | 107 | void transport_slave(matrix_row_t matrix[]) { |
| 108 | # ifndef DISABLE_SYNC_TIMER | ||
| 109 | sync_timer_update(i2c_buffer->sync_timer); | ||
| 110 | # endif | ||
| 98 | // Copy matrix to I2C buffer | 111 | // Copy matrix to I2C buffer |
| 99 | memcpy((void *)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix)); | 112 | memcpy((void *)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix)); |
| 100 | 113 | ||
| @@ -133,12 +146,15 @@ typedef struct _Serial_s2m_buffer_t { | |||
| 133 | matrix_row_t smatrix[ROWS_PER_HAND]; | 146 | matrix_row_t smatrix[ROWS_PER_HAND]; |
| 134 | 147 | ||
| 135 | # ifdef ENCODER_ENABLE | 148 | # ifdef ENCODER_ENABLE |
| 136 | uint8_t encoder_state[NUMBER_OF_ENCODERS]; | 149 | uint8_t encoder_state[NUMBER_OF_ENCODERS]; |
| 137 | # endif | 150 | # endif |
| 138 | 151 | ||
| 139 | } Serial_s2m_buffer_t; | 152 | } Serial_s2m_buffer_t; |
| 140 | 153 | ||
| 141 | typedef struct _Serial_m2s_buffer_t { | 154 | typedef struct _Serial_m2s_buffer_t { |
| 155 | # ifndef DISABLE_SYNC_TIMER | ||
| 156 | uint32_t sync_timer; | ||
| 157 | # endif | ||
| 142 | # ifdef BACKLIGHT_ENABLE | 158 | # ifdef BACKLIGHT_ENABLE |
| 143 | uint8_t backlight_level; | 159 | uint8_t backlight_level; |
| 144 | # endif | 160 | # endif |
| @@ -251,11 +267,19 @@ bool transport_master(matrix_row_t matrix[]) { | |||
| 251 | // Write wpm to slave | 267 | // Write wpm to slave |
| 252 | serial_m2s_buffer.current_wpm = get_current_wpm(); | 268 | serial_m2s_buffer.current_wpm = get_current_wpm(); |
| 253 | # endif | 269 | # endif |
| 270 | |||
| 271 | # ifndef DISABLE_SYNC_TIMER | ||
| 272 | serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; | ||
| 273 | # endif | ||
| 254 | return true; | 274 | return true; |
| 255 | } | 275 | } |
| 256 | 276 | ||
| 257 | void transport_slave(matrix_row_t matrix[]) { | 277 | void transport_slave(matrix_row_t matrix[]) { |
| 258 | transport_rgblight_slave(); | 278 | transport_rgblight_slave(); |
| 279 | # ifndef DISABLE_SYNC_TIMER | ||
| 280 | sync_timer_update(serial_m2s_buffer.sync_timer); | ||
| 281 | # endif | ||
| 282 | |||
| 259 | // TODO: if MATRIX_COLS > 8 change to pack() | 283 | // TODO: if MATRIX_COLS > 8 change to pack() |
| 260 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | 284 | for (int i = 0; i < ROWS_PER_HAND; ++i) { |
| 261 | serial_s2m_buffer.smatrix[i] = matrix[i]; | 285 | serial_s2m_buffer.smatrix[i] = matrix[i]; |
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index fdf2aa097..05839824c 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk | |||
| @@ -18,6 +18,7 @@ TMK_COMMON_SRC += $(COMMON_DIR)/host.c \ | |||
| 18 | $(COMMON_DIR)/report.c \ | 18 | $(COMMON_DIR)/report.c \ |
| 19 | $(PLATFORM_COMMON_DIR)/suspend.c \ | 19 | $(PLATFORM_COMMON_DIR)/suspend.c \ |
| 20 | $(PLATFORM_COMMON_DIR)/timer.c \ | 20 | $(PLATFORM_COMMON_DIR)/timer.c \ |
| 21 | $(COMMON_DIR)/sync_timer.c \ | ||
| 21 | $(PLATFORM_COMMON_DIR)/bootloader.c \ | 22 | $(PLATFORM_COMMON_DIR)/bootloader.c \ |
| 22 | 23 | ||
| 23 | ifeq ($(PLATFORM),AVR) | 24 | ifeq ($(PLATFORM),AVR) |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 8c7bdc8b5..a1fbc01da 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 23 | #include "led.h" | 23 | #include "led.h" |
| 24 | #include "keycode.h" | 24 | #include "keycode.h" |
| 25 | #include "timer.h" | 25 | #include "timer.h" |
| 26 | #include "sync_timer.h" | ||
| 26 | #include "print.h" | 27 | #include "print.h" |
| 27 | #include "debug.h" | 28 | #include "debug.h" |
| 28 | #include "command.h" | 29 | #include "command.h" |
| @@ -255,6 +256,7 @@ __attribute__((weak)) void housekeeping_task_user(void) {} | |||
| 255 | */ | 256 | */ |
| 256 | void keyboard_init(void) { | 257 | void keyboard_init(void) { |
| 257 | timer_init(); | 258 | timer_init(); |
| 259 | sync_timer_init(); | ||
| 258 | matrix_init(); | 260 | matrix_init(); |
| 259 | #ifdef VIA_ENABLE | 261 | #ifdef VIA_ENABLE |
| 260 | via_init(); | 262 | via_init(); |
diff --git a/tmk_core/common/sync_timer.c b/tmk_core/common/sync_timer.c new file mode 100644 index 000000000..de24b463b --- /dev/null +++ b/tmk_core/common/sync_timer.c | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | /* | ||
| 2 | Copyright (C) 2020 Ryan Caltabiano <https://github.com/XScorpion2> | ||
| 3 | |||
| 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 5 | this software and associated documentation files (the "Software"), to deal in | ||
| 6 | the Software without restriction, including without limitation the rights to | ||
| 7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
| 8 | of the Software, and to permit persons to whom the Software is furnished to do | ||
| 9 | so, subject to the following conditions: | ||
| 10 | |||
| 11 | The above copyright notice and this permission notice shall be included in all | ||
| 12 | copies or substantial portions of the Software. | ||
| 13 | |||
| 14 | If you happen to meet one of the copyright holders in a bar you are obligated | ||
| 15 | to buy them one pint of beer. | ||
| 16 | |||
| 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 23 | SOFTWARE. | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include "sync_timer.h" | ||
| 27 | #include "keyboard.h" | ||
| 28 | |||
| 29 | #if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER) | ||
| 30 | volatile int32_t sync_timer_ms; | ||
| 31 | |||
| 32 | void sync_timer_init(void) { sync_timer_ms = 0; } | ||
| 33 | |||
| 34 | void sync_timer_update(uint32_t time) { | ||
| 35 | if (is_keyboard_master()) return; | ||
| 36 | sync_timer_ms = time - timer_read32(); | ||
| 37 | } | ||
| 38 | |||
| 39 | uint16_t sync_timer_read(void) { | ||
| 40 | if (is_keyboard_master()) return timer_read(); | ||
| 41 | return sync_timer_read32(); | ||
| 42 | } | ||
| 43 | |||
| 44 | uint32_t sync_timer_read32(void) { | ||
| 45 | if (is_keyboard_master()) return timer_read32(); | ||
| 46 | return sync_timer_ms + timer_read32(); | ||
| 47 | } | ||
| 48 | |||
| 49 | uint16_t sync_timer_elapsed(uint16_t last) { | ||
| 50 | if (is_keyboard_master()) return timer_elapsed(last); | ||
| 51 | return TIMER_DIFF_16(sync_timer_read(), last); | ||
| 52 | } | ||
| 53 | |||
| 54 | uint32_t sync_timer_elapsed32(uint32_t last) { | ||
| 55 | if (is_keyboard_master()) return timer_elapsed32(last); | ||
| 56 | return TIMER_DIFF_32(sync_timer_read32(), last); | ||
| 57 | } | ||
| 58 | #endif | ||
diff --git a/tmk_core/common/sync_timer.h b/tmk_core/common/sync_timer.h new file mode 100644 index 000000000..9ddef45bb --- /dev/null +++ b/tmk_core/common/sync_timer.h | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | /* | ||
| 2 | Copyright (C) 2020 Ryan Caltabiano <https://github.com/XScorpion2> | ||
| 3 | |||
| 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 5 | this software and associated documentation files (the "Software"), to deal in | ||
| 6 | the Software without restriction, including without limitation the rights to | ||
| 7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
| 8 | of the Software, and to permit persons to whom the Software is furnished to do | ||
| 9 | so, subject to the following conditions: | ||
| 10 | |||
| 11 | The above copyright notice and this permission notice shall be included in all | ||
| 12 | copies or substantial portions of the Software. | ||
| 13 | |||
| 14 | If you happen to meet one of the copyright holders in a bar you are obligated | ||
| 15 | to buy them one pint of beer. | ||
| 16 | |||
| 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 23 | SOFTWARE. | ||
| 24 | */ | ||
| 25 | |||
| 26 | #pragma once | ||
| 27 | |||
| 28 | #include <stdint.h> | ||
| 29 | #include "timer.h" | ||
| 30 | |||
| 31 | #ifdef __cplusplus | ||
| 32 | extern "C" { | ||
| 33 | #endif | ||
| 34 | |||
| 35 | #if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER) | ||
| 36 | void sync_timer_init(void); | ||
| 37 | void sync_timer_update(uint32_t time); | ||
| 38 | uint16_t sync_timer_read(void); | ||
| 39 | uint32_t sync_timer_read32(void); | ||
| 40 | uint16_t sync_timer_elapsed(uint16_t last); | ||
| 41 | uint32_t sync_timer_elapsed32(uint32_t last); | ||
| 42 | #else | ||
| 43 | # define sync_timer_init() | ||
| 44 | # define sync_timer_clear() | ||
| 45 | # define sync_timer_update(t) | ||
| 46 | # define sync_timer_read() timer_read() | ||
| 47 | # define sync_timer_read32() timer_read32() | ||
| 48 | # define sync_timer_elapsed(t) timer_elapsed(t) | ||
| 49 | # define sync_timer_elapsed32(t) timer_elapsed32(t) | ||
| 50 | #endif | ||
| 51 | |||
| 52 | #ifdef __cplusplus | ||
| 53 | } | ||
| 54 | #endif | ||
