aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32F1xx/RTC
diff options
context:
space:
mode:
Diffstat (limited to 'testhal/STM32F1xx/RTC')
-rw-r--r--testhal/STM32F1xx/RTC/Makefile17
-rw-r--r--testhal/STM32F1xx/RTC/halconf.h54
-rw-r--r--testhal/STM32F1xx/RTC/main.c62
-rw-r--r--testhal/STM32F1xx/RTC/mcuconf.h28
4 files changed, 85 insertions, 76 deletions
diff --git a/testhal/STM32F1xx/RTC/Makefile b/testhal/STM32F1xx/RTC/Makefile
index 2f471c293..e0c032c91 100644
--- a/testhal/STM32F1xx/RTC/Makefile
+++ b/testhal/STM32F1xx/RTC/Makefile
@@ -12,13 +12,18 @@ 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
#USE_OPT = -Os -ggdb -fomit-frame-pointer -falign-functions=16
endif
+# C specific options here (added to USE_OPT).
+ifeq ($(USE_COPT),)
+ USE_COPT =
+endif
+
# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
USE_CPPOPT = -fno-rtti
@@ -34,9 +39,9 @@ ifeq ($(USE_THUMB),)
USE_THUMB = yes
endif
-# Enable register caching optimization (read documentation).
-ifeq ($(USE_CURRP_CACHING),)
- USE_CURRP_CACHING = no
+# Enable this if you want to see the full log while compiling.
+ifeq ($(USE_VERBOSE_COMPILE),)
+ USE_VERBOSE_COMPILE = no
endif
#
@@ -86,7 +91,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 +219,3 @@ ifeq ($(USE_FWLIB),yes)
endif
include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk
-
-
-
diff --git a/testhal/STM32F1xx/RTC/halconf.h b/testhal/STM32F1xx/RTC/halconf.h
index 553decda8..12944d159 100644
--- a/testhal/STM32F1xx/RTC/halconf.h
+++ b/testhal/STM32F1xx/RTC/halconf.h
@@ -55,6 +55,13 @@
#endif
/**
+ * @brief Enables the EXT subsystem.
+ */
+#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
+#define HAL_USE_EXT FALSE
+#endif
+
+/**
* @brief Enables the GPT subsystem.
*/
#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
@@ -97,6 +104,13 @@
#endif
/**
+ * @brief Enables the RTC subsystem.
+ */
+#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
+#define HAL_USE_RTC TRUE
+#endif
+
+/**
* @brief Enables the SDC subsystem.
*/
#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
@@ -138,13 +152,6 @@
#define HAL_USE_USB FALSE
#endif
-/**
- * @brief Enables the USB subsystem.
- */
-#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
-#define HAL_USE_RTC TRUE
-#endif
-
/*===========================================================================*/
/* ADC driver related settings. */
/*===========================================================================*/
@@ -205,24 +212,18 @@
/*===========================================================================*/
/* RTC driver related settings. */
/*===========================================================================*/
-/**
- * @brief Switch to TRUE if you need callbacks from RTC.
- */
-#if !defined(RTC_SUPPORTS_CALLBACKS) || defined(__DOXYGEN__)
-#define RTC_SUPPORTS_CALLBACKS FALSE
-#endif
-
-/**
- * @brief Clock source selecting. LSE by default.
- */
-#if !defined(RTC_CLOCK_SOURCE) || defined(__DOXYGEN__)
-#define RTC_CLOCK_SOURCE RCC_BDCR_RTCSEL_LSE
-#endif
/*===========================================================================*/
/* MAC driver related settings. */
/*===========================================================================*/
+/**
+ * @brief Enables an event sources for incoming packets.
+ */
+#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
+#define MAC_USE_EVENTS TRUE
+#endif
+
/*===========================================================================*/
/* MMC_SPI driver related settings. */
/*===========================================================================*/
@@ -273,16 +274,9 @@
#endif
/*===========================================================================*/
-/* PAL driver related settings. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* PWM driver related settings. */
-/*===========================================================================*/
-
-/*===========================================================================*/
/* SDC driver related settings. */
/*===========================================================================*/
+
/**
* @brief Number of initialization attempts before rejecting the card.
* @note Attempts are performed at 10mS intevals.
@@ -354,10 +348,6 @@
#define SPI_USE_MUTUAL_EXCLUSION FALSE
#endif
-/*===========================================================================*/
-/* UART driver related settings. */
-/*===========================================================================*/
-
#endif /* _HALCONF_H_ */
/** @} */
diff --git a/testhal/STM32F1xx/RTC/main.c b/testhal/STM32F1xx/RTC/main.c
index 497b7f0cf..ea7155f47 100644
--- a/testhal/STM32F1xx/RTC/main.c
+++ b/testhal/STM32F1xx/RTC/main.c
@@ -21,30 +21,33 @@
#include "ch.h"
#include "hal.h"
-#define TEST_DEEPSLEEP_ENABLE
+RTCTime timespec;
+RTCAlarm alarmspec;
-#ifdef TEST_DEEPSLEEP_ENABLE
+#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);
@@ -58,43 +61,40 @@ int main(void) {
return 0;
}
+#else /* TEST_ALARM_WAKEUP */
+static void my_cb(RTCDriver *rtcp, rtcevent_t event) {
-#else /* TEST_DEEPSLEEP_ENABLE */
-
-static void my_secondcb(RTCDriver *rtcp){
(void)rtcp;
- //palTogglePad(IOPORT3, GPIOC_LED);
-}
-static void my_alarmcb(RTCDriver *rtcp){
- (void)rtcp;
- palTogglePad(IOPORT3, GPIOC_LED);
- rtcSetAlarm(rtcGetSec() + 10);
-}
-
-static void my_overflowcb(RTCDriver *rtcp){
- (void)rtcp;
- palTogglePad(IOPORT3, GPIOC_LED);
- rtcSetAlarm(rtcGetSec() + 10);
+ 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, &timespec);
+ alarmspec.tv_sec = timespec.tv_sec + 10;
+ rtcSetAlarm(&RTCD1, 0, &alarmspec);
+ break;
+ }
}
-static const RTCConfig rtccfg={
- my_overflowcb,
- my_secondcb,
- my_alarmcb,
-};
-
int main(void) {
halInit();
chSysInit();
- rtcSetAlarm(rtcGetSec() + 10);
- rtcStart(&RTCD, &rtccfg);
+ rtcGetTime(&RTCD1, &timespec);
+ alarmspec.tv_sec = timespec.tv_sec + 10;
+ rtcSetAlarm(&RTCD1, 0, &alarmspec);
+ rtcSetCallback(&RTCD1, my_cb);
while (TRUE){
chThdSleepMilliseconds(500);
}
return 0;
}
-#endif /* TEST_DEEPSLEEP_ENABLE */
+#endif /* TEST_ALARM_WAKEUP */
diff --git a/testhal/STM32F1xx/RTC/mcuconf.h b/testhal/STM32F1xx/RTC/mcuconf.h
index fc7ce0053..8413e2421 100644
--- a/testhal/STM32F1xx/RTC/mcuconf.h
+++ b/testhal/STM32F1xx/RTC/mcuconf.h
@@ -43,6 +43,7 @@
#define STM32_PPRE2 STM32_PPRE2_DIV2
#define STM32_ADCPRE STM32_ADCPRE_DIV4
#define STM32_MCO STM32_MCO_NOCLOCK
+#define STM32_RTC STM32_RTC_LSE
/*
* ADC driver system settings.
@@ -59,6 +60,21 @@
#define STM32_CAN_CAN1_IRQ_PRIORITY 11
/*
+ * EXT driver system settings.
+ */
+#define STM32_EXT_EXTI0_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI1_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI2_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI3_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI4_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI5_9_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI10_15_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI16_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI17_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI18_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI19_IRQ_PRIORITY 6
+
+/*
* GPT driver system settings.
*/
#define STM32_GPT_USE_TIM1 FALSE
@@ -115,11 +131,13 @@
#define STM32_SERIAL_USE_USART3 FALSE
#define STM32_SERIAL_USE_UART4 FALSE
#define STM32_SERIAL_USE_UART5 FALSE
-#define STM32_SERIAL_USART1_PRIORITY 9
-#define STM32_SERIAL_USART2_PRIORITY 10
-#define STM32_SERIAL_USART3_PRIORITY 2
-#define STM32_SERIAL_UART4_PRIORITY 2
-#define STM32_SERIAL_UART5_PRIORITY 2
+#define STM32_SERIAL_USE_USART6 FALSE
+#define STM32_SERIAL_USART1_PRIORITY 12
+#define STM32_SERIAL_USART2_PRIORITY 12
+#define STM32_SERIAL_USART3_PRIORITY 12
+#define STM32_SERIAL_UART4_PRIORITY 12
+#define STM32_SERIAL_UART5_PRIORITY 12
+#define STM32_SERIAL_USART6_PRIORITY 12
/*
* SPI driver system settings.