From 3f4af2fe30571b1741459bc6a9d6d86d1828c63d Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 1 Oct 2011 22:09:00 +0000 Subject: [PATCH] Add support for lo- and hi-res RTC hardware git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4005 42af7a65-404d-4744-a932-0658087f49c3 --- ChangeLog | 5 + Documentation/NuttxPortingGuide.html | 67 ++- arch/arm/src/stm32/stm32_i2c.c | 3 +- arch/arm/src/stm32/stm32_rtc.c | 624 +++++++++++++++++++-------- configs/vsn/nsh/defconfig | 1 + configs/vsn/src/sif.c | 5 +- include/nuttx/clock.h | 2 +- include/nuttx/rtc.h | 131 +++++- include/time.h | 2 +- sched/clock_gettime.c | 57 +-- sched/clock_initialize.c | 116 +++-- sched/clock_settime.c | 30 +- sched/clock_systimer.c | 14 +- 13 files changed, 750 insertions(+), 307 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1557285cf..d774bb48ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2121,3 +2121,8 @@ * configs/sam3u/touchscreen - This is the configuration that I plan to use to verify the SAM3U-EK touchscreen driver. However, as of this writing, there is no touchscreen driver for the board. + * CONFIG_RTC_HIRES - Add an option to support either a high-resolution RTC + that completely replaces the system timer tick but may overflow and lose + time when the MCU is off and also for a low-resolution (1 sec/tick) RTC + that can run until 2106 with no overflow. But in this latter case, higher + resolution time must come from the system timer. diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html index 20f6778ca8..d05eea2396 100644 --- a/Documentation/NuttxPortingGuide.html +++ b/Documentation/NuttxPortingGuide.html @@ -12,7 +12,7 @@

NuttX RTOS Porting Guide

-

Last Updated: September 13, 2011

+

Last Updated: October 1, 2011

@@ -1989,18 +1989,30 @@ CONFIG_SYSTEM_UTC=y

4.1.20.2 Hardware

- To enable hardware module use option: + To enable hardware module use the following configuration options:

-

+

which requires the following three base functions to read time:

This module depends on CONFIG_SYSTEM_UTC=y. @@ -2024,15 +2036,17 @@ CONFIG_RTC=y Running at rate of system base timer, used for time-slicing, and so forth.

- If hardware RTC is present (CONFIG_RTC) and enabled, then after successful - initiliazation variables are overriden by calls to up_rtc_getclock() which is + If hardware RTC is present (CONFIG_RTC) and and high-resolution timeing + is enabled (CONFIG_RTC_HIRES), then after successful + initiliazation variables are overriden by calls to up_rtc_gettime() which is running continously even in power-down modes.

- In the case of CONFIG_RTC is set the g_tickcount and g_system_utc keep - counting at rate of a system timer, which however, is disabled in power-down - mode. By comparing this time and RTC (actual time) one may determine the - actual system active time. To retrieve that variable use: + In the case of CONFIG_RTC_HIRES is set the g_tickcount and + g_system_utc keep counting at rate of a system timer, which however, is + disabled in power-down mode. + By comparing this time and RTC (actual time) one may determine the actual system active time. + To retrieve that variable use:

Device Drivers

+

RTC

+ +

SPI driver