From 13006e1c737bf557f83ef9da6ccd9037eacb5a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Date: Tue, 3 Dec 2013 18:51:39 +0100 Subject: [PATCH] cc2538: lpm: Let system clock transitions complete before further changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As a matter of precaution, always make sure that pending system clock transitions are complete before requesting a new change of the system clock source. Signed-off-by: Benoît Thébaudeau --- cpu/cc2538/lpm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpu/cc2538/lpm.c b/cpu/cc2538/lpm.c index 74d00df91..da0349495 100644 --- a/cpu/cc2538/lpm.c +++ b/cpu/cc2538/lpm.c @@ -158,6 +158,9 @@ enter_pm0(void) static void select_32_mhz_xosc(void) { + /*First, make sure there is no ongoing clock source change */ + while((REG(SYS_CTRL_CLOCK_STA) & SYS_CTRL_CLOCK_STA_SOURCE_CHANGE) != 0); + /* Turn on the 32 MHz XOSC and source the system clock on it. */ REG(SYS_CTRL_CLOCK_CTRL) &= ~SYS_CTRL_CLOCK_CTRL_OSC;