Skip to content

Commit e523c73

Browse files
committed
drivers: litex_timer: Do not hard code tick rate
The litex_timer driver used hard coded tick rate (set to 100 ticks per second). This commit replaces the fixed value with a call to system function which takes under account system configuration. Signed-off-by: Piotr Zięcik <[email protected]>
1 parent 0fa4549 commit e523c73

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/timer/litex_timer.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
#define TIMER_IRQ DT_LITEX_TIMER0_E0002800_IRQ_0
2222
#define TIMER_DISABLE 0x0
2323
#define TIMER_ENABLE 0x1
24-
#define TIMER_VALUE ((CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) / 100)
25-
2624

2725
static u32_t accumulated_cycle_count;
2826

@@ -59,9 +57,9 @@ int z_clock_driver_init(struct device *device)
5957
sys_write8(TIMER_DISABLE, TIMER_EN_ADDR);
6058

6159
for (int i = 0; i < 4; i++) {
62-
sys_write8(TIMER_VALUE >> (24 - i * 8),
60+
sys_write8(sys_clock_hw_cycles_per_tick() >> (24 - i * 8),
6361
TIMER_RELOAD_ADDR + i * 0x4);
64-
sys_write8(TIMER_VALUE >> (24 - i * 8),
62+
sys_write8(sys_clock_hw_cycles_per_tick() >> (24 - i * 8),
6563
TIMER_LOAD_ADDR + i * 0x4);
6664
}
6765

0 commit comments

Comments
 (0)