diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-08-16 11:38:45 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-08-16 11:38:45 +0000 |
commit | 752b44ba0e550159fb6d2372c54a278fb94080eb (patch) | |
tree | 786c78c4c662213708ccccde28c98cd25f32d16c | |
parent | 9dcb2a31c07e7dddf21f470f7c98457c02421059 (diff) | |
download | ChibiOS-752b44ba0e550159fb6d2372c54a278fb94080eb.tar.gz ChibiOS-752b44ba0e550159fb6d2372c54a278fb94080eb.tar.bz2 ChibiOS-752b44ba0e550159fb6d2372c54a278fb94080eb.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6165 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | demos/ARMCM4-STM32F303-DISCOVERY/chconf.h | 22 | ||||
-rw-r--r-- | os/rt/src/chschd.c | 20 |
2 files changed, 42 insertions, 0 deletions
diff --git a/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h b/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h index 6ee0bd743..0bf8693a1 100644 --- a/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h +++ b/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h @@ -500,6 +500,28 @@ #endif
/**
+ * @brief Idle thread enter hook.
+ * @note This hook is invoked within a critical zone, no OS functions
+ * should be invoked from here.
+ * @note This macro can be used to activate a power saving mode.
+ */
+#if !defined(CH_CFG_IDLE_ENTER_HOOK) || defined(__DOXYGEN__)
+#define CH_CFG_IDLE_ENTER_HOOK() { \
+}
+#endif
+
+/**
+ * @brief Idle thread leave hook.
+ * @note This hook is invoked within a critical zone, no OS functions
+ * should be invoked from here.
+ * @note This macro can be used to deactivate a power saving mode.
+ */
+#if !defined(CH_CFG_IDLE_LEAVE_HOOK) || defined(__DOXYGEN__)
+#define CH_CFG_IDLE_LEAVE_HOOK() { \
+}
+#endif
+
+/**
* @brief Idle Loop hook.
* @details This hook is continuously invoked by the idle thread loop.
*/
diff --git a/os/rt/src/chschd.c b/os/rt/src/chschd.c index ac77139ae..9b7147a32 100644 --- a/os/rt/src/chschd.c +++ b/os/rt/src/chschd.c @@ -125,6 +125,11 @@ void chSchGoSleepS(tstate_t newstate) { otp->p_preempt = CH_CFG_TIME_QUANTUM;
#endif
setcurrp(queue_fifo_remove(&ch.rlist.r_queue));
+#if defined(CH_CFG_IDLE_ENTER_HOOK)
+ if (currp->p_prio == IDLEPRIO) {
+ CH_CFG_IDLE_ENTER_HOOK();
+ }
+#endif
currp->p_state = CH_STATE_CURRENT;
chSysSwitch(currp, otp);
}
@@ -237,6 +242,11 @@ void chSchWakeupS(thread_t *ntp, msg_t msg) { else {
thread_t *otp = chSchReadyI(currp);
setcurrp(ntp);
+#if defined(CH_CFG_IDLE_LEAVE_HOOK)
+ if (otp->p_prio == IDLEPRIO) {
+ CH_CFG_IDLE_LEAVE_HOOK();
+ }
+#endif
ntp->p_state = CH_STATE_CURRENT;
chSysSwitch(ntp, otp);
}
@@ -302,6 +312,11 @@ void chSchDoRescheduleBehind(void) { otp = currp;
/* Picks the first thread from the ready queue and makes it current.*/
setcurrp(queue_fifo_remove(&ch.rlist.r_queue));
+#if defined(CH_CFG_IDLE_LEAVE_HOOK)
+ if (otp->p_prio == IDLEPRIO) {
+ CH_CFG_IDLE_LEAVE_HOOK();
+ }
+#endif
currp->p_state = CH_STATE_CURRENT;
#if CH_CFG_TIME_QUANTUM > 0
otp->p_preempt = CH_CFG_TIME_QUANTUM;
@@ -325,6 +340,11 @@ void chSchDoRescheduleAhead(void) { otp = currp;
/* Picks the first thread from the ready queue and makes it current.*/
setcurrp(queue_fifo_remove(&ch.rlist.r_queue));
+#if defined(CH_CFG_IDLE_LEAVE_HOOK)
+ if (otp->p_prio == IDLEPRIO) {
+ CH_CFG_IDLE_LEAVE_HOOK();
+ }
+#endif
currp->p_state = CH_STATE_CURRENT;
otp->p_state = CH_STATE_READY;
|