diff options
author | gdisirio <gdisirio@110e8d01-0319-4d1e-a829-52ad28d1bb01> | 2018-11-25 12:02:19 +0000 |
---|---|---|
committer | gdisirio <gdisirio@110e8d01-0319-4d1e-a829-52ad28d1bb01> | 2018-11-25 12:02:19 +0000 |
commit | b8a4c26a9cab50e5a845d0033665a4d74b17444b (patch) | |
tree | 3eba7daf5c024f22cb3d45969da49d44930b1eca /testhal/STM32/multi | |
parent | 7a0857aa5d161a27128622b0d9f61867dc7520ae (diff) | |
download | ChibiOS-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).launch | 2 | ||||
-rw-r--r-- | testhal/STM32/multi/RTC/main.c | 25 |
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="<?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.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"/><content id="regval-_write-(format)" val="4"/><content id="*bkpr-bkpr-_read-(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}"/> 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, ×pec);
- 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) {
|