diff --git a/ChangeLog b/ChangeLog index f918f79..5508b30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2017-11-17 NIIBE Yutaka + * chopstx.c (chopstx_conf_idle): Call chx_sleep_mode before + changing chx_allow_sleep. + * board/board-blue-pill.h, board/board-cq-starm.h, board/board-fst-01-00.h, board/board-fst-01.h, board/board-fst-01g.h, board/board-maple-mini.h, diff --git a/chopstx.c b/chopstx.c index 9fe96e8..ca36560 100644 --- a/chopstx.c +++ b/chopstx.c @@ -79,7 +79,7 @@ chx_fatal (uint32_t err_code) #include "chopstx-cortex-m.h" #endif -/* ALLOW_SLEEP for idle */ +/* ALLOW_SLEEP for the idle thread. */ int chx_allow_sleep; static struct chx_spinlock chx_enable_sleep_lock; @@ -1488,12 +1488,15 @@ chopstx_setpriority (chopstx_prio_t prio_new) * For STM32F0, 1 for Sleep (CPU clock OFF only), 2 for Stop (Wakeup * by EXTI, voltage regulator on), 3 for Stop (Wakeup by EXTI, voltage * regulator low-power), 4 for Standby (Wakeup by RESET, voltage - * regulator off), and 128 is or-ed to ask WFE instead of WFI. + * regulator off). * - * For STM32F103, 1 for sleep with lower 8MHz clock. + * For STM32F103, 1 for normal sleep, and 2 for sleep with lower 8MHz + * clock. * * Return previous value of @enable_sleep. */ +extern void chx_sleep_mode (int enable_sleep); + int chopstx_conf_idle (int enable_sleep) { @@ -1501,8 +1504,8 @@ chopstx_conf_idle (int enable_sleep) chx_spin_lock (&chx_enable_sleep_lock); r = chx_allow_sleep; + chx_sleep_mode (enable_sleep); chx_allow_sleep = enable_sleep; - chx_sleep_mode ((enable_sleep & 0x7f)); chx_spin_unlock (&chx_enable_sleep_lock); return r;