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; }