aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32/multi
diff options
context:
space:
mode:
authorgdisirio <gdisirio@110e8d01-0319-4d1e-a829-52ad28d1bb01>2018-11-25 12:02:19 +0000
committergdisirio <gdisirio@110e8d01-0319-4d1e-a829-52ad28d1bb01>2018-11-25 12:02:19 +0000
commitb8a4c26a9cab50e5a845d0033665a4d74b17444b (patch)
tree3eba7daf5c024f22cb3d45969da49d44930b1eca /testhal/STM32/multi
parent7a0857aa5d161a27128622b0d9f61867dc7520ae (diff)
downloadChibiOS-b8a4c26a9cab50e5a845d0033665a4d74b17444b.tar.gz
ChibiOS-b8a4c26a9cab50e5a845d0033665a4d74b17444b.tar.bz2
ChibiOS-b8a4c26a9cab50e5a845d0033665a4d74b17444b.zip
Persistent storage for STM32 RTCV1 driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12438 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'testhal/STM32/multi')
-rw-r--r--testhal/STM32/multi/RTC/debug/STM32-RTC (Select ELF file)(OpenOCD, Just Run).launch2
-rw-r--r--testhal/STM32/multi/RTC/main.c25
2 files changed, 25 insertions, 2 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 835e7d705..3bd927aff 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
@@ -33,7 +33,7 @@
<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.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;content id=&quot;regval-_write-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;*bkpr-bkpr-_read-(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}"/>
diff --git a/testhal/STM32/multi/RTC/main.c b/testhal/STM32/multi/RTC/main.c
index 3c273c238..f4dfb5334 100644
--- a/testhal/STM32/multi/RTC/main.c
+++ b/testhal/STM32/multi/RTC/main.c
@@ -39,7 +39,7 @@ static void cmd_date(BaseSequentialStream *chp, int argc, char *argv[]) {
}
rtcGetTime(&RTCD1, &timespec);
- chprintf(chp, "%02d:%02d:%02d (%02d) - %02d-%02d-%04d\r\n",
+ chprintf(chp, "%02d:%02d:%02d:%03d - %02d-%02d-%04d\r\n",
timespec.millisecond / 3600000U,
(timespec.millisecond % 3600000U) / 60000U,
(timespec.millisecond % 60000U) / 1000U,
@@ -49,8 +49,30 @@ static void cmd_date(BaseSequentialStream *chp, int argc, char *argv[]) {
timespec.year + 1980U);
}
+static void cmd_storage(BaseSequentialStream *chp, int argc, char *argv[]) {
+ size_t storage_size = psGetStorageSize(&RTCD1);
+ ps_offset_t i;
+
+ (void)argv;
+
+ if (argc > 0) {
+ chprintf(chp, "Usage: storage\r\n");
+ return;
+ }
+
+ for (i = 0U; i < (ps_offset_t)storage_size; i++) {
+ uint8_t val;
+ psRead(&RTCD1, i, 1U, &val);
+ chprintf(chp, "%02x ", val);
+ if (((i + 1) & 15) == 0U) {
+ chprintf(chp, "\r\n");
+ }
+ }
+}
+
static const ShellCommand commands[] = {
{"date", cmd_date},
+ {"storage", cmd_storage},
{NULL, NULL}
};
@@ -140,6 +162,7 @@ int main(void) {
rtcSetAlarm(&RTCD1, 0, &alarm1);
rtcSetAlarm(&RTCD1, 1, &alarm2);
rtcSetCallback(&RTCD1, alarmcb);
+ psWrite(&RTCD1, 0U, 12U, (const uint8_t *)"Hello World!");
/* Normal main() thread activity, spawning shells.*/
while (true) {