mirror of
https://github.com/apache/nuttx.git
synced 2025-12-10 20:24:51 +08:00
timers/oneshot: Remove all private callback.
This commit removed all private callback and handle it on the upperhalf of oneshot. Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
committed by
Alin Jerpelea
parent
f70ec7384b
commit
5c113f79b7
@@ -63,8 +63,6 @@ struct arm_timer_lowerhalf_s
|
||||
{
|
||||
struct oneshot_lowerhalf_s lh; /* Lower half operations */
|
||||
uint32_t freq; /* Timer working clock frequency(Hz) */
|
||||
oneshot_callback_t callback; /* Current user interrupt callback */
|
||||
void *arg; /* Argument passed to upper half callback */
|
||||
|
||||
/* which cpu timer is running, -1 indicate timer stoppd */
|
||||
|
||||
@@ -180,9 +178,6 @@ static int arm_timer_start(struct oneshot_lowerhalf_s *lower_,
|
||||
|
||||
flags = up_irq_save();
|
||||
|
||||
lower->callback = callback;
|
||||
lower->arg = arg;
|
||||
|
||||
lower->running = this_cpu();
|
||||
|
||||
count = sec_to_count(ts->tv_sec, lower->freq) +
|
||||
@@ -206,8 +201,6 @@ static int arm_timer_cancel(struct oneshot_lowerhalf_s *lower_,
|
||||
|
||||
flags = up_irq_save();
|
||||
|
||||
lower->callback = NULL;
|
||||
lower->arg = NULL;
|
||||
lower->running = -1;
|
||||
|
||||
arm_timer_phy_set_irq_mask(true);
|
||||
@@ -234,23 +227,14 @@ static int arm_timer_current(struct oneshot_lowerhalf_s *lower_,
|
||||
static int arm_timer_interrupt(int irq, void *context, void *arg)
|
||||
{
|
||||
struct arm_timer_lowerhalf_s *lower = arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(lower != NULL);
|
||||
|
||||
arm_timer_phy_set_irq_mask(true);
|
||||
|
||||
if (lower->callback != NULL && lower->running == this_cpu())
|
||||
if (lower->running == this_cpu())
|
||||
{
|
||||
callback = lower->callback;
|
||||
cbarg = lower->arg;
|
||||
lower->callback = NULL;
|
||||
lower->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&lower->lh, cbarg);
|
||||
oneshot_process_callback(&lower->lh);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -62,8 +62,6 @@ struct arm_timer_lowerhalf_s
|
||||
{
|
||||
struct oneshot_lowerhalf_s lh; /* Lower half operations */
|
||||
uint32_t freq; /* Timer working clock frequency(Hz) */
|
||||
oneshot_callback_t callback; /* Current user interrupt callback */
|
||||
void *arg; /* Argument passed to upper half callback */
|
||||
|
||||
/* which cpu timer is running, -1 indicate timer stoppd */
|
||||
|
||||
@@ -173,9 +171,6 @@ static int arm_timer_start(struct oneshot_lowerhalf_s *lower_,
|
||||
|
||||
flags = up_irq_save();
|
||||
|
||||
lower->callback = callback;
|
||||
lower->arg = arg;
|
||||
|
||||
lower->running = this_cpu();
|
||||
|
||||
count = sec_to_count(ts->tv_sec, arm_timer_get_freq()) +
|
||||
@@ -199,8 +194,6 @@ static int arm_timer_cancel(struct oneshot_lowerhalf_s *lower_,
|
||||
|
||||
flags = up_irq_save();
|
||||
|
||||
lower->callback = NULL;
|
||||
lower->arg = NULL;
|
||||
lower->running = -1;
|
||||
|
||||
arm_timer_phy_set_irq_mask(true);
|
||||
@@ -225,23 +218,13 @@ static int arm_timer_current(struct oneshot_lowerhalf_s *lower_,
|
||||
static int arm_timer_interrupt(int irq, void *context, void *arg)
|
||||
{
|
||||
struct arm_timer_lowerhalf_s *lower = arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(lower != NULL);
|
||||
|
||||
arm_timer_phy_set_irq_mask(true);
|
||||
|
||||
if (lower->callback != NULL && lower->running == this_cpu())
|
||||
if (lower->running == this_cpu())
|
||||
{
|
||||
callback = lower->callback;
|
||||
cbarg = lower->arg;
|
||||
lower->callback = NULL;
|
||||
lower->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&lower->lh, cbarg);
|
||||
oneshot_process_callback(&lower->lh);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -80,9 +80,7 @@ struct arm_oneshot_lowerhalf_s
|
||||
|
||||
/* Private lower half data follows */
|
||||
|
||||
void *arg; /* Argument that is passed to the handler */
|
||||
uint32_t frequency; /* Frequency */
|
||||
oneshot_callback_t callback; /* Internal handler that receives callback */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -146,12 +144,9 @@ static int arm_arch_timer_compare_isr(int irq, void *regs, void *arg)
|
||||
|
||||
arm_timer_phy_set_irq_mask(true);
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Then perform the callback */
|
||||
/* Then perform the callback */
|
||||
|
||||
priv->callback(&priv->lh, priv->arg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -258,11 +253,6 @@ static int arm_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
DEBUGASSERT(priv && callback && ts);
|
||||
|
||||
/* Save the new handler and its argument */
|
||||
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
|
||||
/* Set the timeout */
|
||||
|
||||
count = arm_timer_phy_count();
|
||||
|
||||
@@ -58,8 +58,6 @@ struct sam_oneshot_lowerhalf_s
|
||||
/* Private lower half data follows */
|
||||
|
||||
struct sam_oneshot_s oneshot; /* SAM-specific oneshot state */
|
||||
oneshot_callback_t callback; /* internal handler that receives callback */
|
||||
void *arg; /* Argument that is passed to the handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -112,8 +110,6 @@ static void sam_oneshot_handler(void *arg)
|
||||
{
|
||||
struct sam_oneshot_lowerhalf_s *priv =
|
||||
(struct sam_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
@@ -121,21 +117,7 @@ static void sam_oneshot_handler(void *arg)
|
||||
* sam_cancel?
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -211,11 +193,9 @@ static int sam_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = sam_oneshot_start(&priv->oneshot, NULL,
|
||||
sam_oneshot_handler, priv, ts);
|
||||
flags = enter_critical_section();
|
||||
ret = sam_oneshot_start(&priv->oneshot, NULL,
|
||||
sam_oneshot_handler, priv, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -262,10 +242,8 @@ static int sam_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
ret = sam_oneshot_cancel(&priv->oneshot, NULL, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = enter_critical_section();
|
||||
ret = sam_oneshot_cancel(&priv->oneshot, NULL, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
@@ -60,8 +60,6 @@ struct sam_oneshot_lowerhalf_s
|
||||
/* Private lower half data follows */
|
||||
|
||||
struct sam_oneshot_s oneshot; /* SAM-specific oneshot state */
|
||||
oneshot_callback_t callback; /* internal handler that receives callback */
|
||||
void *arg; /* Argument that is passed to the handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -114,8 +112,6 @@ static void sam_oneshot_handler(void *arg)
|
||||
{
|
||||
struct sam_oneshot_lowerhalf_s *priv =
|
||||
(struct sam_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
@@ -123,21 +119,7 @@ static void sam_oneshot_handler(void *arg)
|
||||
* sam_cancel?
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -213,11 +195,9 @@ static int sam_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = sam_oneshot_start(&priv->oneshot, NULL,
|
||||
sam_oneshot_handler, priv, ts);
|
||||
flags = enter_critical_section();
|
||||
ret = sam_oneshot_start(&priv->oneshot, NULL,
|
||||
sam_oneshot_handler, priv, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -264,10 +244,8 @@ static int sam_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
ret = sam_oneshot_cancel(&priv->oneshot, NULL, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = enter_critical_section();
|
||||
ret = sam_oneshot_cancel(&priv->oneshot, NULL, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
@@ -58,8 +58,6 @@ struct sam_oneshot_lowerhalf_s
|
||||
/* Private lower half data follows */
|
||||
|
||||
struct sam_oneshot_s oneshot; /* SAM-specific oneshot state */
|
||||
oneshot_callback_t callback; /* internal handler that receives callback */
|
||||
void *arg; /* Argument that is passed to the handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -112,8 +110,6 @@ static void sam_oneshot_handler(void *arg)
|
||||
{
|
||||
struct sam_oneshot_lowerhalf_s *priv =
|
||||
(struct sam_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
@@ -121,21 +117,7 @@ static void sam_oneshot_handler(void *arg)
|
||||
* sam_cancel?
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -211,11 +193,9 @@ static int sam_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = sam_oneshot_start(&priv->oneshot, NULL,
|
||||
sam_oneshot_handler, priv, ts);
|
||||
flags = enter_critical_section();
|
||||
ret = sam_oneshot_start(&priv->oneshot, NULL,
|
||||
sam_oneshot_handler, priv, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -262,10 +242,8 @@ static int sam_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
ret = sam_oneshot_cancel(&priv->oneshot, NULL, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = enter_critical_section();
|
||||
ret = sam_oneshot_cancel(&priv->oneshot, NULL, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
@@ -58,8 +58,6 @@ struct sam_oneshot_lowerhalf_s
|
||||
/* Private lower half data follows */
|
||||
|
||||
struct sam_oneshot_s oneshot; /* SAMV7-specific oneshot state */
|
||||
oneshot_callback_t callback; /* internal handler that receives callback */
|
||||
void *arg; /* Argument that is passed to the handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -112,8 +110,6 @@ static void sam_oneshot_handler(void *arg)
|
||||
{
|
||||
struct sam_oneshot_lowerhalf_s *priv =
|
||||
(struct sam_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
@@ -121,21 +117,7 @@ static void sam_oneshot_handler(void *arg)
|
||||
* sam_cancel?
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -211,11 +193,9 @@ static int sam_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = sam_oneshot_start(&priv->oneshot, NULL,
|
||||
sam_oneshot_handler, priv, ts);
|
||||
flags = enter_critical_section();
|
||||
ret = sam_oneshot_start(&priv->oneshot, NULL,
|
||||
sam_oneshot_handler, priv, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -262,10 +242,8 @@ static int sam_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
ret = sam_oneshot_cancel(&priv->oneshot, NULL, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = enter_critical_section();
|
||||
ret = sam_oneshot_cancel(&priv->oneshot, NULL, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
@@ -57,8 +57,6 @@ struct stm32_oneshot_lowerhalf_s
|
||||
/* Private lower half data follows */
|
||||
|
||||
struct stm32_oneshot_s oneshot; /* STM32-specific oneshot state */
|
||||
oneshot_callback_t callback; /* Internal handler that receives callback */
|
||||
void *arg; /* Argument that is passed to the handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -111,8 +109,6 @@ static void stm32_oneshot_handler(void *arg)
|
||||
{
|
||||
struct stm32_oneshot_lowerhalf_s *priv =
|
||||
(struct stm32_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
@@ -120,21 +116,7 @@ static void stm32_oneshot_handler(void *arg)
|
||||
* stm32_cancel?
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -210,11 +192,9 @@ static int stm32_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = stm32_oneshot_start(&priv->oneshot,
|
||||
stm32_oneshot_handler, priv, ts);
|
||||
flags = enter_critical_section();
|
||||
ret = stm32_oneshot_start(&priv->oneshot,
|
||||
stm32_oneshot_handler, priv, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -261,10 +241,8 @@ static int stm32_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
ret = stm32_oneshot_cancel(&priv->oneshot, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = enter_critical_section();
|
||||
ret = stm32_oneshot_cancel(&priv->oneshot, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
@@ -57,8 +57,6 @@ struct stm32_oneshot_lowerhalf_s
|
||||
/* Private lower half data follows */
|
||||
|
||||
struct stm32_oneshot_s oneshot; /* STM32-specific oneshot state */
|
||||
oneshot_callback_t callback; /* Internal handler that receives callback */
|
||||
void *arg; /* Argument that is passed to the handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -111,8 +109,6 @@ static void stm32_oneshot_handler(void *arg)
|
||||
{
|
||||
struct stm32_oneshot_lowerhalf_s *priv =
|
||||
(struct stm32_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
@@ -120,21 +116,7 @@ static void stm32_oneshot_handler(void *arg)
|
||||
* stm32_cancel?
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -210,11 +192,9 @@ static int stm32_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = stm32_oneshot_start(&priv->oneshot,
|
||||
stm32_oneshot_handler, priv, ts);
|
||||
flags = enter_critical_section();
|
||||
ret = stm32_oneshot_start(&priv->oneshot,
|
||||
stm32_oneshot_handler, priv, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -261,10 +241,8 @@ static int stm32_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
ret = stm32_oneshot_cancel(&priv->oneshot, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = enter_critical_section();
|
||||
ret = stm32_oneshot_cancel(&priv->oneshot, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
@@ -58,8 +58,6 @@ struct stm32l4_oneshot_lowerhalf_s
|
||||
/* Private lower half data follows */
|
||||
|
||||
struct stm32l4_oneshot_s oneshot; /* STM32-specific oneshot state */
|
||||
oneshot_callback_t callback; /* internal handler that receives callback */
|
||||
void *arg; /* Argument that is passed to the handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -112,8 +110,6 @@ static void stm32l4_oneshot_handler(void *arg)
|
||||
{
|
||||
struct stm32l4_oneshot_lowerhalf_s *priv =
|
||||
(struct stm32l4_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
@@ -121,21 +117,7 @@ static void stm32l4_oneshot_handler(void *arg)
|
||||
* stm32l4_cancel?
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -211,11 +193,9 @@ static int stm32l4_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = stm32l4_oneshot_start(&priv->oneshot,
|
||||
stm32l4_oneshot_handler, priv, ts);
|
||||
flags = enter_critical_section();
|
||||
ret = stm32l4_oneshot_start(&priv->oneshot,
|
||||
stm32l4_oneshot_handler, priv, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -262,10 +242,8 @@ static int stm32l4_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
ret = stm32l4_oneshot_cancel(&priv->oneshot, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = enter_critical_section();
|
||||
ret = stm32l4_oneshot_cancel(&priv->oneshot, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
@@ -58,8 +58,6 @@ struct stm32wb_oneshot_lowerhalf_s
|
||||
/* Private lower half data follows */
|
||||
|
||||
struct stm32wb_oneshot_s oneshot; /* STM32-specific oneshot state */
|
||||
oneshot_callback_t callback; /* internal handler that receives callback */
|
||||
void *arg; /* Argument that is passed to the handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -112,8 +110,6 @@ static void stm32wb_oneshot_handler(void *arg)
|
||||
{
|
||||
struct stm32wb_oneshot_lowerhalf_s *priv =
|
||||
(struct stm32wb_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
@@ -121,21 +117,7 @@ static void stm32wb_oneshot_handler(void *arg)
|
||||
* stm32wb_cancel?
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -211,11 +193,9 @@ static int stm32wb_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = stm32wb_oneshot_start(&priv->oneshot,
|
||||
stm32wb_oneshot_handler, priv, ts);
|
||||
flags = enter_critical_section();
|
||||
ret = stm32wb_oneshot_start(&priv->oneshot,
|
||||
stm32wb_oneshot_handler, priv, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -262,10 +242,8 @@ static int stm32wb_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
ret = stm32wb_oneshot_cancel(&priv->oneshot, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = enter_critical_section();
|
||||
ret = stm32wb_oneshot_cancel(&priv->oneshot, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
@@ -69,9 +69,7 @@ struct arm64_oneshot_lowerhalf_s
|
||||
|
||||
/* Private lower half data follows */
|
||||
|
||||
void *arg; /* Argument that is passed to the handler */
|
||||
uint64_t frequency; /* Frequency in cycle per second */
|
||||
oneshot_callback_t callback; /* Internal handler that receives callback */
|
||||
|
||||
/* which cpu timer is running, -1 indicate timer stoppd */
|
||||
|
||||
@@ -136,11 +134,11 @@ static int arm64_arch_timer_compare_isr(int irq, void *regs, void *arg)
|
||||
|
||||
arm64_arch_timer_set_irq_mask(true);
|
||||
|
||||
if (priv->callback && priv->running == this_cpu())
|
||||
if (priv->running == this_cpu())
|
||||
{
|
||||
/* Then perform the callback */
|
||||
|
||||
priv->callback(&priv->lh, priv->arg);
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
return OK;
|
||||
@@ -247,11 +245,6 @@ static int arm64_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
DEBUGASSERT(priv && callback && ts);
|
||||
|
||||
/* Save the new handler and its argument */
|
||||
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
|
||||
priv->running = this_cpu();
|
||||
|
||||
count = arm64_arch_timer_count();
|
||||
|
||||
@@ -56,8 +56,6 @@ struct pic32mz_oneshot_lowerhalf_s
|
||||
/* Private lower half data follows */
|
||||
|
||||
struct pic32mz_oneshot_s oneshot; /* PIC32MZ-specific oneshot state */
|
||||
oneshot_callback_t callback; /* Handler that receives callback */
|
||||
void *arg; /* Argument passed to the handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -110,8 +108,6 @@ static void pic32mz_oneshot_handler(void *arg)
|
||||
{
|
||||
struct pic32mz_oneshot_lowerhalf_s *priv =
|
||||
(struct pic32mz_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
@@ -119,21 +115,7 @@ static void pic32mz_oneshot_handler(void *arg)
|
||||
* pic32mz_cancel?
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -212,12 +194,9 @@ static int pic32mz_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = pic32mz_oneshot_start(&priv->oneshot,
|
||||
pic32mz_oneshot_handler,
|
||||
priv, ts);
|
||||
flags = enter_critical_section();
|
||||
ret = pic32mz_oneshot_start(&priv->oneshot,
|
||||
pic32mz_oneshot_handler, priv, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -264,10 +243,8 @@ static int pic32mz_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
ret = pic32mz_oneshot_cancel(&priv->oneshot, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = enter_critical_section();
|
||||
ret = pic32mz_oneshot_cancel(&priv->oneshot, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
@@ -72,8 +72,6 @@ struct bl602_oneshot_lowerhalf_s
|
||||
|
||||
/* Private lower half data follows */
|
||||
|
||||
oneshot_callback_t callback; /* Internal handler that receives callback */
|
||||
void * arg; /* Argument that is passed to the handler */
|
||||
uint8_t tim; /* timer tim 0,1 */
|
||||
uint8_t irq; /* IRQ associated with this timer */
|
||||
bool started; /* True: Timer has been started */
|
||||
@@ -129,9 +127,6 @@ static int bl602_oneshot_handler(int irq, void *context, void *arg)
|
||||
struct bl602_oneshot_lowerhalf_s *priv =
|
||||
(struct bl602_oneshot_lowerhalf_s *)arg;
|
||||
|
||||
oneshot_callback_t callback;
|
||||
void * cbarg;
|
||||
|
||||
/* Clear Interrupt Bits */
|
||||
|
||||
uint32_t int_id;
|
||||
@@ -156,13 +151,7 @@ static int bl602_oneshot_handler(int irq, void *context, void *arg)
|
||||
if ((int_id & TIMER_TMSR2_TMSR_0) != 0)
|
||||
{
|
||||
putreg32(ticr_val | TIMER_TICR2_TCLR_0, ticr_addr);
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
|
||||
if (callback)
|
||||
{
|
||||
callback(&priv->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/* Comparator 1 match interrupt */
|
||||
@@ -261,9 +250,7 @@ static int bl602_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Express the delay in microseconds */
|
||||
|
||||
@@ -328,8 +315,6 @@ static int bl602_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
priv->started = false;
|
||||
up_disable_irq(priv->irq);
|
||||
bl602_timer_intmask(priv->tim, TIMER_INT_COMP_0, 1);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
leave_critical_section(flags);
|
||||
return OK;
|
||||
|
||||
@@ -80,8 +80,6 @@ struct esp_oneshot_lowerhalf_s
|
||||
{
|
||||
struct oneshot_lowerhalf_s lh; /* Lower half instance */
|
||||
timer_hal_context_t hal; /* HAL context */
|
||||
oneshot_callback_t callback; /* Current user interrupt callback */
|
||||
void *arg; /* Argument passed to upper half callback */
|
||||
uint16_t resolution; /* Timer resolution in microseconds */
|
||||
bool running; /* True: the timer is running */
|
||||
};
|
||||
@@ -129,8 +127,6 @@ static struct esp_oneshot_lowerhalf_s g_oneshot_lowerhalf =
|
||||
{
|
||||
.ops = &g_oneshot_ops,
|
||||
},
|
||||
.callback = NULL,
|
||||
.arg = NULL
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -223,11 +219,6 @@ static int esp_oneshot_start(struct oneshot_lowerhalf_s *lower,
|
||||
esp_oneshot_cancel(lower, NULL);
|
||||
}
|
||||
|
||||
/* Save the new callback and its argument */
|
||||
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
|
||||
/* Retrieve the duration from timespec in microsecond */
|
||||
|
||||
timeout_us = (uint64_t)ts->tv_sec * USEC_PER_SEC +
|
||||
@@ -368,9 +359,7 @@ static int esp_oneshot_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
ts->tv_nsec = remaining_us * NSEC_PER_USEC;
|
||||
}
|
||||
|
||||
priv->running = false;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
priv->running = false;
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -441,8 +430,6 @@ IRAM_ATTR static int esp_oneshot_isr(int irq, void *context, void *arg)
|
||||
{
|
||||
struct esp_oneshot_lowerhalf_s *priv =
|
||||
(struct esp_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *callback_arg;
|
||||
|
||||
timer_hal_context_t *hal = &(priv->hal);
|
||||
uint32_t intr_status = timer_ll_get_intr_status(hal->dev);
|
||||
@@ -460,16 +447,9 @@ IRAM_ATTR static int esp_oneshot_isr(int irq, void *context, void *arg)
|
||||
|
||||
priv->running = false;
|
||||
|
||||
/* Forward the event, clearing out any vestiges */
|
||||
|
||||
callback = priv->callback;
|
||||
callback_arg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Call the callback */
|
||||
|
||||
callback(&priv->lh, callback_arg);
|
||||
oneshot_process_callback(&priv->lh);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -510,8 +490,6 @@ struct oneshot_lowerhalf_s *oneshot_initialize(int chan, uint16_t resolution)
|
||||
|
||||
/* Initialize the elements of lower half state structure */
|
||||
|
||||
lower->callback = NULL;
|
||||
lower->arg = NULL;
|
||||
lower->resolution = resolution;
|
||||
lower->running = false;
|
||||
|
||||
|
||||
@@ -46,8 +46,6 @@ struct riscv_mtimer_lowerhalf_s
|
||||
uintreg_t mtimecmp;
|
||||
uint64_t freq;
|
||||
uint64_t alarm;
|
||||
oneshot_callback_t callback;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -154,9 +152,7 @@ static int riscv_mtimer_start(struct oneshot_lowerhalf_s *lower,
|
||||
alarm = mtime + ts->tv_sec * priv->freq +
|
||||
ts->tv_nsec * priv->freq / NSEC_PER_SEC;
|
||||
|
||||
priv->alarm = alarm;
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
priv->alarm = alarm;
|
||||
|
||||
riscv_mtimer_set_mtimecmp(priv, priv->alarm);
|
||||
|
||||
@@ -210,9 +206,7 @@ static int riscv_mtimer_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
ts->tv_sec = nsec / NSEC_PER_SEC;
|
||||
ts->tv_nsec = nsec % NSEC_PER_SEC;
|
||||
|
||||
priv->alarm = 0;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
priv->alarm = 0;
|
||||
|
||||
up_irq_restore(flags);
|
||||
|
||||
@@ -257,10 +251,7 @@ static int riscv_mtimer_interrupt(int irq, void *context, void *arg)
|
||||
{
|
||||
struct riscv_mtimer_lowerhalf_s *priv = arg;
|
||||
|
||||
if (priv->callback != NULL)
|
||||
{
|
||||
priv->callback(&priv->lower, priv->arg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lower);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,6 @@ struct esp32c3_oneshot_lowerhalf_s
|
||||
|
||||
struct oneshot_lowerhalf_s lh; /* Lower half instance */
|
||||
struct esp32c3_oneshot_s oneshot; /* ESP32-C3-specific oneshot state */
|
||||
oneshot_callback_t callback; /* Upper half Interrupt callback */
|
||||
void *arg; /* Argument passed to handler */
|
||||
uint16_t resolution;
|
||||
};
|
||||
|
||||
@@ -116,11 +114,8 @@ static void esp32c3_oneshot_lh_handler(void *arg)
|
||||
{
|
||||
struct esp32c3_oneshot_lowerhalf_s *priv =
|
||||
(struct esp32c3_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cb_arg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
DEBUGASSERT(priv->callback != NULL);
|
||||
|
||||
tmrinfo("Oneshot LH handler triggered\n");
|
||||
|
||||
@@ -128,14 +123,7 @@ static void esp32c3_oneshot_lh_handler(void *arg)
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cb_arg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cb_arg);
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -215,13 +203,9 @@ static int oneshot_lh_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = esp32c3_oneshot_start(&priv->oneshot,
|
||||
esp32c3_oneshot_lh_handler,
|
||||
priv,
|
||||
ts);
|
||||
flags = enter_critical_section();
|
||||
ret = esp32c3_oneshot_start(&priv->oneshot, esp32c3_oneshot_lh_handler,
|
||||
priv, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -268,10 +252,8 @@ static int oneshot_lh_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
ret = esp32c3_oneshot_cancel(&priv->oneshot, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = enter_critical_section();
|
||||
ret = esp32c3_oneshot_cancel(&priv->oneshot, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -358,8 +340,6 @@ struct oneshot_lowerhalf_s *oneshot_initialize(int chan,
|
||||
}
|
||||
|
||||
priv->lh.ops = &g_esp32c3_timer_ops; /* Pointer to the LH operations */
|
||||
priv->callback = NULL; /* No callback yet */
|
||||
priv->arg = NULL; /* No arg yet */
|
||||
priv->resolution = resolution; /* Configured resolution */
|
||||
|
||||
/* Initialize esp32c3_oneshot_s structure */
|
||||
|
||||
@@ -62,9 +62,7 @@ struct sim_oneshot_lowerhalf_s
|
||||
|
||||
sq_entry_t link;
|
||||
struct timespec alarm;
|
||||
|
||||
oneshot_callback_t callback; /* internal handler that receives callback */
|
||||
void *arg; /* Argument that is passed to the handler */
|
||||
int running;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -223,8 +221,6 @@ static void sim_process_tick(sq_entry_t *entry)
|
||||
{
|
||||
struct sim_oneshot_lowerhalf_s *priv =
|
||||
container_of(entry, struct sim_oneshot_lowerhalf_s, link);
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
@@ -238,20 +234,10 @@ static void sim_process_tick(sq_entry_t *entry)
|
||||
|
||||
sim_reset_alarm(&priv->alarm);
|
||||
|
||||
if (priv->callback)
|
||||
if (priv->running == 1)
|
||||
{
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cbarg);
|
||||
priv->running = 0;
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,12 +301,10 @@ static int sim_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
clock_ticks2time(&priv->alarm,
|
||||
host_gettime(false) / NSEC_PER_TICK +
|
||||
clock_time2ticks(ts));
|
||||
priv->running = 1;
|
||||
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
sim_timer_current(¤t);
|
||||
clock_timespec_add(¤t, ts, &priv->alarm);
|
||||
|
||||
sim_update_hosttimer();
|
||||
|
||||
@@ -374,9 +358,6 @@ static int sim_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
sim_reset_alarm(&priv->alarm);
|
||||
sim_update_hosttimer();
|
||||
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
return OK;
|
||||
@@ -474,6 +455,8 @@ struct oneshot_lowerhalf_s *oneshot_initialize(int chan,
|
||||
|
||||
/* Initialize the lower-half driver structure */
|
||||
|
||||
priv->running = 0;
|
||||
|
||||
sq_addlast(&priv->link, &g_oneshot_list);
|
||||
priv->lh.ops = &g_oneshot_ops;
|
||||
|
||||
|
||||
@@ -60,8 +60,6 @@ struct bm3803_oneshot_lowerhalf_s
|
||||
/* STM32-specific oneshot state */
|
||||
|
||||
struct bm3803_oneshot_s oneshot;
|
||||
oneshot_callback_t callback; /* internal handler that receives callback */
|
||||
void *arg; /* Argument that is passed to the handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -114,8 +112,6 @@ static void bm3803_oneshot_handler(void *arg)
|
||||
{
|
||||
struct bm3803_oneshot_lowerhalf_s *priv =
|
||||
(struct bm3803_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
@@ -123,21 +119,7 @@ static void bm3803_oneshot_handler(void *arg)
|
||||
* bm3803_cancel?
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -213,11 +195,9 @@ static int bm3803_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = bm3803_oneshot_start(&priv->oneshot,
|
||||
bm3803_oneshot_handler, priv, ts);
|
||||
flags = enter_critical_section();
|
||||
ret = bm3803_oneshot_start(&priv->oneshot,
|
||||
bm3803_oneshot_handler, priv, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -264,10 +244,8 @@ static int bm3803_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
ret = bm3803_oneshot_cancel(&priv->oneshot, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = enter_critical_section();
|
||||
ret = bm3803_oneshot_cancel(&priv->oneshot, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
@@ -49,8 +49,6 @@ struct tricore_systimer_lowerhalf_s
|
||||
volatile void *tbase;
|
||||
uint64_t freq;
|
||||
uint64_t alarm;
|
||||
oneshot_callback_t callback;
|
||||
void *arg;
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
@@ -184,9 +182,6 @@ static int tricore_systimer_start(struct oneshot_lowerhalf_s *lower,
|
||||
priv->alarm = UINT64_MAX;
|
||||
}
|
||||
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
|
||||
tricore_systimer_set_timecmp(priv, priv->alarm);
|
||||
return 0;
|
||||
}
|
||||
@@ -239,9 +234,7 @@ static int tricore_systimer_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
ts->tv_nsec = 0;
|
||||
}
|
||||
|
||||
priv->alarm = 0;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
priv->alarm = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -335,10 +328,7 @@ static int tricore_systimer_interrupt(int irq, void *context, void *arg)
|
||||
struct tricore_systimer_lowerhalf_s *priv = arg;
|
||||
|
||||
tricore_systimer_set_timecmp(priv, UINT64_MAX);
|
||||
if (priv->callback != NULL)
|
||||
{
|
||||
priv->callback(&priv->lower, priv->arg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lower);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,6 @@ struct intel64_oneshot_lowerhalf_s
|
||||
{
|
||||
struct oneshot_lowerhalf_s lh;
|
||||
struct intel64_oneshot_s oneshot;
|
||||
oneshot_callback_t callback;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -120,8 +118,6 @@ static spinlock_t g_oneshotlow_spin;
|
||||
static void intel64_oneshot_handler(void *arg)
|
||||
{
|
||||
struct intel64_oneshot_lowerhalf_s *priv = arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
@@ -129,21 +125,7 @@ static void intel64_oneshot_handler(void *arg)
|
||||
* intel64_cancel?
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cbarg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -220,12 +202,9 @@ static int intel64_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = spin_lock_irqsave(&g_oneshotlow_spin);
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = intel64_oneshot_start(&priv->oneshot,
|
||||
intel64_oneshot_handler,
|
||||
priv, ts);
|
||||
flags = spin_lock_irqsave(&g_oneshotlow_spin);
|
||||
ret = intel64_oneshot_start(&priv->oneshot, intel64_oneshot_handler,
|
||||
priv, ts);
|
||||
spin_unlock_irqrestore(&g_oneshotlow_spin, flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -272,10 +251,8 @@ static int intel64_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = spin_lock_irqsave(&g_oneshotlow_spin);
|
||||
ret = intel64_oneshot_cancel(&priv->oneshot, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = spin_lock_irqsave(&g_oneshotlow_spin);
|
||||
ret = intel64_oneshot_cancel(&priv->oneshot, ts);
|
||||
spin_unlock_irqrestore(&g_oneshotlow_spin, flags);
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
@@ -47,8 +47,6 @@ struct xoneshot_lowerhalf_s
|
||||
{
|
||||
struct oneshot_lowerhalf_s lh; /* Lower half operations */
|
||||
uint32_t freq; /* Timer working clock frequency(Hz) */
|
||||
oneshot_callback_t callback; /* Current user interrupt callback */
|
||||
void *arg; /* Argument passed to upper half callback */
|
||||
uint32_t irq;
|
||||
};
|
||||
|
||||
@@ -105,9 +103,6 @@ static int xtensa_oneshot_start(struct oneshot_lowerhalf_s *lower_,
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
lower->callback = callback;
|
||||
lower->arg = arg;
|
||||
|
||||
count = sec_to_count((uint64_t)ts->tv_sec, lower->freq) +
|
||||
nsec_to_count((uint64_t)ts->tv_nsec, lower->freq);
|
||||
|
||||
@@ -130,9 +125,6 @@ static int xtensa_oneshot_cancel(struct oneshot_lowerhalf_s *lower_,
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
lower->callback = NULL;
|
||||
lower->arg = NULL;
|
||||
|
||||
up_disable_irq(lower->irq);
|
||||
|
||||
leave_critical_section(flags);
|
||||
@@ -157,22 +149,10 @@ static int xtensa_oneshot_maxdelay(struct oneshot_lowerhalf_s *lower_,
|
||||
static int xtensa_oneshot_interrupt(int irq, void *context, void *arg)
|
||||
{
|
||||
struct xoneshot_lowerhalf_s *lower = arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(lower != NULL);
|
||||
|
||||
if (lower->callback != NULL)
|
||||
{
|
||||
callback = lower->callback;
|
||||
cbarg = lower->arg;
|
||||
lower->callback = NULL;
|
||||
lower->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&lower->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&lower->lh);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,6 @@ struct esp32_oneshot_lowerhalf_s
|
||||
|
||||
struct oneshot_lowerhalf_s lh; /* Lower half instance */
|
||||
struct esp32_oneshot_s oneshot; /* ESP32-specific oneshot state */
|
||||
oneshot_callback_t callback; /* Upper half Interrupt callback */
|
||||
void *arg; /* Argument passed to handler */
|
||||
uint16_t resolution; /* Timer's resulation in uS */
|
||||
spinlock_t lock; /* Device specific lock */
|
||||
};
|
||||
@@ -117,26 +115,12 @@ static void esp32_oneshot_lh_handler(void *arg)
|
||||
{
|
||||
struct esp32_oneshot_lowerhalf_s *priv =
|
||||
(struct esp32_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cb_arg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
DEBUGASSERT(priv->callback != NULL);
|
||||
|
||||
tmrinfo("Oneshot LH handler triggered\n");
|
||||
|
||||
/* Sample and nullify BEFORE executing callback (in case the callback
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cb_arg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cb_arg);
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -215,11 +199,9 @@ static int esp32_lh_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = esp32_oneshot_start(&priv->oneshot,
|
||||
esp32_oneshot_lh_handler, priv, ts);
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
ret = esp32_oneshot_start(&priv->oneshot,
|
||||
esp32_oneshot_lh_handler, priv, ts);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -266,10 +248,8 @@ static int esp32_lh_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
ret = esp32_oneshot_cancel(&priv->oneshot, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
ret = esp32_oneshot_cancel(&priv->oneshot, ts);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -356,8 +336,6 @@ struct oneshot_lowerhalf_s *oneshot_initialize(int chan,
|
||||
}
|
||||
|
||||
priv->lh.ops = &g_esp32_timer_ops; /* Pointer to the LH operations */
|
||||
priv->callback = NULL; /* No callback yet */
|
||||
priv->arg = NULL; /* No arg yet */
|
||||
priv->resolution = resolution; /* Configured resolution */
|
||||
|
||||
/* Initialize esp32_oneshot_s structure */
|
||||
|
||||
@@ -56,8 +56,6 @@ struct esp32s2_oneshot_lowerhalf_s
|
||||
|
||||
struct oneshot_lowerhalf_s lh; /* Lower half instance */
|
||||
struct esp32s2_oneshot_s oneshot; /* ESP32-S2-specific oneshot state */
|
||||
oneshot_callback_t callback; /* Upper half Interrupt callback */
|
||||
void *arg; /* Argument passed to handler */
|
||||
uint16_t resolution;
|
||||
};
|
||||
|
||||
@@ -114,11 +112,8 @@ static void esp32s2_oneshot_lh_handler(void *arg)
|
||||
{
|
||||
struct esp32s2_oneshot_lowerhalf_s *priv =
|
||||
(struct esp32s2_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cb_arg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
DEBUGASSERT(priv->callback != NULL);
|
||||
|
||||
tmrinfo("Oneshot LH handler triggered\n");
|
||||
|
||||
@@ -126,14 +121,7 @@ static void esp32s2_oneshot_lh_handler(void *arg)
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cb_arg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cb_arg);
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -213,13 +201,9 @@ static int oneshot_lh_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = esp32s2_oneshot_start(&priv->oneshot,
|
||||
esp32s2_oneshot_lh_handler,
|
||||
priv,
|
||||
ts);
|
||||
flags = enter_critical_section();
|
||||
ret = esp32s2_oneshot_start(&priv->oneshot, esp32s2_oneshot_lh_handler,
|
||||
priv, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -266,10 +250,8 @@ static int oneshot_lh_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
ret = esp32s2_oneshot_cancel(&priv->oneshot, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = enter_critical_section();
|
||||
ret = esp32s2_oneshot_cancel(&priv->oneshot, ts);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -356,8 +338,6 @@ struct oneshot_lowerhalf_s *oneshot_initialize(int chan,
|
||||
}
|
||||
|
||||
priv->lh.ops = &g_esp32s2_timer_ops; /* Pointer to the LH operations */
|
||||
priv->callback = NULL; /* No callback yet */
|
||||
priv->arg = NULL; /* No arg yet */
|
||||
priv->resolution = resolution; /* Configured resolution */
|
||||
|
||||
/* Initialize esp32s2_oneshot_s structure */
|
||||
|
||||
@@ -57,8 +57,6 @@ struct esp32s3_oneshot_lowerhalf_s
|
||||
|
||||
struct oneshot_lowerhalf_s lh; /* Lower-half instance */
|
||||
struct esp32s3_oneshot_s oneshot; /* ESP32-S3-specific oneshot state */
|
||||
oneshot_callback_t callback; /* Upper-half Interrupt callback */
|
||||
void *arg; /* Argument passed to handler */
|
||||
uint16_t resolution; /* Timer's resolution in microseconds */
|
||||
spinlock_t lock; /* Device-specific lock */
|
||||
};
|
||||
@@ -116,11 +114,8 @@ static void oneshot_lh_handler(void *arg)
|
||||
{
|
||||
struct esp32s3_oneshot_lowerhalf_s *priv =
|
||||
(struct esp32s3_oneshot_lowerhalf_s *)arg;
|
||||
oneshot_callback_t callback;
|
||||
void *cb_arg;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
DEBUGASSERT(priv->callback != NULL);
|
||||
|
||||
tmrinfo("Oneshot LH handler triggered\n");
|
||||
|
||||
@@ -128,14 +123,7 @@ static void oneshot_lh_handler(void *arg)
|
||||
* restarts the oneshot).
|
||||
*/
|
||||
|
||||
callback = priv->callback;
|
||||
cb_arg = priv->arg;
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
callback(&priv->lh, cb_arg);
|
||||
oneshot_process_callback(&priv->lh);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -212,11 +200,9 @@ static int oneshot_lh_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = esp32s3_oneshot_start(&priv->oneshot, oneshot_lh_handler,
|
||||
priv, ts);
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
ret = esp32s3_oneshot_start(&priv->oneshot, oneshot_lh_handler,
|
||||
priv, ts);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -263,10 +249,8 @@ static int oneshot_lh_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
ret = esp32s3_oneshot_cancel(&priv->oneshot, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
ret = esp32s3_oneshot_cancel(&priv->oneshot, ts);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -352,8 +336,6 @@ struct oneshot_lowerhalf_s *oneshot_initialize(int chan, uint16_t resolution)
|
||||
}
|
||||
|
||||
priv->lh.ops = &g_esp32s3_timer_ops; /* Pointer to the LH operations */
|
||||
priv->callback = NULL; /* No callback yet */
|
||||
priv->arg = NULL; /* No arg yet */
|
||||
priv->resolution = resolution; /* Configured resolution */
|
||||
|
||||
/* Initialize esp32s3_oneshot_s structure */
|
||||
|
||||
@@ -958,6 +958,9 @@ int tone_register(FAR const char *path, FAR struct pwm_lowerhalf_s *tone,
|
||||
upper->channel = (uint8_t)channel;
|
||||
#endif
|
||||
|
||||
upper->oneshot->callback = oneshot_callback;
|
||||
upper->oneshot->arg = upper;
|
||||
|
||||
/* Register the PWM device */
|
||||
|
||||
audinfo("Registering %s\n", path);
|
||||
|
||||
@@ -90,6 +90,9 @@ void up_alarm_set_lowerhalf(FAR struct oneshot_lowerhalf_s *lower)
|
||||
|
||||
g_oneshot_lower = lower;
|
||||
|
||||
lower->callback = oneshot_callback;
|
||||
lower->arg = lower;
|
||||
|
||||
#ifdef CONFIG_SCHED_TICKLESS
|
||||
ONESHOT_TICK_MAX_DELAY(g_oneshot_lower, &ticks);
|
||||
g_oneshot_maxticks = ticks < UINT32_MAX ? ticks : UINT32_MAX;
|
||||
|
||||
@@ -64,8 +64,6 @@
|
||||
struct goldfish_timer_lowerhalf_s
|
||||
{
|
||||
struct oneshot_lowerhalf_s lh; /* Lower half operations */
|
||||
oneshot_callback_t callback; /* Current user interrupt callback */
|
||||
FAR void *arg; /* Argument passed to upper half callback */
|
||||
uintptr_t base; /* Base address of registers */
|
||||
spinlock_t lock; /* Lock for interrupt handling */
|
||||
};
|
||||
@@ -126,9 +124,6 @@ static int goldfish_timer_start(FAR struct oneshot_lowerhalf_s *lower_,
|
||||
|
||||
flags = spin_lock_irqsave(&lower->lock);
|
||||
|
||||
lower->callback = callback;
|
||||
lower->arg = arg;
|
||||
|
||||
nsec = ts->tv_sec * 1000000000 + ts->tv_nsec;
|
||||
l32 = getreg32(lower->base + GOLDFISH_TIMER_TIME_LOW);
|
||||
h32 = getreg32(lower->base + GOLDFISH_TIMER_TIME_HIGH);
|
||||
@@ -154,9 +149,6 @@ static int goldfish_timer_cancel(FAR struct oneshot_lowerhalf_s *lower_,
|
||||
|
||||
flags = spin_lock_irqsave(&lower->lock);
|
||||
|
||||
lower->callback = NULL;
|
||||
lower->arg = NULL;
|
||||
|
||||
putreg32(0, lower->base + GOLDFISH_TIMER_IRQ_ENABLED);
|
||||
putreg32(1, lower->base + GOLDFISH_TIMER_CLEAR_ALARM);
|
||||
|
||||
@@ -196,9 +188,7 @@ static int goldfish_timer_interrupt(int irq,
|
||||
FAR void *arg)
|
||||
{
|
||||
FAR struct goldfish_timer_lowerhalf_s *lower = arg;
|
||||
oneshot_callback_t callback = NULL;
|
||||
irqstate_t flags;
|
||||
void *cbarg;
|
||||
|
||||
DEBUGASSERT(lower != NULL);
|
||||
|
||||
@@ -207,22 +197,11 @@ static int goldfish_timer_interrupt(int irq,
|
||||
putreg32(1, lower->base + GOLDFISH_TIMER_CLEAR_ALARM);
|
||||
putreg32(1, lower->base + GOLDFISH_TIMER_CLEAR_INTERRUPT);
|
||||
|
||||
if (lower->callback != NULL)
|
||||
{
|
||||
callback = lower->callback;
|
||||
cbarg = lower->arg;
|
||||
lower->callback = NULL;
|
||||
lower->arg = NULL;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&lower->lock, flags);
|
||||
|
||||
/* Then perform the callback */
|
||||
|
||||
if (callback)
|
||||
{
|
||||
callback(&lower->lh, cbarg);
|
||||
}
|
||||
oneshot_process_callback(&lower->lh);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -311,6 +311,10 @@ int oneshot_register(FAR const char *devname,
|
||||
/* Initialize the new oneshot timer driver instance */
|
||||
|
||||
priv->od_lower = lower;
|
||||
|
||||
lower->callback = oneshot_callback;
|
||||
lower->arg = lower;
|
||||
|
||||
nxmutex_init(&priv->od_lock);
|
||||
|
||||
/* And register the oneshot timer driver */
|
||||
|
||||
@@ -848,6 +848,8 @@ FAR void *watchdog_register(FAR const char *path,
|
||||
}
|
||||
|
||||
#if defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_ONESHOT)
|
||||
upper->oneshot->callback = watchdog_automonitor_oneshot;
|
||||
upper->oneshot->arg = upper;
|
||||
watchdog_automonitor_start(upper, oneshot);
|
||||
#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_TIMER)
|
||||
watchdog_automonitor_start(upper, timer);
|
||||
|
||||
@@ -231,6 +231,9 @@ struct oneshot_lowerhalf_s
|
||||
|
||||
FAR const struct oneshot_operations_s *ops;
|
||||
|
||||
FAR oneshot_callback_t callback;
|
||||
FAR void *arg;
|
||||
|
||||
/* Private lower half data may follow */
|
||||
};
|
||||
|
||||
@@ -400,6 +403,15 @@ int oneshot_tick_current(FAR struct oneshot_lowerhalf_s *lower,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline_function
|
||||
void oneshot_process_callback(FAR struct oneshot_lowerhalf_s *lower)
|
||||
{
|
||||
if (lower->callback)
|
||||
{
|
||||
lower->callback(lower, lower->arg);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: oneshot_initialize
|
||||
*
|
||||
|
||||
@@ -328,6 +328,8 @@ void nxsched_oneshot_extclk(FAR struct oneshot_lowerhalf_s *lower)
|
||||
/* Then start the oneshot */
|
||||
|
||||
g_sched_oneshot.oneshot = lower;
|
||||
lower->callback = nxsched_oneshot_callback;
|
||||
lower->arg = NULL;
|
||||
nxsched_oneshot_start();
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user