MAX32665 SDK Documentation  0.2
Software Development Kit Overview and API Documentation
RTC

Modules

 RTC_Registers
 Registers, Bit Masks and Bit Positions for the RTC Peripheral Module.
 

Enumerations

enum  rtc_sqwave_en_t {
  SQUARE_WAVE_DISABLED,
  SQUARE_WAVE_ENABLED
}
 
enum  rtc_freq_sel_t {
  F_1HZ = MXC_S_RTC_CTRL_FT_FREQ1HZ,
  F_512HZ = MXC_S_RTC_CTRL_FT_FREQ512HZ,
  F_4KHZ = MXC_S_RTC_CTRL_FT_FREQ4KHZ,
  F_32KHZ = 32
}
 
enum  rtc_osc_mode_t {
  NOISE_IMMUNE_MODE = MXC_S_RTC_CTRL_X32KMD_NOISEIMMUNEMODE,
  QUIET_MODE = MXC_S_RTC_CTRL_X32KMD_QUIETMODE,
  QUIET_STOP_WARMUP_MODE = MXC_S_RTC_CTRL_X32KMD_QUIETINSTOPWITHWARMUP,
  QUIET_STOP_NOWARMUP_MODE = MXC_S_RTC_CTRL_X32KMD_QUIETINSTOPNOWARMUP
}
 

Functions

int RTC_EnableTimeofdayInterrupt (mxc_rtc_regs_t *rtc)
 Enables Time-of-Day's Alarm Interrupt. More...
 
int RTC_DisableTimeofdayInterrupt (mxc_rtc_regs_t *rtc)
 Disable Time-of-Day's Alarm Interrupt. More...
 
int RTC_EnableSubsecondInterrupt (mxc_rtc_regs_t *rtc)
 Enables Sub-Second's Alarm Interrupt. More...
 
int RTC_DisableSubsecondInterrupt (mxc_rtc_regs_t *rtc)
 Disable Sub-Second's Alarm Interrupt. More...
 
int RTC_SetTimeofdayAlarm (mxc_rtc_regs_t *rtc, uint32_t ras)
 Set Time-of-Day alarm value and enable Interrupt. More...
 
int RTC_SetSubsecondAlarm (mxc_rtc_regs_t *rtc, uint32_t rssa)
 Set Sub-Second alarm value and enable interrupt,. More...
 
int RTC_EnableRTCE (mxc_rtc_regs_t *rtc)
 Enable/Start the Real Time Clock. More...
 
int RTC_DisableRTCE (mxc_rtc_regs_t *rtc)
 Disable/Stop the Real Time Clock. More...
 
int RTC_Init (mxc_rtc_regs_t *rtc, uint32_t sec, uint16_t ssec, sys_cfg_rtc_t *sys_cfg)
 Initialize the sec and ssec registers and enable RTC. More...
 
int RTC_SquareWave (mxc_rtc_regs_t *rtc, rtc_sqwave_en_t sqe, rtc_freq_sel_t ft, rtc_osc_mode_t x32kmd, const sys_cfg_rtc_t *sys_cfg)
 Allow generation of Square Wave on the SQW pin. More...
 
int RTC_Trim (mxc_rtc_regs_t *rtc, int8_t trm)
 Set Trim register value. More...
 
int RTC_CheckBusy (void)
 Check if BUSY bit is 0. More...
 
int RTC_GetFlags (void)
 Gets Interrupt flags. More...
 
int RTC_ClearFlags (int flags)
 Clear Interrupt flag. More...
 
int RTC_GetSubSecond (void)
 Get SubSecond. More...
 
int RTC_GetSecond (void)
 Get Second. More...
 
int RTC_GetTime (uint32_t *sec, uint32_t *subsec)
 Read seconds, then subseconds, and finally seconds. More...
 

Detailed Description

Enumeration Type Documentation

◆ rtc_sqwave_en_t

Enumerator
SQUARE_WAVE_DISABLED 

Sq.

wave output disabled

SQUARE_WAVE_ENABLED 

Sq.

wave output enabled

◆ rtc_freq_sel_t

Enumerator
F_1HZ 

1Hz (Compensated)

F_512HZ 

512Hz (Compensated)

F_4KHZ 

4Khz

F_32KHZ 

32Khz

Function Documentation

◆ RTC_EnableTimeofdayInterrupt()

int RTC_EnableTimeofdayInterrupt ( mxc_rtc_regs_t rtc)
Parameters
rtcpointer to the rtc register structure
Returns
E_SUCCESS If enable is successful.
E_BAD_STATE If RTC fails.
E_BUSY If RTC is busy.

◆ RTC_DisableTimeofdayInterrupt()

