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
This commit is contained in:
barthess 2011-09-01 17:31:10 +00:00
parent 7194b7a7fe
commit 88f24294e2
1 changed files with 40 additions and 2 deletions

View File

@ -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 */