1 /***************************************************************************//**
2 * @file
3 * @brief System API
4 *******************************************************************************
5 * # License
6 * <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
7 *******************************************************************************
8 *
9 * SPDX-License-Identifier: Zlib
10 *
11 * The licensor of this software is Silicon Laboratories Inc.
12 *
13 * This software is provided 'as-is', without any express or implied
14 * warranty. In no event will the authors be held liable for any damages
15 * arising from the use of this software.
16 *
17 * Permission is granted to anyone to use this software for any purpose,
18 * including commercial applications, and to alter it and redistribute it
19 * freely, subject to the following restrictions:
20 *
21 * 1. The origin of this software must not be misrepresented; you must not
22 * claim that you wrote the original software. If you use this software
23 * in a product, an acknowledgment in the product documentation would be
24 * appreciated but is not required.
25 * 2. Altered source versions must be plainly marked as such, and must not be
26 * misrepresented as being the original software.
27 * 3. This notice may not be removed or altered from any source distribution.
28 *
29 ******************************************************************************/
30
31 #ifndef EM_SYSTEM_H
32 #define EM_SYSTEM_H
33
34 #include <stdbool.h>
35 #include "em_device.h"
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 /***************************************************************************//**
42 * @addtogroup system SYSTEM - System Utils
43 * @brief System API
44 * @details
45 * This module contains functions to read information such as RAM and Flash size,
46 * device unique ID, chip revision, family, and part number from DEVINFO and
47 * SCB blocks. Functions to configure and read status from FPU are available for
48 * compatible devices.
49 * @{
50 ******************************************************************************/
51
52 /*******************************************************************************
53 ******************************** ENUMS ************************************
54 ******************************************************************************/
55
56 /** Family identifiers. */
57 typedef enum {
58 /* New style family #defines */
59 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32G)
60 systemPartFamilyEfm32Gecko = _DEVINFO_PART_DEVICE_FAMILY_EFM32G, /**< EFM32 Gecko Device Family. */
61 #endif
62 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32GG)
63 systemPartFamilyEfm32Giant = _DEVINFO_PART_DEVICE_FAMILY_EFM32GG, /**< EFM32 Giant Gecko Series 0 Device Family. */
64 #endif
65 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32GG11B)
66 systemPartFamilyEfm32Giant11B = _DEVINFO_PART_DEVICE_FAMILY_EFM32GG11B, /**< EFM32 Giant Gecko Series 1 Configuration 1 Basic Device Family. */
67 #endif
68 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32GG12B)
69 systemPartFamilyEfm32Giant12B = _DEVINFO_PART_DEVICE_FAMILY_EFM32GG12B, /**< EFM32 Giant Gecko Series 1 Configuration 2 Basic Device Family. */
70 #endif
71 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32TG)
72 systemPartFamilyEfm32Tiny = _DEVINFO_PART_DEVICE_FAMILY_EFM32TG, /**< EFM32 Tiny Gecko Device Family. */
73 #endif
74 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32TG11B)
75 systemPartFamilyEfm32Tiny11B = _DEVINFO_PART_DEVICE_FAMILY_EFM32TG11B, /**< EFM32 Tiny Gecko 11 Device Family. */
76 #endif
77 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32LG)
78 systemPartFamilyEfm32Leopard = _DEVINFO_PART_DEVICE_FAMILY_EFM32LG, /**< EFM32 Leopard Gecko Device Family. */
79 #endif
80 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32WG)
81 systemPartFamilyEfm32Wonder = _DEVINFO_PART_DEVICE_FAMILY_EFM32WG, /**< EFM32 Wonder Gecko Device Family. */
82 #endif
83 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32ZG)
84 systemPartFamilyEfm32Zero = _DEVINFO_PART_DEVICE_FAMILY_EFM32ZG, /**< EFM32 Zero Gecko Device Family. */
85 #endif
86 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32HG)
87 systemPartFamilyEfm32Happy = _DEVINFO_PART_DEVICE_FAMILY_EFM32HG, /**< EFM32 Happy Gecko Device Family. */
88 #endif
89 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32PG1B)
90 systemPartFamilyEfm32Pearl1B = _DEVINFO_PART_DEVICE_FAMILY_EFM32PG1B, /**< EFM32 Pearl Gecko Series 1 Configuration 1 Basic Device Family. */
91 #endif
92 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32JG1B)
93 systemPartFamilyEfm32Jade1B = _DEVINFO_PART_DEVICE_FAMILY_EFM32JG1B, /**< EFM32 Jade Gecko Series 1 Configuration 1 Basic Device Family. */
94 #endif
95 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32PG12B)
96 systemPartFamilyEfm32Pearl12B = _DEVINFO_PART_DEVICE_FAMILY_EFM32PG12B, /**< EFM32 Pearl Gecko Series 1 Configuration 2 Basic Device Family. */
97 #endif
98 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32JG12B)
99 systemPartFamilyEfm32Jade12B = _DEVINFO_PART_DEVICE_FAMILY_EFM32JG12B, /**< EFM32 Jade Gecko Series 1 Configuration 2 Basic Device Family. */
100 #endif
101 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EZR32WG)
102 systemPartFamilyEzr32Wonder = _DEVINFO_PART_DEVICE_FAMILY_EZR32WG, /**< EZR32 Wonder Device Family. */
103 #endif
104 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EZR32LG)
105 systemPartFamilyEzr32Leopard = _DEVINFO_PART_DEVICE_FAMILY_EZR32LG, /**< EZR32 Leopard Device Family. */
106 #endif
107 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EZR32HG)
108 systemPartFamilyEzr32Happy = _DEVINFO_PART_DEVICE_FAMILY_EZR32HG, /**< EZR32 Happy Device Family. */
109 #endif
110 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG1P)
111 systemPartFamilyMighty1P = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG1P, /**< EFR32 Mighty Gecko Series 1 Configuration 1 Premium Device Family. */
112 #endif
113 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG1B)
114 systemPartFamilyMighty1B = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG1B, /**< EFR32 Mighty Gecko Series 1 Configuration 1 Basic Device Family. */
115 #endif
116 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG1V)
117 systemPartFamilyMighty1V = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG1V, /**< EFR32 Mighty Gecko Series 1 Configuration 1 Value Device Family. */
118 #endif
119 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG1P)
120 systemPartFamilyBlue1P = _DEVINFO_PART_DEVICE_FAMILY_EFR32BG1P, /**< EFR32 Blue Gecko Series 1 Configuration 1 Premium Device Family. */
121 #endif
122 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG1B)
123 systemPartFamilyBlue1B = _DEVINFO_PART_DEVICE_FAMILY_EFR32BG1B, /**< EFR32 Blue Gecko Series 1 Configuration 1 Basic Device Family. */
124 #endif
125 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG1V)
126 systemPartFamilyBlue1V = _DEVINFO_PART_DEVICE_FAMILY_EFR32BG1V, /**< EFR32 Blue Gecko Series 1 Configuration 1 Value Device Family. */
127 #endif
128 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG1P)
129 systemPartFamilyFlex1P = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG1P, /**< EFR32 Flex Gecko Series 1 Configuration 1 Premium Device Family. */
130 #endif
131 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG1B)
132 systemPartFamilyFlex1B = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG1B, /**< EFR32 Flex Gecko Series 1 Configuration 1 Basic Device Family. */
133 #endif
134 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG1V)
135 systemPartFamilyFlex1V = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG1V, /**< EFR32 Flex Gecko Series 1 Configuration 1 Value Device Family. */
136 #endif
137 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG12P)
138 systemPartFamilyMighty12P = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG12P, /**< EFR32 Mighty Gecko Series 1 Configuration 2 Premium Device Family. */
139 #endif
140 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG12B)
141 systemPartFamilyMighty12B = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG12B, /**< EFR32 Mighty Gecko Series 1 Configuration 2 Basic Device Family. */
142 #endif
143 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG12V)
144 systemPartFamilyMighty12V = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG12V, /**< EFR32 Mighty Gecko Series 1 Configuration 2 Value Device Family. */
145 #endif
146 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG12P)
147 systemPartFamilyBlue12P = _DEVINFO_PART_DEVICE_FAMILY_EFR32BG12P, /**< EFR32 Blue Gecko Series 1 Configuration 2 Premium Device Family. */
148 #endif
149 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG12B)
150 systemPartFamilyBlue12B = _DEVINFO_PART_DEVICE_FAMILY_EFR32BG12B, /**< EFR32 Blue Gecko Series 1 Configuration 2 Basic Device Family. */
151 #endif
152 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG12V)
153 systemPartFamilyBlue12V = _DEVINFO_PART_DEVICE_FAMILY_EFR32BG12V, /**< EFR32 Blue Gecko Series 1 Configuration 2 Value Device Family. */
154 #endif
155 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG12P)
156 systemPartFamilyFlex12P = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG12P, /**< EFR32 Flex Gecko Series 1 Configuration 2 Premium Device Family. */
157 #endif
158 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG12B)
159 systemPartFamilyFlex12B = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG12B, /**< EFR32 Flex Gecko Series 1 Configuration 2 Basic Device Family. */
160 #endif
161 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG12V)
162 systemPartFamilyFlex12V = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG12V, /**< EFR32 Flex Gecko Series 1 Configuration 2 Value Device Family. */
163 #endif
164 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG13P)
165 systemPartFamilyMighty13P = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG13P, /**< EFR32 Mighty Gecko Series 1 Configuration 3 Premium Device Family. */
166 #endif
167 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG13B)
168 systemPartFamilyMighty13B = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG13B, /**< EFR32 Mighty Gecko Series 1 Configuration 3 Basic Device Family. */
169 #endif
170 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG13V)
171 systemPartFamilyMighty13V = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG13V, /**< EFR32 Mighty Gecko Series 1 Configuration 3 Value Device Family. */
172 #endif
173 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG13P)
174 systemPartFamilyBlue13P = _DEVINFO_PART_DEVICE_FAMILY_EFR32BG13P, /**< EFR32 Blue Gecko Series 1 Configuration 3 Premium Device Family. */
175 #endif
176 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG13B)
177 systemPartFamilyBlue13B = _DEVINFO_PART_DEVICE_FAMILY_EFR32BG13B, /**< EFR32 Blue Gecko Series 1 Configuration 3 Basic Device Family. */
178 #endif
179 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG13V)
180 systemPartFamilyBlue13V = _DEVINFO_PART_DEVICE_FAMILY_EFR32BG13V, /**< EFR32 Blue Gecko Series 1 Configuration 3 Value Device Family. */
181 #endif
182 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG13P)
183 systemPartFamilyFlex13P = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG13P, /**< EFR32 Flex Gecko Series 1 Configuration 3 Premium Device Family. */
184 #endif
185 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG13B)
186 systemPartFamilyFlex13B = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG13B, /**< EFR32 Flex Gecko Series 1 Configuration 3 Basic Device Family. */
187 #endif
188 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG13V)
189 systemPartFamilyFlex13V = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG13V, /**< EFR32 Flex Gecko Series 1 Configuration 3 Value Device Family. */
190 #endif
191 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32ZG13P)
192 systemPartFamilyZen13P = _DEVINFO_PART_DEVICE_FAMILY_EFR32ZG13P, /**< EFR32 Zen Gecko Series 1 Configuration 3 Premium Device Family. */
193 #endif
194 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32ZG13L)
195 systemPartFamilyZen13L = _DEVINFO_PART_DEVICE_FAMILY_EFR32ZG13L, /**< EFR32 Zen Gecko Series 1 Configuration 3 Led Device Family. */
196 #endif
197 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32ZG13S)
198 systemPartFamilyZen13S = _DEVINFO_PART_DEVICE_FAMILY_EFR32ZG13S, /**< EFR32 Zen Gecko Series 1 Configuration 3 Sensor Device Family. */
199 #endif
200 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG14P)
201 systemPartFamilyMighty14P = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG14P, /**< EFR32 Mighty Gecko Series 1 Configuration 4 Premium Device Family. */
202 #endif
203 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG14B)
204 systemPartFamilyMighty14B = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG14B, /**< EFR32 Mighty Gecko Series 1 Configuration 4 Basic Device Family. */
205 #endif
206 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG14V)
207 systemPartFamilyMighty14V = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG14V, /**< EFR32 Mighty Gecko Series 1 Configuration 4 Value Device Family. */
208 #endif
209 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG14P)
210 systemPartFamilyFlex14P = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG14P, /**< EFR32 Flex Gecko Series 1 Configuration 4 Premium Device Family. */
211 #endif
212 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG14B)
213 systemPartFamilyFlex14B = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG14B, /**< EFR32 Flex Gecko Series 1 Configuration 4 Basic Device Family. */
214 #endif
215 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG14V)
216 systemPartFamilyFlex14V = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG14V, /**< EFR32 Flex Gecko Series 1 Configuration 4 Value Device Family. */
217 #endif
218 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32ZG14P)
219 systemPartFamilyZen14P = _DEVINFO_PART_DEVICE_FAMILY_EFR32ZG14P, /**< EFR32 Zen Gecko Series 1 Configuration 4 Premium Device Family. */
220 #endif
221 #if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_1)
222 systemPartFamilyMighty21 = DEVINFO_PART_FAMILY_MG | (21 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Mighty Gecko Series 2 Config 1 Value Device Family */
223 systemPartFamilyFlex21 = DEVINFO_PART_FAMILY_FG | (21 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Flex Gecko Series 2 Config 1 Value Device Family */
224 systemPartFamilyBlue21 = DEVINFO_PART_FAMILY_BG | (21 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Blue Gecko Series 2 Config 1 Value Device Family */
225 systemPartFamilyMightyRcp21 = DEVINFO_PART_FAMILY_MR | (21 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Mighty RCP Series 2 Config 1 Value Device Family */
226 #endif
227 #if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_2)
228 systemPartFamilyMighty22 = DEVINFO_PART_FAMILY_MG | (22 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Mighty Gecko Series 2 Config 2 Value Device Family */
229 systemPartFamilyFlex22 = DEVINFO_PART_FAMILY_FG | (22 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Flex Gecko Series 2 Config 2 Value Device Family */
230 systemPartFamilyBlue22 = DEVINFO_PART_FAMILY_BG | (22 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Blue Gecko Series 2 Config 2 Value Device Family */
231 systemPartFamilyEfm32Pearl22 = DEVINFO_PART_FAMILY_PG | (22 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFM32 Pearl Gecko Series 2 Config 2 Value Device Family */
232 #endif
233 #if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_3)
234 systemPartFamilyFlex23 = DEVINFO_PART_FAMILY_FG | (23 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Flex Gecko Series 2 Config 3 Value Device Family */
235 systemPartFamilyZen23 = DEVINFO_PART_FAMILY_ZG | (23 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Zen Gecko Series 2 Config 3 Value Device Family */
236 systemPartFamilyEfm32Pearl23 = DEVINFO_PART_FAMILY_PG | (23 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFM32 Pearl Gecko Series 2 Config 3 Value Device Family */
237 #endif
238 #if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_4)
239 systemPartFamilyMighty24 = DEVINFO_PART_FAMILY_MG | (24 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Mighty Gecko Series 2 Config 4 Value Device Family */
240 systemPartFamilyFlex24 = DEVINFO_PART_FAMILY_FG | (24 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Flex Gecko Series 2 Config 4 Value Device Family */
241 systemPartFamilyBlue24 = DEVINFO_PART_FAMILY_BG | (24 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Blue Gecko Series 2 Config 4 Value Device Family */
242 #endif
243 #if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_5)
244 systemPartFamilyFlex25 = DEVINFO_PART_FAMILY_FG | (25 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Flex Gecko Series 2 Config 5 Value Device Family */
245 #endif
246 #if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_7)
247 systemPartFamilyMighty27 = DEVINFO_PART_FAMILY_MG | (27 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Mighty Gecko Series 2 Config 7 Value Device Family */
248 systemPartFamilyBlue27 = DEVINFO_PART_FAMILY_BG | (27 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Blue Gecko Series 2 Config 7 Value Device Family */
249 #endif
250 #if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_8)
251 systemPartFamilyFlex28 = DEVINFO_PART_FAMILY_FG | (28 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Flex Gecko Series 2 Config 8 Value Device Family */
252 systemPartFamilyZen28 = DEVINFO_PART_FAMILY_ZG | (28 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Zen Gecko Series 2 Config 8 Value Device Family */
253 systemPartFamilyPerl28 = DEVINFO_PART_FAMILY_PG | (28 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Perl Gecko Series 2 Config 8 Value Device Family */
254 #endif
255 /* Deprecated family #defines */
256 #if defined(_DEVINFO_PART_DEVICE_FAMILY_G)
257 systemPartFamilyGecko = _DEVINFO_PART_DEVICE_FAMILY_G, /**< Gecko Device Family. */
258 #endif
259 #if defined(_DEVINFO_PART_DEVICE_FAMILY_GG)
260 systemPartFamilyGiant = _DEVINFO_PART_DEVICE_FAMILY_GG, /**< Giant Gecko Device Family. */
261 #endif
262 #if defined(_DEVINFO_PART_DEVICE_FAMILY_TG)
263 systemPartFamilyTiny = _DEVINFO_PART_DEVICE_FAMILY_TG, /**< Tiny Gecko Device Family. */
264 #endif
265 #if defined(_DEVINFO_PART_DEVICE_FAMILY_LG)
266 systemPartFamilyLeopard = _DEVINFO_PART_DEVICE_FAMILY_LG, /**< Leopard Gecko Device Family. */
267 #endif
268 #if defined(_DEVINFO_PART_DEVICE_FAMILY_WG)
269 systemPartFamilyWonder = _DEVINFO_PART_DEVICE_FAMILY_WG, /**< Wonder Gecko Device Family. */
270 #endif
271 #if defined(_DEVINFO_PART_DEVICE_FAMILY_ZG)
272 systemPartFamilyZero = _DEVINFO_PART_DEVICE_FAMILY_ZG, /**< Zero Gecko Device Family. */
273 #endif
274 #if defined(_DEVINFO_PART_DEVICE_FAMILY_HG)
275 systemPartFamilyHappy = _DEVINFO_PART_DEVICE_FAMILY_HG, /**< Happy Gecko Device Family. */
276 #endif
277 systemPartFamilyUnknown = 0xFF /**< Unknown Device Family.
278 Family ID is missing
279 on unprogrammed parts. */
280 } SYSTEM_PartFamily_TypeDef;
281
282 /** Family security capability. */
283 typedef enum {
284 securityCapabilityUnknown, /**< Unknown security capability. */
285 securityCapabilityNA, /**< Security capability not applicable. */
286 securityCapabilityBasic, /**< Basic security capability. */
287 securityCapabilityRoT, /**< Root of Trust security capability. */
288 securityCapabilitySE, /**< Secure Element security capability. */
289 securityCapabilityVault /**< Secure Vault security capability. */
290 } SYSTEM_SecurityCapability_TypeDef;
291
292 /*******************************************************************************
293 ******************************* STRUCTS ***********************************
294 ******************************************************************************/
295
296 /** Chip revision details. */
297 typedef struct {
298 uint8_t minor; /**< Minor revision number. */
299 uint8_t major; /**< Major revision number. */
300 #if defined(_SYSCFG_CHIPREV_PARTNUMBER_MASK)
301 uint16_t partNumber; /**< Device part number. */
302 #else
303 uint8_t family; /**< Device family number. */
304 #endif
305 } SYSTEM_ChipRevision_TypeDef;
306
307 #if defined(__FPU_PRESENT) && (__FPU_PRESENT == 1)
308 /** Floating point co-processor access modes. */
309 typedef enum {
310 fpuAccessDenied = (0x0 << 20), /**< Access denied, any attempted access generates a NOCP UsageFault. */
311 fpuAccessPrivilegedOnly = (0x5 << 20), /**< Privileged access only, an unprivileged access generates a NOCP UsageFault. */
312 fpuAccessReserved = (0xA << 20), /**< Reserved. */
313 fpuAccessFull = (0xF << 20) /**< Full access. */
314 } SYSTEM_FpuAccess_TypeDef;
315 #endif
316
317 /** DEVINFO calibration address/value pair. */
318 typedef struct {
319 uint32_t address; /**< Peripheral calibration register address. */
320 uint32_t calValue; /**< Calibration value for register at address. */
321 }
322 SYSTEM_CalAddrVal_TypeDef;
323
324 /*******************************************************************************
325 ***************************** PROTOTYPES **********************************
326 ******************************************************************************/
327
328 void SYSTEM_ChipRevisionGet(SYSTEM_ChipRevision_TypeDef *rev);
329 bool SYSTEM_GetCalibrationValue(volatile uint32_t *regAddress);
330 SYSTEM_SecurityCapability_TypeDef SYSTEM_GetSecurityCapability(void);
331
332 #if defined(_DEVINFO_DEVINFOREV_DEVINFOREV_MASK) || defined(_DEVINFO_INFO_DEVINFOREV_MASK)
333 /***************************************************************************//**
334 * @brief
335 * Get DEVINFO revision.
336 *
337 * @return
338 * Revision of the DEVINFO contents.
339 ******************************************************************************/
SYSTEM_GetDevinfoRev(void)340 __STATIC_INLINE uint8_t SYSTEM_GetDevinfoRev(void)
341 {
342 #if defined(_DEVINFO_DEVINFOREV_DEVINFOREV_MASK)
343 return (uint8_t)((DEVINFO->DEVINFOREV & _DEVINFO_DEVINFOREV_DEVINFOREV_MASK)
344 >> _DEVINFO_DEVINFOREV_DEVINFOREV_SHIFT);
345 #elif defined(_DEVINFO_INFO_DEVINFOREV_MASK)
346 return (uint8_t)((DEVINFO->INFO & _DEVINFO_INFO_DEVINFOREV_MASK)
347 >> _DEVINFO_INFO_DEVINFOREV_SHIFT);
348 #endif
349 }
350 #endif
351
352 #if defined(__FPU_PRESENT) && (__FPU_PRESENT == 1)
353 /***************************************************************************//**
354 * @brief
355 * Set floating point co-processor (FPU) access mode.
356 *
357 * @param[in] accessMode
358 * Floating point co-processor access mode. See @ref SYSTEM_FpuAccess_TypeDef
359 * for details.
360 ******************************************************************************/
SYSTEM_FpuAccessModeSet(SYSTEM_FpuAccess_TypeDef accessMode)361 __STATIC_INLINE void SYSTEM_FpuAccessModeSet(SYSTEM_FpuAccess_TypeDef accessMode)
362 {
363 SCB->CPACR = (SCB->CPACR & ~(0xFUL << 20)) | (uint32_t)accessMode;
364 }
365 #endif
366
367 /***************************************************************************//**
368 * @brief
369 * Get the unique number for this device.
370 *
371 * @return
372 * Unique number for this device.
373 ******************************************************************************/
SYSTEM_GetUnique(void)374 __STATIC_INLINE uint64_t SYSTEM_GetUnique(void)
375 {
376 #if defined (_DEVINFO_EUI64H_MASK)
377 uint32_t tmp = DEVINFO->EUI64L;
378 return (uint64_t)((uint64_t)DEVINFO->EUI64H << 32) | tmp;
379 #elif defined(_DEVINFO_UNIQUEH_MASK)
380 uint32_t tmp = DEVINFO->UNIQUEL;
381 return (uint64_t)((uint64_t)DEVINFO->UNIQUEH << 32) | tmp;
382 #else
383 #error Location of device unique number is not defined.
384 #endif
385 }
386
387 /***************************************************************************//**
388 * @brief
389 * Get the production revision for this part.
390 *
391 * @return
392 * Production revision for this part.
393 ******************************************************************************/
SYSTEM_GetProdRev(void)394 __STATIC_INLINE uint8_t SYSTEM_GetProdRev(void)
395 {
396 #if defined (_DEVINFO_PART_PROD_REV_MASK)
397 return (uint8_t)((DEVINFO->PART & _DEVINFO_PART_PROD_REV_MASK)
398 >> _DEVINFO_PART_PROD_REV_SHIFT);
399 #elif defined (_DEVINFO_INFO_PRODREV_MASK)
400 return (uint8_t)((DEVINFO->INFO & _DEVINFO_INFO_PRODREV_MASK)
401 >> _DEVINFO_INFO_PRODREV_SHIFT);
402 #else
403 #error Location of production revision is not defined.
404 #endif
405 }
406
407 /***************************************************************************//**
408 * @brief
409 * Get the SRAM size (in KB).
410 *
411 * @note
412 * This function retrieves SRAM size by reading the chip device
413 * info structure. If your binary is made for one specific device only,
414 * use SRAM_SIZE instead.
415 *
416 * @return
417 * Size of internal SRAM (in KB).
418 ******************************************************************************/
SYSTEM_GetSRAMSize(void)419 __STATIC_INLINE uint16_t SYSTEM_GetSRAMSize(void)
420 {
421 uint16_t sizekb;
422
423 #if defined(_EFM32_GECKO_FAMILY)
424 /* Early Gecko devices had a bug where SRAM and Flash size were swapped. */
425 if (SYSTEM_GetProdRev() < 5) {
426 sizekb = (DEVINFO->MSIZE & _DEVINFO_MSIZE_FLASH_MASK)
427 >> _DEVINFO_MSIZE_FLASH_SHIFT;
428 }
429 #endif
430 sizekb = (uint16_t)((DEVINFO->MSIZE & _DEVINFO_MSIZE_SRAM_MASK)
431 >> _DEVINFO_MSIZE_SRAM_SHIFT);
432
433 #if defined(_SILICON_LABS_GECKO_INTERNAL_SDID_80) && defined(_EFR_DEVICE)
434 /* Do not include EFR32xG1 RAMH. */
435 sizekb--;
436 #endif
437
438 return sizekb;
439 }
440
441 /***************************************************************************//**
442 * @brief
443 * Get the flash size (in KB).
444 *
445 * @note
446 * This function retrieves flash size by reading the chip device
447 * info structure. If your binary is made for one specific device only,
448 * use FLASH_SIZE instead.
449 *
450 * @return
451 * Size of internal flash (in KB).
452 ******************************************************************************/
SYSTEM_GetFlashSize(void)453 __STATIC_INLINE uint16_t SYSTEM_GetFlashSize(void)
454 {
455 #if defined(_EFM32_GECKO_FAMILY)
456 /* Early Gecko devices had a bug where SRAM and Flash size were swapped. */
457 if (SYSTEM_GetProdRev() < 5) {
458 return (DEVINFO->MSIZE & _DEVINFO_MSIZE_SRAM_MASK)
459 >> _DEVINFO_MSIZE_SRAM_SHIFT;
460 }
461 #endif
462 return (uint16_t)((DEVINFO->MSIZE & _DEVINFO_MSIZE_FLASH_MASK)
463 >> _DEVINFO_MSIZE_FLASH_SHIFT);
464 }
465
466 /***************************************************************************//**
467 * @brief
468 * Get the flash page size in bytes.
469 *
470 * @note
471 * This function retrieves flash page size by reading the chip device
472 * info structure. If your binary is made for one specific device only,
473 * use FLASH_PAGE_SIZE instead.
474 *
475 * @return
476 * Page size of internal flash in bytes.
477 ******************************************************************************/
SYSTEM_GetFlashPageSize(void)478 __STATIC_INLINE uint32_t SYSTEM_GetFlashPageSize(void)
479 {
480 uint32_t tmp;
481
482 #if defined(_SILICON_LABS_32B_SERIES_0)
483
484 #if defined(_EFM32_GIANT_FAMILY)
485 if (SYSTEM_GetProdRev() < 18) {
486 /* Early Giant/Leopard devices did not have MEMINFO in DEVINFO. */
487 return FLASH_PAGE_SIZE;
488 }
489 #elif defined(_EFM32_ZERO_FAMILY)
490 if (SYSTEM_GetProdRev() < 24) {
491 /* Early Zero devices have an incorrect DEVINFO flash page size */
492 return FLASH_PAGE_SIZE;
493 }
494 #endif
495 #endif
496
497 #if defined(_DEVINFO_MEMINFO_FLASHPAGESIZE_MASK)
498 tmp = (DEVINFO->MEMINFO & _DEVINFO_MEMINFO_FLASHPAGESIZE_MASK)
499 >> _DEVINFO_MEMINFO_FLASHPAGESIZE_SHIFT;
500 #elif defined(_DEVINFO_MEMINFO_FLASH_PAGE_SIZE_MASK)
501 tmp = (DEVINFO->MEMINFO & _DEVINFO_MEMINFO_FLASH_PAGE_SIZE_MASK)
502 >> _DEVINFO_MEMINFO_FLASH_PAGE_SIZE_SHIFT;
503 #else
504 #error Location of flash page size is not defined.
505 #endif
506
507 return 1UL << ((tmp + 10UL) & 0x1FUL);
508 }
509
510 /***************************************************************************//**
511 * @brief
512 * Get the MCU part number.
513 *
514 * @return
515 * The part number of MCU.
516 ******************************************************************************/
SYSTEM_GetPartNumber(void)517 __STATIC_INLINE uint16_t SYSTEM_GetPartNumber(void)
518 {
519 #if defined(_DEVINFO_PART_DEVICENUM_MASK)
520 return (uint16_t)((DEVINFO->PART & _DEVINFO_PART_DEVICENUM_MASK)
521 >> _DEVINFO_PART_DEVICENUM_SHIFT);
522 #elif defined(_DEVINFO_PART_DEVICE_NUMBER_MASK)
523 return (uint16_t)((DEVINFO->PART & _DEVINFO_PART_DEVICE_NUMBER_MASK)
524 >> _DEVINFO_PART_DEVICE_NUMBER_SHIFT);
525 #else
526 #error Location of device part number is not defined.
527 #endif
528 }
529
530 /***************************************************************************//**
531 * @brief
532 * Get the MCU family identifier.
533 *
534 * @note
535 * This function retrieves family ID by reading the chip's device info
536 * structure in flash memory. Users can retrieve family ID directly
537 * by reading DEVINFO->PART item and decode with mask and shift
538 * \#defines defined in \<part_family\>_devinfo.h (refer to code
539 * below for details).
540 *
541 * @return
542 * Family identifier of MCU.
543 ******************************************************************************/
SYSTEM_GetFamily(void)544 __STATIC_INLINE SYSTEM_PartFamily_TypeDef SYSTEM_GetFamily(void)
545 {
546 #if defined(_DEVINFO_PART_FAMILY_MASK)
547 return (SYSTEM_PartFamily_TypeDef)
548 ((uint32_t)((DEVINFO->PART & (_DEVINFO_PART_FAMILY_MASK
549 | _DEVINFO_PART_FAMILYNUM_MASK))));
550 #elif defined(_DEVINFO_PART_DEVICE_FAMILY_MASK)
551 return (SYSTEM_PartFamily_TypeDef)
552 ((uint32_t)((DEVINFO->PART & _DEVINFO_PART_DEVICE_FAMILY_MASK)
553 >> _DEVINFO_PART_DEVICE_FAMILY_SHIFT));
554 #else
555 #error Location of device family name is not defined.
556 #endif
557 }
558
559 /***************************************************************************//**
560 * @brief
561 * Get the calibration temperature (in degrees Celsius).
562 *
563 * @return
564 * Calibration temperature in Celsius.
565 ******************************************************************************/
SYSTEM_GetCalibrationTemperature(void)566 __STATIC_INLINE uint8_t SYSTEM_GetCalibrationTemperature(void)
567 {
568 #if defined(_DEVINFO_CAL_TEMP_MASK)
569 return (uint8_t)((DEVINFO->CAL & _DEVINFO_CAL_TEMP_MASK)
570 >> _DEVINFO_CAL_TEMP_SHIFT);
571 #elif defined(_DEVINFO_CALTEMP_TEMP_MASK)
572 return (uint8_t)((DEVINFO->CALTEMP & _DEVINFO_CALTEMP_TEMP_MASK)
573 >> _DEVINFO_CALTEMP_TEMP_SHIFT);
574 #else
575 #error Location of calibration temperature is not defined.
576 #endif
577 }
578
579 /** @} (end addtogroup system) */
580
581 #ifdef __cplusplus
582 }
583 #endif
584 #endif /* EM_SYSTEM_H */
585