aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-09-25 10:32:39 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-09-25 10:32:39 +0000
commit0af85bab42eda2d80ce6efd2a0c1f5a94bad5f34 (patch)
tree0880a08e05b3c42b904dd99320e58625efac34a7
parentfa0a7f52dbe51185794b3fa5c0279738790ee131 (diff)
downloadChibiOS-0af85bab42eda2d80ce6efd2a0c1f5a94bad5f34.tar.gz
ChibiOS-0af85bab42eda2d80ce6efd2a0c1f5a94bad5f34.tar.bz2
ChibiOS-0af85bab42eda2d80ce6efd2a0c1f5a94bad5f34.zip
RTC. Test updated.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3408 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/hal/src/rtc.c2
-rw-r--r--testhal/STM32F1xx/RTC/main.c36
2 files changed, 24 insertions, 14 deletions
diff --git a/os/hal/src/rtc.c b/os/hal/src/rtc.c
index 0c8959ea6..17c83f4b3 100644
--- a/os/hal/src/rtc.c
+++ b/os/hal/src/rtc.c
@@ -76,7 +76,7 @@ void rtcInit(void){
*/
void rtcSetCallback(RTCDriver *rtcp, rtccb_t overflowcb,
rtccb_t secondcb, rtccb_t alarmcb){
- chDbgCheck((rtcp != NULL), "rtcStart");
+ chDbgCheck((rtcp != NULL), "rtcSetCallback");
rtc_lld_set_callback(rtcp, overflowcb, secondcb, alarmcb);
}
#endif /* RTC_SUPPORTS_CALLBACKS */
diff --git a/testhal/STM32F1xx/RTC/main.c b/testhal/STM32F1xx/RTC/main.c
index d68919ecf..070ac50f2 100644
--- a/testhal/STM32F1xx/RTC/main.c
+++ b/testhal/STM32F1xx/RTC/main.c
@@ -21,30 +21,36 @@
#include "ch.h"
#include "hal.h"
-//#define TEST_DEEPSLEEP_ENABLE
-#ifdef TEST_DEEPSLEEP_ENABLE
+RTCDateTime timespec;
+RTCDateTime alarmspec;
+#define TEST_ALARM_WAKEUP FALSE
+
+
+
+#if TEST_ALARM_WAKEUP
+
+/* sleep indicator thread */
static WORKING_AREA(blinkWA, 128);
static msg_t blink_thd(void *arg){
(void)arg;
while (TRUE) {
- chThdSleepMilliseconds(500);
+ chThdSleepMilliseconds(100);
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);
+ rtcGetTime(&timespec);
+ alarmspec.tv_sec = timespec.tv_sec + 60;
+ rtcSetAlarm(&alarmspec);
while (TRUE){
chThdSleepSeconds(10);
@@ -60,12 +66,11 @@ int main(void) {
-#else /* TEST_DEEPSLEEP_ENABLE */
+#else /* TEST_ALARM_WAKEUP */
static void my_overflowcb(RTCDriver *rtcp){
(void)rtcp;
palTogglePad(IOPORT3, GPIOC_LED);
- rtcSetAlarm(rtcGetSec() + 10);
}
static void my_secondcb(RTCDriver *rtcp){
@@ -76,7 +81,9 @@ static void my_secondcb(RTCDriver *rtcp){
static void my_alarmcb(RTCDriver *rtcp){
(void)rtcp;
palTogglePad(IOPORT3, GPIOC_LED);
- rtcSetAlarm(rtcGetSec() + 10);
+ rtcGetTime(&timespec);
+ alarmspec.tv_sec = timespec.tv_sec + 10;
+ rtcSetAlarm(&alarmspec);
}
@@ -84,11 +91,14 @@ int main(void) {
halInit();
chSysInit();
- rtcSetAlarm(rtcGetSec() + 10);
- rtcSetCallback(&RTCD, NULL, my_secondcb, my_alarmcb);
+ rtcGetTime(&timespec);
+ alarmspec.tv_sec = timespec.tv_sec + 10;
+ rtcSetAlarm(&alarmspec);
+
+ rtcSetCallback(&RTCD, my_overflowcb, my_secondcb, my_alarmcb);
while (TRUE){
chThdSleepMilliseconds(500);
}
return 0;
}
-#endif /* TEST_DEEPSLEEP_ENABLE */
+#endif /* TEST_ALARM_WAKEUP */