mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
Separate CLOCK_TIMEKEEPING and SCHED_TICKLESS.
This commit is contained in:
committed by
Xiang Xiao
parent
fa5daea3d9
commit
9c8c2b0db2
@@ -126,9 +126,8 @@ struct stm32_tickless_s
|
|||||||
uint32_t frequency;
|
uint32_t frequency;
|
||||||
#ifdef CONFIG_CLOCK_TIMEKEEPING
|
#ifdef CONFIG_CLOCK_TIMEKEEPING
|
||||||
uint64_t counter_mask;
|
uint64_t counter_mask;
|
||||||
#else
|
|
||||||
uint32_t overflow; /* Timer counter overflow */
|
|
||||||
#endif
|
#endif
|
||||||
|
uint32_t overflow; /* Timer counter overflow */
|
||||||
volatile bool pending; /* True: pending task */
|
volatile bool pending; /* True: pending task */
|
||||||
uint32_t period; /* Interval period */
|
uint32_t period; /* Interval period */
|
||||||
uint32_t base;
|
uint32_t base;
|
||||||
@@ -339,14 +338,12 @@ static void stm32_interval_handler(void)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
|
||||||
static void stm32_timing_handler(void)
|
static void stm32_timing_handler(void)
|
||||||
{
|
{
|
||||||
g_tickless.overflow++;
|
g_tickless.overflow++;
|
||||||
|
|
||||||
STM32_TIM_ACKINT(g_tickless.tch, GTIM_SR_UIF);
|
STM32_TIM_ACKINT(g_tickless.tch, GTIM_SR_UIF);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_tickless_handler
|
* Name: stm32_tickless_handler
|
||||||
@@ -367,12 +364,10 @@ static int stm32_tickless_handler(int irq, void *context, void *arg)
|
|||||||
{
|
{
|
||||||
int interrupt_flags = stm32_tickless_getint();
|
int interrupt_flags = stm32_tickless_getint();
|
||||||
|
|
||||||
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
|
||||||
if (interrupt_flags & ATIM_SR_UIF)
|
if (interrupt_flags & ATIM_SR_UIF)
|
||||||
{
|
{
|
||||||
stm32_timing_handler();
|
stm32_timing_handler();
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
|
||||||
|
|
||||||
if (interrupt_flags & (1 << g_tickless.channel))
|
if (interrupt_flags & (1 << g_tickless.channel))
|
||||||
{
|
{
|
||||||
@@ -529,6 +524,7 @@ void up_timer_initialize(void)
|
|||||||
g_tickless.channel = CONFIG_STM32_TICKLESS_CHANNEL;
|
g_tickless.channel = CONFIG_STM32_TICKLESS_CHANNEL;
|
||||||
g_tickless.pending = false;
|
g_tickless.pending = false;
|
||||||
g_tickless.period = 0;
|
g_tickless.period = 0;
|
||||||
|
g_tickless.overflow = 0;
|
||||||
|
|
||||||
tmrinfo("timer=%d channel=%d frequency=%lu Hz\n",
|
tmrinfo("timer=%d channel=%d frequency=%lu Hz\n",
|
||||||
g_tickless.timer, g_tickless.channel, g_tickless.frequency);
|
g_tickless.timer, g_tickless.channel, g_tickless.frequency);
|
||||||
@@ -547,13 +543,11 @@ void up_timer_initialize(void)
|
|||||||
/* Should this be changed to 0xffff because we use 16 bit timers? */
|
/* Should this be changed to 0xffff because we use 16 bit timers? */
|
||||||
|
|
||||||
g_tickless.counter_mask = 0xffffffffull;
|
g_tickless.counter_mask = 0xffffffffull;
|
||||||
#else
|
#endif
|
||||||
g_tickless.overflow = 0;
|
|
||||||
|
|
||||||
/* Set up to receive the callback when the counter overflow occurs */
|
/* Set up to receive the callback when the counter overflow occurs */
|
||||||
|
|
||||||
STM32_TIM_SETISR(g_tickless.tch, stm32_tickless_handler, NULL, 0);
|
STM32_TIM_SETISR(g_tickless.tch, stm32_tickless_handler, NULL, 0);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Initialize interval to zero */
|
/* Initialize interval to zero */
|
||||||
|
|
||||||
@@ -620,8 +614,6 @@ void up_timer_initialize(void)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
|
||||||
|
|
||||||
int up_timer_gettime(FAR struct timespec *ts)
|
int up_timer_gettime(FAR struct timespec *ts)
|
||||||
{
|
{
|
||||||
uint64_t usec;
|
uint64_t usec;
|
||||||
@@ -700,7 +692,21 @@ int up_timer_gettime(FAR struct timespec *ts)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#ifdef CONFIG_CLOCK_TIMEKEEPING
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_timer_getcounter
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* To be provided
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* cycles - 64-bit return value
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
int up_timer_getcounter(FAR uint64_t *cycles)
|
int up_timer_getcounter(FAR uint64_t *cycles)
|
||||||
{
|
{
|
||||||
@@ -708,8 +714,6 @@ int up_timer_getcounter(FAR uint64_t *cycles)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_timer_getmask
|
* Name: up_timer_getmask
|
||||||
*
|
*
|
||||||
@@ -724,12 +728,12 @@ int up_timer_getcounter(FAR uint64_t *cycles)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_TIMEKEEPING
|
|
||||||
void up_timer_getmask(FAR uint64_t *mask)
|
void up_timer_getmask(FAR uint64_t *mask)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(mask != NULL);
|
DEBUGASSERT(mask != NULL);
|
||||||
*mask = g_tickless.counter_mask;
|
*mask = g_tickless.counter_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -134,9 +134,8 @@ struct stm32_tickless_s
|
|||||||
uint32_t frequency;
|
uint32_t frequency;
|
||||||
#ifdef CONFIG_CLOCK_TIMEKEEPING
|
#ifdef CONFIG_CLOCK_TIMEKEEPING
|
||||||
uint64_t counter_mask;
|
uint64_t counter_mask;
|
||||||
#else
|
|
||||||
uint32_t overflow; /* Timer counter overflow */
|
|
||||||
#endif
|
#endif
|
||||||
|
uint32_t overflow; /* Timer counter overflow */
|
||||||
volatile bool pending; /* True: pending task */
|
volatile bool pending; /* True: pending task */
|
||||||
uint32_t period; /* Interval period */
|
uint32_t period; /* Interval period */
|
||||||
uint32_t base;
|
uint32_t base;
|
||||||
@@ -351,14 +350,12 @@ static void stm32_interval_handler(void)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
|
||||||
static void stm32_timing_handler(void)
|
static void stm32_timing_handler(void)
|
||||||
{
|
{
|
||||||
g_tickless.overflow++;
|
g_tickless.overflow++;
|
||||||
|
|
||||||
STM32_TIM_ACKINT(g_tickless.tch, ATIM_SR_UIF);
|
STM32_TIM_ACKINT(g_tickless.tch, ATIM_SR_UIF);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_tickless_handler
|
* Name: stm32_tickless_handler
|
||||||
@@ -379,12 +376,10 @@ static int stm32_tickless_handler(int irq, void *context, void *arg)
|
|||||||
{
|
{
|
||||||
int interrupt_flags = stm32_tickless_getint();
|
int interrupt_flags = stm32_tickless_getint();
|
||||||
|
|
||||||
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
|
||||||
if (interrupt_flags & ATIM_SR_UIF)
|
if (interrupt_flags & ATIM_SR_UIF)
|
||||||
{
|
{
|
||||||
stm32_timing_handler();
|
stm32_timing_handler();
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
|
||||||
|
|
||||||
if (interrupt_flags & (1 << g_tickless.channel))
|
if (interrupt_flags & (1 << g_tickless.channel))
|
||||||
{
|
{
|
||||||
@@ -578,6 +573,7 @@ void up_timer_initialize(void)
|
|||||||
g_tickless.channel = CONFIG_STM32F7_TICKLESS_CHANNEL;
|
g_tickless.channel = CONFIG_STM32F7_TICKLESS_CHANNEL;
|
||||||
g_tickless.pending = false;
|
g_tickless.pending = false;
|
||||||
g_tickless.period = 0;
|
g_tickless.period = 0;
|
||||||
|
g_tickless.overflow = 0;
|
||||||
|
|
||||||
tmrinfo("timer=%d channel=%d frequency=%lu Hz\n",
|
tmrinfo("timer=%d channel=%d frequency=%lu Hz\n",
|
||||||
g_tickless.timer, g_tickless.channel, g_tickless.frequency);
|
g_tickless.timer, g_tickless.channel, g_tickless.frequency);
|
||||||
@@ -596,13 +592,11 @@ void up_timer_initialize(void)
|
|||||||
/* Should this be changed to 0xffff because we use 16 bit timers? */
|
/* Should this be changed to 0xffff because we use 16 bit timers? */
|
||||||
|
|
||||||
g_tickless.counter_mask = 0xffffffffull;
|
g_tickless.counter_mask = 0xffffffffull;
|
||||||
#else
|
#endif
|
||||||
g_tickless.overflow = 0;
|
|
||||||
|
|
||||||
/* Set up to receive the callback when the counter overflow occurs */
|
/* Set up to receive the callback when the counter overflow occurs */
|
||||||
|
|
||||||
STM32_TIM_SETISR(g_tickless.tch, stm32_tickless_handler, NULL, 0);
|
STM32_TIM_SETISR(g_tickless.tch, stm32_tickless_handler, NULL, 0);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Initialize interval to zero */
|
/* Initialize interval to zero */
|
||||||
|
|
||||||
@@ -669,7 +663,6 @@ void up_timer_initialize(void)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
|
||||||
int up_timer_gettime(FAR struct timespec *ts)
|
int up_timer_gettime(FAR struct timespec *ts)
|
||||||
{
|
{
|
||||||
uint64_t usec;
|
uint64_t usec;
|
||||||
@@ -757,7 +750,21 @@ int up_timer_gettime(FAR struct timespec *ts)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#ifdef CONFIG_CLOCK_TIMEKEEPING
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_timer_getcounter
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* To be provided
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* cycles - 64-bit return value
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
int up_timer_getcounter(FAR uint64_t *cycles)
|
int up_timer_getcounter(FAR uint64_t *cycles)
|
||||||
{
|
{
|
||||||
@@ -765,8 +772,6 @@ int up_timer_getcounter(FAR uint64_t *cycles)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_timer_getmask
|
* Name: up_timer_getmask
|
||||||
*
|
*
|
||||||
@@ -781,12 +786,12 @@ int up_timer_getcounter(FAR uint64_t *cycles)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_TIMEKEEPING
|
|
||||||
void up_timer_getmask(FAR uint64_t *mask)
|
void up_timer_getmask(FAR uint64_t *mask)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(mask != NULL);
|
DEBUGASSERT(mask != NULL);
|
||||||
*mask = g_tickless.counter_mask;
|
*mask = g_tickless.counter_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -246,7 +246,9 @@ void up_timer_getmask(FAR uint64_t *mask)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(CONFIG_SCHED_TICKLESS)
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SCHED_TICKLESS)
|
||||||
int up_timer_gettime(FAR struct timespec *ts)
|
int up_timer_gettime(FAR struct timespec *ts)
|
||||||
{
|
{
|
||||||
int ret = -EAGAIN;
|
int ret = -EAGAIN;
|
||||||
|
|||||||
@@ -301,8 +301,9 @@ void up_timer_getmask(FAR uint64_t *mask)
|
|||||||
*mask = next;
|
*mask = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#elif defined(CONFIG_SCHED_TICKLESS)
|
#if defined(CONFIG_SCHED_TICKLESS)
|
||||||
int up_timer_gettime(FAR struct timespec *ts)
|
int up_timer_gettime(FAR struct timespec *ts)
|
||||||
{
|
{
|
||||||
int ret = -EAGAIN;
|
int ret = -EAGAIN;
|
||||||
|
|||||||
@@ -1539,7 +1539,7 @@ void up_timer_initialize(void);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_SCHED_TICKLESS) && !defined(CONFIG_CLOCK_TIMEKEEPING)
|
#if defined(CONFIG_SCHED_TICKLESS)
|
||||||
int up_timer_gettime(FAR struct timespec *ts);
|
int up_timer_gettime(FAR struct timespec *ts);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,10 @@
|
|||||||
|
|
||||||
int clock_gettime(clockid_t clock_id, struct timespec *tp)
|
int clock_gettime(clockid_t clock_id, struct timespec *tp)
|
||||||
{
|
{
|
||||||
|
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
uint32_t carry;
|
uint32_t carry;
|
||||||
|
#endif
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
sinfo("clock_id=%d\n", clock_id);
|
sinfo("clock_id=%d\n", clock_id);
|
||||||
|
|||||||
@@ -51,8 +51,10 @@
|
|||||||
|
|
||||||
int clock_settime(clockid_t clock_id, FAR const struct timespec *tp)
|
int clock_settime(clockid_t clock_id, FAR const struct timespec *tp)
|
||||||
{
|
{
|
||||||
|
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
||||||
struct timespec bias;
|
struct timespec bias;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
#endif
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
sinfo("clock_id=%d\n", clock_id);
|
sinfo("clock_id=%d\n", clock_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user