int RTC_DisableTimeofdayInterrupt ( mxc_rtc_regs_t rtc)
Parameters
rtcpointer to the rtc register structure
Returns
E_SUCCESS If function is successful.
E_BAD_STATE If RTC is in a bad state.
E_BUSY If RTC is busy.

◆ RTC_EnableSubsecondInterrupt()

int RTC_EnableSubsecondInterrupt ( mxc_rtc_regs_t rtc)
Parameters
rtcpointer to the rtc register structure
Returns
E_SUCCESS If function is successful.
E_BAD_STATE If RTC is in a bad state.
E_BUSY If RTC is busy.

◆ RTC_DisableSubsecondInterrupt()

int RTC_DisableSubsecondInterrupt ( mxc_rtc_regs_t rtc)
Parameters
rtcpointer to the rtc register structure
Returns
E_SUCCESS If function is successful.
E_BAD_STATE If RTC is in a bad state.
E_BUSY If RTC is busy.

◆ RTC_SetTimeofdayAlarm()

int RTC_SetTimeofdayAlarm ( mxc_rtc_regs_t rtc,
uint32_t  ras 
)
Parameters
rtcpointer to the rtc register structure
ras20-bit value 0-0xFFFFF
Returns
E_SUCCESS If function is successful.
E_BAD_STATE If RTC is in a bad state.
E_BUSY If RTC is busy.

◆ RTC_SetSubsecondAlarm()

int RTC_SetSubsecondAlarm ( mxc_rtc_regs_t rtc,
uint32_t  rssa 
)

this is to be called after the init_rtc() function

Parameters
rtcpointer to the rtc register structure
rssa32-bit value 0-0xFFFFFFFF
Returns
E_SUCCESS If function is successful.
E_BAD_STATE If RTC is in a bad state.
E_BUSY If RTC is busy.

◆ RTC_EnableRTCE()

int RTC_EnableRTCE ( mxc_rtc_regs_t rtc)
Parameters
rtcpointer to the rtc register structure
Returns
E_SUCCESS If function is successful.
E_BUSY If RTC is busy.

◆ RTC_DisableRTCE()

int RTC_DisableRTCE ( mxc_rtc_regs_t rtc)
Parameters
rtcpointer to the rtc register structure
Returns
E_SUCCESS If function is successful.
E_BUSY If RTC is busy.

◆ RTC_Init()

int RTC_Init ( mxc_rtc_regs_t rtc,
uint32_t  sec,
uint16_t  ssec,
sys_cfg_rtc_t *  sys_cfg 
)
Parameters
rtcpointer to the rtc register structure
secset the RTC Sec counter (32-bit)
ssecset the RTC Sub-second counter (8-bit)
sys_cfgSystem configuration object
Returns
E_SUCCESS If function is successful.
E_BUSY If RTC is busy.

◆ RTC_SquareWave()

int RTC_SquareWave ( mxc_rtc_regs_t rtc,
rtc_sqwave_en_t  sqe,
rtc_freq_sel_t  ft,
rtc_osc_mode_t  x32kmd,
const sys_cfg_rtc_t *  sys_cfg 
)
Parameters
rtcpointer to the rtc register structure
sqeEnable/Disable square wave output
ftFrequency output selection
x32kmd32KHz Oscillator mode
sys_cfgThe system configuration
Returns
E_SUCCESS If function is successful.
E_BUSY If RTC is busy.

◆ RTC_Trim()

int RTC_Trim ( mxc_rtc_regs_t rtc,
int8_t  trm 
)
Parameters
rtcpointer to the rtc register structure
trmset the RTC Trim (8-bit, +/- 127)
Returns
E_SUCCESS If function is successful.
E_BUSY If RTC is busy.

◆ RTC_CheckBusy()

int RTC_CheckBusy ( void  )
Returns
E_SUCCESS If function is successful.
E_BUSY If RTC is busy.

◆ RTC_GetFlags()

int RTC_GetFlags ( void  )
Returns
Interrupts flags that have not been cleared

◆ RTC_ClearFlags()

int RTC_ClearFlags ( int  flags)
Parameters
flagsthe flags that need to be cleared

◆ RTC_GetSubSecond()

int RTC_GetSubSecond ( void  )
Returns
Returns subsecond value

◆ RTC_GetSecond()

int RTC_GetSecond ( void  )
Returns
returns Second value

◆ RTC_GetTime()

int RTC_GetTime ( uint32_t *  sec,
uint32_t *  subsec 
)

If RTC ready flag ever gets cleared during this sequence, the RTC is in the middle of updating the counts and the user should come back later and try again. If the first read of the seconds register doesn't match the next read, then a subsecond overflow condition has happened and another attempt to read the counts should be made.

Parameters
secvariable that will be changed to hold second value
subsecvariable that will be changed to hold Subsecond value
Returns
E_SUCCESS If function is successful.
E_BUSY If RTC is busy.