tao_z
2022-06-01 0ff91e66071237834a1501c78648729c8c32f67a
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/**
  ******************************************************************************
  * @file     xl_ics.h
  * @author   software group
  * @brief    This file contains all the functions prototypes for the ICS 
  *           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_ICS_H_
#define XL_ICS_H_
 
#ifdef __cplusplus
extern "C"{
#endif
/* Includes ---------------------------------------------------------------*/
#include "XL6600.h"
    
/* Register define ------------------------------------------------------------*/
    
/* C1 Bit Fields */
#define ICS_C1_IREFSTEN_MASK                     0x1u
#define ICS_C1_IREFSTEN_SHIFT                    0u
 
#define ICS_C1_IRCLKEN_MASK                      0x2u
#define ICS_C1_IRCLKEN_SHIFT                     1u
 
#define ICS_C1_IREFS_MASK                        0x4u
#define ICS_C1_IREFS_SHIFT                       2u
 
#define ICS_C1_RDIV_MASK                         0x38u
#define ICS_C1_RDIV_SHIFT                        3u
 
#define ICS_C1_CLKS_MASK                         0xC0u
#define ICS_C1_CLKS_SHIFT                        6u
 
/* C2 Bit Fields */
#define ICS_C2_LP_MASK                           0x01u
#define ICS_C2_LP_SHIFT                          0u
 
#define ICS_C2_BDIV_MASK                         0xFEu
#define ICS_C2_BDIV_SHIFT                        1u
 
/* C3 Bit Fields */
#define ICS_C3_SCTRIM_MASK                       0xFFu
#define ICS_C3_SCTRIM_SHIFT                      0u
 
/* C4 Bit Fields */
#define ICS_C4_RDIV2_MASK                        0x1Cu
#define ICS_C4_RDIV2_SHIFT                       2u
 
#define ICS_C4_CME_MASK                          0x20u
#define ICS_C4_CME_SHIFT                         5u
 
#define ICS_C4_FLLSTEN_MASK                      0x40u
#define ICS_C4_FLLSTEN_SHIFT                     6u
 
#define ICS_C4_LOLIE_MASK                        0x80u
#define ICS_C4_LOLIE_SHIFT                       7u
 
/* S Bit Fields */
#define ICS_S_CLKST_MASK                         0xCu
#define ICS_S_CLKST_SHIFT                        2u
 
#define ICS_S_IREFST_MASK                        0x10u
#define ICS_S_IREFST_SHIFT                       4u
 
#define ICS_S_LOCK_MASK                          0x40u
#define ICS_S_LOCK_SHIFT                         6u
 
#define ICS_S_LOLS_MASK                          0x80u
#define ICS_S_LOLS_SHIFT                         7u
 
/* CFG Bit Fields */
#define ICS_CFG_FLLFSEL_MASK                     0x1u
#define ICS_CFG_FLLFSEL_SHIFT                    0u
 
#define ICS_CFG_IRCSEL_MASK                      0x2u
#define ICS_CFG_IRCSEL_SHIFT                     1u
 
#define ICS_CFG_WPROT_MASK                       0xFFFF0000u
#define ICS_CFG_WPROT_SHIFT                      16
 
/** ICS - Register Layout Typedef */
typedef struct {
  __IO uint8_t C1;                                 /*!< ICS¿ØÖƼĴæÆ÷1, offset: 0x0 */
  __IO uint8_t C2;                                 /*!< ICS¿ØÖƼĴæÆ÷2, offset: 0x1 */
  __IO uint8_t C3;                                 /*!< ICS¿ØÖƼĴæÆ÷3, offset: 0x2 */
  __IO uint8_t C4;                                 /*!< ICS¿ØÖƼĴæÆ÷4, offset: 0x3 */
  __IO uint8_t S;                                  /*!< ICS״̬¼Ä´æÆ÷, offset: 0x4 */
         uint8_t RESERVED_0[3];
  __IO uint32_t CFG;                               /*!< ICSʱÖÓÅäÖüĴæÆ÷, offset: 0x8 */    
    __IO uint32_t TRIM_EN;                           /*!< ICSʱÖÓÐÞµ÷ʹÄܼĴæÆ÷, offset: 0xC */
} ICS_Type;
extern ICS_Type* ICS;
 
/** @addtogroup XL6600_StdPeriph_Driver
  * @{
  */
 
/** @addtogroup ICS 
  * @{
  */
 
/* Exported types ------------------------------------------------------------*/ 
 
/* Exported constants --------------------------------------------------------*/
/** @defgroup ICS_Exported_Constants ACMPÄ£¿éʹÓòÎÊý¶¨Òå
  * @{
  */     
 
