EFM32 Pearl Gecko 12 Software Documentation  efm32pg12-doc-5.1.2
em_system.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef EM_SYSTEM_H
34 #define EM_SYSTEM_H
35 
36 #include <stdbool.h>
37 #include "em_device.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /***************************************************************************/
48 /***************************************************************************/
59 /*******************************************************************************
60  ******************************** ENUMS ************************************
61  ******************************************************************************/
62 
64 typedef enum
65 {
66 /* New style family #defines */
67 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32G)
69 #endif
70 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32GG)
72 #endif
73 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32TG)
75 #endif
76 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32LG)
78 #endif
79 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32WG)
81 #endif
82 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32ZG)
84 #endif
85 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32HG)
87 #endif
88 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32PG1B)
90 #endif
91 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32JG1B)
93 #endif
94 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32PG12B)
96 #endif
97 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32JG12B)
99 #endif
100 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32PG13B)
101  systemPartFamilyEfm32Pearl13B = _DEVINFO_PART_DEVICE_FAMILY_EFM32PG13B,
102 #endif
103 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFM32JG13B)
104  systemPartFamilyEfm32Jade13B = _DEVINFO_PART_DEVICE_FAMILY_EFM32JG13B,
105 #endif
106 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EZR32WG)
108 #endif
109 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EZR32LG)
111 #endif
112 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EZR32HG)
114 #endif
115 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG1P)
117 #endif
118 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG1B)
120 #endif
121 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG1V)
123 #endif
124 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG1P)
126 #endif
127 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG1B)
129 #endif
130 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG1V)
132 #endif
133 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG1P)
135 #endif
136 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG1B)
138 #endif
139 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG1V)
141 #endif
142 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG2P)
144 #endif
145 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG12P)
147 #endif
148 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG12B)
150 #endif
151 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG12V)
153 #endif
154 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG12P)
156 #endif
157 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG12B)
159 #endif
160 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG12V)
162 #endif
163 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG12P)
165 #endif
166 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG12B)
168 #endif
169 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG12V)
171 #endif
172 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG13P)
173  systemPartFamilyMighty13P = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG13P,
174 #endif
175 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG13B)
176  systemPartFamilyMighty13B = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG13B,
177 #endif
178 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32MG13V)
179  systemPartFamilyMighty13V = _DEVINFO_PART_DEVICE_FAMILY_EFR32MG13V,
180 #endif
181 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG13P)
182  systemPartFamilyBlue13P = _DEVINFO_PART_DEVICE_FAMILY_EFR32BG13P,
183 #endif
184 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG13B)
185  systemPartFamilyBlue13B = _DEVINFO_PART_DEVICE_FAMILY_EFR32BG13B,
186 #endif
187 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32BG13V)
188  systemPartFamilyBlue13V = _DEVINFO_PART_DEVICE_FAMILY_EFR32BG13V,
189 #endif
190 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG13P)
191  systemPartFamilyFlex13P = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG13P,
192 #endif
193 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG13B)
194  systemPartFamilyFlex13B = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG13B,
195 #endif
196 #if defined(_DEVINFO_PART_DEVICE_FAMILY_EFR32FG13V)
197  systemPartFamilyFlex13V = _DEVINFO_PART_DEVICE_FAMILY_EFR32FG13V,
198 #endif
199 
200 
201 
202 /* Deprecated family #defines */
203 #if defined(_DEVINFO_PART_DEVICE_FAMILY_G)
205 #endif
206 #if defined(_DEVINFO_PART_DEVICE_FAMILY_GG)
208 #endif
209 #if defined(_DEVINFO_PART_DEVICE_FAMILY_TG)
211 #endif
212 #if defined(_DEVINFO_PART_DEVICE_FAMILY_LG)
214 #endif
215 #if defined(_DEVINFO_PART_DEVICE_FAMILY_WG)
217 #endif
218 #if defined(_DEVINFO_PART_DEVICE_FAMILY_ZG)
220 #endif
221 #if defined(_DEVINFO_PART_DEVICE_FAMILY_HG)
223 #endif
228 
229 
230 /*******************************************************************************
231  ******************************* STRUCTS ***********************************
232  ******************************************************************************/
233 
235 typedef struct
236 {
237  uint8_t minor;
238  uint8_t major;
239  uint8_t family;
241 
242 #if defined(__FPU_PRESENT) && (__FPU_PRESENT == 1)
243 
244 typedef enum
245 {
246  fpuAccessDenied = (0x0 << 20),
247  fpuAccessPrivilegedOnly = (0x5 << 20),
248  fpuAccessReserved = (0xA << 20),
249  fpuAccessFull = (0xF << 20)
251 #endif
252 
254 typedef struct
255 {
256  uint32_t address;
257  uint32_t calValue;
258 }
260 
261 /*******************************************************************************
262  ***************************** PROTOTYPES **********************************
263  ******************************************************************************/
264 
266 bool SYSTEM_GetCalibrationValue(volatile uint32_t *regAddress);
267 
268 #if defined(__FPU_PRESENT) && (__FPU_PRESENT == 1)
269 /***************************************************************************/
277 __STATIC_INLINE void SYSTEM_FpuAccessModeSet(SYSTEM_FpuAccess_TypeDef accessMode)
278 {
279  SCB->CPACR = (SCB->CPACR & ~(0xF << 20)) | accessMode;
280 }
281 #endif
282 
283 /***************************************************************************/
290 __STATIC_INLINE uint64_t SYSTEM_GetUnique(void)
291 {
292  uint32_t tmp = DEVINFO->UNIQUEL;
293  return (uint64_t)((uint64_t)DEVINFO->UNIQUEH << 32) | tmp;
294 }
295 
296 /***************************************************************************/
303 __STATIC_INLINE uint8_t SYSTEM_GetProdRev(void)
304 {
305  return (DEVINFO->PART & _DEVINFO_PART_PROD_REV_MASK)
307 }
308 
309 /***************************************************************************/
321 __STATIC_INLINE uint16_t SYSTEM_GetSRAMSize(void)
322 {
323  uint16_t sizekb;
324 
325 #if defined(_EFM32_GECKO_FAMILY)
326  /* Early Gecko devices had a bug where SRAM and Flash size were swapped. */
327  if (SYSTEM_GetProdRev() < 5)
328  {
329  sizekb = (DEVINFO->MSIZE & _DEVINFO_MSIZE_FLASH_MASK)
331  }
332 #endif
333  sizekb = (DEVINFO->MSIZE & _DEVINFO_MSIZE_SRAM_MASK)
335 
336 #if defined(_SILICON_LABS_GECKO_INTERNAL_SDID_80) && defined(_EFR_DEVICE)
337  /* Do not include EFR32xG1 RAMH */
338  sizekb--;
339 #endif
340 
341  return sizekb;
342 }
343 
344 /***************************************************************************/
356 __STATIC_INLINE uint16_t SYSTEM_GetFlashSize(void)
357 {
358 #if defined(_EFM32_GECKO_FAMILY)
359  /* Early Gecko devices had a bug where SRAM and Flash size were swapped. */
360  if (SYSTEM_GetProdRev() < 5)
361  {
362  return (DEVINFO->MSIZE & _DEVINFO_MSIZE_SRAM_MASK)
364  }
365 #endif
366  return (DEVINFO->MSIZE & _DEVINFO_MSIZE_FLASH_MASK)
368 }
369 
370 
371 /***************************************************************************/
383 __STATIC_INLINE uint32_t SYSTEM_GetFlashPageSize(void)
384 {
385  uint32_t tmp;
386 
387 #if defined(_EFM32_GIANT_FAMILY)
388  if (SYSTEM_GetProdRev() < 18)
389  {
390  /* Early Giant/Leopard devices did not have MEMINFO in DEVINFO. */
391  return FLASH_PAGE_SIZE;
392  }
393 #elif defined(_EFM32_ZERO_FAMILY)
394  if (SYSTEM_GetProdRev() < 24)
395  {
396  /* Early Zero devices have an incorrect DEVINFO flash page size */
397  return FLASH_PAGE_SIZE;
398  }
399 #endif
400 
403 
404  return 1 << ((tmp + 10) & 0xFF);
405 }
406 
407 
408 #if defined( _DEVINFO_DEVINFOREV_DEVINFOREV_MASK )
409 /***************************************************************************/
416 __STATIC_INLINE uint8_t SYSTEM_GetDevinfoRev(void)
417 {
418  return (DEVINFO->DEVINFOREV & _DEVINFO_DEVINFOREV_DEVINFOREV_MASK)
420 }
421 #endif
422 
423 
424 /***************************************************************************/
431 __STATIC_INLINE uint16_t SYSTEM_GetPartNumber(void)
432 {
435 }
436 
437 /***************************************************************************/
452 {
456 }
457 
458 
459 /***************************************************************************/
466 __STATIC_INLINE uint8_t SYSTEM_GetCalibrationTemperature(void)
467 {
468  return (DEVINFO->CAL & _DEVINFO_CAL_TEMP_MASK)
470 }
471 
475 #ifdef __cplusplus
476 }
477 #endif
478 
479 #endif /* EM_SYSTEM_H */
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32FG12V
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32BG1B
#define _DEVINFO_MSIZE_SRAM_MASK
#define _DEVINFO_PART_DEVICE_FAMILY_SHIFT
#define _DEVINFO_PART_PROD_REV_MASK
#define _DEVINFO_MSIZE_SRAM_SHIFT
#define _DEVINFO_DEVINFOREV_DEVINFOREV_MASK
#define _DEVINFO_MEMINFO_FLASH_PAGE_SIZE_MASK
#define _DEVINFO_PART_DEVICE_NUMBER_SHIFT
#define _DEVINFO_PART_DEVICE_FAMILY_EFM32LG
void SYSTEM_ChipRevisionGet(SYSTEM_ChipRevision_TypeDef *rev)
Get chip major/minor revision.
Definition: em_system.c:58
#define _DEVINFO_PART_PROD_REV_SHIFT
__STATIC_INLINE void SYSTEM_FpuAccessModeSet(SYSTEM_FpuAccess_TypeDef accessMode)
Set floating point coprocessor (FPU) access mode.
Definition: em_system.h:277
#define _DEVINFO_PART_DEVICE_FAMILY_EFM32WG
#define _DEVINFO_PART_DEVICE_FAMILY_WG
#define _DEVINFO_PART_DEVICE_FAMILY_EFM32JG1B
#define _DEVINFO_PART_DEVICE_FAMILY_LG
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define DEVINFO
SYSTEM_FpuAccess_TypeDef
Definition: em_system.h:244
#define _DEVINFO_PART_DEVICE_FAMILY_EFM32HG
#define _DEVINFO_PART_DEVICE_FAMILY_EFM32ZG
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32BG12P
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32BG1V
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32FG12B
#define _DEVINFO_PART_DEVICE_FAMILY_GG
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32FG1B
#define _DEVINFO_MSIZE_FLASH_MASK
#define _DEVINFO_DEVINFOREV_DEVINFOREV_SHIFT
bool SYSTEM_GetCalibrationValue(volatile uint32_t *regAddress)
Get factory calibration value for a given peripheral register.
Definition: em_system.c:93
#define _DEVINFO_PART_DEVICE_NUMBER_MASK
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32BG1P
__STATIC_INLINE uint8_t SYSTEM_GetProdRev(void)
Get the production revision for this part.
Definition: em_system.h:303
#define _DEVINFO_CAL_TEMP_SHIFT
__STATIC_INLINE SYSTEM_PartFamily_TypeDef SYSTEM_GetFamily(void)
Get family identifier of the MCU.
Definition: em_system.h:451
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32MG12V
#define _DEVINFO_PART_DEVICE_FAMILY_EFM32JG12B
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32FG12P
#define _DEVINFO_PART_DEVICE_FAMILY_EFM32PG1B
#define _DEVINFO_PART_DEVICE_FAMILY_EFM32G
#define _DEVINFO_MEMINFO_FLASH_PAGE_SIZE_SHIFT
#define _DEVINFO_PART_DEVICE_FAMILY_EZR32HG
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32MG12B
#define _DEVINFO_PART_DEVICE_FAMILY_EFM32PG12B
#define _DEVINFO_PART_DEVICE_FAMILY_MASK
#define _DEVINFO_PART_DEVICE_FAMILY_G
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32MG2P
__STATIC_INLINE uint8_t SYSTEM_GetDevinfoRev(void)
Get DEVINFO revision.
Definition: em_system.h:416
#define _DEVINFO_PART_DEVICE_FAMILY_EZR32WG
#define _DEVINFO_PART_DEVICE_FAMILY_EFM32TG
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32MG12P
__STATIC_INLINE uint16_t SYSTEM_GetSRAMSize(void)
Get the SRAM size (in KB).
Definition: em_system.h:321
__STATIC_INLINE uint16_t SYSTEM_GetPartNumber(void)
Get part number of the MCU.
Definition: em_system.h:431
#define _DEVINFO_PART_DEVICE_FAMILY_ZG
#define FLASH_PAGE_SIZE
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32BG12V
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32FG1V
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32MG1V
#define _DEVINFO_MSIZE_FLASH_SHIFT
#define _DEVINFO_PART_DEVICE_FAMILY_HG
#define _DEVINFO_CAL_TEMP_MASK
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32MG1P
#define _DEVINFO_PART_DEVICE_FAMILY_EFM32GG
__STATIC_INLINE uint16_t SYSTEM_GetFlashSize(void)
Get the flash size (in KB).
Definition: em_system.h:356
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32FG1P
__STATIC_INLINE uint32_t SYSTEM_GetFlashPageSize(void)
Get the flash page size in bytes.
Definition: em_system.h:383
#define _DEVINFO_PART_DEVICE_FAMILY_EZR32LG
__STATIC_INLINE uint8_t SYSTEM_GetCalibrationTemperature(void)
Get the calibration temperature (in degrees Celsius).
Definition: em_system.h:466
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32BG12B
__STATIC_INLINE uint64_t SYSTEM_GetUnique(void)
Get the unique number for this device.
Definition: em_system.h:290
SYSTEM_PartFamily_TypeDef
Definition: em_system.h:64
#define _DEVINFO_PART_DEVICE_FAMILY_TG
#define _DEVINFO_PART_DEVICE_FAMILY_EFR32MG1B