From 355482550b8dce869bf8629ad5fb399007d602cf Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Mon, 18 Nov 2019 08:26:30 +0900 Subject: [PATCH] New: ticks_to_usec. Signed-off-by: NIIBE Yutaka --- ChangeLog | 6 ++++++ chopstx-cortex-m.c | 6 ++++++ chopstx-gnu-linux.c | 5 +++++ chopstx.c | 2 +- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1760ec4..554c49e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2019-11-18 NIIBE Yutaka + + * chopstx-cortex-m.c (ticks_to_usec): New. + * chopstx-gnu-linux.c (ticks_to_usec): New. + * chopstx.c (chx_snooze): Use ticks_to_usec. + 2019-11-18 NIIBE Yutaka * rules.mk (CSRC): Change the rule of entry*.c. diff --git a/chopstx-cortex-m.c b/chopstx-cortex-m.c index 23cfe03..ea824d9 100644 --- a/chopstx-cortex-m.c +++ b/chopstx-cortex-m.c @@ -141,6 +141,12 @@ static uint32_t usec_to_ticks (uint32_t usec) return usec * MHZ; } +static uint32_t +ticks_to_usec (uint32_t ticks) +{ + return ticks / MHZ; +} + /* * Interrupt Handling */ diff --git a/chopstx-gnu-linux.c b/chopstx-gnu-linux.c index 9c7f8df..d9f9876 100644 --- a/chopstx-gnu-linux.c +++ b/chopstx-gnu-linux.c @@ -76,6 +76,11 @@ usec_to_ticks (uint32_t usec) return usec * MHZ; } +static uint32_t +ticks_to_usec (uint32_t ticks) +{ + return ticks / MHZ; +} static void chx_enable_intr (uint8_t irq_num) diff --git a/chopstx.c b/chopstx.c index 022d821..74947d0 100644 --- a/chopstx.c +++ b/chopstx.c @@ -688,7 +688,7 @@ chx_snooze (uint32_t state, uint32_t *usec_p) *usec_p -= usec0; else if (r > 0) { - *usec_p -= (usec0 - r / MHZ); + *usec_p -= (usec0 - ticks_to_usec (r)); r = 1; }