From 88f24294e2d23667667cf9c37bd6925550b1c714 Mon Sep 17 00:00:00 2001 From: barthess Date: Thu, 1 Sep 2011 17:31:10 +0000 Subject: RTC. Added deep sleep test git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/rtc_dev@3277 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F1xx/RTC/main.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'testhal/STM32F1xx/RTC/main.c') diff --git a/testhal/STM32F1xx/RTC/main.c b/testhal/STM32F1xx/RTC/main.c index b8c243810..497b7f0cf 100644 --- a/testhal/STM32F1xx/RTC/main.c +++ b/testhal/STM32F1xx/RTC/main.c @@ -21,7 +21,46 @@ #include "ch.h" #include "hal.h" +#define TEST_DEEPSLEEP_ENABLE +#ifdef TEST_DEEPSLEEP_ENABLE + +static WORKING_AREA(blinkWA, 128); +static msg_t blink_thd(void *arg){ + (void)arg; + while (TRUE) { + chThdSleepMilliseconds(500); + palTogglePad(IOPORT3, GPIOC_LED); + } + return 0; +} + + + + +int main(void) { + halInit(); + chSysInit(); + + chThdCreateStatic(blinkWA, sizeof(blinkWA), NORMALPRIO, blink_thd, NULL); + /* set alarm in near future */ + rtcSetAlarm(rtcGetSec() + 60); + + while (TRUE){ + chThdSleepSeconds(10); + chSysLock(); + + /* going to anabiosis*/ + PWR->CR |= (PWR_CR_PDDS | PWR_CR_LPDS | PWR_CR_CSBF | PWR_CR_CWUF); + SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; + __WFI(); + } + return 0; +} + + + +#else /* TEST_DEEPSLEEP_ENABLE */ static void my_secondcb(RTCDriver *rtcp){ (void)rtcp; @@ -46,8 +85,6 @@ static const RTCConfig rtccfg={ my_alarmcb, }; - - int main(void) { halInit(); chSysInit(); @@ -60,3 +97,4 @@ int main(void) { } return 0; } +#endif /* TEST_DEEPSLEEP_ENABLE */ -- cgit v1.2.3