mirror of
https://github.com/apache/nuttx.git
synced 2026-10-08 14:55:18 +00:00
Merge remote-tracking branch 'origin/master' into ieee802154
This commit is contained in:
commit
9d094a28be
31 changed files with 992 additions and 65 deletions
|
|
@ -2185,6 +2185,35 @@ int up_rtc_gettime(FAR struct timespec *tp);
|
|||
int up_rtc_getdatetime(FAR struct tm *tp);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: up_rtc_getdatetime_with_subseconds
|
||||
*
|
||||
* Description:
|
||||
* Get the current date and time from the date/time RTC. This interface
|
||||
* is only supported by the date/time RTC hardware implementation.
|
||||
* It is used to replace the system timer. It is only used by the RTOS during
|
||||
* initialization to set up the system time when CONFIG_RTC and CONFIG_RTC_DATETIME
|
||||
* are selected (and CONFIG_RTC_HIRES is not).
|
||||
*
|
||||
* NOTE: This interface exposes sub-second accuracy capability of RTC hardware.
|
||||
* This interface allow maintaining timing accuracy when system time needs constant
|
||||
* resynchronization with RTC, for example on MCU with low-power state that
|
||||
* stop system timer.
|
||||
*
|
||||
* Input Parameters:
|
||||
* tp - The location to return the high resolution time value.
|
||||
* nsec - The location to return the subsecond time value.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno on failure
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#if defined(CONFIG_RTC) && defined(CONFIG_RTC_DATETIME) && \
|
||||
defined(CONFIG_ARCH_HAVE_RTC_SUBSECONDS)
|
||||
int up_rtc_getdatetime_with_subseconds(FAR struct tm *tp, FAR long *nsec);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: up_rtc_settime
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* include/nuttx/clock.h
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011-2012, 2014, 2016 Gregory Nutt.
|
||||
* Copyright (C) 2007-2009, 2011-2012, 2014, 2016-2017 Gregory Nutt.
|
||||
All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
|
|
@ -50,6 +50,7 @@
|
|||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
/* Efficient, direct access to OS global timer variables will be supported
|
||||
* if the execution environment has direct access to kernel global data.
|
||||
|
|
@ -71,12 +72,12 @@
|
|||
/* Case 1: There is no global timer data */
|
||||
|
||||
#elif defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)
|
||||
/* Case 3: Kernel mode of protected kernel build */
|
||||
/* Case 3: Kernel mode of protected kernel build */
|
||||
|
||||
# define __HAVE_KERNEL_GLOBALS 1
|
||||
|
||||
#elif defined(CONFIG_BUILD_KERNEL) && defined(__KERNEL__)
|
||||
/* Case 3: Kernel only build */
|
||||
/* Case 3: Kernel only build */
|
||||
|
||||
# define __HAVE_KERNEL_GLOBALS 1
|
||||
|
||||
|
|
@ -198,6 +199,14 @@ typedef uint64_t systime_t;
|
|||
typedef uint32_t systime_t;
|
||||
#endif
|
||||
|
||||
/* This type used to hold relative ticks that may have negative value */
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TIME64
|
||||
typedef int64_t ssystime_t;
|
||||
#else
|
||||
typedef int32_t ssystime_t;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
|
@ -261,6 +270,37 @@ EXTERN volatile systime_t g_system_timer;
|
|||
void clock_synchronize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: clock_resynchronize
|
||||
*
|
||||
* Description:
|
||||
* Resynchronize the system timer to a hardware RTC. The user can
|
||||
* explicitly re-synchronize the system timer to the RTC under certain
|
||||
* conditions where the system timer is known to be in error. For example,
|
||||
* in certain low-power states, the system timer may be stopped but the
|
||||
* RTC will continue keep correct time. After recovering from such
|
||||
* low-power state, this function should be called to restore the correct
|
||||
* system time. Function also keeps monotonic clock at rate of RTC.
|
||||
*
|
||||
* Calling this function will not result in system time going "backward" in
|
||||
* time. If setting system time with RTC would result time going "backward"
|
||||
* then resynchronization is not performed.
|
||||
*
|
||||
* Parameters:
|
||||
* diff: amount of time system-time is adjusted forward with RTC
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_RTC) && !defined(CONFIG_SCHED_TICKLESS) && \
|
||||
!defined(CONFIG_CLOCK_TIMEKEEPING)
|
||||
void clock_resynchronize(FAR struct timespec *rtc_diff);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: clock_systimer
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue