![]() |
MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The MCUXpresso SDK provides a driver for the Real Time Clock (RTC) of MCUXpresso SDK devices.
The RTC driver supports operating the module as a time counter.
The function RTC_Init() initializes the RTC with specified configurations. The function RTC_GetDefaultConfig() gets the default configurations.
The function RTC_Deinit() disables the RTC timer and disables the module clock.
The function RTC_GetCounter() reads the current counter.
The function RTC_SetAlarm() sets the alarm counter. When the RTC counter reaches the value of alarm counter, the alarm interrupt may occur.
The function RTC_GetAlarm() reads the alarm counter.
The function RTC_StartTimer() starts the RTC time counter.
The function RTC_StopTimer() stops the RTC time counter.
The function RTC_ResetTimer() resets the RTC time counter.
Provides functions to get and clear the RTC status.
Provides functions to enable/disable RTC interrupts and get current enabled interrupts.
Example to set the RTC current time and trigger an alarm. Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/rtc
Data Structures | |
struct | rtc_config_t |
RTC config structure. More... | |
Enumerations | |
enum | rtc_interrupt_enable_t { kRTC_AlarmInterruptEnable = (1U << 15U), kRTC_TimeOverflowInterruptEnable = (1U << 16U), kRTC_AllInterruptsEnable = (3U << 15U) } |
List of RTC interrupts. More... | |
enum | rtc_status_flags_t { kRTC_CntRunFlag = (1U << 0U), kRTC_CntRstDoneFlag = (1U << 1U), kRTC_ResetFlag = (1U << 2U), kRTC_AlarmFlag = (1U << 15U), kRTC_TimeOverflowFlag = (1U << 16U), kRTC_AllNonClearableFlags = (7U << 0U), kRTC_AllClearableFlags = (3U << 15U) } |
List of RTC flags. More... | |
enum | rtc_clock_div_t { kRTC_ClockDiv1 = 0U, kRTC_ClockDiv2 = 1U, kRTC_ClockDiv4 = 2U, kRTC_ClockDiv8 = 3U, kRTC_ClockDiv16 = 4U, kRTC_ClockDiv32 = 5U, kRTC_ClockDiv64 = 6U, kRTC_ClockDiv128 = 7U, kRTC_ClockDiv256 = 8U, kRTC_ClockDiv512 = 9U, kRTC_ClockDiv1024 = 10U, kRTC_ClockDiv2048 = 11U, kRTC_ClockDiv4096 = 12U, kRTC_ClockDiv8192 = 13U, kRTC_ClockDiv16384 = 14U, kRTC_ClockDiv32768 = 15U } |
List of clock divider. More... | |
Driver version | |
#define | FSL_RTC_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
Version 2.0.0. | |
Initialization and deinitialization | |
void | RTC_Init (RTC_Type *base, const rtc_config_t *config) |
Ungates the RTC clock and configures the peripheral for basic operation. More... | |
void | RTC_Deinit (RTC_Type *base) |
Stops the timer and gate the RTC clock. More... | |
void | RTC_GetDefaultConfig (rtc_config_t *config) |
Fills in the RTC config struct with the default settings. More... | |
Current Time & Alarm | |
uint32_t | RTC_GetCounter (RTC_Type *base) |
Gets current RTC counter value. More... | |
status_t | RTC_SetAlarm (RTC_Type *base, uint32_t alarmCnt) |
Sets the RTC alarm time. More... | |
uint32_t | RTC_GetAlarm (RTC_Type *base) |
Returns the RTC alarm counter value. More... | |
Interrupt Interface | |
void | RTC_EnableInterrupts (RTC_Type *base, uint32_t mask) |
Enables the selected RTC interrupts. More... | |
void | RTC_DisableInterrupts (RTC_Type *base, uint32_t mask) |
Disables the selected RTC interrupts. More... | |
uint32_t | RTC_GetEnabledInterrupts (RTC_Type *base) |
Gets the enabled RTC interrupts. More... | |
Status Interface | |
uint32_t | RTC_GetStatusFlags (RTC_Type *base) |
Gets the RTC status flags. More... | |
void | RTC_ClearStatusFlags (RTC_Type *base, uint32_t mask) |
Clears the RTC status flags. More... | |
Timer Start and Stop | |
void | RTC_StartTimer (RTC_Type *base) |
Starts the RTC time counter. More... | |
void | RTC_StopTimer (RTC_Type *base) |
Stops the RTC time counter. More... | |
void | RTC_ResetTimer (RTC_Type *base) |
Performs a counter reset on the RTC module. More... | |
struct rtc_config_t |
This structure holds the configuration settings for the RTC peripheral. To initialize this structure to reasonable defaults, call the RTC_GetDefaultConfig() function and pass a pointer to your config structure instance.
The config struct can be made const so it resides in flash
Data Fields | |
bool | ignoreInRunning |
true: If the counter is already running, the configuration will be ignored. More... | |
bool | autoUpdateCntVal |
true: CNT_VAL is updated on every counter clock tick. More... | |
bool | stopCntInDebug |
true: In debug mode, stop the counters. More... | |
rtc_clock_div_t | clkDiv |
Counter clock divider. More... | |
uint32_t | cntUppVal |
If counter reaches this value, the counter will overflow to 0. More... | |
bool rtc_config_t::ignoreInRunning |
false: Counter will always be reset and the the configurations will always be set.
bool rtc_config_t::autoUpdateCntVal |
false: CNT_VAL is not updated.
bool rtc_config_t::stopCntInDebug |
false: In debug mode, counters are not affected.
rtc_clock_div_t rtc_config_t::clkDiv |
uint32_t rtc_config_t::cntUppVal |
enum rtc_status_flags_t |
enum rtc_clock_div_t |
void RTC_Init | ( | RTC_Type * | base, |
const rtc_config_t * | config | ||
) |
This function configures the RTC only if the counter is not running.
base | RTC peripheral base address |
config | Pointer to the user's RTC configuration structure. |
void RTC_Deinit | ( | RTC_Type * | base | ) |
base | RTC peripheral base address |
void RTC_GetDefaultConfig | ( | rtc_config_t * | config | ) |
The default values are as follows.
config | Pointer to the user's RTC configuration structure. |
uint32_t RTC_GetCounter | ( | RTC_Type * | base | ) |
base | RTC peripheral base address |
status_t RTC_SetAlarm | ( | RTC_Type * | base, |
uint32_t | alarmCnt | ||
) |
The function checks whether the specified alarm time is greater than the present time. If not, the function does not set the alarm and returns an error.
base | RTC peripheral base address |
alarmCnt | Counter value to trigger the alarm. |
uint32_t RTC_GetAlarm | ( | RTC_Type * | base | ) |
base | RTC peripheral base address |
void RTC_EnableInterrupts | ( | RTC_Type * | base, |
uint32_t | mask | ||
) |
base | RTC peripheral base address |
mask | The interrupts to enable. This is a logical OR of members of the enumeration rtc_interrupt_enable_t |
void RTC_DisableInterrupts | ( | RTC_Type * | base, |
uint32_t | mask | ||
) |
base | RTC peripheral base address |
mask | The interrupts to enable. This is a logical OR of members of the enumeration rtc_interrupt_enable_t |
uint32_t RTC_GetEnabledInterrupts | ( | RTC_Type * | base | ) |
base | RTC peripheral base address |
uint32_t RTC_GetStatusFlags | ( | RTC_Type * | base | ) |
base | RTC peripheral base address |
void RTC_ClearStatusFlags | ( | RTC_Type * | base, |
uint32_t | mask | ||
) |
base | RTC peripheral base address |
mask | The status flags to clear. This is a logical OR of members of the enumeration rtc_status_flags_t |
void RTC_StartTimer | ( | RTC_Type * | base | ) |
base | RTC peripheral base address |
void RTC_StopTimer | ( | RTC_Type * | base | ) |
base | RTC peripheral base address |
void RTC_ResetTimer | ( | RTC_Type * | base | ) |
base | RTC peripheral base address |