/** @defgroup Clocks_SourceSelect ClocksʱÖÓÔ´Ñ¡Ôñ
  * @{
  */
#define ICS_CLOCKS_FLL                                   ((uint8_t)0x00)   /*!< Ñ¡ÔñFLLΪʱÖÓÔ´Êä³ö */
#define ICS_CLOCKS_IRC                                   ((uint8_t)0x01)   /*!< Ñ¡ÔñIRCΪʱÖÓÔ´Êä³ö */
#define ICS_CLOCKS_OSC                                   ((uint8_t)0x02)   /*!< Ñ¡ÔñOSCΪʱÖÓÔ´Êä³ö */
#define ICS_CLOCKS_RESERVED                            ((uint8_t)0x03)   /*!< Ê±ÖÓÔ´±£Áô*/
/**
  * @}
  */
 
 
/** @defgroup Clocks_BaseDivider ClocksʱÖÓÔ´»ù×¼·ÖƵ
  * @{
  */
#define ICS_RDIV_1or32                                     ((uint8_t)0x00)   /*!< ÆµÂÊ·¶Î§Îª32kHzµÍƵ·¶Î§£º·ÖƵϵÊýΪ1  £»ÆµÂÊ·¶Î§Îª4-24MHz¸ßƵ·¶Î§£º·ÖƵϵÊýΪ32 */
#define ICS_RDIV_2or64                                   ((uint8_t)0x01)   /*!< ÆµÂÊ·¶Î§Îª32kHzµÍƵ·¶Î§£º·ÖƵϵÊýΪ2  £»ÆµÂÊ·¶Î§Îª4-24MHz¸ßƵ·¶Î§£º·ÖƵϵÊýΪ64 */
#define ICS_RDIV_4or128                               ((uint8_t)0x02)   /*!< ÆµÂÊ·¶Î§Îª32kHzµÍƵ·¶Î§£º·ÖƵϵÊýΪ4  £»ÆµÂÊ·¶Î§Îª4-24MHz¸ßƵ·¶Î§£º·ÖƵϵÊýΪ128 */
#define ICS_RDIV_8or256                                    ((uint8_t)0x03)   /*!< ÆµÂÊ·¶Î§Îª32kHzµÍƵ·¶Î§£º·ÖƵϵÊýΪ8  £»ÆµÂÊ·¶Î§Îª4-24MHz¸ßƵ·¶Î§£º·ÖƵϵÊýΪ256 */
#define ICS_RDIV_16or512                               ((uint8_t)0x04)   /*!< ÆµÂÊ·¶Î§Îª32kHzµÍƵ·¶Î§£º·ÖƵϵÊýΪ16  £»ÆµÂÊ·¶Î§Îª4-24MHz¸ßƵ·¶Î§£º·ÖƵϵÊýΪ512 */
#define ICS_RDIV_32or1024                                ((uint8_t)0x05)   /*!< ÆµÂÊ·¶Î§Îª32kHzµÍƵ·¶Î§£º·ÖƵϵÊýΪ32  £»ÆµÂÊ·¶Î§Îª4-24MHz¸ßƵ·¶Î§£º·ÖƵϵÊýΪ1024 */
#define ICS_RDIV_64                                       ((uint8_t)0x06)   /*!< ÆµÂÊ·¶Î§Îª32kHzµÍƵ·¶Î§£º·ÖƵϵÊýΪ64  £»ÆµÂÊ·¶Î§Îª4-24MHz¸ßƵ·¶Î§£º·ÖƵϵÊýΪ±£Áô */
#define ICS_RDIV_128                                        ((uint8_t)0x07)   /*!< ÆµÂÊ·¶Î§Îª32kHzµÍƵ·¶Î§£º·ÖƵϵÊýΪ128  £»ÆµÂÊ·¶Î§Îª4-24MHz¸ßƵ·¶Î§£º·ÖƵϵÊýΪ±£Áô */                                                     */
/**
  * @}
  */
 
/** @defgroup Clocks_BaseDivider2 ClocksʱÖÓÔ´»ù×¼·ÖƵ
  * @{
  */
#define ICS_RDIV2_1                                      ((uint8_t)0x00)   /*!< 1·ÖƵ */
#define ICS_RDIV2_2                                       ((uint8_t)0x01)   /*!< 2·ÖƵ */
#define ICS_RDIV2_3                                    ((uint8_t)0x02)   /*!< 3·ÖƵ */
#define ICS_RDIV2_4                                        ((uint8_t)0x03)   /*!< 4·ÖƵ */
#define ICS_RDIV2_5                                    ((uint8_t)0x04)   /*!< 5·ÖƵ */
#define ICS_RDIV2_6                                         ((uint8_t)0x05)   /*!< 6·ÖƵ */
#define ICS_RDIV2_7                                    ((uint8_t)0x06)   /*!< 7·ÖƵ */
#define ICS_RDIV2_8                                         ((uint8_t)0x07)   /*!< 8·ÖƵ */
/**
  * @}
  */
 
