aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-09-03 13:50:15 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-09-03 13:50:15 +0000
commit1292b0230ccdef3a445647185e12ac159d7a9ed8 (patch)
treeaf832979f6e4cd7ef345301ef9bfa8e8dbe1fe22
parent6db8c459a58514b2c49fbe94b9ff73aaf7ccba5f (diff)
downloadChibiOS-1292b0230ccdef3a445647185e12ac159d7a9ed8.tar.gz
ChibiOS-1292b0230ccdef3a445647185e12ac159d7a9ed8.tar.bz2
ChibiOS-1292b0230ccdef3a445647185e12ac159d7a9ed8.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6257 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/nil/NIL-STM32F051-DISCOVERY/main.c10
-rw-r--r--os/nil/include/nil.h136
-rw-r--r--os/nil/ports/ARMCMx/compilers/GCC/nilcoreasm_v6m.s4
-rw-r--r--os/nil/src/nil.c152
4 files changed, 151 insertions, 151 deletions
diff --git a/demos/nil/NIL-STM32F051-DISCOVERY/main.c b/demos/nil/NIL-STM32F051-DISCOVERY/main.c
index 2600550bb..d92c94b35 100644
--- a/demos/nil/NIL-STM32F051-DISCOVERY/main.c
+++ b/demos/nil/NIL-STM32F051-DISCOVERY/main.c
@@ -29,9 +29,9 @@ THD_FUNCTION(Thread1, arg) {
while (true) {
// gpioSetPad(GPIOC, GPIOC_LED4);
- nilThdSleepMilliseconds(500);
+ chThdSleepMilliseconds(500);
// gpioClearPad(GPIOC, GPIOC_LED4);
- nilThdSleepMilliseconds(500);
+ chThdSleepMilliseconds(500);
}
}
@@ -45,9 +45,9 @@ THD_FUNCTION(Thread2, arg) {
while (true) {
// gpioSetPad(GPIOC, GPIOC_LED3);
- nilThdSleepMilliseconds(250);
+ chThdSleepMilliseconds(250);
// gpioClearPad(GPIOC, GPIOC_LED3);
- nilThdSleepMilliseconds(250);
+ chThdSleepMilliseconds(250);
}
}
@@ -71,7 +71,7 @@ int main(void) {
* - Nil RTOS initialization.
*/
// hwInit();
- nilSysInit();
+ chSysInit();
/* This is now the idle thread loop, you may perform here a low priority
task but you must never try to sleep or wait in this loop.*/
diff --git a/os/nil/include/nil.h b/os/nil/include/nil.h
index 5f4b09768..898ec6f35 100644
--- a/os/nil/include/nil.h
+++ b/os/nil/include/nil.h
@@ -43,11 +43,11 @@
*/
#define _NIL_ /**< @brief Nil RTOS identification.*/
-#define NIL_KERNEL_VERSION "0.1.0alpha"
+#define CH_KERNEL_VERSION "0.1.0alpha"
-#define NIL_KERNEL_MAJOR 0
-#define NIL_KERNEL_MINOR 1
-#define NIL_KERNEL_PATCH 0
+#define CH_KERNEL_MAJOR 0
+#define CH_KERNEL_MINOR 1
+#define CH_KERNEL_PATCH 0
/** @} */
/**
@@ -84,14 +84,14 @@
* @name Thread state related macros
* @{
*/
-#define NIL_THD_READY 0 /**< @brief Thread ready or executing. */
-#define NIL_THD_SLEEPING 1 /**< @brief Thread sleeping. */
-#define NIL_THD_SUSP 2 /**< @brief Thread suspended. */
-#define NIL_THD_WTSEM 3 /**< @brief Thread waiting on semaphore.*/
-#define NIL_THD_IS_READY(tr) ((tr)->state == NIL_THD_READY)
-#define NIL_THD_IS_SLEEPING(tr) ((tr)->state == NIL_THD_SLEEPING)
-#define NIL_THD_IS_SUSP(tr) ((tr)->state == NIL_THD_SUSP)
-#define NIL_THD_IS_WTSEM(tr) ((tr)->state == NIL_THD_WTSEM)
+#define NIL_STATE_READY 0 /**< @brief Thread ready or executing. */
+#define NIL_STATE_SLEEPING 1 /**< @brief Thread sleeping. */
+#define NIL_STATE_SUSP 2 /**< @brief Thread suspended. */
+#define NIL_STATE_WTSEM 3 /**< @brief Thread waiting on semaphore.*/
+#define NIL_THD_IS_READY(tr) ((tr)->state == NIL_STATE_READY)
+#define NIL_THD_IS_SLEEPING(tr) ((tr)->state == NIL_STATE_SLEEPING)
+#define NIL_THD_IS_SUSP(tr) ((tr)->state == NIL_STATE_SUSP)
+#define NIL_THD_IS_WTSEM(tr) ((tr)->state == NIL_STATE_WTSEM)
/** @} */
/*===========================================================================*/
@@ -163,9 +163,9 @@
#endif
#if NIL_CFG_ENABLE_ASSERTS
-#define NIL_DBG_ENABLED TRUE
+#define CH_DBG_ENABLED TRUE
#else
-#define NIL_DBG_ENABLED FALSE
+#define CH_DBG_ENABLED FALSE
#endif
/*===========================================================================*/
@@ -222,7 +222,7 @@ struct nil_thread {
intctx_t *ctxp; /**< @brief Pointer to internal context. */
tstate_t state; /**< @brief Thread state. */
/* Note, the following union contains a pointer while the thread is in a
- sleeping state (!NIL_THD_IS_READY()) else contains the wake-up message.*/
+ sleeping state (!CH_THD_IS_READY()) else contains the wake-up message.*/
union {
msg_t msg; /**< @brief Wake-up message. */
void *p; /**< @brief Generic pointer. */
@@ -271,7 +271,7 @@ typedef struct {
* @brief Thread structures for all the defined threads.
*/
thread_t threads[NIL_CFG_NUM_THREADS + 1];
-#if NIL_DBG_ENABLED || defined(__DOXYGEN__)
+#if CH_DBG_ENABLED || defined(__DOXYGEN__)
/**
* @brief Panic message.
* @note This field is only present if some debug options have been
@@ -288,7 +288,7 @@ typedef struct {
/**
* @brief String quotation macro.
*/
-#define __NIL_QUOTE(p) #p
+#define __CH_QUOTE(p) #p
/**
* @name Threads tables definition macros
@@ -375,7 +375,7 @@ typedef struct {
*
* @special
*/
-#define NIL_IRQ_PROLOGUE() PORT_IRQ_PROLOGUE()
+#define CH_IRQ_PROLOGUE() PORT_IRQ_PROLOGUE()
/**
* @brief IRQ handler exit code.
@@ -383,7 +383,7 @@ typedef struct {
*
* @special
*/
-#define NIL_IRQ_EPILOGUE() PORT_IRQ_EPILOGUE()
+#define CH_IRQ_EPILOGUE() PORT_IRQ_EPILOGUE()
/**
* @brief Standard normal IRQ handler declaration.
@@ -392,7 +392,7 @@ typedef struct {
*
* @special
*/
-#define NIL_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id)
+#define CH_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id)
/** @} */
/**
@@ -406,7 +406,7 @@ typedef struct {
*
* @special
*/
-#define NIL_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
+#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
/** @} */
/**
@@ -464,28 +464,28 @@ typedef struct {
*
* @special
*/
-#define nilSysDisable() port_disable()
+#define chSysDisable() port_disable()
/**
* @brief Enters the kernel lock mode.
*
* @special
*/
-#define nilSysEnable() port_enable()
+#define chSysEnable() port_enable()
/**
* @brief Enters the kernel lock mode.
*
* @special
*/
-#define nilSysLock() port_lock()
+#define chSysLock() port_lock()
/**
* @brief Leaves the kernel lock mode.
*
* @special
*/
-#define nilSysUnlock() port_unlock()
+#define chSysUnlock() port_unlock()
/**
* @brief Enters the kernel lock mode from within an interrupt handler.
@@ -499,7 +499,7 @@ typedef struct {
*
* @special
*/
-#define nilSysLockFromISR() port_lock_from_isr()
+#define chSysLockFromISR() port_lock_from_isr()
/**
* @brief Leaves the kernel lock mode from within an interrupt handler.
@@ -514,7 +514,7 @@ typedef struct {
*
* @special
*/
-#define nilSysUnlockFromISR() port_unlock_from_isr()
+#define chSysUnlockFromISR() port_unlock_from_isr()
/**
* @brief Delays the invoking thread for the specified number of seconds.
@@ -526,7 +526,7 @@ typedef struct {
*
* @api
*/
-#define nilThdSleepSeconds(sec) nilThdSleep(S2ST(sec))
+#define chThdSleepSeconds(sec) chThdSleep(S2ST(sec))
/**
* @brief Delays the invoking thread for the specified number of
@@ -539,7 +539,7 @@ typedef struct {
*
* @api
*/
-#define nilThdSleepMilliseconds(msec) nilThdSleep(MS2ST(msec))
+#define chThdSleepMilliseconds(msec) chThdSleep(MS2ST(msec))
/**
* @brief Delays the invoking thread for the specified number of
@@ -552,7 +552,7 @@ typedef struct {
*
* @api
*/
-#define nilThdSleepMicroseconds(usec) nilThdSleep(US2ST(usec))
+#define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec))
/**
* @brief Suspends the invoking thread for the specified time.
@@ -561,7 +561,7 @@ typedef struct {
*
* @sclass
*/
-#define nilThdSleepS(timeout) nilSchGoSleepTimeoutS(NIL_THD_SLEEPING, timeout)
+#define chThdSleepS(timeout) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, timeout)
/**
* @brief Suspends the invoking thread until the system time arrives to the
@@ -571,8 +571,8 @@ typedef struct {
*
* @sclass
*/
-#define nilThdSleepUntilS(time) \
- nilSchGoSleepTimeoutS(NIL_THD_SLEEPING, (time) - nilTimeNow())
+#define chThdSleepUntilS(time) \
+ chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, (time) - chTimeNow())
/**
* @brief Initializes a semaphore with the specified counter value.
@@ -583,7 +583,7 @@ typedef struct {
*
* @init
*/
-#define nilSemInit(sp, n) ((sp)->cnt = n)
+#define chSemInit(sp, n) ((sp)->cnt = n)
/**
* @brief Performs a wait operation on a semaphore.
@@ -591,13 +591,13 @@ typedef struct {
* @param[in] sp pointer to a @p semaphore_t structure
* @return A message specifying how the invoking thread has been
* released from the semaphore.
- * @retval NIL_MSG_OK if the thread has not stopped on the semaphore or the
+ * @retval CH_MSG_OK if the thread has not stopped on the semaphore or the
* semaphore has been signaled.
- * @retval NIL_MSG_RST if the semaphore has been reset using @p nilSemReset().
+ * @retval CH_MSG_RST if the semaphore has been reset using @p chSemReset().
*
* @api
*/
-#define nilSemWait(sp) nilSemWaitTimeout(sp, TIME_INFINITE)
+#define chSemWait(sp) chSemWaitTimeout(sp, TIME_INFINITE)
/**
* @brief Performs a wait operation on a semaphore.
@@ -605,29 +605,29 @@ typedef struct {
* @param[in] sp pointer to a @p semaphore_t structure
* @return A message specifying how the invoking thread has been
* released from the semaphore.
- * @retval NIL_MSG_OK if the thread has not stopped on the semaphore or the
+ * @retval CH_MSG_OK if the thread has not stopped on the semaphore or the
* semaphore has been signaled.
- * @retval NIL_MSG_RST if the semaphore has been reset using @p nilSemReset().
+ * @retval CH_MSG_RST if the semaphore has been reset using @p chSemReset().
*
* @sclass
*/
-#define nilSemWaitS(sp) nilSemWaitTimeoutS(sp, TIME_INFINITE)
+#define chSemWaitS(sp) chSemWaitTimeoutS(sp, TIME_INFINITE)
/**
* @brief Current system time.
- * @details Returns the number of system ticks since the @p nilSysInit()
+ * @details Returns the number of system ticks since the @p chSysInit()
* invocation.
* @note The counter can reach its maximum and then restart from zero.
- * @note This function is designed to work with the @p nilThdSleepUntil().
+ * @note This function is designed to work with the @p chThdSleepUntil().
*
* @return The system time in ticks.
*
* @iclass
*/
#if NIL_CFG_TIMEDELTA == 0 || defined(__DOXYGEN__)
-#define nilTimeNowI() (nil.systime)
+#define chTimeNowI() (nil.systime)
#else
-#define nilTimeNowI() port_timer_get_time()
+#define chTimeNowI() port_timer_get_time()
#endif
/**
@@ -644,7 +644,7 @@ typedef struct {
*
* @api
*/
-#define nilTimeIsWithin(time, start, end) \
+#define chTimeIsWithin(time, start, end) \
((end) > (start) ? ((time) >= (start)) && ((time) < (end)) : \
((time) >= (start)) || ((time) < (end)))
@@ -663,14 +663,14 @@ typedef struct {
*
* @api
*/
-#if !defined(nilDbgAssert)
-#define nilDbgAssert(c, r) { \
+#if !defined(chDbgAssert)
+#define chDbgAssert(c, r) { \
if (!(c)) \
- nilSysHalt("A:"__NIL_QUOTE(__FUNCTION__)":"__NIL_QUOTE(__LINE__)); \
+ chSysHalt("A:"__CH_QUOTE(__FUNCTION__)":"__CH_QUOTE(__LINE__)); \
}
-#endif /* !defined(nilDbgAssert) */
+#endif /* !defined(chDbgAssert) */
#else /* !NIL_CFG_ENABLE_ASSERTS */
-#define nilDbgAssert(c, r) /*{(void)(c);}*/
+#define chDbgAssert(c, r) /*{(void)(c);}*/
#endif /* !NIL_CFG_ENABLE_ASSERTS */
/** @} */
@@ -686,24 +686,24 @@ extern const thread_config_t nil_thd_configs[NIL_CFG_NUM_THREADS + 1];
#ifdef __cplusplus
extern "C" {
#endif
- void nilSysInit(void);
- void nilSysHalt(const char *reason);
- void nilSysTimerHandlerI(void);
- thread_ref_t nilSchReadyI(thread_ref_t trp, msg_t msg);
- msg_t nilSchGoSleepTimeoutS(tstate_t newstate, systime_t timeout);
- void nilSchRescheduleS(void);
- msg_t nilThdSuspendTimeoutS(thread_ref_t *trp, systime_t timeout);
- void nilThdResumeI(thread_ref_t *trp, msg_t msg);
- void nilThdSleep(systime_t time);
- void nilThdSleepUntil(systime_t time);
- systime_t nilTimeNow(void);
- bool nilTimeNowIsWithin(systime_t start, systime_t end);
- msg_t nilSemWaitTimeout(semaphore_t *sp, systime_t time);
- msg_t nilSemWaitTimeoutS(semaphore_t *sp, systime_t time);
- void nilSemSignal(semaphore_t *sp);
- void nilSemSignalI(semaphore_t *sp);
- void nilSemReset(semaphore_t *sp, cnt_t n);
- void nilSemResetI(semaphore_t *sp, cnt_t n);
+ void chSysInit(void);
+ void chSysHalt(const char *reason);
+ void chSysTimerHandlerI(void);
+ thread_ref_t chSchReadyI(thread_ref_t trp, msg_t msg);
+ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t timeout);
+ void chSchRescheduleS(void);
+ msg_t chThdSuspendTimeoutS(thread_ref_t *trp, systime_t timeout);
+ void chThdResumeI(thread_ref_t *trp, msg_t msg);
+ void chThdSleep(systime_t time);
+ void chThdSleepUntil(systime_t time);
+ systime_t chTimeNow(void);
+ bool chTimeNowIsWithin(systime_t start, systime_t end);
+ msg_t chSemWaitTimeout(semaphore_t *sp, systime_t time);
+ msg_t chSemWaitTimeoutS(semaphore_t *sp, systime_t time);
+ void chSemSignal(semaphore_t *sp);
+ void chSemSignalI(semaphore_t *sp);
+ void chSemReset(semaphore_t *sp, cnt_t n);
+ void chSemResetI(semaphore_t *sp, cnt_t n);
#ifdef __cplusplus
}
#endif
diff --git a/os/nil/ports/ARMCMx/compilers/GCC/nilcoreasm_v6m.s b/os/nil/ports/ARMCMx/compilers/GCC/nilcoreasm_v6m.s
index 7ab0f0432..8112d9802 100644
--- a/os/nil/ports/ARMCMx/compilers/GCC/nilcoreasm_v6m.s
+++ b/os/nil/ports/ARMCMx/compilers/GCC/nilcoreasm_v6m.s
@@ -89,7 +89,7 @@ _port_thread_start:
mov r0, r5
blx r4
mov r3, #0
- bl nilSysHalt
+ bl chSysHalt
/*--------------------------------------------------------------------------*
* Post-IRQ switch code.
@@ -99,7 +99,7 @@ _port_thread_start:
.thumb_func
.globl _port_switch_from_isr
_port_switch_from_isr:
- bl nilSchRescheduleS
+ bl chSchRescheduleS
.globl _port_exit_from_isr
_port_exit_from_isr:
ldr r2, .L2
diff --git a/os/nil/src/nil.c b/os/nil/src/nil.c
index b9b44e4c9..a7677aeeb 100644
--- a/os/nil/src/nil.c
+++ b/os/nil/src/nil.c
@@ -65,7 +65,7 @@ nil_system_t nil;
*
* @special
*/
-void nilSysInit(void) {
+void chSysInit(void) {
thread_ref_t tr;
const thread_config_t *tcp;
@@ -76,7 +76,7 @@ void nilSysInit(void) {
for (tr = &nil.threads[0], tcp = nil_thd_configs;
tr < &nil.threads[NIL_CFG_NUM_THREADS];
tr++, tcp++) {
- tr->state = NIL_THD_READY;
+ tr->state = NIL_STATE_READY;
tr->timeout = 0;
/* Port dependent thread initialization.*/
@@ -94,7 +94,7 @@ void nilSysInit(void) {
port_switch(nil.threads, &nil.threads[NIL_CFG_NUM_THREADS]);
/* Interrupts enabled for the idle thread.*/
- nilSysEnable();
+ chSysEnable();
}
/**
@@ -107,7 +107,7 @@ void nilSysInit(void) {
*
* @special
*/
-void nilSysHalt(const char *reason) {
+void chSysHalt(const char *reason) {
port_disable();
@@ -133,7 +133,7 @@ void nilSysHalt(const char *reason) {
*
* @iclass
*/
-void nilSysTimerHandlerI(void) {
+void chSysTimerHandlerI(void) {
#if NIL_CFG_TIMEDELTA == 0
thread_ref_t tr = &nil.threads[0];
@@ -142,7 +142,7 @@ void nilSysTimerHandlerI(void) {
/* Is the thread in a wait state with timeout?.*/
if (tr->timeout > 0) {
- nilDbgAssert(!NIL_THD_IS_READY(tr), "is ready");
+ chDbgAssert(!NIL_THD_IS_READY(tr), "is ready");
/* Did the timer reach zero?*/
if (--tr->timeout == 0) {
@@ -152,30 +152,30 @@ void nilSysTimerHandlerI(void) {
tr->u1.semp->cnt++;
else if (NIL_THD_IS_SUSP(tr))
tr->u1.trp = NULL;
- nilSchReadyI(tr, MSG_TIMEOUT);
+ chSchReadyI(tr, MSG_TIMEOUT);
}
}
/* Lock released in order to give a preemption chance on those
architectures supporting IRQ preemption.*/
- nilSysUnlockFromISR();
+ chSysUnlockFromISR();
tr++;
- nilSysLockFromISR();
+ chSysLockFromISR();
} while (tr < &nil.threads[NIL_CFG_NUM_THREADS]);
#else
thread_ref_t tr = &nil.threads[0];
systime_t next = 0;
- nilDbgAssert(nil.nexttime == port_timer_get_alarm(),
- "nilSysTimerHandlerI(), #1", "time mismatch");
+ chDbgAssert(nil.nexttime == port_timer_get_alarm(),
+ "chSysTimerHandlerI(), #1", "time mismatch");
do {
/* Is the thread in a wait state with timeout?.*/
if (tr->timeout > 0) {
- nilDbgAssert(!NIL_THD_IS_READY(tr),
- "nilSysTimerHandlerI(), #2", "is ready");
- nilDbgAssert(tr->timeout >= nil.nexttime - nil.lasttime,
- "nilSysTimerHandlerI(), #3", "skipped one");
+ chDbgAssert(!NIL_THD_IS_READY(tr),
+ "chSysTimerHandlerI(), #2", "is ready");
+ chDbgAssert(tr->timeout >= nil.nexttime - nil.lasttime,
+ "chSysTimerHandlerI(), #3", "skipped one");
tr->timeout -= nil.nexttime - nil.lasttime;
if (tr->timeout == 0) {
@@ -185,7 +185,7 @@ void nilSysTimerHandlerI(void) {
tr->u1.semp->cnt++;
else if (NIL_THD_IS_SUSP(tr))
tr->u1.trp = NULL;
- nilSchReadyI(tr, NIL_MSG_TMO);
+ chSchReadyI(tr, NIL_MSG_TMO);
}
else {
if (tr->timeout <= next - 1)
@@ -194,9 +194,9 @@ void nilSysTimerHandlerI(void) {
}
/* Lock released in order to give a preemption chance on those
architectures supporting IRQ preemption.*/
- nilSysUnlockFromISR();
+ chSysUnlockFromISR();
tr++;
- nilSysLockFromISR();
+ chSysLockFromISR();
} while (tr < &nil.threads[NIL_CFG_NUM_THREADS]);
nil.lasttime = nil.nexttime;
if (next > 0) {
@@ -218,16 +218,16 @@ void nilSysTimerHandlerI(void) {
*
* @return The same reference passed as parameter.
*/
-thread_ref_t nilSchReadyI(thread_ref_t tr, msg_t msg) {
+thread_ref_t chSchReadyI(thread_ref_t tr, msg_t msg) {
- nilDbgAssert((tr >= nil.threads) &&
+ chDbgAssert((tr >= nil.threads) &&
(tr < &nil.threads[NIL_CFG_NUM_THREADS]),
"pointer out of range");
- nilDbgAssert(!NIL_THD_IS_READY(tr), "already ready");
- nilDbgAssert(nil.next <= nil.current, "priority ordering");
+ chDbgAssert(!NIL_THD_IS_READY(tr), "already ready");
+ chDbgAssert(nil.next <= nil.current, "priority ordering");
tr->u1.msg = msg;
- tr->state = NIL_THD_READY;
+ tr->state = NIL_STATE_READY;
tr->timeout = 0;
if (tr < nil.next)
nil.next = tr;
@@ -239,7 +239,7 @@ thread_ref_t nilSchReadyI(thread_ref_t tr, msg_t msg) {
*
* @sclass
*/
-void nilSchRescheduleS() {
+void chSchRescheduleS() {
thread_ref_t otr = nil.current;
thread_ref_t ntr = nil.next;
@@ -271,10 +271,10 @@ void nilSchRescheduleS() {
*
* @sclass
*/
-msg_t nilSchGoSleepTimeoutS(tstate_t newstate, systime_t timeout) {
+msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t timeout) {
thread_ref_t ntr, otr = nil.current;
- nilDbgAssert(otr != &nil.threads[NIL_CFG_NUM_THREADS],
+ chDbgAssert(otr != &nil.threads[NIL_CFG_NUM_THREADS],
"idle cannot sleep");
/* Storing the wait object for the current thread.*/
@@ -282,7 +282,7 @@ msg_t nilSchGoSleepTimeoutS(tstate_t newstate, systime_t timeout) {
#if NIL_CFG_TIMEDELTA > 0
if (timeout != TIME_INFINITE) {
- systime_t time = nilTimeNowI() + timeout;
+ systime_t time = chTimeNowI() + timeout;
/* TIMEDELTA makes sure to have enough time to reprogram the timer
before the free-running timer counter reaches the selected timeout.*/
@@ -297,7 +297,7 @@ msg_t nilSchGoSleepTimeoutS(tstate_t newstate, systime_t timeout) {
else {
/* Special case, there are already other threads with a timeout
activated, evaluating the order.*/
- if (nilTimeIsWithin(time, nil.lasttime, nil.nexttime)) {
+ if (chTimeIsWithin(time, nil.lasttime, nil.nexttime)) {
port_timer_set_alarm(time);
nil.nexttime = time;
}
@@ -329,7 +329,7 @@ msg_t nilSchGoSleepTimeoutS(tstate_t newstate, systime_t timeout) {
/* Points to the next thread in lowering priority order.*/
ntr++;
- nilDbgAssert(ntr <= &nil.threads[NIL_CFG_NUM_THREADS],
+ chDbgAssert(ntr <= &nil.threads[NIL_CFG_NUM_THREADS],
"pointer out of range");
}
}
@@ -348,13 +348,13 @@ msg_t nilSchGoSleepTimeoutS(tstate_t newstate, systime_t timeout) {
*
* @sclass
*/
-msg_t nilThdSuspendTimeoutS(thread_ref_t *trp, systime_t timeout) {
+msg_t chThdSuspendTimeoutS(thread_ref_t *trp, systime_t timeout) {
- nilDbgAssert(*trp == NULL, "not NULL");
+ chDbgAssert(*trp == NULL, "not NULL");
*trp = nil.current;
nil.current->u1.trp = trp;
- return nilSchGoSleepTimeoutS(NIL_THD_SUSP, timeout);
+ return chSchGoSleepTimeoutS(NIL_STATE_SUSP, timeout);
}
/**
@@ -367,15 +367,15 @@ msg_t nilThdSuspendTimeoutS(thread_ref_t *trp, systime_t timeout) {
*
* @iclass
*/
-void nilThdResumeI(thread_ref_t *trp, msg_t msg) {
+void chThdResumeI(thread_ref_t *trp, msg_t msg) {
if (*trp != NULL) {
thread_ref_t tr = *trp;
- nilDbgAssert(NIL_THD_IS_SUSP(tr), "not suspended");
+ chDbgAssert(NIL_THD_IS_SUSP(tr), "not suspended");
*trp = NULL;
- nilSchReadyI(tr, msg);
+ chSchReadyI(tr, msg);
}
}
@@ -386,11 +386,11 @@ void nilThdResumeI(thread_ref_t *trp, msg_t msg) {
*
* @api
*/
-void nilThdSleep(systime_t time) {
+void chThdSleep(systime_t time) {
- nilSysLock();
- nilThdSleepS(time);
- nilSysUnlock();
+ chSysLock();
+ chThdSleepS(time);
+ chSysUnlock();
}
/**
@@ -401,30 +401,30 @@ void nilThdSleep(systime_t time) {
*
* @api
*/
-void nilThdSleepUntil(systime_t time) {
+void chThdSleepUntil(systime_t time) {
- nilSysLock();
- nilThdSleepUntilS(time);
- nilSysUnlock();
+ chSysLock();
+ chThdSleepUntilS(time);
+ chSysUnlock();
}
/**
* @brief Current system time.
- * @details Returns the number of system ticks since the @p nilSysInit()
+ * @details Returns the number of system ticks since the @p chSysInit()
* invocation.
* @note The counter can reach its maximum and then restart from zero.
- * @note This function is designed to work with the @p nilThdSleepUntil().
+ * @note This function is designed to work with the @p chThdSleepUntil().
*
* @return The system time in ticks.
*
* @api
*/
-systime_t nilTimeNow(void) {
+systime_t chTimeNow(void) {
systime_t time;
- nilSysLock();
- time = nilTimeNowI();
- nilSysUnlock();
+ chSysLock();
+ time = chTimeNowI();
+ chSysUnlock();
return time;
}
@@ -442,10 +442,10 @@ systime_t nilTimeNow(void) {
*
* @api
*/
-bool nilTimeNowIsWithin(systime_t start, systime_t end) {
+bool chTimeNowIsWithin(systime_t start, systime_t end) {
- systime_t time = nilTimeNow();
- return nilTimeIsWithin(time, start, end);
+ systime_t time = chTimeNow();
+ return chTimeIsWithin(time, start, end);
}
/**
@@ -461,18 +461,18 @@ bool nilTimeNowIsWithin(systime_t start, systime_t end) {
* released from the semaphore.
* @retval NIL_MSG_OK if the thread has not stopped on the semaphore or the
* semaphore has been signaled.
- * @retval NIL_MSG_RST if the semaphore has been reset using @p nilSemReset().
+ * @retval NIL_MSG_RST if the semaphore has been reset using @p chSemReset().
* @retval NIL_MSG_TMO if the semaphore has not been signaled or reset within
* the specified timeout.
*
* @api
*/
-msg_t nilSemWaitTimeout(semaphore_t *sp, systime_t timeout) {
+msg_t chSemWaitTimeout(semaphore_t *sp, systime_t timeout) {
msg_t msg;
- nilSysLock();
- msg = nilSemWaitTimeoutS(sp, timeout);
- nilSysUnlock();
+ chSysLock();
+ msg = chSemWaitTimeoutS(sp, timeout);
+ chSysUnlock();
return msg;
}
@@ -489,13 +489,13 @@ msg_t nilSemWaitTimeout(semaphore_t *sp, systime_t timeout) {
* released from the semaphore.
* @retval NIL_MSG_OK if the thread has not stopped on the semaphore or the
* semaphore has been signaled.
- * @retval NIL_MSG_RST if the semaphore has been reset using @p nilSemReset().
+ * @retval NIL_MSG_RST if the semaphore has been reset using @p chSemReset().
* @retval NIL_MSG_TMO if the semaphore has not been signaled or reset within
* the specified timeout.
*
* @sclass
*/
-msg_t nilSemWaitTimeoutS(semaphore_t *sp, systime_t timeout) {
+msg_t chSemWaitTimeoutS(semaphore_t *sp, systime_t timeout) {
/* Note, the semaphore counter is a volatile variable so accesses are
manually optimized.*/
@@ -505,7 +505,7 @@ msg_t nilSemWaitTimeoutS(semaphore_t *sp, systime_t timeout) {
return MSG_TIMEOUT;
sp->cnt = cnt - 1;
nil.current->u1.semp = sp;
- return nilSchGoSleepTimeoutS(NIL_THD_WTSEM, timeout);
+ return chSchGoSleepTimeoutS(NIL_STATE_WTSEM, timeout);
}
sp->cnt = cnt - 1;
return MSG_OK;
@@ -522,12 +522,12 @@ msg_t nilSemWaitTimeoutS(semaphore_t *sp, systime_t timeout) {
*
* @api
*/
-void nilSemSignal(semaphore_t *sp) {
+void chSemSignal(semaphore_t *sp) {
- nilSysLock();
- nilSemSignalI(sp);
- nilSchRescheduleS();
- nilSysUnlock();
+ chSysLock();
+ chSemSignalI(sp);
+ chSchRescheduleS();
+ chSysUnlock();
}
/**
@@ -541,7 +541,7 @@ void nilSemSignal(semaphore_t *sp) {
*
* @iclass
*/
-void nilSemSignalI(semaphore_t *sp) {
+void chSemSignalI(semaphore_t *sp) {
if (++sp->cnt <= 0) {
thread_ref_t tr = nil.threads;
@@ -549,9 +549,9 @@ void nilSemSignalI(semaphore_t *sp) {
/* Is this thread waiting on this semaphore?*/
if (tr->u1.semp == sp) {
- nilDbgAssert(NIL_THD_IS_WTSEM(tr), "not waiting");
+ chDbgAssert(NIL_THD_IS_WTSEM(tr), "not waiting");
- nilSchReadyI(tr, MSG_OK);
+ chSchReadyI(tr, MSG_OK);
return;
}
tr++;
@@ -575,12 +575,12 @@ void nilSemSignalI(semaphore_t *sp) {
*
* @api
*/
-void nilSemReset(semaphore_t *sp, cnt_t n) {
+void chSemReset(semaphore_t *sp, cnt_t n) {
- nilSysLock();
- nilSemResetI(sp, n);
- nilSchRescheduleS();
- nilSysUnlock();
+ chSysLock();
+ chSemResetI(sp, n);
+ chSchRescheduleS();
+ chSysUnlock();
}
/**
@@ -599,7 +599,7 @@ void nilSemReset(semaphore_t *sp, cnt_t n) {
*
* @iclass
*/
-void nilSemResetI(semaphore_t *sp, cnt_t n) {
+void chSemResetI(semaphore_t *sp, cnt_t n) {
thread_ref_t tr;
cnt_t cnt;
@@ -610,10 +610,10 @@ void nilSemResetI(semaphore_t *sp, cnt_t n) {
/* Is this thread waiting on this semaphore?*/
if (tr->u1.semp == sp) {
- nilDbgAssert(NIL_THD_IS_WTSEM(tr), "not waiting");
+ chDbgAssert(NIL_THD_IS_WTSEM(tr), "not waiting");
cnt++;
- nilSchReadyI(tr, MSG_RESET);
+ chSchReadyI(tr, MSG_RESET);
}
tr++;
}