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 "em_device.h"
35 #include "em_system_generic.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   systemPartFamilySideWalk23 = DEVINFO_PART_FAMILY_SG | (23 << _DEVINFO_PART_FAMILYNUM_SHIFT),   /**< EFR32 Side Walk Gecko Series 2 Config 3 Value Device Family */
238 #endif
239 #if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_4)
240   systemPartFamilyMighty24 = DEVINFO_PART_FAMILY_MG | (24 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Mighty Gecko Series 2 Config 4 Value Device Family */
241   systemPartFamilyFlex24 = DEVINFO_PART_FAMILY_FG | (24 << _DEVINFO_PART_FAMILYNUM_SHIFT),   /**< EFR32 Flex Gecko Series 2 Config 4 Value Device Family */
242   systemPartFamilyBlue24 = DEVINFO_PART_FAMILY_BG | (24 << _DEVINFO_PART_FAMILYNUM_SHIFT),   /**< EFR32 Blue Gecko Series 2 Config 4 Value Device Family */
243 #endif
244 #if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_5)
245   systemPartFamilyFlex25 = DEVINFO_PART_FAMILY_FG | (25 << _DEVINFO_PART_FAMILYNUM_SHIFT),       /**< EFR32 Flex Gecko Series 2 Config 5 Value Device Family */
246 #endif
247 #if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_6)
248   systemPartFamilyMighty26 = DEVINFO_PART_FAMILY_MG | (26 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Mighty Gecko Series 2 Config 6 Value Device Family */
249   systemPartFamilyBlue26 = DEVINFO_PART_FAMILY_BG | (26 << _DEVINFO_PART_FAMILYNUM_SHIFT),   /**< EFR32 Blue Gecko Series 2 Config 6 Value Device Family */
250   systemPartFamilyEfm32Pearl26 = DEVINFO_PART_FAMILY_PG | (26 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFM32 Pearl Gecko Series 2 Config 6 Value Device Family */
251 #endif
252 #if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_7)
253   systemPartFamilyMighty27 = DEVINFO_PART_FAMILY_MG | (27 << _DEVINFO_PART_FAMILYNUM_SHIFT), /**< EFR32 Mighty Gecko Series 2 Config 7 Value Device Family */
254   systemPartFamilyBlue27 = DEVINFO_PART_FAMILY_BG | (27 << _DEVINFO_PART_FAMILYNUM_SHIFT),   /**< EFR32 Blue Gecko Series 2 Config 7 Value Device Family */
255 #endif
256 #if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_8)
257   systemPartFamilyFlex28 = DEVINFO_PART_FAMILY_FG | (28 << _DEVINFO_PART_FAMILYNUM_SHIFT),  /**< EFR32 Flex Gecko Series 2 Config 8 Value Device Family */
258   systemPartFamilyZen28 = DEVINFO_PART_FAMILY_ZG | (28 << _DEVINFO_PART_FAMILYNUM_SHIFT),   /**< EFR32 Zen Gecko Series 2 Config 8 Value Device Family */
259   systemPartFamilySideWalk28 = DEVINFO_PART_FAMILY_SG | (28 << _DEVINFO_PART_FAMILYNUM_SHIFT),   /**< EFR32 Side Walk Gecko Series 2 Config 8 Value Device Family */
260   systemPartFamilyEfm32Pearl28 = DEVINFO_PART_FAMILY_PG | (28 << _DEVINFO_PART_FAMILYNUM_SHIFT),  /**< EFM32 Pearl Gecko Series 2 Config 8 Value Device Family */
261 #endif
262 /* Deprecated family #defines */
263 #if defined(_DEVINFO_PART_DEVICE_FAMILY_G)
264   systemPartFamilyGecko   = _DEVINFO_PART_DEVICE_FAMILY_G,   /**< Gecko Device Family. */
265 #endif
266 #if defined(_DEVINFO_PART_DEVICE_FAMILY_GG)
267   systemPartFamilyGiant   = _DEVINFO_PART_DEVICE_FAMILY_GG,  /**< Giant Gecko Device Family. */
268 #endif
269 #if defined(_DEVINFO_PART_DEVICE_FAMILY_TG)
270   systemPartFamilyTiny    = _DEVINFO_PART_DEVICE_FAMILY_TG,  /**< Tiny Gecko Device Family. */
271 #endif
272 #if defined(_DEVINFO_PART_DEVICE_FAMILY_LG)
273   systemPartFamilyLeopard = _DEVINFO_PART_DEVICE_FAMILY_LG,  /**< Leopard Gecko Device Family. */
274 #endif
275 #if defined(_DEVINFO_PART_DEVICE_FAMILY_WG)
276   systemPartFamilyWonder  = _DEVINFO_PART_DEVICE_FAMILY_WG,  /**< Wonder Gecko Device Family. */
277 #endif
278 #if defined(_DEVINFO_PART_DEVICE_FAMILY_ZG)
279   systemPartFamilyZero    = _DEVINFO_PART_DEVICE_FAMILY_ZG,  /**< Zero Gecko Device Family. */
280 #endif
281 #if defined(_DEVINFO_PART_DEVICE_FAMILY_HG)
282   systemPartFamilyHappy   = _DEVINFO_PART_DEVICE_FAMILY_HG,  /**< Happy Gecko Device Family. */
283 #endif
284   systemPartFamilyUnknown = 0xFF                             /**< Unknown Device Family.
285                                                                   Family ID is missing
286                                                                   on unprogrammed parts. */
287 } SYSTEM_PartFamily_TypeDef;
288 
289 /*******************************************************************************
290  *******************************   STRUCTS   ***********************************
291  ******************************************************************************/
292 
293 /** Chip revision details. */
294 typedef struct {
295   uint8_t minor;       /**< Minor revision number. */
296   uint8_t major;       /**< Major revision number. */
297 #if defined(_SYSCFG_CHIPREV_PARTNUMBER_MASK)
298   uint16_t partNumber; /**< Device part number.    */
299 #else
300   uint8_t family;      /**< Device family number.  */
301 #endif
302 } SYSTEM_ChipRevision_TypeDef;
303 
304 #if defined(__FPU_PRESENT) && (__FPU_PRESENT == 1)
305 /** Floating point co-processor access modes. */
306 typedef enum {
307   fpuAccessDenied         = (0x0 << 20),  /**< Access denied, any attempted access generates a NOCP UsageFault. */
308   fpuAccessPrivilegedOnly = (0x5 << 20),  /**< Privileged access only, an unprivileged access generates a NOCP UsageFault. */
309   fpuAccessReserved       = (0xA << 20),  /**< Reserved. */
310   fpuAccessFull           = (0xF << 20)   /**< Full access. */
311 } SYSTEM_FpuAccess_TypeDef;
312 #endif
313 
314 /*******************************************************************************
315  *****************************   PROTOTYPES   **********************************
316  ******************************************************************************/
317 
318 void                      SYSTEM_ChipRevisionGet(SYSTEM_ChipRevision_TypeDef *rev);
319 SYSTEM_PartFamily_TypeDef SYSTEM_GetFamily(void);
320 
321 #if defined(_DEVINFO_DEVINFOREV_DEVINFOREV_MASK) || defined(_DEVINFO_INFO_DEVINFOREV_MASK)
322 /***************************************************************************//**
323  * @brief
324  *   Get DEVINFO revision.
325  *
326  * @return
327  *   Revision of the DEVINFO contents.
328  ******************************************************************************/
SYSTEM_GetDevinfoRev(void)329 __STATIC_INLINE uint8_t SYSTEM_GetDevinfoRev(void)
330 {
331 #if defined(_DEVINFO_DEVINFOREV_DEVINFOREV_MASK)
332   return (uint8_t)((DEVINFO->DEVINFOREV & _DEVINFO_DEVINFOREV_DEVINFOREV_MASK)
333                    >> _DEVINFO_DEVINFOREV_DEVINFOREV_SHIFT);
334 #elif defined(_DEVINFO_INFO_DEVINFOREV_MASK)
335   return (uint8_t)((DEVINFO->INFO & _DEVINFO_INFO_DEVINFOREV_MASK)
336                    >> _DEVINFO_INFO_DEVINFOREV_SHIFT);
337 #endif
338 }
339 #endif
340 
341 #if defined(__FPU_PRESENT) && (__FPU_PRESENT == 1)
342 /***************************************************************************//**
343  * @brief
344  *   Set floating point co-processor (FPU) access mode.
345  *
346  * @param[in] accessMode
347  *   Floating point co-processor access mode. See @ref SYSTEM_FpuAccess_TypeDef
348  *   for details.
349  ******************************************************************************/
SYSTEM_FpuAccessModeSet(SYSTEM_FpuAccess_TypeDef accessMode)350 __STATIC_INLINE void SYSTEM_FpuAccessModeSet(SYSTEM_FpuAccess_TypeDef accessMode)
351 {
352   SCB->CPACR = (SCB->CPACR & ~(0xFUL << 20)) | (uint32_t)accessMode;
353 }
354 #endif
355 
356 /** @} (end addtogroup system) */
357 
358 #ifdef __cplusplus
359 }
360 #endif
361 #endif /* EM_SYSTEM_H */
362