mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 18:27:56 +08:00
Restore CLOCK_ACTIVETIME
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4009 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -80,6 +80,18 @@
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
/* Configuration ********************************************************************/
|
||||
/* In hi-res mode, the RTC operates at 16384Hz. Overflow interrupts are handled
|
||||
* when the 32-bit RTC counter overflows every 3 days and 43 minutes. A BKP register
|
||||
* is incremented on each overflow interrupt creating, effectively, a 48-bit RTC
|
||||
* counter.
|
||||
*
|
||||
* In the lo-res mode, the RTC operates at 1Hz. Overflow interrupts are not handled
|
||||
* (because the next overflow is not expected until the year 2106.
|
||||
*
|
||||
* WARNING: Overflow interrupts are lost whenever the STM32 is powered down. The
|
||||
* overflow interrupt may be lost even if the STM32 is powered down only momentarily.
|
||||
* Therefor hi-res solution is only useful in systems where the power is always on.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_RTC_HIRES
|
||||
# ifndef CONFIG_RTC_FREQUENCY
|
||||
|
||||
@@ -607,6 +607,23 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
option will enable a limited form of memory mapping that is
|
||||
implemented by copying whole files into memory.
|
||||
|
||||
RTC
|
||||
|
||||
CONFIG_RTC - Enables general support for a hardware RTC. Specific
|
||||
architectures may require other specific settings.
|
||||
CONFIG_RTC_HIRES - The typical RTC keeps time to resolution of 1
|
||||
second, usually supporting a 32-bit time_t value. In this case,
|
||||
the RTC is used to "seed" the normal NuttX timer and the
|
||||
NuttX timer provides for higher resoution time. If CONFIG_RTC_HIRES
|
||||
is enabled in the NuttX configuration, then the RTC provides higher
|
||||
resolution time and completely replaces the system timer for purpose of
|
||||
date and time.
|
||||
CONFIG_RTC_FREQUENCY - If CONFIG_RTC_HIRES is defined, then the
|
||||
frequency of the high resolution RTC must be provided. If CONFIG_RTC_HIRES
|
||||
is not defined, CONFIG_RTC_FREQUENCY is assumed to be one.
|
||||
CONFIG_RTC_ALARM - Enable if the RTC hardware supports setting of an alarm.
|
||||
A callback function will be executed when the alarm goes off
|
||||
|
||||
SPI driver
|
||||
|
||||
CONFIG_SPI_OWNBUS - Set if there is only one active device
|
||||
|
||||
@@ -14,6 +14,7 @@ Contents
|
||||
- DFU
|
||||
- LEDs
|
||||
- Temperature Sensor
|
||||
- RTC
|
||||
- STM3210E-EVAL-specific Configuration Options
|
||||
- Configurations
|
||||
|
||||
@@ -264,6 +265,38 @@ commands enumerated in include/nuttx/sensors/lm75.h. Also read the descriptions
|
||||
of the stm32_lm75initialize() and stm32_lm75attach() interfaces in the
|
||||
arch/board/board.h file (sames as configs/stm3210e-eval/include/board.h).
|
||||
|
||||
RTC
|
||||
===
|
||||
|
||||
The STM32 RTC may configured using the following settings.
|
||||
|
||||
CONFIG_RTC - Enables general support for a hardware RTC. Specific
|
||||
architectures may require other specific settings.
|
||||
CONFIG_RTC_HIRES - The typical RTC keeps time to resolution of 1
|
||||
second, usually supporting a 32-bit time_t value. In this case,
|
||||
the RTC is used to "seed" the normal NuttX timer and the
|
||||
NuttX timer provides for higher resoution time. If CONFIG_RTC_HIRES
|
||||
is enabled in the NuttX configuration, then the RTC provides higher
|
||||
resolution time and completely replaces the system timer for purpose of
|
||||
date and time.
|
||||
CONFIG_RTC_FREQUENCY - If CONFIG_RTC_HIRES is defined, then the
|
||||
frequency of the high resolution RTC must be provided. If CONFIG_RTC_HIRES
|
||||
is not defined, CONFIG_RTC_FREQUENCY is assumed to be one.
|
||||
CONFIG_RTC_ALARM - Enable if the RTC hardware supports setting of an alarm.
|
||||
A callback function will be executed when the alarm goes off
|
||||
|
||||
In hi-res mode, the STM32 RTC operates only at 16384Hz. Overflow interrupts
|
||||
are handled when the 32-bit RTC counter overflows every 3 days and 43 minutes.
|
||||
A BKP register is incremented on each overflow interrupt creating, effectively,
|
||||
a 48-bit RTC counter.
|
||||
|
||||
In the lo-res mode, the RTC operates at 1Hz. Overflow interrupts are not handled
|
||||
(because the next overflow is not expected until the year 2106.
|
||||
|
||||
WARNING: Overflow interrupts are lost whenever the STM32 is powered down. The
|
||||
overflow interrupt may be lost even if the STM32 is powered down only momentarily.
|
||||
Therefore hi-res solution is only useful in systems where the power is always on.
|
||||
|
||||
STM3210E-EVAL-specific Configuration Options
|
||||
============================================
|
||||
|
||||
|
||||
@@ -712,7 +712,7 @@ int sif_main(int argc, char *argv[])
|
||||
fprintf(stderr, "%s:\tinit\n\tgpio\tA B\n\tpwr\tval\n", argv[0]);
|
||||
|
||||
struct timespec t_active;
|
||||
clock_gettime(CLOCK_REALTIME, &t_active);
|
||||
clock_gettime(CLOCK_ACTIVETIME, &t_active);
|
||||
|
||||
fprintf(stderr, "rtc time = %u, active = %u / %u, time / systick = %u / %u\n",
|
||||
up_rtc_time(), t_active.tv_sec, t_active.tv_nsec,
|
||||
|
||||
+19
-2
@@ -67,12 +67,29 @@
|
||||
# define CLOCKS_PER_SEC (100)
|
||||
#endif
|
||||
|
||||
/* This is the only clock_id supported by the "Clock and Timer
|
||||
* Functions."
|
||||
/* CLOCK_REALTIME refers to the standard time source. For most implementations,
|
||||
* the standard time source is the system timer interrupt. However, if the
|
||||
* platform supports an RTC, then the standard time source will be the RTC
|
||||
* for the clock_gettime() and clock_settime() interfaces (the system timer
|
||||
* is still the time source for all of the interfaces).
|
||||
*/
|
||||
|
||||
#define CLOCK_REALTIME 0
|
||||
|
||||
/* If an RTC is supported, then the non-standard CLOCK_ACTIVETIME is also
|
||||
* supported to manage time based on the system timer interrupt separately from
|
||||
* the RTC. This may be necessary, for example, in certain cases where the
|
||||
* system timer interrupt has been stopped in low power modes.
|
||||
*
|
||||
* CLOCK_ACTIVETIME is only recognized by clock_gettime() and clock_settime().
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_RTC
|
||||
# define CLOCK_ACTIVETIME 1
|
||||
#else
|
||||
# define CLOCK_ACTIVETIME CLOCK_REALTIME
|
||||
#endif
|
||||
|
||||
/* This is a flag that may be passed to the timer_settime() function */
|
||||
|
||||
#define TIMER_ABSTIME 1
|
||||
|
||||
@@ -110,12 +110,16 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
|
||||
* time clock.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_RTC
|
||||
if (clock_id == CLOCK_REALTIME || clockid == CLOCK_ACTIVETIME)
|
||||
#else
|
||||
if (clock_id == CLOCK_REALTIME)
|
||||
#endif
|
||||
{
|
||||
/* Do we have a high-resolution RTC that can provie us with the time? */
|
||||
|
||||
#ifdef CONFIG_RTC_HIRES
|
||||
if (g_rtc_enabled)
|
||||
if (g_rtc_enabled && clockid != CLOCK_ACTIVETIME)
|
||||
{
|
||||
/* Yes.. Get the hi-resolution time from the RTC */
|
||||
|
||||
|
||||
@@ -100,7 +100,11 @@ int clock_settime(clockid_t clock_id, FAR const struct timespec *tp)
|
||||
* time clock.
|
||||
*/
|
||||
|
||||
if (clock_id == CLOCK_REALTIME)
|
||||
#ifdef CONFIG_RTC
|
||||
if (clock_id == CLOCK_REALTIME || clockid == CLOCK_ACTIVETIME)
|
||||
#else
|
||||
if (clock_id == CLOCK_REALTIME)
|
||||
#endif
|
||||
{
|
||||
/* Interrupts are disabled here so that the in-memory time
|
||||
* representation and the RTC setting will be as close as
|
||||
@@ -123,7 +127,7 @@ int clock_settime(clockid_t clock_id, FAR const struct timespec *tp)
|
||||
/* Setup the RTC (lo- or high-res) */
|
||||
|
||||
#ifdef CONFIG_RTC
|
||||
if (g_rtc_enabled)
|
||||
if (g_rtc_enabled && clockid != CLOCK_ACTIVETIME)
|
||||
{
|
||||
up_rtc_settime(tp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user