MAX32665 SDK Documentation  0.2
Software Development Kit Overview and API Documentation
rtc.h
1 
6 /* ****************************************************************************
7  * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
23  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * Except as contained in this notice, the name of Maxim Integrated
28  * Products, Inc. shall not be used except as stated in the Maxim Integrated
29  * Products, Inc. Branding Policy.
30  *
31  * The mere transfer of this software does not imply any licenses
32  * of trade secrets, proprietary technology, copyrights, patents,
33  * trademarks, maskwork rights, or any other form of intellectual
34  * property whatsoever. Maxim Integrated Products, Inc. retains all
35  * ownership rights.
36  *
37  *
38  * $Date: 2019-07-18 14:30:02 -0500 (Thu, 18 Jul 2019) $
39  * $Revision: 44725 $
40  *************************************************************************** */
41 
42 /* Define to prevent redundant inclusion */
43 #ifndef _RTC_H_
44 #define _RTC_H_
45 
46 /* **** Includes **** */
47 #include <stdint.h>
48 #include "mxc_config.h"
49 #include "rtc_regs.h"
50 #include "mxc_sys.h"
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
62 /* **** Definitions **** */
63 
64 typedef enum {
68 
69 typedef enum {
73  F_32KHZ = 32,
75 
76 typedef enum {
77  NOISE_IMMUNE_MODE = MXC_S_RTC_CTRL_X32KMD_NOISEIMMUNEMODE,
79  QUIET_STOP_WARMUP_MODE = MXC_S_RTC_CTRL_X32KMD_QUIETINSTOPWITHWARMUP,
80  QUIET_STOP_NOWARMUP_MODE = MXC_S_RTC_CTRL_X32KMD_QUIETINSTOPNOWARMUP,
81 } rtc_osc_mode_t;
82 
91 
100 
109 
118 
127 int RTC_SetTimeofdayAlarm(mxc_rtc_regs_t *rtc, uint32_t ras);
128 
138 int RTC_SetSubsecondAlarm(mxc_rtc_regs_t *rtc, uint32_t rssa);
139 
147 
155 
165 int RTC_Init(mxc_rtc_regs_t *rtc, uint32_t sec, uint16_t ssec, sys_cfg_rtc_t *sys_cfg);
166 
177 int RTC_SquareWave(mxc_rtc_regs_t *rtc, rtc_sqwave_en_t sqe, rtc_freq_sel_t ft,
178  rtc_osc_mode_t x32kmd, const sys_cfg_rtc_t* sys_cfg);
179 
187 int RTC_Trim(mxc_rtc_regs_t *rtc, int8_t trm);
188 
194 int RTC_CheckBusy(void);
195 
200 int RTC_GetFlags(void);
201 
206 int RTC_ClearFlags(int flags);
207 
212 int RTC_GetSubSecond(void);
213 
218 int RTC_GetSecond(void);
219 
230 int RTC_GetTime(uint32_t* sec, uint32_t* subsec);
231 
232 #ifdef __cplusplus
233 }
234 #endif
235 
237 #endif /* _RTC_H_ */
int RTC_EnableRTCE(mxc_rtc_regs_t *rtc)
Enable/Start the Real Time Clock.
4Khz
Definition: rtc.h:72
int RTC_SetSubsecondAlarm(mxc_rtc_regs_t *rtc, uint32_t rssa)
Set Sub-Second alarm value and enable interrupt,.
#define MXC_S_RTC_CTRL_X32KMD_NOISEIMMUNEMODE
CTRL_X32KMD_NOISEIMMUNEMODE Setting.
Definition: rtc_regs.h:196
int RTC_EnableSubsecondInterrupt(mxc_rtc_regs_t *rtc)
Enables Sub-Second&#39;s Alarm Interrupt.
int RTC_GetFlags(void)
Gets Interrupt flags.
int RTC_DisableTimeofdayInterrupt(mxc_rtc_regs_t *rtc)
Disable Time-of-Day&#39;s Alarm Interrupt.
1Hz (Compensated)
Definition: rtc.h:70
#define MXC_S_RTC_CTRL_X32KMD_QUIETINSTOPNOWARMUP
CTRL_X32KMD_QUIETINSTOPNOWARMUP Setting.
Definition: rtc_regs.h:202
int RTC_SetTimeofdayAlarm(mxc_rtc_regs_t *rtc, uint32_t ras)
Set Time-of-Day alarm value and enable Interrupt.
#define MXC_S_RTC_CTRL_FT_FREQ512HZ
CTRL_FT_FREQ512HZ Setting.
Definition: rtc_regs.h:187
Structure type to access the RTC Registers.
Definition: rtc_regs.h:88
int RTC_CheckBusy(void)
Check if BUSY bit is 0.
int RTC_ClearFlags(int flags)
Clear Interrupt flag.
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.
int RTC_GetTime(uint32_t *sec, uint32_t *subsec)
Read seconds, then subseconds, and finally seconds.
int RTC_GetSecond(void)
Get Second.
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.
#define MXC_S_RTC_CTRL_FT_FREQ4KHZ
CTRL_FT_FREQ4KHZ Setting.
Definition: rtc_regs.h:189
512Hz (Compensated)
Definition: rtc.h:71
int RTC_GetSubSecond(void)
Get SubSecond.
rtc_sqwave_en_t
Definition: rtc.h:64
int RTC_Trim(mxc_rtc_regs_t *rtc, int8_t trm)
Set Trim register value.
#define MXC_S_RTC_CTRL_X32KMD_QUIETINSTOPWITHWARMUP
CTRL_X32KMD_QUIETINSTOPWITHWARMUP Setting.
Definition: rtc_regs.h:200
Sq.
Definition: rtc.h:66
int RTC_DisableSubsecondInterrupt(mxc_rtc_regs_t *rtc)
Disable Sub-Second&#39;s Alarm Interrupt.
#define MXC_S_RTC_CTRL_FT_FREQ1HZ
CTRL_FT_FREQ1HZ Setting.
Definition: rtc_regs.h:185
32Khz
Definition: rtc.h:73
#define MXC_S_RTC_CTRL_X32KMD_QUIETMODE
CTRL_X32KMD_QUIETMODE Setting.
Definition: rtc_regs.h:198
int RTC_DisableRTCE(mxc_rtc_regs_t *rtc)
Disable/Stop the Real Time Clock.
rtc_freq_sel_t
Definition: rtc.h:69
Sq.
Definition: rtc.h:65
int RTC_EnableTimeofdayInterrupt(mxc_rtc_regs_t *rtc)
Enables Time-of-Day&#39;s Alarm Interrupt.