diff options
Diffstat (limited to 'testhal/STM32F1xx')
-rw-r--r-- | testhal/STM32F1xx/RTC/Makefile | 6 | ||||
-rw-r--r-- | testhal/STM32F1xx/RTC/main.c | 44 |
2 files changed, 21 insertions, 29 deletions
diff --git a/testhal/STM32F1xx/RTC/Makefile b/testhal/STM32F1xx/RTC/Makefile index 2f471c293..7748841bd 100644 --- a/testhal/STM32F1xx/RTC/Makefile +++ b/testhal/STM32F1xx/RTC/Makefile @@ -12,7 +12,7 @@ ifeq ($(USE_OPT),) # If all calls to a given function are integrated, and the function is declared static, then the function is normally not output as assembler code in its own right.
# Enabled at level '-O3'.
- USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
+ USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
#USE_OPT = -O1 -ggdb -fomit-frame-pointer -falign-functions=16 -fno-inline
#USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -fno-strict-aliasing
#USE_OPT = -O3 -ggdb -fomit-frame-pointer -falign-functions=16
@@ -86,7 +86,6 @@ CSRC = $(PORTSRC) \ $(CHIBIOS)/os/various/evtimer.c \
$(CHIBIOS)/os/various/syscalls.c \
main.c \
-
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
@@ -215,6 +214,3 @@ ifeq ($(USE_FWLIB),yes) endif
include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk
-
-
-
diff --git a/testhal/STM32F1xx/RTC/main.c b/testhal/STM32F1xx/RTC/main.c index 070ac50f2..ea7155f47 100644 --- a/testhal/STM32F1xx/RTC/main.c +++ b/testhal/STM32F1xx/RTC/main.c @@ -21,14 +21,11 @@ #include "ch.h"
#include "hal.h"
-
-RTCDateTime timespec;
-RTCDateTime alarmspec;
+RTCTime timespec;
+RTCAlarm alarmspec;
#define TEST_ALARM_WAKEUP FALSE
-
-
#if TEST_ALARM_WAKEUP
/* sleep indicator thread */
@@ -64,38 +61,37 @@ int main(void) { return 0;
}
-
-
#else /* TEST_ALARM_WAKEUP */
-static void my_overflowcb(RTCDriver *rtcp){
- (void)rtcp;
- palTogglePad(IOPORT3, GPIOC_LED);
-}
+static void my_cb(RTCDriver *rtcp, rtcevent_t event) {
-static void my_secondcb(RTCDriver *rtcp){
(void)rtcp;
- //palTogglePad(IOPORT3, GPIOC_LED);
-}
-static void my_alarmcb(RTCDriver *rtcp){
- (void)rtcp;
- palTogglePad(IOPORT3, GPIOC_LED);
- rtcGetTime(×pec);
- alarmspec.tv_sec = timespec.tv_sec + 10;
- rtcSetAlarm(&alarmspec);
+ switch (event) {
+ case RTC_EVENT_OVERFLOW:
+ palTogglePad(GPIOC, GPIOC_LED);
+ break;
+ case RTC_EVENT_SECOND:
+ //palTogglePad(GPIOC, GPIOC_LED);
+ break;
+ case RTC_EVENT_ALARM:
+ palTogglePad(GPIOC, GPIOC_LED);
+ rtcGetTime(&RTCD1, ×pec);
+ alarmspec.tv_sec = timespec.tv_sec + 10;
+ rtcSetAlarm(&RTCD1, 0, &alarmspec);
+ break;
+ }
}
-
int main(void) {
halInit();
chSysInit();
- rtcGetTime(×pec);
+ rtcGetTime(&RTCD1, ×pec);
alarmspec.tv_sec = timespec.tv_sec + 10;
- rtcSetAlarm(&alarmspec);
+ rtcSetAlarm(&RTCD1, 0, &alarmspec);
- rtcSetCallback(&RTCD, my_overflowcb, my_secondcb, my_alarmcb);
+ rtcSetCallback(&RTCD1, my_cb);
while (TRUE){
chThdSleepMilliseconds(500);
}
|