diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-12-15 20:49:24 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-12-15 20:49:24 +0000 |
commit | 9a98744b28ecfda0d78d5983e3a2d264c36bcec7 (patch) | |
tree | fe7dd0f7dad67a0d18c5693786f4c32594c8a962 /testhal | |
parent | 124a432b0ed05568381f2bf6930a86a767f85ea6 (diff) | |
download | ChibiOS-9a98744b28ecfda0d78d5983e3a2d264c36bcec7.tar.gz ChibiOS-9a98744b28ecfda0d78d5983e3a2d264c36bcec7.tar.bz2 ChibiOS-9a98744b28ecfda0d78d5983e3a2d264c36bcec7.zip |
RTC. Testhal works on F4x, compiles (but not deeply tested) on F1x.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3615 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal')
-rw-r--r-- | testhal/STM32F1xx/RTC/Makefile | 11 | ||||
-rw-r--r-- | testhal/STM32F1xx/RTC/mcuconf.h | 2 | ||||
-rw-r--r-- | testhal/STM32F4xx/RTC/halconf.h | 2 | ||||
-rw-r--r-- | testhal/STM32F4xx/RTC/main.c | 22 |
4 files changed, 22 insertions, 15 deletions
diff --git a/testhal/STM32F1xx/RTC/Makefile b/testhal/STM32F1xx/RTC/Makefile index e0c032c91..d11c0f579 100644 --- a/testhal/STM32F1xx/RTC/Makefile +++ b/testhal/STM32F1xx/RTC/Makefile @@ -5,14 +5,7 @@ # Compiler options here.
ifeq ($(USE_OPT),)
-#-fno-inline
-# Don't pay attention to the inline keyword. Normally this option is used to keep the compiler from expanding any functions inline. Note that if you are not optimizing, no functions can be expanded inline.
-#-finline-functions
-# Integrate all simple functions into their callers. The compiler heuristically decides which functions are simple enough to be worth integrating in this way.
-# 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 = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
+ USE_OPT = -O0 -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
@@ -41,7 +34,7 @@ endif # Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),)
- USE_VERBOSE_COMPILE = no
+ USE_VERBOSE_COMPILE = yes
endif
#
diff --git a/testhal/STM32F1xx/RTC/mcuconf.h b/testhal/STM32F1xx/RTC/mcuconf.h index 8413e2421..0ac17c3fd 100644 --- a/testhal/STM32F1xx/RTC/mcuconf.h +++ b/testhal/STM32F1xx/RTC/mcuconf.h @@ -30,7 +30,7 @@ * DMA priorities:
* 0...3 Lowest...Highest.
*/
-#include "main.h"
+
/*
* HAL driver system settings.
*/
diff --git a/testhal/STM32F4xx/RTC/halconf.h b/testhal/STM32F4xx/RTC/halconf.h index fc6e7aa8d..9e64ec3c0 100644 --- a/testhal/STM32F4xx/RTC/halconf.h +++ b/testhal/STM32F4xx/RTC/halconf.h @@ -156,7 +156,7 @@ * @brief Enables the RTC subsystem.
*/
#if !defined(RTC_SUPPORTS_CALLBACKS) || defined(__DOXYGEN__)
-#define RTC_SUPPORTS_CALLBACKS FLASE
+#define RTC_SUPPORTS_CALLBACKS TRUE
#endif
/*===========================================================================*/
diff --git a/testhal/STM32F4xx/RTC/main.c b/testhal/STM32F4xx/RTC/main.c index d6cf4f533..8864e0f01 100644 --- a/testhal/STM32F4xx/RTC/main.c +++ b/testhal/STM32F4xx/RTC/main.c @@ -18,12 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <time.h>
+#include <stdlib.h>
#include "ch.h"
#include "hal.h"
RTCTime timespec;
RTCAlarm alarmspec;
+RTCWakeup wakeupspec;
RTCCallbackConfig cb_cfg;
time_t unix_time;
@@ -39,17 +41,20 @@ static inline void exti_rtcalarm_cb(EXTDriver *extp, expchannel_t channel){ if (RTCD1.id_rtc->ISR | RTC_ISR_ALRAF){
RTCD1.id_rtc->ISR &= ~RTC_ISR_ALRAF;
}
+ palTogglePad(GPIOB, GPIOB_LED_R);
}
/**
- * Wakeup callback
+ * Periodic wakeup callback
*/
static inline void exti_rtcwakeup_cb(EXTDriver *extp, expchannel_t channel){
(void)extp;
(void)channel;
+ /* manually clear flags because exti driver does not do that */
if (RTCD1.id_rtc->ISR | RTC_ISR_WUTF){
RTCD1.id_rtc->ISR &= ~RTC_ISR_WUTF;
}
+ palTogglePad(GPIOB, GPIOB_LED_R);
}
@@ -72,12 +77,12 @@ static const EXTConfig extcfg = { {EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
- {EXT_CH_MODE_RISING_EDGE, exti_rtcalarm_cb},// RTC alarms
+ {EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART, exti_rtcalarm_cb},// RTC alarms
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},// timestamp
- {EXT_CH_MODE_RISING_EDGE, exti_rtcwakeup_cb},// wakeup
+ {EXT_CH_MODE_RISING_EDGE| EXT_CH_MODE_AUTOSTART, exti_rtcwakeup_cb},// wakeup
},
EXT_MODE_EXTI(
0,
@@ -157,6 +162,15 @@ int main(void){ extStart(&EXTD1, &extcfg);
+ /* tune wakeup callback */
+ wakeupspec.wakeup = ((uint32_t)4) << 16; // select 1 Hz clock source
+ wakeupspec.wakeup |= 3; // set counter value to 3. Period will be 3+1 seconds.
+ rtcSetWakeup(&RTCD1, &wakeupspec);
+
+ /* enable wakeup callback */
+ cb_cfg.cb_cfg = WAKEUP_CB_FLAG;
+ rtcSetCallback(&RTCD1, &cb_cfg);
+
/* get current time in unix format */
rtcGetTime(&RTCD1, ×pec);
bcd2tm(&timp, timespec.tv_time, timespec.tv_date);
@@ -165,7 +179,7 @@ int main(void){ if (unix_time == -1){// incorrect time in RTC cell
unix_time = 1000000000;
}
-
+ /* set correct time */
tm2bcd((localtime(&unix_time)), ×pec);
rtcSetTime(&RTCD1, ×pec);
|