EFM32 Giant Gecko Software Documentation  efm32gg-doc-4.2.1
em_chip.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __SILICON_LABS_EM_CHIP_H__
34 #define __SILICON_LABS_EM_CHIP_H__
35 
36 #include "em_device.h"
37 #include "em_system.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /***************************************************************************/
48 /***************************************************************************/
54 /**************************************************************************/
62 __STATIC_INLINE void CHIP_Init(void)
63 {
64 #if defined(_EFM32_GECKO_FAMILY)
65  uint32_t rev;
67  volatile uint32_t *reg;
68 
69  rev = *(volatile uint32_t *)(0x0FE081FC);
70  /* Engineering Sample calibration setup */
71  if ((rev >> 24) == 0)
72  {
73  reg = (volatile uint32_t *)0x400CA00C;
74  *reg &= ~(0x70UL);
75  /* DREG */
76  reg = (volatile uint32_t *)0x400C6020;
77  *reg &= ~(0xE0000000UL);
78  *reg |= ~(7UL << 25);
79  }
80  if ((rev >> 24) <= 3)
81  {
82  /* DREG */
83  reg = (volatile uint32_t *)0x400C6020;
84  *reg &= ~(0x00001F80UL);
85  /* Update CMU reset values */
86  reg = (volatile uint32_t *)0x400C8040;
87  *reg = 0;
88  reg = (volatile uint32_t *)0x400C8044;
89  *reg = 0;
90  reg = (volatile uint32_t *)0x400C8058;
91  *reg = 0;
92  reg = (volatile uint32_t *)0x400C8060;
93  *reg = 0;
94  reg = (volatile uint32_t *)0x400C8078;
95  *reg = 0;
96  }
97 
98  SYSTEM_ChipRevisionGet(&chipRev);
99  if (chipRev.major == 0x01)
100  {
101  /* Rev A errata handling for EM2/3. Must enable DMA clock in order for EM2/3 */
102  /* to work. This will be fixed in later chip revisions, so only do for rev A. */
103  if (chipRev.minor == 00)
104  {
105  reg = (volatile uint32_t *)0x400C8040;
106  *reg |= 0x2;
107  }
108 
109  /* Rev A+B errata handling for I2C when using EM2/3. USART0 clock must be enabled */
110  /* after waking up from EM2/EM3 in order for I2C to work. This will be fixed in */
111  /* later chip revisions, so only do for rev A+B. */
112  if (chipRev.minor <= 0x01)
113  {
114  reg = (volatile uint32_t *)0x400C8044;
115  *reg |= 0x1;
116  }
117  }
118  /* Ensure correct ADC/DAC calibration value */
119  rev = *(volatile uint32_t *)0x0FE081F0;
120  if (rev < 0x4C8ABA00)
121  {
122  uint32_t cal;
123 
124  /* Enable ADC/DAC clocks */
125  reg = (volatile uint32_t *)0x400C8044UL;
126  *reg |= (1 << 14 | 1 << 11);
127 
128  /* Retrive calibration values */
129  cal = ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x00007F00UL) >>
130  8) << 24;
131 
132  cal |= ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x0000007FUL) >>
133  0) << 16;
134 
135  cal |= ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x00007F00UL) >>
136  8) << 8;
137 
138  cal |= ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x0000007FUL) >>
139  0) << 0;
140 
141  /* ADC0->CAL = 1.25 reference */
142  reg = (volatile uint32_t *)0x40002034UL;
143  *reg = cal;
144 
145  /* DAC0->CAL = 1.25 reference */
146  reg = (volatile uint32_t *)(0x4000402CUL);
147  cal = *(volatile uint32_t *)0x0FE081C8UL;
148  *reg = cal;
149 
150  /* Turn off ADC/DAC clocks */
151  reg = (volatile uint32_t *)0x400C8044UL;
152  *reg &= ~(1 << 14 | 1 << 11);
153  }
154 #endif
155 
156 #if defined(_EFM32_GIANT_FAMILY)
157  uint32_t rev;
159 
160  rev = *(volatile uint32_t *)(0x0FE081FC);
161  SYSTEM_ChipRevisionGet(&chipRev);
162 
163  if (((rev >> 24) > 15) && (chipRev.minor == 3))
164  {
165  /* This fixes an issue with the LFXO on high temperatures. */
166  *(volatile uint32_t*)0x400C80C0 =
167  ( *(volatile uint32_t*)0x400C80C0 & ~(1<<6) ) | (1<<4);
168  }
169 #endif
170 
171 #if defined(_EFM32_HAPPY_FAMILY)
172  uint32_t rev;
173  rev = *(volatile uint32_t *)(0x0FE081FC);
174 
175  if ((rev >> 24) <= 129)
176  {
177  /* This fixes a mistaken internal connection between PC0 and PC4 */
178  /* This disables an internal pulldown on PC4 */
179  *(volatile uint32_t*)(0x400C6018) = (1 << 26) | (5 << 0);
180  /* This disables an internal LDO test signal driving PC4 */
181  *(volatile uint32_t*)(0x400C80E4) &= ~(1 << 24);
182  }
183 #endif
184 }
185 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #endif /* __SILICON_LABS_EM_CHIP_H__ */
void SYSTEM_ChipRevisionGet(SYSTEM_ChipRevision_TypeDef *rev)
Get chip major/minor revision.
Definition: em_system.c:58
__STATIC_INLINE void CHIP_Init(void)
Chip initialization routine for revision errata workarounds.
Definition: em_chip.h:62
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
System API.