1 /***************************************************************************//**
\r
3 * @brief Chip Initialization API
\r
5 *******************************************************************************
\r
7 * <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
\r
8 *******************************************************************************
\r
10 * Permission is granted to anyone to use this software for any purpose,
\r
11 * including commercial applications, and to alter it and redistribute it
\r
12 * freely, subject to the following restrictions:
\r
14 * 1. The origin of this software must not be misrepresented; you must not
\r
15 * claim that you wrote the original software.
\r
16 * 2. Altered source versions must be plainly marked as such, and must not be
\r
17 * misrepresented as being the original software.
\r
18 * 3. This notice may not be removed or altered from any source distribution.
\r
20 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
\r
21 * obligation to support this Software. Silicon Labs is providing the
\r
22 * Software "AS IS", with no express or implied warranties of any kind,
\r
23 * including, but not limited to, any implied warranties of merchantability
\r
24 * or fitness for any particular purpose or warranties against infringement
\r
25 * of any proprietary rights of a third party.
\r
27 * Silicon Labs will not be liable for any consequential, incidental, or
\r
28 * special damages, or any other relief, or for any claim by any third party,
\r
29 * arising from your use of this Software.
\r
31 ******************************************************************************/
\r
34 #ifndef __SILICON_LABS_EM_CHIP_H_
\r
35 #define __SILICON_LABS_EM_CHIP_H_
\r
37 #include "em_device.h"
\r
38 #include "em_system.h"
\r
44 /***************************************************************************//**
\r
45 * @addtogroup EM_Library
\r
47 ******************************************************************************/
\r
49 /***************************************************************************//**
\r
51 * @brief Chip Initialization API
\r
53 ******************************************************************************/
\r
55 /**************************************************************************//**
\r
57 * Chip initialization routine for revision errata workarounds
\r
59 * This init function will configure the EFM32 device to a state where it is
\r
60 * as similar as later revisions as possible, to improve software compatibility
\r
61 * with newer parts. See the device specific errata for details.
\r
62 *****************************************************************************/
\r
63 __STATIC_INLINE void CHIP_Init(void)
\r
65 #if defined(_EFM32_GECKO_FAMILY)
\r
67 SYSTEM_ChipRevision_TypeDef chipRev;
\r
68 volatile uint32_t *reg;
\r
70 rev = *(volatile uint32_t *)(0x0FE081FC);
\r
71 /* Engineering Sample calibration setup */
\r
72 if ((rev >> 24) == 0)
\r
74 reg = (volatile uint32_t *)0x400CA00C;
\r
77 reg = (volatile uint32_t *)0x400C6020;
\r
78 *reg &= ~(0xE0000000UL);
\r
79 *reg |= ~(7UL << 25);
\r
81 if ((rev >> 24) <= 3)
\r
84 reg = (volatile uint32_t *)0x400C6020;
\r
85 *reg &= ~(0x00001F80UL);
\r
86 /* Update CMU reset values */
\r
87 reg = (volatile uint32_t *)0x400C8040;
\r
89 reg = (volatile uint32_t *)0x400C8044;
\r
91 reg = (volatile uint32_t *)0x400C8058;
\r
93 reg = (volatile uint32_t *)0x400C8060;
\r
95 reg = (volatile uint32_t *)0x400C8078;
\r
99 SYSTEM_ChipRevisionGet(&chipRev);
\r
100 if (chipRev.major == 0x01)
\r
102 /* Rev A errata handling for EM2/3. Must enable DMA clock in order for EM2/3 */
\r
103 /* to work. This will be fixed in later chip revisions, so only do for rev A. */
\r
104 if (chipRev.minor == 00)
\r
106 reg = (volatile uint32_t *)0x400C8040;
\r
110 /* Rev A+B errata handling for I2C when using EM2/3. USART0 clock must be enabled */
\r
111 /* after waking up from EM2/EM3 in order for I2C to work. This will be fixed in */
\r
112 /* later chip revisions, so only do for rev A+B. */
\r
113 if (chipRev.minor <= 0x01)
\r
115 reg = (volatile uint32_t *)0x400C8044;
\r
119 /* Ensure correct ADC/DAC calibration value */
\r
120 rev = *(volatile uint32_t *)0x0FE081F0;
\r
121 if (rev < 0x4C8ABA00)
\r
125 /* Enable ADC/DAC clocks */
\r
126 reg = (volatile uint32_t *)0x400C8044UL;
\r
127 *reg |= (1 << 14 | 1 << 11);
\r
129 /* Retrive calibration values */
\r
130 cal = ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x00007F00UL) >>
\r
133 cal |= ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x0000007FUL) >>
\r
136 cal |= ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x00007F00UL) >>
\r
139 cal |= ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x0000007FUL) >>
\r
142 /* ADC0->CAL = 1.25 reference */
\r
143 reg = (volatile uint32_t *)0x40002034UL;
\r
146 /* DAC0->CAL = 1.25 reference */
\r
147 reg = (volatile uint32_t *)(0x4000402CUL);
\r
148 cal = *(volatile uint32_t *)0x0FE081C8UL;
\r
151 /* Turn off ADC/DAC clocks */
\r
152 reg = (volatile uint32_t *)0x400C8044UL;
\r
153 *reg &= ~(1 << 14 | 1 << 11);
\r
157 #if defined(_EFM32_GIANT_FAMILY)
\r
159 SYSTEM_ChipRevision_TypeDef chipRev;
\r
161 rev = *(volatile uint32_t *)(0x0FE081FC);
\r
162 SYSTEM_ChipRevisionGet(&chipRev);
\r
164 if (((rev >> 24) > 15) && (chipRev.minor == 3))
\r
166 /* This fixes an issue with the LFXO on high temperatures. */
\r
167 *(volatile uint32_t*)0x400C80C0 =
\r
168 ( *(volatile uint32_t*)0x400C80C0 & ~(1<<6) ) | (1<<4);
\r
172 #if defined(_EFM32_HAPPY_FAMILY)
\r
174 rev = *(volatile uint32_t *)(0x0FE081FC);
\r
176 if ((rev >> 24) <= 129)
\r
178 /* This fixes a mistaken internal connection between PC0 and PC4 */
\r
179 /* This disables an internal pulldown on PC4 */
\r
180 *(volatile uint32_t*)(0x400C6018) = (1 << 26) | (5 << 0);
\r
181 /* This disables an internal LDO test signal driving PC4 */
\r
182 *(volatile uint32_t*)(0x400C80E4) &= ~(1 << 24);
\r
187 /** @} (end addtogroup CHIP) */
\r
188 /** @} (end addtogroup EM_Library) */
\r
194 #endif /* __SILICON_LABS_EM_CHIP_H_ */
\r