aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32F1xx/RTC
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-09-01 17:31:10 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-09-01 17:31:10 +0000
commit88f24294e2d23667667cf9c37bd6925550b1c714 (patch)
tree4d8d13aca3e5aebf2ce555e02c9d07ada011f00a /testhal/STM32F1xx/RTC
parent7194b7a7fe49bab8d9422dbc2e78d1ae2d39dc9e (diff)
downloadChibiOS-88f24294e2d23667667cf9c37bd6925550b1c714.tar.gz
ChibiOS-88f24294e2d23667667cf9c37bd6925550b1c714.tar.bz2
ChibiOS-88f24294e2d23667667cf9c37bd6925550b1c714.zip
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
Diffstat (limited to 'testhal/STM32F1xx/RTC')
-rw-r--r--testhal/STM32F1xx/RTC/main.c42
1 files changed, 40 insertions, 2 deletions
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 */