![]() |
NHS31xx SW API
|
The Real-Time Clock (RTC) module has two main features:
Both the counters step on a "tick". A tick consists of a number of TFRO pulses. The TFRO is calibrated during production to run at about 32768 Hz on reset, one tick is typically about 32768 TFRO pulses and thus 1 second. The exact number of TFRO clocks to make 1 second is loaded during boot time and stored in the RTCCAL register. Both the TFRO oscillator and the RTC HW block are part of the always-on power domain.
wait
period. A single wait period can take up to 100us to complete due to hardware synchronization within the module. All functions in this driver make at least one such register access unless stated otherwise. This impacts performance and should be taken into account, especially when calling RTC driver functions in an interrupt context. If an RTC block register read/write preempts another RTC block register read/write, the procedure is repeated leading to another wait
period, until no preemption is detected.Data Structures | |
struct | NSS_RTC_T |
Enumerations | |
enum | RTC_WAKEUPCTRL_T { RTC_WAKEUPCTRL_ENABLE = (1 << 0), RTC_WAKEUPCTRL_AUTO = (1 << 1), RTC_WAKEUPCTRL_START = (1 << 2), RTC_WAKEUPCTRL_DISABLE = 0 } |
enum | RTC_INT_T { RTC_INT_WAKEUP = (1 << 0), RTC_INT_ALL = 0x01, RTC_INT_NONE = 0 } |
Functions | |
void | Chip_RTC_Init (NSS_RTC_T *pRTC) |
void | Chip_RTC_DeInit (NSS_RTC_T *pRTC) |
void | Chip_RTC_SetCalibration (NSS_RTC_T *pRTC, int calibValue) |
int | Chip_RTC_GetCalibration (NSS_RTC_T *pRTC) |
void | Chip_RTC_Wakeup_SetControl (NSS_RTC_T *pRTC, RTC_WAKEUPCTRL_T control) |
RTC_WAKEUPCTRL_T | Chip_RTC_Wakeup_GetControl (NSS_RTC_T *pRTC) |
void | Chip_RTC_Wakeup_SetReload (NSS_RTC_T *pRTC, int ticks) |
int | Chip_RTC_Wakeup_GetReload (NSS_RTC_T *pRTC) |
int | Chip_RTC_Wakeup_GetRemaining (NSS_RTC_T *pRTC) |
bool | Chip_RTC_Wakeup_IsRunning (NSS_RTC_T *pRTC) |
int | Chip_RTC_Time_GetValue (NSS_RTC_T *pRTC) |
void | Chip_RTC_Time_SetValue (NSS_RTC_T *pRTC, int tickValue) |
void | Chip_RTC_Int_SetEnabledMask (NSS_RTC_T *pRTC, RTC_INT_T mask) |
RTC_INT_T | Chip_RTC_Int_GetEnabledMask (NSS_RTC_T *pRTC) |
RTC_INT_T | Chip_RTC_Int_GetRawStatus (NSS_RTC_T *pRTC) |
void | Chip_RTC_Int_ClearRawStatus (NSS_RTC_T *pRTC, RTC_INT_T flags) |
struct NSS_RTC_T |
RTC block register block structure
enum RTC_WAKEUPCTRL_T |
RTC "wake-up down-counter" control. For use with Chip_RTC_Wakeup_SetControl and Chip_RTC_Wakeup_GetControl
Enumerator | |
---|---|
RTC_WAKEUPCTRL_ENABLE | Enables "wake-up down-counter" |
RTC_WAKEUPCTRL_AUTO | Enables the automatic start/restart of the "wake-up down-counter", each time a tick value is written in NSS_RTC_T.SLEEPT with Chip_RTC_Wakeup_SetReload(). |
RTC_WAKEUPCTRL_START | Starts counting of "wake-up down-counter" with tick value loaded with Chip_RTC_Wakeup_SetReload. |
RTC_WAKEUPCTRL_DISABLE | Disables "wake-up down-counter" and stops counting |
enum RTC_INT_T |
void Chip_RTC_Init | ( | NSS_RTC_T * | pRTC | ) |
Enables ARM access to RTC block via APB bus
pRTC | : The base address of the RTC peripheral on the chip |
void Chip_RTC_DeInit | ( | NSS_RTC_T * | pRTC | ) |
Halts the counting of "wake-up down-counter" and disables ARM access to RTC block via APB bus.
This function:
pRTC | : The base address of the RTC peripheral on the chip |
void Chip_RTC_SetCalibration | ( | NSS_RTC_T * | pRTC, |
int | calibValue | ||
) |
Sets the number of TFRO clock pulses in one RTC 'tick'
pRTC | : The base address of the RTC peripheral on the chip |
calibValue | 16-bit value indicating the number of TFRO clock pulses in one tick. |
int Chip_RTC_GetCalibration | ( | NSS_RTC_T * | pRTC | ) |
Returns the number of TFRO clock pulses in one RTC 'tick'
pRTC | : The base address of the RTC peripheral on the chip |
void Chip_RTC_Wakeup_SetControl | ( | NSS_RTC_T * | pRTC, |
RTC_WAKEUPCTRL_T | control | ||
) |
Controls the operation of "wake-up down-counter"
pRTC | : The base address of the RTC peripheral on the chip |
control | : Bitfield of Control Mode of type RTC_WAKEUPCTRL_T |
RTC_WAKEUPCTRL_T Chip_RTC_Wakeup_GetControl | ( | NSS_RTC_T * | pRTC | ) |
Returns the control register of the "wake-up down-counter" operation
pRTC | : The base address of the RTC peripheral on the chip |
void Chip_RTC_Wakeup_SetReload | ( | NSS_RTC_T * | pRTC, |
int | ticks | ||
) |
Sets the "wake-up down-counter" ticks. This tick value is decremented until it reaches zero, and the RTC interrupt is generated, thus a 'wake-up' event
pRTC | : The base address of the RTC peripheral on the chip |
ticks | : 24bit unsigned number of ticks (seconds) to wake-up. Acceptable value from 0 to 16,777,215 |
int Chip_RTC_Wakeup_GetReload | ( | NSS_RTC_T * | pRTC | ) |
Returns the number of "wake-up down-counter" ticks (seconds) previously set by Chip_RTC_Wakeup_SetReload
pRTC | : The base address of the RTC peripheral on the chip |
int Chip_RTC_Wakeup_GetRemaining | ( | NSS_RTC_T * | pRTC | ) |
Returns the remaining ("wake-up down-counter") ticks until 'wake-up' event occurs
pRTC | : The base address of the RTC peripheral on the chip |
bool Chip_RTC_Wakeup_IsRunning | ( | NSS_RTC_T * | pRTC | ) |
Indicates whether or not the "wake-up-down-counter" is in fact running
pRTC | : The base address of the RTC peripheral on the chip |
int Chip_RTC_Time_GetValue | ( | NSS_RTC_T * | pRTC | ) |
Returns the current 'tick' value of the "time up-counter"
pRTC | : The base address of the RTC peripheral on the chip |
void Chip_RTC_Time_SetValue | ( | NSS_RTC_T * | pRTC, |
int | tickValue | ||
) |
Sets a new 'tick' value to the "time up-counter". When using as an epoch, the number of seconds since that epoch can be written to the "time up-counter", so that it maintains the current date/time.
pRTC | : The base address of the RTC peripheral on the chip |
tickValue | tick value to assign to "time up-counter". This value will be type-casted as unsigned 32-bit then applied to HW registers |
Enables/Disables the RTC interrupts.
pRTC | : The base address of the RTC block on the chip |
mask | : Interrupt enabled mask to set |
Retrieves the RTC interrupt enabled mask.
pRTC | : base address of the RTC block on chip. |
Retrieves a bitVector with the RAW RTC interrupt flags
pRTC | : The base address of the RTC peripheral on the chip |
Clears the required RTC interrupt flags.
pRTC | : The base address of the RTC peripheral on the chip |
flags | : Bitvector indicating which interrupt flags to clear |