1 /***************************************************************************//**
\r
3 * @brief Chip Initialization API
\r
5 *******************************************************************************
\r
7 * <b>(C) Copyright 2015 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
33 #ifndef __SILICON_LABS_EM_CHIP_H__
\r
34 #define __SILICON_LABS_EM_CHIP_H__
\r
36 #include "em_device.h"
\r
37 #include "em_system.h"
\r
43 /***************************************************************************//**
\r
44 * @addtogroup EM_Library
\r
46 ******************************************************************************/
\r
48 /***************************************************************************//**
\r
50 * @brief Chip Initialization API
\r
52 ******************************************************************************/
\r
54 /**************************************************************************//**
\r
56 * Chip initialization routine for revision errata workarounds
\r
58 * This init function will configure the device to a state where it is
\r
59 * as similar as later revisions as possible, to improve software compatibility
\r
60 * with newer parts. See the device specific errata for details.
\r
61 *****************************************************************************/
\r
62 __STATIC_INLINE void CHIP_Init(void)
\r
64 #if defined(_EFM32_GECKO_FAMILY)
\r
66 SYSTEM_ChipRevision_TypeDef chipRev;
\r
67 volatile uint32_t *reg;
\r
69 rev = *(volatile uint32_t *)(0x0FE081FC);
\r
70 /* Engineering Sample calibration setup */
\r
71 if ((rev >> 24) == 0)
\r
73 reg = (volatile uint32_t *)0x400CA00C;
\r
76 reg = (volatile uint32_t *)0x400C6020;
\r
77 *reg &= ~(0xE0000000UL);
\r
78 *reg |= ~(7UL << 25);
\r
80 if ((rev >> 24) <= 3)
\r
83 reg = (volatile uint32_t *)0x400C6020;
\r
84 *reg &= ~(0x00001F80UL);
\r
85 /* Update CMU reset values */
\r
86 reg = (volatile uint32_t *)0x400C8040;
\r
88 reg = (volatile uint32_t *)0x400C8044;
\r
90 reg = (volatile uint32_t *)0x400C8058;
\r
92 reg = (volatile uint32_t *)0x400C8060;
\r
94 reg = (volatile uint32_t *)0x400C8078;
\r
98 SYSTEM_ChipRevisionGet(&chipRev);
\r
99 if (chipRev.major == 0x01)
\r
101 /* Rev A errata handling for EM2/3. Must enable DMA clock in order for EM2/3 */
\r
102 /* to work. This will be fixed in later chip revisions, so only do for rev A. */
\r
103 if (chipRev.minor == 00)
\r
105 reg = (volatile uint32_t *)0x400C8040;
\r
109 /* Rev A+B errata handling for I2C when using EM2/3. USART0 clock must be enabled */
\r
110 /* after waking up from EM2/EM3 in order for I2C to work. This will be fixed in */
\r
111 /* later chip revisions, so only do for rev A+B. */
\r
112 if (chipRev.minor <= 0x01)
\r
114 reg = (volatile uint32_t *)0x400C8044;
\r
118 /* Ensure correct ADC/DAC calibration value */
\r
119 rev = *(volatile uint32_t *)0x0FE081F0;
\r
120 if (rev < 0x4C8ABA00)
\r
124 /* Enable ADC/DAC clocks */
\r
125 reg = (volatile uint32_t *)0x400C8044UL;
\r
126 *reg |= (1 << 14 | 1 << 11);
\r
128 /* Retrive calibration values */
\r
129 cal = ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x00007F00UL) >>
\r
132 cal |= ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x0000007FUL) >>
\r
135 cal |= ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x00007F00UL) >>
\r
138 cal |= ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x0000007FUL) >>
\r
141 /* ADC0->CAL = 1.25 reference */
\r
142 reg = (volatile uint32_t *)0x40002034UL;
\r
145 /* DAC0->CAL = 1.25 reference */
\r
146 reg = (volatile uint32_t *)(0x4000402CUL);
\r
147 cal = *(volatile uint32_t *)0x0FE081C8UL;
\r
150 /* Turn off ADC/DAC clocks */
\r
151 reg = (volatile uint32_t *)0x400C8044UL;
\r
152 *reg &= ~(1 << 14 | 1 << 11);
\r
156 #if defined(_EFM32_GIANT_FAMILY)
\r
158 SYSTEM_ChipRevision_TypeDef chipRev;
\r
160 rev = *(volatile uint32_t *)(0x0FE081FC);
\r
161 SYSTEM_ChipRevisionGet(&chipRev);
\r
163 if (((rev >> 24) > 15) && (chipRev.minor == 3))
\r
165 /* This fixes an issue with the LFXO on high temperatures. */
\r
166 *(volatile uint32_t*)0x400C80C0 =
\r
167 ( *(volatile uint32_t*)0x400C80C0 & ~(1<<6) ) | (1<<4);
\r
171 #if defined(_EFM32_HAPPY_FAMILY)
\r
173 rev = *(volatile uint32_t *)(0x0FE081FC);
\r
175 if ((rev >> 24) <= 129)
\r
177 /* This fixes a mistaken internal connection between PC0 and PC4 */
\r
178 /* This disables an internal pulldown on PC4 */
\r
179 *(volatile uint32_t*)(0x400C6018) = (1 << 26) | (5 << 0);
\r
180 /* This disables an internal LDO test signal driving PC4 */
\r
181 *(volatile uint32_t*)(0x400C80E4) &= ~(1 << 24);
\r
186 /** @} (end addtogroup CHIP) */
\r
187 /** @} (end addtogroup EM_Library) */
\r
193 #endif /* __SILICON_LABS_EM_CHIP_H__ */
\r