mirror of
https://github.com/apache/nuttx.git
synced 2026-06-10 20:28:06 +08:00
SAM3/4, SAMA5, SAMv7 Tickless: Refuse to call lower-level timer logic if not yet initialized
This commit is contained in:
@@ -49,6 +49,12 @@
|
||||
|
||||
#ifdef CONFIG_SAM34_FREERUN
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define FREERUN_INITIALIZED(s) (((s)->tch) != NULL)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -49,6 +49,12 @@
|
||||
|
||||
#ifdef CONFIG_SAM34_ONESHOT
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ONESHOT_INITIALIZED(s) (((s)->tch) != NULL)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
@@ -247,6 +248,8 @@ void up_timer_initialize(void)
|
||||
PANIC();
|
||||
}
|
||||
|
||||
DEBUGASSERT(ONESHOT_INITIALIZED(&g_tickless.oneshot));
|
||||
|
||||
#ifdef CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP
|
||||
/* Get the maximum delay of the one-shot timer in microseconds */
|
||||
|
||||
@@ -280,6 +283,8 @@ void up_timer_initialize(void)
|
||||
tclldbg("ERROR: sam_freerun_initialize failed\n");
|
||||
PANIC();
|
||||
}
|
||||
|
||||
DEBUGASSERT(FREERUN_INITIALIZED(&g_tickless.freerun));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -317,7 +322,9 @@ void up_timer_initialize(void)
|
||||
|
||||
int up_timer_gettime(FAR struct timespec *ts)
|
||||
{
|
||||
return sam_freerun_counter(&g_tickless.freerun, ts);
|
||||
return FREERUN_INITIALIZED(&g_tickless.freerun) ?
|
||||
sam_freerun_counter(&g_tickless.freerun, ts) :
|
||||
-EAGAIN;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -358,7 +365,9 @@ int up_timer_gettime(FAR struct timespec *ts)
|
||||
|
||||
int up_timer_cancel(FAR struct timespec *ts)
|
||||
{
|
||||
return sam_oneshot_cancel(&g_tickless.oneshot, ts);
|
||||
return ONESHOT_INITIALIZED(&g_tickless.oneshot) ?
|
||||
sam_oneshot_cancel(&g_tickless.oneshot, ts) :
|
||||
-EAGAIN;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -388,6 +397,8 @@ int up_timer_cancel(FAR struct timespec *ts)
|
||||
|
||||
int up_timer_start(FAR const struct timespec *ts)
|
||||
{
|
||||
return sam_oneshot_start(&g_tickless.oneshot, sam_oneshot_handler, NULL, ts);
|
||||
return ONESHOT_INITIALIZED(&g_tickless.oneshot) ?
|
||||
sam_oneshot_start(&g_tickless.oneshot, sam_oneshot_handler, NULL, ts) :
|
||||
-EAGAIN;
|
||||
}
|
||||
#endif /* CONFIG_SCHED_TICKLESS */
|
||||
|
||||
@@ -53,6 +53,8 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define FREERUN_INITIALIZED(s) (((s)->tch) != NULL)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -53,6 +53,8 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ONESHOT_INITIALIZED(s) (((s)->tch) != NULL)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
@@ -259,6 +260,8 @@ void up_timer_initialize(void)
|
||||
PANIC();
|
||||
}
|
||||
|
||||
DEBUGASSERT(ONESHOT_INITIALIZED(&g_tickless.oneshot));
|
||||
|
||||
#ifdef CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP
|
||||
/* Get the maximum delay of the one-shot timer in microseconds */
|
||||
|
||||
@@ -292,6 +295,8 @@ void up_timer_initialize(void)
|
||||
tclldbg("ERROR: sam_freerun_initialize failed\n");
|
||||
PANIC();
|
||||
}
|
||||
|
||||
DEBUGASSERT(FREERUN_INITIALIZED(&g_tickless.freerun));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -329,7 +334,9 @@ void up_timer_initialize(void)
|
||||
|
||||
int up_timer_gettime(FAR struct timespec *ts)
|
||||
{
|
||||
return sam_freerun_counter(&g_tickless.freerun, ts);
|
||||
return FREERUN_INITIALIZED(&g_tickless.freerun) ?
|
||||
sam_freerun_counter(&g_tickless.freerun, ts) :
|
||||
-EAGAIN;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -370,7 +377,9 @@ int up_timer_gettime(FAR struct timespec *ts)
|
||||
|
||||
int up_timer_cancel(FAR struct timespec *ts)
|
||||
{
|
||||
return sam_oneshot_cancel(&g_tickless.oneshot, ts);
|
||||
return ONESHOT_INITIALIZED(&g_tickless.oneshot) ?
|
||||
sam_oneshot_cancel(&g_tickless.oneshot, ts) :
|
||||
-EAGAIN;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -400,6 +409,8 @@ int up_timer_cancel(FAR struct timespec *ts)
|
||||
|
||||
int up_timer_start(FAR const struct timespec *ts)
|
||||
{
|
||||
return sam_oneshot_start(&g_tickless.oneshot, sam_oneshot_handler, NULL, ts);
|
||||
return ONESHOT_INITIALIZED(&g_tickless.oneshot) ?
|
||||
sam_oneshot_start(&g_tickless.oneshot, sam_oneshot_handler, NULL, ts) :
|
||||
-EAGAIN;
|
||||
}
|
||||
#endif /* CONFIG_SCHED_TICKLESS */
|
||||
|
||||
@@ -53,6 +53,8 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define FREERUN_INITIALIZED(s) (((s)->tch) != NULL)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -53,6 +53,8 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ONESHOT_INITIALIZED(s) (((s)->tch) != NULL)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
@@ -268,6 +269,8 @@ void up_timer_initialize(void)
|
||||
PANIC();
|
||||
}
|
||||
|
||||
DEBUGASSERT(ONESHOT_INITIALIZED(&g_tickless.oneshot));
|
||||
|
||||
/* Initialize the free-running timer */
|
||||
|
||||
ret = sam_freerun_initialize(&g_tickless.freerun,
|
||||
@@ -278,6 +281,8 @@ void up_timer_initialize(void)
|
||||
tclldbg("ERROR: sam_freerun_initialize failed\n");
|
||||
PANIC();
|
||||
}
|
||||
|
||||
DEBUGASSERT(FREERUN_INITIALIZED(&g_tickless.freerun));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -315,7 +320,9 @@ void up_timer_initialize(void)
|
||||
|
||||
int up_timer_gettime(FAR struct timespec *ts)
|
||||
{
|
||||
return sam_freerun_counter(&g_tickless.freerun, ts);
|
||||
return FREERUN_INITIALIZED(&g_tickless.freerun) ?
|
||||
sam_freerun_counter(&g_tickless.freerun, ts) :
|
||||
-EAGAIN;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -356,7 +363,9 @@ int up_timer_gettime(FAR struct timespec *ts)
|
||||
|
||||
int up_timer_cancel(FAR struct timespec *ts)
|
||||
{
|
||||
return sam_oneshot_cancel(&g_tickless.oneshot, ts);
|
||||
return ONESHOT_INITIALIZED(&g_tickless.oneshot) ?
|
||||
sam_oneshot_cancel(&g_tickless.oneshot, ts) :
|
||||
-EAGAIN;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -386,6 +395,8 @@ int up_timer_cancel(FAR struct timespec *ts)
|
||||
|
||||
int up_timer_start(FAR const struct timespec *ts)
|
||||
{
|
||||
return sam_oneshot_start(&g_tickless.oneshot, sam_oneshot_handler, NULL, ts);
|
||||
return ONESHOT_INITIALIZED(&g_tickless.oneshot) ?
|
||||
sam_oneshot_start(&g_tickless.oneshot, sam_oneshot_handler, NULL, ts) :
|
||||
-EAGAIN;
|
||||
}
|
||||
#endif /* CONFIG_SCHED_TICKLESS */
|
||||
|
||||
Reference in New Issue
Block a user