New: ticks_to_usec.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka
2019-11-18 08:26:30 +09:00
parent 858a9f5d01
commit 355482550b
4 changed files with 18 additions and 1 deletions

View File

@@ -1,3 +1,9 @@
2019-11-18 NIIBE Yutaka <gniibe@fsij.org>
* 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 <gniibe@fsij.org> 2019-11-18 NIIBE Yutaka <gniibe@fsij.org>
* rules.mk (CSRC): Change the rule of entry*.c. * rules.mk (CSRC): Change the rule of entry*.c.

View File

@@ -141,6 +141,12 @@ static uint32_t usec_to_ticks (uint32_t usec)
return usec * MHZ; return usec * MHZ;
} }
static uint32_t
ticks_to_usec (uint32_t ticks)
{
return ticks / MHZ;
}
/* /*
* Interrupt Handling * Interrupt Handling
*/ */

View File

@@ -76,6 +76,11 @@ usec_to_ticks (uint32_t usec)
return usec * MHZ; return usec * MHZ;
} }
static uint32_t
ticks_to_usec (uint32_t ticks)
{
return ticks / MHZ;
}
static void static void
chx_enable_intr (uint8_t irq_num) chx_enable_intr (uint8_t irq_num)

View File

@@ -688,7 +688,7 @@ chx_snooze (uint32_t state, uint32_t *usec_p)
*usec_p -= usec0; *usec_p -= usec0;
else if (r > 0) else if (r > 0)
{ {
*usec_p -= (usec0 - r / MHZ); *usec_p -= (usec0 - ticks_to_usec (r));
r = 1; r = 1;
} }