diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2018-11-25 10:20:09 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2018-11-25 10:20:09 +0000 |
commit | 7a0857aa5d161a27128622b0d9f61867dc7520ae (patch) | |
tree | 760371b2a169e11c5f24c904f52fa68d23d2405e /testhal/STM32/multi/RTC | |
parent | e9fbae0881b5c4aa4302ff2629efe06360e34fa5 (diff) | |
download | ChibiOS-7a0857aa5d161a27128622b0d9f61867dc7520ae.tar.gz ChibiOS-7a0857aa5d161a27128622b0d9f61867dc7520ae.tar.bz2 ChibiOS-7a0857aa5d161a27128622b0d9f61867dc7520ae.zip |
RTC callbacks now working.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12437 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'testhal/STM32/multi/RTC')
-rw-r--r-- | testhal/STM32/multi/RTC/debug/STM32-RTC (Select ELF file)(OpenOCD, Just Run).launch | 104 | ||||
-rw-r--r-- | testhal/STM32/multi/RTC/main.c | 50 |
2 files changed, 100 insertions, 54 deletions
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 monitor reset init monitor sleep 50 "/>
-<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="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="xPSR-(format)" val="4"/></contentList>"/>
-<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
-<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList> <memoryBlockExpressionItem> <expression text="0x40021004"/> </memoryBlockExpressionItem> </memoryBlockExpressionList> "/>
-<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 monitor reset init monitor sleep 50 "/> +<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="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="xPSR-(format)" val="4"/><content id="ISR-rtc-rtcp-rtc_lld_get_time-(format)" val="4"/></contentList>"/> +<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/> +<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList> <memoryBlockExpressionItem> <expression text="0x40021004"/> </memoryBlockExpressionItem> </memoryBlockExpressionList> "/> +<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, ×pec);
+ 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,
|