Change all time conversions. Yech. New timer units in microseconds breaks all existing logic that used milliseconds in the conversions. Something likely got broken doing this, probably because I confused a MSEC2TICK conversion with a TICK2MSEC conversion. Also, the tickless OS no appears fully functional and passes the OS test on the simulator with no errors
This commit is contained in:
parent
17ea50b45e
commit
c9661ad5a7
50 changed files with 119 additions and 114 deletions
|
@ -100,7 +100,7 @@ void up_unblock_task(FAR struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -97,7 +97,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -96,7 +96,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -97,7 +97,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -97,7 +97,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
************************************************************/
|
************************************************************/
|
||||||
|
|
||||||
/* We want the general purpose timer running at the rate
|
/* We want the general purpose timer running at the rate
|
||||||
* MSEC_PER_TICK. The C5471 clock is 47.5MHz and we're using
|
* USEC_PER_TICK. The C5471 clock is 47.5MHz and we're using
|
||||||
* a timer PTV value of 3 (3 == divide incoming frequency by
|
* a timer PTV value of 3 (3 == divide incoming frequency by
|
||||||
* 16) which then yields a 16 bitCLKS_PER_INT value
|
* 16) which then yields a 16 bitCLKS_PER_INT value
|
||||||
* of 29687.
|
* of 29687.
|
||||||
|
@ -114,7 +114,7 @@ void up_timer_initialize(void)
|
||||||
up_disable_irq(C5471_IRQ_SYSTIMER);
|
up_disable_irq(C5471_IRQ_SYSTIMER);
|
||||||
|
|
||||||
/* Start the general purpose timer running in auto-reload mode
|
/* Start the general purpose timer running in auto-reload mode
|
||||||
* so that an interrupt is generated at the rate MSEC_PER_TICK.
|
* so that an interrupt is generated at the rate USEC_PER_TICK.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
val = ((CLKS_PER_INT-1) << CLKS_PER_INT_SHIFT) | AR | ST | PTV;
|
val = ((CLKS_PER_INT-1) << CLKS_PER_INT_SHIFT) | AR | ST | PTV;
|
||||||
|
|
|
@ -139,7 +139,7 @@ void up_timer_initialize(void)
|
||||||
up_disable_irq(DM320_IRQ_SYSTIMER);
|
up_disable_irq(DM320_IRQ_SYSTIMER);
|
||||||
|
|
||||||
/* Start timer0 running so that an interrupt is generated at
|
/* Start timer0 running so that an interrupt is generated at
|
||||||
* the rate MSEC_PER_TICK.
|
* the rate USEC_PER_TICK.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
putreg16(DM320_TMR0_PRSCL, DM320_TIMER0_TMPRSCL); /* Timer 0 Prescalar */
|
putreg16(DM320_TMR0_PRSCL, DM320_TIMER0_TMPRSCL); /* Timer 0 Prescalar */
|
||||||
|
|
|
@ -138,11 +138,11 @@ void up_timer_initialize(void)
|
||||||
* putreg(0, IMX_TIMER1_TPRER); -- already the case
|
* putreg(0, IMX_TIMER1_TPRER); -- already the case
|
||||||
*
|
*
|
||||||
* Set the compare register so that the COMP interrupt is generated
|
* Set the compare register so that the COMP interrupt is generated
|
||||||
* with a period of MSEC_PER_TICK. The value IMX_PERCLK1_FREQ/1000
|
* with a period of USEC_PER_TICK. The value IMX_PERCLK1_FREQ/1000
|
||||||
* (defined in board.h) is the number of counts in millisecond, so:
|
* (defined in board.h) is the number of counts in millisecond, so:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
putreg32((IMX_PERCLK1_FREQ / 1000) * MSEC_PER_TICK, IMX_TIMER1_TCMP);
|
putreg32(MSEC2TICK(IMX_PERCLK1_FREQ / 1000), IMX_TIMER1_TCMP);
|
||||||
|
|
||||||
/* Configure to provide timer COMP interrupts when TCN increments
|
/* Configure to provide timer COMP interrupts when TCN increments
|
||||||
* to TCMP.
|
* to TCMP.
|
||||||
|
|
|
@ -2409,7 +2409,7 @@ static sdio_eventset_t kinetis_eventwait(FAR struct sdio_dev_s *dev,
|
||||||
|
|
||||||
/* Start the watchdog timer */
|
/* Start the watchdog timer */
|
||||||
|
|
||||||
delay = (timeout + (MSEC_PER_TICK-1)) / MSEC_PER_TICK;
|
delay = MSEC2TICK(timeout);
|
||||||
ret = wd_start(priv->waitwdog, delay, (wdentry_t)kinetis_eventtimeout,
|
ret = wd_start(priv->waitwdog, delay, (wdentry_t)kinetis_eventtimeout,
|
||||||
1, (uint32_t)priv);
|
1, (uint32_t)priv);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
|
|
|
@ -2266,7 +2266,7 @@ static sdio_eventset_t lpc17_eventwait(FAR struct sdio_dev_s *dev,
|
||||||
|
|
||||||
/* Start the watchdog timer */
|
/* Start the watchdog timer */
|
||||||
|
|
||||||
delay = (timeout + (MSEC_PER_TICK-1)) / MSEC_PER_TICK;
|
delay = MSEC2TICK(timeout);
|
||||||
ret = wd_start(priv->waitwdog, delay, (wdentry_t)lpc17_eventtimeout,
|
ret = wd_start(priv->waitwdog, delay, (wdentry_t)lpc17_eventtimeout,
|
||||||
1, (uint32_t)priv);
|
1, (uint32_t)priv);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
|
|
|
@ -2273,7 +2273,7 @@ static sdio_eventset_t sam_eventwait(FAR struct sdio_dev_s *dev,
|
||||||
|
|
||||||
/* Start the watchdog timer */
|
/* Start the watchdog timer */
|
||||||
|
|
||||||
delay = (timeout + (MSEC_PER_TICK-1)) / MSEC_PER_TICK;
|
delay = MSEC2TICK(timeout);
|
||||||
ret = wd_start(priv->waitwdog, delay, (wdentry_t)sam_eventtimeout,
|
ret = wd_start(priv->waitwdog, delay, (wdentry_t)sam_eventtimeout,
|
||||||
1, (uint32_t)priv);
|
1, (uint32_t)priv);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
|
|
|
@ -127,7 +127,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DMA_TIMEOUT_MS (800)
|
#define DMA_TIMEOUT_MS (800)
|
||||||
#define DMA_TIMEOUT_TICKS ((DMA_TIMEOUT_MS + (MSEC_PER_TICK-1)) / MSEC_PER_TICK)
|
#define DMA_TIMEOUT_TICKS MSEC2TICK(DMA_TIMEOUT_MS)
|
||||||
|
|
||||||
/* Debug *******************************************************************/
|
/* Debug *******************************************************************/
|
||||||
/* Check if SPI debut is enabled (non-standard.. no support in
|
/* Check if SPI debut is enabled (non-standard.. no support in
|
||||||
|
|
|
@ -2737,7 +2737,7 @@ static sdio_eventset_t sam_eventwait(FAR struct sdio_dev_s *dev,
|
||||||
timeout = MAX(5000, timeout);
|
timeout = MAX(5000, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = (timeout + (MSEC_PER_TICK-1)) / MSEC_PER_TICK;
|
delay = MSEC2TICK(timeout);
|
||||||
ret = wd_start(priv->waitwdog, delay, (wdentry_t)sam_eventtimeout,
|
ret = wd_start(priv->waitwdog, delay, (wdentry_t)sam_eventtimeout,
|
||||||
1, (uint32_t)priv);
|
1, (uint32_t)priv);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
|
|
|
@ -120,7 +120,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DMA_TIMEOUT_MS (800)
|
#define DMA_TIMEOUT_MS (800)
|
||||||
#define DMA_TIMEOUT_TICKS ((DMA_TIMEOUT_MS + (MSEC_PER_TICK-1)) / MSEC_PER_TICK)
|
#define DMA_TIMEOUT_TICKS MSEC2TICK(DMA_TIMEOUT_MS)
|
||||||
|
|
||||||
/* Debug *******************************************************************/
|
/* Debug *******************************************************************/
|
||||||
/* Check if SPI debut is enabled (non-standard.. no support in
|
/* Check if SPI debut is enabled (non-standard.. no support in
|
||||||
|
|
|
@ -390,7 +390,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DMA_TIMEOUT_MS (800)
|
#define DMA_TIMEOUT_MS (800)
|
||||||
#define DMA_TIMEOUT_TICKS ((DMA_TIMEOUT_MS + (MSEC_PER_TICK-1)) / MSEC_PER_TICK)
|
#define DMA_TIMEOUT_TICKS MSEC2TICK(DMA_TIMEOUT_MS)
|
||||||
|
|
||||||
/* Debug *******************************************************************/
|
/* Debug *******************************************************************/
|
||||||
/* Check if SSC debut is enabled (non-standard.. no support in
|
/* Check if SSC debut is enabled (non-standard.. no support in
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
|
|
||||||
/* Poll the pen position while the pen is down at this rate (50MS): */
|
/* Poll the pen position while the pen is down at this rate (50MS): */
|
||||||
|
|
||||||
#define TSD_WDOG_DELAY ((50 + (MSEC_PER_TICK-1))/ MSEC_PER_TICK)
|
#define TSD_WDOG_DELAY MSEC2TICK(50)
|
||||||
|
|
||||||
/* This is a value for the threshold that guantees a big difference on the
|
/* This is a value for the threshold that guantees a big difference on the
|
||||||
* first pendown (but can't overflow).
|
* first pendown (but can't overflow).
|
||||||
|
|
|
@ -527,7 +527,7 @@ static int twi_wait(struct twi_dev_s *priv, unsigned int size)
|
||||||
* There is no concern about arithmetic overflow for reasonable transfer sizes.
|
* There is no concern about arithmetic overflow for reasonable transfer sizes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
timeout = (TWI_TIMEOUT_MSPB * size) / MSEC_PER_TICK;
|
timeout = MSEC2TICK(TWI_TIMEOUT_MSPB);
|
||||||
if (timeout < 1)
|
if (timeout < 1)
|
||||||
{
|
{
|
||||||
timeout = 1;
|
timeout = 1;
|
||||||
|
|
|
@ -151,8 +151,8 @@
|
||||||
|
|
||||||
#define STM32_READY_DELAY 200000 /* In loop counts */
|
#define STM32_READY_DELAY 200000 /* In loop counts */
|
||||||
#define STM32_FLUSH_DELAY 200000 /* In loop counts */
|
#define STM32_FLUSH_DELAY 200000 /* In loop counts */
|
||||||
#define STM32_SETUP_DELAY (5000 / MSEC_PER_TICK) /* 5 seconds in system ticks */
|
#define STM32_SETUP_DELAY SEC2TICK(5) /* 5 seconds in system ticks */
|
||||||
#define STM32_DATANAK_DELAY (5000 / MSEC_PER_TICK) /* 5 seconds in system ticks */
|
#define STM32_DATANAK_DELAY SEC2TICK(5) /* 5 seconds in system ticks */
|
||||||
|
|
||||||
/* Ever-present MIN/MAX macros */
|
/* Ever-present MIN/MAX macros */
|
||||||
|
|
||||||
|
|
|
@ -2315,7 +2315,7 @@ static sdio_eventset_t stm32_eventwait(FAR struct sdio_dev_s *dev,
|
||||||
|
|
||||||
/* Start the watchdog timer */
|
/* Start the watchdog timer */
|
||||||
|
|
||||||
delay = (timeout + (MSEC_PER_TICK-1)) / MSEC_PER_TICK;
|
delay = MSEC2TICK(timeout);
|
||||||
ret = wd_start(priv->waitwdog, delay, (wdentry_t)stm32_eventtimeout,
|
ret = wd_start(priv->waitwdog, delay, (wdentry_t)stm32_eventtimeout,
|
||||||
1, (uint32_t)priv);
|
1, (uint32_t)priv);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
|
|
|
@ -97,7 +97,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -97,7 +97,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -97,7 +97,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -99,7 +99,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -326,7 +326,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||||
* robin tasks but it doesn't here to do it for everything
|
* robin tasks but it doesn't here to do it for everything
|
||||||
*/
|
*/
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Add the task in the correct location in the prioritized
|
// Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -97,7 +97,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/clock.h>
|
||||||
|
|
||||||
#ifdef CONFIG_SCHED_TICKLESS
|
#ifdef CONFIG_SCHED_TICKLESS
|
||||||
|
|
||||||
|
@ -74,12 +75,12 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_SIM_WALLTIME) || defined(CONFIG_SIM_X11FB)
|
#if defined(CONFIG_SIM_WALLTIME) || defined(CONFIG_SIM_X11FB)
|
||||||
# define TICK_USEC (1000000 / CLK_TCK)
|
# define TICK_USEC (USEC_PER_SEC / CLK_TCK)
|
||||||
# define TICK_SEC (TICK_USEC / 1000000)
|
# define TICK_SEC (TICK_USEC / USEC_PER_SEC)
|
||||||
# define TICK_NSEC ((TICK_USEC % 1000) * 1000)
|
# define TICK_NSEC ((TICK_USEC % NSEC_PER_USEC) * NSEC_PER_USEC)
|
||||||
#else
|
#else
|
||||||
# define TICK_SEC 0
|
# define TICK_SEC 0
|
||||||
# define TICK_NSEC (128 * 1000)
|
# define TICK_NSEC NSEC_PER_TICK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -209,8 +210,8 @@ int up_timer_cancel(FAR struct timespec *ts)
|
||||||
|
|
||||||
if (g_timer_active)
|
if (g_timer_active)
|
||||||
{
|
{
|
||||||
ts->tv_sec = g_interval_delay.tv_nsec;
|
ts->tv_sec = g_interval_delay.tv_sec;
|
||||||
ts->tv_nsec = g_interval_delay.tv_sec;
|
ts->tv_nsec = g_interval_delay.tv_nsec;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -220,8 +221,8 @@ int up_timer_cancel(FAR struct timespec *ts)
|
||||||
|
|
||||||
/* Disable and reset the simulated timer */
|
/* Disable and reset the simulated timer */
|
||||||
|
|
||||||
g_interval_delay.tv_nsec = 0;
|
|
||||||
g_interval_delay.tv_sec = 0;
|
g_interval_delay.tv_sec = 0;
|
||||||
|
g_interval_delay.tv_nsec = 0;
|
||||||
g_timer_active = false;
|
g_timer_active = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -253,8 +254,8 @@ int up_timer_cancel(FAR struct timespec *ts)
|
||||||
#ifdef CONFIG_SCHED_TICKLESS
|
#ifdef CONFIG_SCHED_TICKLESS
|
||||||
int up_timer_start(FAR const struct timespec *ts)
|
int up_timer_start(FAR const struct timespec *ts)
|
||||||
{
|
{
|
||||||
g_interval_delay.tv_nsec = ts->tv_nsec;
|
|
||||||
g_interval_delay.tv_sec = ts->tv_sec;
|
g_interval_delay.tv_sec = ts->tv_sec;
|
||||||
|
g_interval_delay.tv_nsec = ts->tv_nsec;
|
||||||
g_timer_active = true;
|
g_timer_active = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -278,10 +279,10 @@ void up_timer_update(void)
|
||||||
/* Increment the elapsed time */
|
/* Increment the elapsed time */
|
||||||
|
|
||||||
g_elapsed_time.tv_nsec += TICK_NSEC;
|
g_elapsed_time.tv_nsec += TICK_NSEC;
|
||||||
if (g_elapsed_time.tv_nsec >= 1000000000)
|
if (g_elapsed_time.tv_nsec >= NSEC_PER_SEC)
|
||||||
{
|
{
|
||||||
g_elapsed_time.tv_nsec++;
|
g_elapsed_time.tv_sec++;
|
||||||
g_elapsed_time.tv_sec -= 1000000000;
|
g_elapsed_time.tv_nsec -= NSEC_PER_SEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_elapsed_time.tv_sec += TICK_SEC;
|
g_elapsed_time.tv_sec += TICK_SEC;
|
||||||
|
@ -307,7 +308,7 @@ void up_timer_update(void)
|
||||||
|
|
||||||
/* Decrement nanoseconds */
|
/* Decrement nanoseconds */
|
||||||
|
|
||||||
if (g_interval_delay.tv_nsec > TICK_NSEC)
|
if (g_interval_delay.tv_nsec >= TICK_NSEC)
|
||||||
{
|
{
|
||||||
g_interval_delay.tv_nsec -= TICK_NSEC;
|
g_interval_delay.tv_nsec -= TICK_NSEC;
|
||||||
}
|
}
|
||||||
|
@ -316,14 +317,10 @@ void up_timer_update(void)
|
||||||
|
|
||||||
else if (g_interval_delay.tv_sec > 0)
|
else if (g_interval_delay.tv_sec > 0)
|
||||||
{
|
{
|
||||||
if (g_interval_delay.tv_nsec >= TICK_NSEC)
|
g_interval_delay.tv_nsec += NSEC_PER_SEC;
|
||||||
{
|
g_interval_delay.tv_sec--;
|
||||||
g_interval_delay.tv_nsec = 0;
|
|
||||||
}
|
g_interval_delay.tv_nsec -= TICK_NSEC;
|
||||||
else
|
|
||||||
{
|
|
||||||
g_interval_delay.tv_sec--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise the timer has expired */
|
/* Otherwise the timer has expired */
|
||||||
|
|
|
@ -99,7 +99,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -96,7 +96,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -101,7 +101,7 @@ void up_unblock_task(FAR struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -102,7 +102,7 @@ void up_unblock_task(FAR struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
|
|
|
@ -156,11 +156,11 @@
|
||||||
/* Delays ***************************************************************************/
|
/* Delays ***************************************************************************/
|
||||||
/* All values will be increased by one system timer tick (probably 10MS). */
|
/* All values will be increased by one system timer tick (probably 10MS). */
|
||||||
|
|
||||||
#define TC_PENUP_POLL_TICKS (70 / MSEC_PER_TICK) /* IDLE polling rate: 100 MSec */
|
#define TC_PENUP_POLL_TICKS MSEC2TICK(70) /* IDLE polling rate: 70 MSec */
|
||||||
#define TC_PENDOWN_POLL_TICKS (40 / MSEC_PER_TICK) /* Active polling rate: 60 MSec */
|
#define TC_PENDOWN_POLL_TICKS MSEC2TICK(40) /* Active polling rate: 40 MSec */
|
||||||
#define TC_DEBOUNCE_TICKS (16 / MSEC_PER_TICK) /* Delay before re-sampling: 30 MSec */
|
#define TC_DEBOUNCE_TICKS MSEC2TICK(16) /* Delay before re-sampling: 16 MSec */
|
||||||
#define TC_SAMPLE_TICKS (4 / MSEC_PER_TICK) /* Delay for A/D sampling: 4 MSec */
|
#define TC_SAMPLE_TICKS MSEC2TICK(4) /* Delay for A/D sampling: 4 MSec */
|
||||||
#define TC_SETTLE_TICKS (10 / MSEC_PER_TICK) /* Delay for A/D settling: 4 MSec */
|
#define TC_SETTLE_TICKS MSECT2TICK(10) /* Delay for A/D settling: 10 MSec */
|
||||||
#define TC_RESAMPLE_TICKS TC_SAMPLE_TICKS
|
#define TC_RESAMPLE_TICKS TC_SAMPLE_TICKS
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
|
|
|
@ -142,10 +142,10 @@
|
||||||
/* Delays ***************************************************************************/
|
/* Delays ***************************************************************************/
|
||||||
/* All values will be increased by one system timer tick (probably 10MS). */
|
/* All values will be increased by one system timer tick (probably 10MS). */
|
||||||
|
|
||||||
#define TC_PENUP_POLL_TICKS (100 / MSEC_PER_TICK) /* IDLE polling rate: 100 MSec */
|
#define TC_PENUP_POLL_TICKS MSEC2TICK(100) /* IDLE polling rate: 100 MSec */
|
||||||
#define TC_PENDOWN_POLL_TICKS (60 / MSEC_PER_TICK) /* Active polling rate: 60 MSec */
|
#define TC_PENDOWN_POLL_TICKS MSEC2TICK(60) /* Active polling rate: 60 MSec */
|
||||||
#define TC_DEBOUNCE_TICKS (30 / MSEC_PER_TICK) /* Delay before re-sampling: 30 MSec */
|
#define TC_DEBOUNCE_TICKS MSEC2TICK(30) /* Delay before re-sampling: 30 MSec */
|
||||||
#define TC_SAMPLE_TICKS (4 / MSEC_PER_TICK) /* Delay for A/D sampling: 4 MSec */
|
#define TC_SAMPLE_TICKS MSEC2TICK(4) /* Delay for A/D sampling: 4 MSec */
|
||||||
#define TC_RESAMPLE_TICKS TC_SAMPLE_TICKS
|
#define TC_RESAMPLE_TICKS TC_SAMPLE_TICKS
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
|
|
|
@ -218,8 +218,8 @@ int sam_timerinitialize(void)
|
||||||
|
|
||||||
/* Set the timeout */
|
/* Set the timeout */
|
||||||
|
|
||||||
tcvdbg("Interval = %d us.\n", (unsigned long)MSEC_PER_TICK * 1000);
|
tcvdbg("Interval = %d us.\n", (unsigned long)USEC_PER_TICK);
|
||||||
ret = ioctl(fd, TCIOC_SETTIMEOUT, (unsigned long)MSEC_PER_TICK * 1000);
|
ret = ioctl(fd, TCIOC_SETTIMEOUT, (unsigned long)USEC_PER_TICK);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
tcdbg("ioctl(TCIOC_SETTIMEOUT) failed: %d\n", errno);
|
tcdbg("ioctl(TCIOC_SETTIMEOUT) failed: %d\n", errno);
|
||||||
|
|
|
@ -1475,6 +1475,9 @@ static int wm8904_sendbuffer(FAR struct wm8904_dev_s *priv)
|
||||||
* REVISIT: Does this take into account the number channels? Perhaps
|
* REVISIT: Does this take into account the number channels? Perhaps
|
||||||
* saving an reusing the bitrate would give a better and simpler
|
* saving an reusing the bitrate would give a better and simpler
|
||||||
* calculation.
|
* calculation.
|
||||||
|
*
|
||||||
|
* REVISIT: Should not use MSEC_PER_TICK. It can be inaccurate with
|
||||||
|
* microsecond resolution timer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
timeout = (((uint32_t)(apb->nbytes - apb->curbyte) << 14) /
|
timeout = (((uint32_t)(apb->nbytes - apb->curbyte) << 14) /
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
|
|
||||||
/* Poll the pen position while the pen is down at this rate (50MS): */
|
/* Poll the pen position while the pen is down at this rate (50MS): */
|
||||||
|
|
||||||
#define ADS7843E_WDOG_DELAY ((50 + (MSEC_PER_TICK-1))/ MSEC_PER_TICK)
|
#define ADS7843E_WDOG_DELAY MSEC2TICK(50)
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
|
|
||||||
/* Poll the pen position while the pen is down at this rate (50MS): */
|
/* Poll the pen position while the pen is down at this rate (50MS): */
|
||||||
|
|
||||||
#define MAX11802_WDOG_DELAY ((50 + (MSEC_PER_TICK-1))/ MSEC_PER_TICK)
|
#define MAX11802_WDOG_DELAY MSEC2TICK(50)
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
|
|
||||||
/* Timeout to detect missing pen up events */
|
/* Timeout to detect missing pen up events */
|
||||||
|
|
||||||
#define STMPE811_PENUP_TICKS ((100 + (MSEC_PER_TICK-1)) / MSEC_PER_TICK)
|
#define STMPE811_PENUP_TICKS MSEC2TICK(100)
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
|
|
|
@ -435,7 +435,7 @@ static int sst39vf_chiperase(FAR struct sst39vf_dev_s *priv)
|
||||||
wrinfo.data = 0xffff;
|
wrinfo.data = 0xffff;
|
||||||
|
|
||||||
start = clock_systimer();
|
start = clock_systimer();
|
||||||
while (delay < SST39VF_TSCE_MSEC * MSEC_PER_TICK)
|
while (delay < MSEC2TICK(SST39VF_TSCE_MSEC))
|
||||||
{
|
{
|
||||||
/* Check if the erase is complete */
|
/* Check if the erase is complete */
|
||||||
|
|
||||||
|
@ -447,14 +447,14 @@ static int sst39vf_chiperase(FAR struct sst39vf_dev_s *priv)
|
||||||
/* No, check if the timeout has elapsed */
|
/* No, check if the timeout has elapsed */
|
||||||
|
|
||||||
elapsed = clock_systimer() - start;
|
elapsed = clock_systimer() - start;
|
||||||
if (elapsed > SST39VF_TSCE_MSEC * MSEC_PER_TICK)
|
if (elapsed > MSEC2TICK(SST39VF_TSCE_MSEC))
|
||||||
{
|
{
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No, wait one system clock tick */
|
/* No, wait one system clock tick */
|
||||||
|
|
||||||
usleep(MSEC_PER_TICK * USEC_PER_MSEC);
|
usleep(USEC_PER_TICK);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Delay the maximum amount of time for the chip erase to complete. */
|
/* Delay the maximum amount of time for the chip erase to complete. */
|
||||||
|
@ -511,7 +511,7 @@ static int sst39vf_sectorerase(FAR struct sst39vf_dev_s *priv,
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
start = clock_systimer();
|
start = clock_systimer();
|
||||||
while (delay < SST39VF_TSE_MSEC * MSEC_PER_TICK)
|
while (delay < MSEC2TICK(SST39VF_TSE_MSEC))
|
||||||
{
|
{
|
||||||
/* Check if the erase is complete */
|
/* Check if the erase is complete */
|
||||||
|
|
||||||
|
@ -523,14 +523,14 @@ static int sst39vf_sectorerase(FAR struct sst39vf_dev_s *priv,
|
||||||
/* No, check if the timeout has elapsed */
|
/* No, check if the timeout has elapsed */
|
||||||
|
|
||||||
elapsed = clock_systimer() - start;
|
elapsed = clock_systimer() - start;
|
||||||
if (elapsed > SST39VF_TSE_MSEC * MSEC_PER_TICK)
|
if (elapsed > MSEC2TICK(SST39VF_TSE_MSEC))
|
||||||
{
|
{
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No, wait one system clock tick */
|
/* No, wait one system clock tick */
|
||||||
|
|
||||||
usleep(MSEC_PER_TICK * USEC_PER_MSEC);
|
usleep(USEC_PER_TICK);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Delay the maximum amount of time for the sector erase to complete. */
|
/* Delay the maximum amount of time for the sector erase to complete. */
|
||||||
|
|
|
@ -115,13 +115,12 @@
|
||||||
|
|
||||||
#define TICK_PER_DSEC (USEC_PER_DSEC / USEC_PER_TICK) /* Truncates! */
|
#define TICK_PER_DSEC (USEC_PER_DSEC / USEC_PER_TICK) /* Truncates! */
|
||||||
#define TICK_PER_SEC (USEC_PER_SEC / USEC_PER_TICK) /* Truncates! */
|
#define TICK_PER_SEC (USEC_PER_SEC / USEC_PER_TICK) /* Truncates! */
|
||||||
#define MSEC_PER_TICK (USEC_PER_MSEC / USEC_PER_TICK) /* Truncates! */
|
#define TICK_PER_MSEC (USEC_PER_MSEC / USEC_PER_TICK) /* Truncates! */
|
||||||
|
#define MSEC_PER_TICK (USEC_PER_TICK / USEC_PER_MSEC) /* Truncates! */
|
||||||
#define NSEC_PER_TICK (USEC_PER_TICK * NSEC_PER_USEC) /* Exact */
|
#define NSEC_PER_TICK (USEC_PER_TICK * NSEC_PER_USEC) /* Exact */
|
||||||
|
|
||||||
#define NSEC2TICK(nsec) (((nsec)+(NSEC_PER_TICK/2))/NSEC_PER_TICK) /* Rounds */
|
#define NSEC2TICK(nsec) (((nsec)+(NSEC_PER_TICK/2))/NSEC_PER_TICK) /* Rounds */
|
||||||
#define USEC2TICK(usec) (((usec)+(USEC_PER_TICK/2))/USEC_PER_TICK) /* Rounds */
|
#define USEC2TICK(usec) (((usec)+(USEC_PER_TICK/2))/USEC_PER_TICK) /* Rounds */
|
||||||
#define DSEC2TICK(dsec) MSEC2TICK((dsec)*MSEC_PER_DSEC) /* Exact */
|
|
||||||
#define SEC2TICK(sec) MSEC2TICK((sec)*MSEC_PER_SEC) /* Exact */
|
|
||||||
|
|
||||||
#if (MSEC_PER_TICK * USEC_PER_MSEC) == USEC_PER_TICK
|
#if (MSEC_PER_TICK * USEC_PER_MSEC) == USEC_PER_TICK
|
||||||
# define MSEC2TICK(msec) (((msec)+(MSEC_PER_TICK/2))/MSEC_PER_TICK) /* Rounds */
|
# define MSEC2TICK(msec) (((msec)+(MSEC_PER_TICK/2))/MSEC_PER_TICK) /* Rounds */
|
||||||
|
@ -129,10 +128,11 @@
|
||||||
# define MSEC2TICK(msec) USEC2TICK(msec * 1000) /* Rounds */
|
# define MSEC2TICK(msec) USEC2TICK(msec * 1000) /* Rounds */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DSEC2TICK(dsec) MSEC2TICK((dsec)*MSEC_PER_DSEC) /* Exact */
|
||||||
|
#define SEC2TICK(sec) MSEC2TICK((sec)*MSEC_PER_SEC) /* Exact */
|
||||||
|
|
||||||
#define TICK2NSEC(tick) ((tick)*NSEC_PER_TICK) /* Exact */
|
#define TICK2NSEC(tick) ((tick)*NSEC_PER_TICK) /* Exact */
|
||||||
#define TICK2USEC(tick) ((tick)*USEC_PER_TICK) /* Exact */
|
#define TICK2USEC(tick) ((tick)*USEC_PER_TICK) /* Exact */
|
||||||
#define TICK2DSEC(tick) (((tick)+(TICK_PER_DSEC/2))/TICK_PER_DSEC) /* Rounds */
|
|
||||||
#define TICK2SEC(tick) (((tick)+(TICK_PER_SEC/2))/TICK_PER_SEC) /* Rounds */
|
|
||||||
|
|
||||||
#if (MSEC_PER_TICK * USEC_PER_MSEC) == USEC_PER_TICK
|
#if (MSEC_PER_TICK * USEC_PER_MSEC) == USEC_PER_TICK
|
||||||
#define TICK2USEC(tick) ((tick)*MSEC_PER_TICK) /* Exact */
|
#define TICK2USEC(tick) ((tick)*MSEC_PER_TICK) /* Exact */
|
||||||
|
@ -140,6 +140,9 @@
|
||||||
# define TICK2MSEC(tick) (((tick)*USEC_PER_TICK)/USEC_PER_MSEC) /* Rounds */
|
# define TICK2MSEC(tick) (((tick)*USEC_PER_TICK)/USEC_PER_MSEC) /* Rounds */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TICK2DSEC(tick) (((tick)+(TICK_PER_DSEC/2))/TICK_PER_DSEC) /* Rounds */
|
||||||
|
#define TICK2SEC(tick) (((tick)+(TICK_PER_SEC/2))/TICK_PER_SEC) /* Rounds */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
|
@ -93,6 +93,9 @@ config USEC_PER_TICK
|
||||||
The default, 100 microseconds, will provide for a range of delays
|
The default, 100 microseconds, will provide for a range of delays
|
||||||
up to 120 hours.
|
up to 120 hours.
|
||||||
|
|
||||||
|
This value should never be less than the underlying resolution of
|
||||||
|
the timer. Error may ensue.
|
||||||
|
|
||||||
if !SCHED_TICKLESS
|
if !SCHED_TICKLESS
|
||||||
|
|
||||||
config SYSTEMTICK_EXTCLK
|
config SYSTEMTICK_EXTCLK
|
||||||
|
|
|
@ -88,7 +88,6 @@
|
||||||
|
|
||||||
int clock_getres(clockid_t clock_id, struct timespec *res)
|
int clock_getres(clockid_t clock_id, struct timespec *res)
|
||||||
{
|
{
|
||||||
uint32_t time_res;
|
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
sdbg("clock_id=%d\n", clock_id);
|
sdbg("clock_id=%d\n", clock_id);
|
||||||
|
@ -103,18 +102,12 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Get the clock resolution in nanoseconds */
|
/* Form the timspec using clock resolution in nanoseconds */
|
||||||
|
|
||||||
time_res = MSEC_PER_TICK * NSEC_PER_MSEC;
|
|
||||||
|
|
||||||
/* And return this as a timespec. */
|
|
||||||
|
|
||||||
res->tv_sec = 0;
|
res->tv_sec = 0;
|
||||||
res->tv_nsec = time_res;
|
res->tv_nsec = NSEC_PER_TICK;
|
||||||
|
|
||||||
sdbg("Returning res=(%d,%d) time_res=%d\n",
|
sdbg("Returning res=(%d,%d)\n", (int)res->tv_sec, (int)res->tv_nsec);
|
||||||
(int)res->tv_sec, (int)res->tv_nsec,
|
|
||||||
(int)time_res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -124,7 +124,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
|
||||||
{
|
{
|
||||||
/* Get the time since power-on in seconds and milliseconds */
|
/* Get the time since power-on in seconds and milliseconds */
|
||||||
|
|
||||||
msecs = MSEC_PER_TICK * clock_systimer();
|
msecs = TICK2MSEC(clock_systimer());
|
||||||
secs = msecs / MSEC_PER_SEC;
|
secs = msecs / MSEC_PER_SEC;
|
||||||
|
|
||||||
/* Return the elapsed time in seconds and nanoseconds */
|
/* Return the elapsed time in seconds and nanoseconds */
|
||||||
|
@ -174,7 +174,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
|
||||||
* when the time-of-day was last set.
|
* when the time-of-day was last set.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
msecs = MSEC_PER_TICK * (clock_systimer() - g_tickbias);
|
msecs = TICK2MSEC((clock_systimer() - g_tickbias));
|
||||||
|
|
||||||
sdbg("msecs = %d g_tickbias=%d\n",
|
sdbg("msecs = %d g_tickbias=%d\n",
|
||||||
(int)msecs, (int)g_tickbias);
|
(int)msecs, (int)g_tickbias);
|
||||||
|
|
|
@ -266,7 +266,7 @@ void clock_synchronize(void)
|
||||||
* Description:
|
* Description:
|
||||||
* This function must be called once every time the real time clock
|
* This function must be called once every time the real time clock
|
||||||
* interrupt occurs. The interval of this clock interrupt must be
|
* interrupt occurs. The interval of this clock interrupt must be
|
||||||
* MSEC_PER_TICK
|
* USEC_PER_TICK
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -277,4 +277,4 @@ void clock_timer(void)
|
||||||
|
|
||||||
g_system_timer++;
|
g_system_timer++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -87,8 +87,7 @@ uint32_t clock_systimer(void)
|
||||||
|
|
||||||
/* Convert to a 64- then 32-bit value */
|
/* Convert to a 64- then 32-bit value */
|
||||||
|
|
||||||
tmp = (1000 * (uint64_t)ts.tv_sec + (uint64_t)ts.tv_nsec / 1000000) /
|
tmp = MSEC2TICK(1000 * (uint64_t)ts.tv_sec + (uint64_t)ts.tv_nsec / 1000000);
|
||||||
MSEC_PER_TICK;
|
|
||||||
return (uint32_t)(tmp & 0x00000000ffffffff);
|
return (uint32_t)(tmp & 0x00000000ffffffff);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -136,8 +135,7 @@ uint64_t clock_systimer64(void)
|
||||||
|
|
||||||
/* Convert to a 64- then 32-bit value */
|
/* Convert to a 64- then 32-bit value */
|
||||||
|
|
||||||
return (1000 * (uint64_t)ts.tv_sec + (uint64_t)ts.tv_nsec / 1000000) /
|
return MSEC2TICK(1000 * (uint64_t)ts.tv_sec + (uint64_t)ts.tv_nsec / 1000000);
|
||||||
MSEC_PER_TICK;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* Return the current system time */
|
/* Return the current system time */
|
||||||
|
|
|
@ -381,7 +381,7 @@ int pthread_create(FAR pthread_t *thread, FAR pthread_attr_t *attr,
|
||||||
if (policy == SCHED_RR)
|
if (policy == SCHED_RR)
|
||||||
{
|
{
|
||||||
ptcb->cmn.flags |= TCB_FLAG_ROUND_ROBIN;
|
ptcb->cmn.flags |= TCB_FLAG_ROUND_ROBIN;
|
||||||
ptcb->cmn.timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
ptcb->cmn.timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ static inline void sched_process_timeslice(void)
|
||||||
{
|
{
|
||||||
/* Reset the timeslice in any case. */
|
/* Reset the timeslice in any case. */
|
||||||
|
|
||||||
rtcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
rtcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
|
|
||||||
/* We know we are at the head of the ready to run
|
/* We know we are at the head of the ready to run
|
||||||
* prioritized list. We must be the highest priority
|
* prioritized list. We must be the highest priority
|
||||||
|
@ -170,7 +170,7 @@ static inline void sched_process_timeslice(void)
|
||||||
* The timer interrupt logic itself is implemented in the
|
* The timer interrupt logic itself is implemented in the
|
||||||
* architecture specific code, but must call the following OS
|
* architecture specific code, but must call the following OS
|
||||||
* function periodically -- the calling interval must be
|
* function periodically -- the calling interval must be
|
||||||
* MSEC_PER_TICK
|
* USEC_PER_TICK
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* None
|
* None
|
||||||
|
|
|
@ -157,7 +157,7 @@ int sched_setscheduler(pid_t pid, int policy,
|
||||||
/* Set round robin scheduling */
|
/* Set round robin scheduling */
|
||||||
|
|
||||||
tcb->flags |= TCB_FLAG_ROUND_ROBIN;
|
tcb->flags |= TCB_FLAG_ROUND_ROBIN;
|
||||||
tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -171,7 +171,7 @@ sched_process_timeslice(unsigned int ticks, bool noswitches)
|
||||||
{
|
{
|
||||||
/* Reset the timeslice. */
|
/* Reset the timeslice. */
|
||||||
|
|
||||||
rtcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
rtcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
ret = rtcb->timeslice;
|
ret = rtcb->timeslice;
|
||||||
|
|
||||||
/* We know we are at the head of the ready to run
|
/* We know we are at the head of the ready to run
|
||||||
|
@ -287,7 +287,7 @@ static void sched_timer_process(unsigned int ticks, bool noswitches)
|
||||||
* understand.
|
* understand.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
msecs = MSEC_PER_TICK * nextime;
|
msecs = TICK2MSEC(nextime);
|
||||||
secs = msecs / MSEC_PER_SEC;
|
secs = msecs / MSEC_PER_SEC;
|
||||||
nsecs = (msecs - (secs * MSEC_PER_SEC)) * NSEC_PER_MSEC;
|
nsecs = (msecs - (secs * MSEC_PER_SEC)) * NSEC_PER_MSEC;
|
||||||
|
|
||||||
|
@ -327,7 +327,11 @@ static void sched_timer_process(unsigned int ticks, bool noswitches)
|
||||||
|
|
||||||
void sched_timer_expiration(void)
|
void sched_timer_expiration(void)
|
||||||
{
|
{
|
||||||
sched_timer_process(g_timer_interval, false);
|
unsigned int elapsed;
|
||||||
|
|
||||||
|
elapsed = g_timer_interval;
|
||||||
|
g_timer_interval = 0;
|
||||||
|
sched_timer_process(elapsed, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -358,6 +362,7 @@ void sched_timer_reassess(void)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
unsigned int ticks;
|
unsigned int ticks;
|
||||||
|
unsigned int elapsed;
|
||||||
|
|
||||||
/* Get the time remaining on the interval timer and cancel the timer. */
|
/* Get the time remaining on the interval timer and cancel the timer. */
|
||||||
|
|
||||||
|
@ -367,13 +372,16 @@ void sched_timer_reassess(void)
|
||||||
|
|
||||||
ticks = SEC2TICK(ts.tv_sec);
|
ticks = SEC2TICK(ts.tv_sec);
|
||||||
ticks += NSEC2TICK(ts.tv_nsec);
|
ticks += NSEC2TICK(ts.tv_nsec);
|
||||||
|
DEBUGASSERT(ticks <= g_timer_interval);
|
||||||
|
|
||||||
/* Handle the partial timer. This will reassess all timer conditions and
|
/* Handle the partial timer. This will reassess all timer conditions and
|
||||||
* re-start the interval timer with the correct delay. Context switches
|
* re-start the interval timer with the correct delay. Context switches
|
||||||
* are not permitted in this case because we are not certain of the
|
* are not permitted in this case because we are not certain of the
|
||||||
* calling conditions.
|
* calling conditions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sched_timer_process(g_timer_interval - ticks, true);
|
elapsed = g_timer_interval - ticks;
|
||||||
|
g_timer_interval = 0;
|
||||||
|
sched_timer_process(elapsed, true);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SCHED_TICKLESS */
|
#endif /* CONFIG_SCHED_TICKLESS */
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#include "os_internal.h"
|
#include "os_internal.h"
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Definitions
|
* Pre-processor Definitions
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Private Functionss
|
* Private Functions
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
@ -125,11 +125,11 @@ int sched_unlock(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_RR_INTERVAL > 0
|
#if CONFIG_RR_INTERVAL > 0
|
||||||
/* If (1) the task that was running running supported round-robin
|
/* If (1) the task that was running supported round-robin
|
||||||
* scheduling and (2) if its time slice has already expired, but (3)
|
* scheduling and (2) if its time slice has already expired, but
|
||||||
* it could not slice out because pre-emption was disabled, then
|
* (3) it could not slice out because pre-emption was disabled,
|
||||||
* we need to swap the task out now and reassess the interval timer
|
* then we need to swap the task out now and reassess the interval
|
||||||
* for the next time slice.
|
* timer for the next time slice.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((rtcb->flags & TCB_FLAG_ROUND_ROBIN) != 0 &&
|
if ((rtcb->flags & TCB_FLAG_ROUND_ROBIN) != 0 &&
|
||||||
|
@ -144,7 +144,7 @@ int sched_unlock(void)
|
||||||
|
|
||||||
if (rtcb != (FAR struct tcb_s*)g_readytorun.head)
|
if (rtcb != (FAR struct tcb_s*)g_readytorun.head)
|
||||||
{
|
{
|
||||||
rtcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
|
rtcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_SCHED_TICKLESS
|
#ifdef CONFIG_SCHED_TICKLESS
|
||||||
else
|
else
|
||||||
|
|
|
@ -254,7 +254,7 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
||||||
DEBUGASSERT(timeout->tv_sec < UINT32_MAX / MSEC_PER_SEC);
|
DEBUGASSERT(timeout->tv_sec < UINT32_MAX / MSEC_PER_SEC);
|
||||||
waitmsec = timeout->tv_sec * MSEC_PER_SEC +
|
waitmsec = timeout->tv_sec * MSEC_PER_SEC +
|
||||||
(timeout->tv_nsec + NSEC_PER_MSEC - 1) / NSEC_PER_MSEC;
|
(timeout->tv_nsec + NSEC_PER_MSEC - 1) / NSEC_PER_MSEC;
|
||||||
waitticks = (waitmsec + MSEC_PER_TICK - 1) / MSEC_PER_TICK;
|
waitticks = MSEC2TICK(waitmsec);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Create a watchdog */
|
/* Create a watchdog */
|
||||||
|
|
Loading…
Reference in a new issue