tao_z
2022-05-31 41f087b7183a5730e46b7eaa322b6852d602babf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/**
  ******************************************************************************
  * @file     xl_rtc.h
  * @author   software group
  * @brief    This file contains all the functions prototypes for the RTC 
  *           firmware library.
  ******************************************************************************
  * @attention
    *
  * 2019 by Chipways Communications,Inc. All Rights Reserved.
  * This software is supplied under the terms of a license
  * agreement or non-disclosure agreement with Chipways.
  * Passing on and copying of this document,and communication
  * of its contents is not permitted without prior written
  * authorization.
  *
  * <h2><center>&copy; COPYRIGHT 2019 Chipways</center></h2>
  ******************************************************************************
  */
    
/* Define to prevent recursive inclusion -------------------------------------*/      
#ifndef __XL_RTC_H_
#define __XL_RTC_H_
 
#ifdef __cplusplus
extern "C"{
#endif
    
/* Includes ---------------------------------------------------------------*/
#include "XL6600.h"
    
/* Register define ------------------------------------------------------------*/
    
/* SC Bit Fields */
#define RTC_SC_RTCEN_MASK                     0x01u
#define RTC_SC_RTCEN_SHIFT                    0
#define RTC_SC_RTCO_MASK                      0x10u
#define RTC_SC_RTCO_SHIFT                     4
#define RTC_SC_RTIE_MASK                      0x40u
#define RTC_SC_RTIE_SHIFT                     6
#define RTC_SC_RTIF_MASK                      0x80u
#define RTC_SC_RTIF_SHIFT                     7
#define RTC_SC_RTCPS_MASK                     0x700u
#define RTC_SC_RTCPS_SHIFT                    8
#define RTC_SC_RTCLKS_MASK                    0xC000u
#define RTC_SC_RTCLKS_SHIFT                   14
    
/* MOD Bit Fields */
#define RTC_MOD_MOD_MASK                      0xFFFFu
#define RTC_MOD_MOD_SHIFT                     0
 
/* CNT Bit Fields */
#define RTC_CNT_CNT_MASK                      0xFFFFu
#define RTC_CNT_CNT_SHIFT                     0
 
/* STAMP CFG Bit Fields */
#define RTC_STAMP_CFG_CNTEN_MASK                      0x01u
#define RTC_STAMP_CFG_CNTEN_SHIFT                     0
 
/* STAMP CNT Bit Fields */
#define RTC_STAMP_CNT_CNTH_MASK                      0x00000000FFFFFFFFu
#define RTC_STAMP_CNT_CNTH_SHIFT                     0
 
#define RTC_STAMP_CNT_CNTL_MASK                      0xFFFFFFFF00000000u
#define RTC_STAMP_CNT_CNTL_SHIFT                     31
 
/** RTC - Register Layout Typedef */
typedef struct {
  __IO uint32_t SC;                                /*!< RTC״̬ºÍ¿ØÖƼĴæÆ÷, offset: 0x0 */
  __IO uint32_t MOD;                               /*!< RTCÄ£Êý¼Ä´æÆ÷, offset: 0x4 */
  __I  uint32_t CNT;                               /*!< RTC¼ÆÊýÆ÷¼Ä´æÆ÷, offset: 0x8 */
       uint32_t RESERVED0[0x39];
  __IO uint32_t STAMP_CFG;                         /*!< STAMPÅäÖüĴæÆ÷, offset: 0xF0 */
       uint32_t RESERVED1;
  __IO uint64_t STAMP_CNT;                         /*!< STAMP¼ÆÊý¼Ä´æÆ÷, offset: 0xF8 */
} RTC_Type, *RTC_MemMapPtr;                            
extern RTC_Type* RTC;    
 
/** @addtogroup XL6600_StdPeriph_Driver  
  * @{
  */
 
/** @addtogroup RTC 
  * @{
  */
 
 
/* Exported types ------------------------------------------------------------*/ 
 
/**
 * @brief RTC ³õʼ»¯½á¹¹Ì嶨Òå
 */
typedef struct 
{    
        uint8_t       RTC_ClkSrc;                                  /*!< ÊµÊ±Ê±ÖÓÔ´Ñ¡Ôñ */
        uint8_t         RTC_ClkPres;                                /*!< ÊµÊ±Ê±ÖÓÔ¤·ÖƵÆ÷Ñ¡Ôñ */
        
}RTC_InitTypeDef, *RTC_MsgConfigPtr;
 
 
/* Exported constants --------------------------------------------------------*/
/** @defgroup RTC_Exported_Constants RTCÄ£¿éʹÓòÎÊý¶¨Òå
  * @{
  */
 
/** @defgroup RTC_Clocks_SourceSelect RTCʱÖÓÔ´Ñ¡Ôñ
  * @{
  */
#define RTC_External_Clock                                    ((uint8_t)0x0)                    /*!< OSCCLK×÷ΪʱÖÓÔ´ */
#define RTC_Realtime_Clock                                    ((uint8_t)0x1)                    /*!< LPOCLK×÷ΪʱÖÓÔ´ */
#define RTC_Internal_Clock                                    ((uint8_t)0x2)                    /*!< ICSIRCLK×÷ΪʱÖÓÔ´ */
#define RTC_Bus_Clock                                        ((uint8_t)0x3)                        /*!< APBCLK×÷ΪʱÖÓÔ´ */
/**
  * @}
  */
 
 
/**
    * @defgroup RTC_Clock_Prescaler_Select RTCʱÖÓ·ÖÆµÑ¡Ôñ
  * @{
  */
#define RTC_Clk_Prescaler_off                            ((uint8_t)0x0)                /*!< ¹Ø±Õ */
#define RTC_Clk_Prescaler_1or128                        ((uint8_t)0x1)                /*!< Èç¹ûRTCLKS=x0£¬ËüΪ1£»Èç¹ûRTCLKS=x1£¬ËüΪ128 */
#define RTC_Clk_Prescaler_2or256                        ((uint8_t)0x2)                /*!< Èç¹ûRTCLKS=x0£¬ËüΪ2£»Èç¹ûRTCLKS=x1£¬ËüΪ256 */
#define RTC_Clk_Prescaler_4or512                        ((uint8_t)0x3)                /*!< Èç¹ûRTCLKS=x0£¬ËüΪ4£»Èç¹ûRTCLKS=x1£¬ËüΪ512 */
#define RTC_Clk_Prescaler_8or1024                        ((uint8_t)0x4)                /*!< Èç¹ûRTCLKS=x0£¬ËüΪ8£»Èç¹ûRTCLKS=x1£¬ËüΪ1024 */
#define RTC_Clk_Prescaler_16or2048                    ((uint8_t)0x5)                /*!< Èç¹ûRTCLKS=x0£¬ËüΪ16£»Èç¹ûRTCLKS=x1£¬ËüΪ2048 */
#define RTC_Clk_Prescaler_32or100                        ((uint8_t)0x6)                /*!< Èç¹ûRTCLKS=x0£¬ËüΪ32£»Èç¹ûRTCLKS=x1£¬ËüΪ100 */
#define RTC_Clk_Prescaler_64or1000                    ((uint8_t)0x7)                /*!< Èç¹ûRTCLKS=x0£¬ËüΪ64£»Èç¹ûRTCLKS=x1£¬ËüΪ1000 */
/**
  * @}
  */
 
 
/**
    * @}
    */
 
 
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ 
void RTC_DeInit(RTC_Type *RTCx);
void RTC_Init(RTC_Type *RTCx, const RTC_InitTypeDef *RTC_InitStruct);
void RTC_InterruptEn(RTC_Type *RTCx,FunctionalState NewState);
void RTC_CountOutputEn(RTC_Type *RTCx,FunctionalState NewState);
ITStatus RTC_GetInterruptFlag(const RTC_Type *RTCx);
void RTC_ClrInterruptFlag(RTC_Type *RTCx);
void RTC_SetModValue(RTC_Type *RTCx,uint16_t RTC_ModValue);
uint16_t RTC_GetCountValue(const RTC_Type *RTCx);
void RTC_EnableCmd(RTC_Type *RTCx, FunctionalState NewState);
void RTC_TimeStampEnableCmd(RTC_Type *RTCx, FunctionalState NewState);
uint64_t RTC_GetStampCountValue(const RTC_Type *RTCx);
#ifdef __cplusplus
}
#endif
#endif     /*__XL_RTC_H__ */
 
/**
  * @}
  */
 
/**
  * @}
  */