diff --git a/src/arch/8051/include/arch/time.h b/src/arch/8051/include/arch/time.h index 9fb414cbf..0c87baaad 100644 --- a/src/arch/8051/include/arch/time.h +++ b/src/arch/8051/include/arch/time.h @@ -5,7 +5,9 @@ #include +typedef uint16_t systick_t; + void time_init(void); -uint32_t time_get(void); +systick_t time_get(void); #endif // _ARCH_TIME_H diff --git a/src/arch/8051/time.c b/src/arch/8051/time.c index 29ef275ca..6fbffb5ec 100644 --- a/src/arch/8051/time.c +++ b/src/arch/8051/time.c @@ -10,7 +10,7 @@ // Value to reload into the timer when the overflow interrupt is triggered. #define TIMER_RELOAD (0xFFFF - (TICK_INTERVAL_MS * (CONFIG_CLOCK_FREQ_KHZ / OSC_DIVISOR))) -static volatile uint32_t time_overflows = 0; +static volatile systick_t time_overflows = 0; void timer_0(void) __interrupt(1) { // Hardware automatically clears the the interrupt @@ -52,6 +52,6 @@ void time_init(void) __critical { TR0 = 1; } -uint32_t time_get(void) __critical { +systick_t time_get(void) __critical { return time_overflows; } diff --git a/src/board/system76/common/kbscan.c b/src/board/system76/common/kbscan.c index 2d783e204..a9001d637 100644 --- a/src/board/system76/common/kbscan.c +++ b/src/board/system76/common/kbscan.c @@ -284,15 +284,15 @@ void kbscan_event(void) { uint8_t matrix_curr[KM_OUT]; static bool debounce = false; - static uint32_t debounce_time = 0; + static systick_t debounce_time = 0; static bool repeat = false; static uint16_t repeat_key = 0; - static uint32_t repeat_key_time = 0; + static systick_t repeat_key_time = 0; // If debounce complete if (debounce) { - uint32_t time = time_get(); + systick_t time = time_get(); if ((time - debounce_time) >= DEBOUNCE_DELAY) { // Debounce time elapsed: Read new state debounce = false; @@ -384,8 +384,8 @@ void kbscan_event(void) { kbscan_matrix[i] = new; } else if (new && repeat_key != 0 && key_should_repeat(repeat_key)) { // A key is being pressed - uint32_t time = time_get(); - static uint32_t repeat_start = 0; + systick_t time = time_get(); + static systick_t repeat_start = 0; if (!repeat) { if (time < repeat_key_time) { diff --git a/src/board/system76/common/main.c b/src/board/system76/common/main.c index 073be24c5..c5b0194ca 100644 --- a/src/board/system76/common/main.c +++ b/src/board/system76/common/main.c @@ -98,8 +98,8 @@ void main(void) { INFO("System76 EC board '%s', version '%s'\n", board(), version()); - uint32_t last_time_battery = 0; - uint32_t last_time_fan = 0; + systick_t last_time_battery = 0; + systick_t last_time_fan = 0; for (main_cycle = 0;; main_cycle++) { // NOTE: Do note use modulo to avoid expensive call to SDCC library @@ -128,7 +128,7 @@ void main(void) { } if (main_cycle == 0) { - uint32_t time = time_get(); + systick_t time = time_get(); // Only run the following once per interval if ((time - last_time_fan) >= fan_interval) { last_time_fan = time; diff --git a/src/board/system76/common/parallel.c b/src/board/system76/common/parallel.c index 45246572c..01c2525ae 100644 --- a/src/board/system76/common/parallel.c +++ b/src/board/system76/common/parallel.c @@ -32,7 +32,7 @@ bool parallel_debug = false; static bool parallel_wait_peripheral(uint8_t mask, uint8_t value) { - uint32_t start = time_get(); + systick_t start = time_get(); while ((time_get() - start) < PARALLEL_TIMEOUT) { if ((KSOHGDMRR & mask) == value) { diff --git a/src/board/system76/common/peci.c b/src/board/system76/common/peci.c index d168bd6db..c48642ecd 100644 --- a/src/board/system76/common/peci.c +++ b/src/board/system76/common/peci.c @@ -93,7 +93,7 @@ bool peci_get_temp(int16_t *const data) { ESUCTRL0 |= ESUCTRL0_GO; // Wait until upstream done - uint32_t start = time_get(); + systick_t start = time_get(); while (!(ESUCTRL0 & ESUCTRL0_DONE)) { if ((time_get() - start) >= PECI_ESPI_TIMEOUT) { DEBUG("peci_get_temp: upstream timeout\n"); @@ -189,7 +189,7 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) { ESUCTRL0 |= ESUCTRL0_GO; // Wait until upstream done - uint32_t start = time_get(); + systick_t start = time_get(); while (!(ESUCTRL0 & ESUCTRL0_DONE)) { DEBUG("peci_wr_pkg_config: wait upstream\n"); if ((time_get() - start) >= PECI_ESPI_TIMEOUT) { @@ -254,7 +254,7 @@ void peci_init(void) { // Returns true on success, false on error bool peci_get_temp(int16_t *const data) { // Wait for any in-progress transaction to complete - uint32_t start = time_get(); + systick_t start = time_get(); while (HOSTAR & BIT(0)) { if ((time_get() - start) >= PECI_ESPI_TIMEOUT) { DEBUG("%s: host timeout\n", __func__); @@ -310,7 +310,7 @@ bool peci_get_temp(int16_t *const data) { // negative (0x1000 | status register) on PECI hardware error int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) { // Wait for any in-progress transaction to complete - uint32_t start = time_get(); + systick_t start = time_get(); while (HOSTAR & BIT(0)) { if ((time_get() - start) >= PECI_ESPI_TIMEOUT) { DEBUG("%s: host timeout\n", __func__); diff --git a/src/board/system76/common/power.c b/src/board/system76/common/power.c index 296f23193..5be58ee94 100644 --- a/src/board/system76/common/power.c +++ b/src/board/system76/common/power.c @@ -572,8 +572,8 @@ void power_event(void) { wake_last = wake_new; #endif // HAVE_LAN_WAKEUP_N - static uint32_t last_time = 0; - uint32_t time = time_get(); + static systick_t last_time = 0; + systick_t time = time_get(); if (power_state == POWER_STATE_S0) { #if CONFIG_BUS_ESPI // HOST_C10 virtual wire is high when CPU is in C10 sleep state