/** @defgroup FLL_ClocksSourceSelect FLLʱÖÓÔ´Ñ¡Ôñ
  * @{
  */
#define ICS_IREFS_OSC                                     ((uint8_t)0x00)   /*!< Ñ¡ÔñOSCΪFLLʱÖÓÔ´ */
#define ICS_IREFS_IRC                                   ((uint8_t)0x01)   /*!< Ñ¡ÔñIRCΪFLLʱÖÓÔ´ */
/**
  * @}
  */
 
 
/** @defgroup ICS_ClockConfig ÄÚ²¿Ê±ÖÓÔ´Ñ¡Ôñ
  * @{
  */
#define ICS_IRC_50K                                         ((uint8_t)0x00u)   /*!< Ñ¡ÔñÄÚ²¿Ê±ÖÓÔ´IRCƵÂÊΪ50k  */
#define ICS_IRC_37o5K                                   ((uint8_t)0x01u)   /*!< Ñ¡ÔñÄÚ²¿Ê±ÖÓÔ´IRCƵÂÊΪ37.5k  */
/**
  * @}
  */
 
 
/** @defgroup FLL_MultiplierFactor FLL±¶ÆµÏµÊýÑ¡Ôñ
  * @{
  */
#define ICS_FLLFACTOR_1280                             ((uint8_t)0x00)   /*!< Ñ¡Ôñ±¶ÆµÆ÷FLLΪ1280 */
#define ICS_FLLFACTOR_1920                           ((uint8_t)0x01)   /*!< Ñ¡Ôñ±¶ÆµÆ÷FLLΪ1920 */
/**
  * @}
  */
    
/** @defgroup ICS_Status ICS״̬
  * @{
  */
#define ICS_STATUS_LOSINGLOCK                         ((uint8_t)0x80)   /*!< FLLµÄÊ§Ëø×´Ì¬  */
#define ICS_STATUS_LOCK                                   ((uint8_t)0x40)   /*!< FLLµÄËø¶¨×´Ì¬  */
#define ICS_STATUS_IREF                                   ((uint8_t)0x10)   /*!< ÄÚ²¿»ù׼ʱÖÓÀ´Ô´×´Ì¬ */
/**
  * @}
  */    
    
/** @defgroup ICS_ClocksModeStatus Ê±ÖÓģʽ״̬
  * @{
  */
#define ICS_MODE_FLL                                           ((uint8_t)0x00)   /*!< ICSʱÖÓģʽΪFLLÊä³ö  */
#define ICS_MODE_IRC                                           ((uint8_t)0x01)   /*!< ICSʱÖÓģʽΪIRCÊä³ö  */
#define ICS_MODE_OSC                                           ((uint8_t)0x02)   /*!< ICSʱÖÓģʽΪOSCÊä³ö  */
#define ICS_MODE_RESERVED                               ((uint8_t)0x03)   /*!< ICSʱÖÓģʽ±£Áô  */
/**
  * @}
  */
 
/**
  * @}
  */
 
 
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ 
void ICS_DeInit(void);
 
void ICS_ClocksSelect(uint8_t Clksel);
void ICS_BaseDivider(uint8_t RDiv);
void ICS_BaseDivider2(uint8_t RDiv2);
void ICS_IREFSSelect(uint8_t FllSel);
void ICS_IRCEnableCmd(FunctionalState State);
void ICS_IREFStopEnableCmd(FunctionalState State);
void ICS_BusDivder(uint8_t BDiv);
uint8_t ICS_GetBusDivder(void);
void ICS_FllLPModeStopEnableCmd(FunctionalState State);
void ICS_LosingLockIntEnableCmd(FunctionalState State);
void ICS_FllStopModeCloseEnableCmd(FunctionalState State);
void ICS_ClockMonitorEnableCmd(FunctionalState State);
void ICS_IRCSelect(uint8_t IRCValue);
void ICS_FllFactorSelect(uint8_t FactorValue);
uint8_t ICS_GetStatus(uint8_t ICSStatus);
uint8_t ICS_GetClockMode(void);
uint8_t ICS_GetIRCFre(void);
uint8_t ICS_GetIREFSSelect(void);
uint8_t ICS_GetFLLMultiple(void);
uint8_t ICS_GetBaseDivider(void);
uint8_t ICS_GetBaseDivider2(void);
#ifdef __cplusplus
}
#endif
    
#endif 
 
/**
  * @}
  */
 
/**
  * @}
  */