aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os/hal/ports/STM32/LLD/EXTIv1/stm32_exti.c4
-rw-r--r--os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.c49
-rw-r--r--readme.txt1
-rw-r--r--testhal/STM32/multi/RTC/debug/STM32-RTC (Select ELF file)(OpenOCD, Just Run).launch104
-rw-r--r--testhal/STM32/multi/RTC/main.c50
5 files changed, 138 insertions, 70 deletions
diff --git a/os/hal/ports/STM32/LLD/EXTIv1/stm32_exti.c b/os/hal/ports/STM32/LLD/EXTIv1/stm32_exti.c
index d2d448e80..e4952937a 100644
--- a/os/hal/ports/STM32/LLD/EXTIv1/stm32_exti.c
+++ b/os/hal/ports/STM32/LLD/EXTIv1/stm32_exti.c
@@ -64,7 +64,7 @@
void extiEnableGroup1(uint32_t mask, extimode_t mode) {
/* Masked out lines must not be touched by this driver.*/
- osalDbgAssert((mask & STM32_EXTI_IMR1_MASK) == 0U, "fixed line");
+ osalDbgAssert((mask & STM32_EXTI_IMR1_MASK) == 0U, "fixed lines");
if ((mode & EXTI_MODE_EDGES_MASK) == 0U) {
/* Disabling channels.*/
@@ -113,7 +113,7 @@ void extiEnableGroup1(uint32_t mask, extimode_t mode) {
void extiEnableGroup2(uint32_t mask, extimode_t mode) {
/* Masked out lines must not be touched by this driver.*/
- osalDbgAssert((mask & STM32_EXTI_IMR2_MASK) == 0U, "fixed line");
+ osalDbgAssert((mask & STM32_EXTI_IMR2_MASK) == 0U, "fixed lines");
if ((mode & EXTI_MODE_EDGES_MASK) == 0U) {
/* Disabling channels.*/
diff --git a/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.c b/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.c
index 7d70cd44b..a7c212b00 100644
--- a/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.c
+++ b/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.c
@@ -243,12 +243,33 @@ struct RTCDriverVMT _rtc_lld_vmt = {
* @isr
*/
OSAL_IRQ_HANDLER(STM32_RTC_COMMON_HANDLER) {
- uint32_t isr;
+ uint32_t isr, clear;
OSAL_IRQ_PROLOGUE();
+ clear = (0U
+ | RTC_ISR_TSF
+ | RTC_ISR_TSOVF
+#if defined(RTC_ISR_TAMP1F)
+ | RTC_ISR_TAMP1F
+#endif
+#if defined(RTC_ISR_TAMP2F)
+ | RTC_ISR_TAMP2F
+#endif
+#if defined(RTC_ISR_TAMP3F)
+ | RTC_ISR_TAMP3F
+#endif
+ | RTC_ISR_WUTF
+#if defined(RTC_ISR_ALRAF)
+ | RTC_ISR_ALRAF
+#endif
+#if defined(RTC_ISR_ALRBF)
+ | RTC_ISR_ALRBF
+#endif
+ );
+
isr = RTCD1.rtc->ISR;
- RTCD1.rtc->ISR = 0U;
+ RTCD1.rtc->ISR = isr & ~clear;
extiClearGroup1(EXTI_MASK1(STM32_RTC_ALARM_EXTI) |
EXTI_MASK1(STM32_RTC_TAMP_STAMP_EXTI) |
@@ -319,22 +340,22 @@ OSAL_IRQ_HANDLER(STM32_RTC_TAMP_STAMP_HANDLER) {
OSAL_IRQ_PROLOGUE();
- clear = ~(0U
- | RTC_ISR_TSF
- | RTC_ISR_TSOVF
+ clear = (0U
+ | RTC_ISR_TSF
+ | RTC_ISR_TSOVF
#if defined(RTC_ISR_TAMP1F)
- | RTC_ISR_TAMP1F
+ | RTC_ISR_TAMP1F
#endif
#if defined(RTC_ISR_TAMP2F)
- | RTC_ISR_TAMP2F
+ | RTC_ISR_TAMP2F
#endif
#if defined(RTC_ISR_TAMP3F)
- | RTC_ISR_TAMP3F
+ | RTC_ISR_TAMP3F
#endif
);
isr = RTCD1.rtc->ISR;
- RTCD1.rtc->ISR = clear;
+ RTCD1.rtc->ISR = isr & ~clear;
extiClearGroup1(EXTI_MASK1(STM32_RTC_TAMP_STAMP_EXTI));
@@ -385,7 +406,7 @@ OSAL_IRQ_HANDLER(STM32_RTC_WKUP_HANDLER) {
OSAL_IRQ_PROLOGUE();
isr = RTCD1.rtc->ISR;
- RTCD1.rtc->ISR = ~RTC_ISR_WUTF;
+ RTCD1.rtc->ISR = isr & ~RTC_ISR_WUTF;
extiClearGroup1(EXTI_MASK1(STM32_RTC_WKUP_EXTI));
@@ -410,17 +431,17 @@ OSAL_IRQ_HANDLER(STM32_RTC_ALARM_HANDLER) {
OSAL_IRQ_PROLOGUE();
- clear = ~(0U
+ clear = (0U
#if defined(RTC_ISR_ALRAF)
- | RTC_ISR_ALRAF
+ | RTC_ISR_ALRAF
#endif
#if defined(RTC_ISR_ALRBF)
- | RTC_ISR_ALRBF
+ | RTC_ISR_ALRBF
#endif
);
isr = RTCD1.rtc->ISR;
- RTCD1.rtc->ISR = clear;
+ RTCD1.rtc->ISR = isr & ~clear;
extiClearGroup1(EXTI_MASK1(STM32_RTC_ALARM_EXTI));
diff --git a/readme.txt b/readme.txt
index c4724f5e5..5180ee598 100644
--- a/readme.txt
+++ b/readme.txt
@@ -75,6 +75,7 @@
*****************************************************************************
*** Next ***
+- NEW: STM32 RTCv2 driver now supports callbacks on events.
- NEW: Added an EXTI helper driver for STM32.
- NEW: Added demo for STM32L4R9I-Discovery board.
- NEW: Support for new serial NOR device MX25LM51245G. Other Macronix devices
diff --git a/testhal/STM32/multi/RTC/debug/STM32-RTC (Select ELF file)(OpenOCD, Just Run).launch b/testhal/STM32/multi/RTC/debug/STM32-RTC (Select ELF file)(OpenOCD, Just Run).launch
index 940c83fad..835e7d705 100644
--- a/testhal/STM32/multi/RTC/debug/STM32-RTC (Select ELF file)(OpenOCD, Just Run).launch
+++ b/testhal/STM32/multi/RTC/debug/STM32-RTC (Select ELF file)(OpenOCD, Just Run).launch
@@ -1,52 +1,52 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType">
-<stringAttribute key="bad_container_name" value="\STM32-RTC\debug"/>
-<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="1"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="true"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#13;&#10;"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="false"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
-<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
-<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/>
-<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/>
-<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
-<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
-<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
-<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
-<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
-<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
-<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;xPSR-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
-<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;globalVariableList/&gt;&#13;&#10;"/>
-<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList&gt;&#13;&#10;&lt;memoryBlockExpressionItem&gt;&#13;&#10;&lt;expression text=&quot;0x40021004&quot;/&gt;&#13;&#10;&lt;/memoryBlockExpressionItem&gt;&#13;&#10;&lt;/memoryBlockExpressionList&gt;&#13;&#10;"/>
-<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="${selected_resource_loc}"/>
-<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32-RTC"/>
-<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/STM32-RTC"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="4"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
-<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
-</listAttribute>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType">
+<stringAttribute key="bad_container_name" value="\STM32-RTC\debug"/>
+<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="1"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="true"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#13;&#10;"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="false"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
+<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
+<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/>
+<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/>
+<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
+<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
+<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
+<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
+<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
+<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
+<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;xPSR-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;ISR-rtc-rtcp-rtc_lld_get_time-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
+<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;globalVariableList/&gt;&#10;"/>
+<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList&gt;&#10;&lt;memoryBlockExpressionItem&gt;&#10;&lt;expression text=&quot;0x40021004&quot;/&gt;&#10;&lt;/memoryBlockExpressionItem&gt;&#10;&lt;/memoryBlockExpressionList&gt;&#10;"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="${selected_resource_loc}"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32-RTC"/>
+<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/STM32-RTC"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+</listAttribute>
+</launchConfiguration>
diff --git a/testhal/STM32/multi/RTC/main.c b/testhal/STM32/multi/RTC/main.c
index be90b57a5..3c273c238 100644
--- a/testhal/STM32/multi/RTC/main.c
+++ b/testhal/STM32/multi/RTC/main.c
@@ -29,6 +29,7 @@
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
static void cmd_date(BaseSequentialStream *chp, int argc, char *argv[]) {
+ RTCDateTime timespec;
(void)argv;
@@ -36,6 +37,16 @@ static void cmd_date(BaseSequentialStream *chp, int argc, char *argv[]) {
chprintf(chp, "Usage: date\r\n");
return;
}
+
+ rtcGetTime(&RTCD1, &timespec);
+ chprintf(chp, "%02d:%02d:%02d (%02d) - %02d-%02d-%04d\r\n",
+ timespec.millisecond / 3600000U,
+ (timespec.millisecond % 3600000U) / 60000U,
+ (timespec.millisecond % 60000U) / 1000U,
+ timespec.millisecond % 1000U,
+ timespec.month,
+ timespec.day,
+ timespec.year + 1980U);
}
static const ShellCommand commands[] = {
@@ -52,6 +63,8 @@ static const ShellConfig shell_cfg1 = {
/* Generic code. */
/*===========================================================================*/
+static sysinterval_t interval = TIME_MS2I(500);
+
/*
* LED blinker thread, times are in milliseconds.
*/
@@ -62,9 +75,24 @@ static THD_FUNCTION(Thread1, arg) {
chRegSetThreadName("blinker");
while (true) {
palToggleLine(PORTAB_LINE_LED1);
- chThdSleepMilliseconds(500);
+ chThdSleep(interval);
palToggleLine(PORTAB_LINE_LED1);
- chThdSleepMilliseconds(500);
+ chThdSleep(interval);
+ }
+}
+
+/*
+ * RTC callback.
+ */
+static void alarmcb(RTCDriver *rtcp, rtcevent_t event) {
+
+ (void)rtcp;
+
+ if (event == RTC_EVENT_ALARM_A) {
+ interval = TIME_MS2I(500);
+ }
+ else if (event == RTC_EVENT_ALARM_B) {
+ interval = TIME_MS2I(50);
}
}
@@ -72,6 +100,20 @@ static THD_FUNCTION(Thread1, arg) {
* Application entry point.
*/
int main(void) {
+ static const RTCAlarm alarm1 = {
+ RTC_ALRM_MSK4 | /* No month/week day match. */
+ RTC_ALRM_MSK3 | /* No hour match. */
+ RTC_ALRM_MSK2 | /* No minutes match. */
+ RTC_ALRM_ST(0) |
+ RTC_ALRM_SU(0) /* Match minute start. */
+ };
+ static const RTCAlarm alarm2 = {
+ RTC_ALRM_MSK4 | /* No month/week day match. */
+ RTC_ALRM_MSK3 | /* No hour match. */
+ RTC_ALRM_MSK2 | /* No minutes match. */
+ RTC_ALRM_ST(3) |
+ RTC_ALRM_SU(0) /* Match minute half. */
+ };
/*
* System initializations.
@@ -95,6 +137,10 @@ int main(void) {
/* Creates the blinker thread.*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+ rtcSetAlarm(&RTCD1, 0, &alarm1);
+ rtcSetAlarm(&RTCD1, 1, &alarm2);
+ rtcSetCallback(&RTCD1, alarmcb);
+
/* Normal main() thread activity, spawning shells.*/
while (true) {
thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,