em_chip.h
Go to the documentation of this file.00001
00034 #ifndef __EM_CHIP_H
00035 #define __EM_CHIP_H
00036
00037 #include "em_device.h"
00038 #include "em_system.h"
00039
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043
00044
00049
00055
00063 __STATIC_INLINE void CHIP_Init(void)
00064 {
00065 #if defined(_EFM32_GECKO_FAMILY)
00066 uint32_t rev;
00067 SYSTEM_ChipRevision_TypeDef chipRev;
00068 volatile uint32_t *reg;
00069
00070 rev = *(volatile uint32_t *)(0x0FE081FC);
00071
00072 if ((rev >> 24) == 0)
00073 {
00074 reg = (volatile uint32_t *)0x400CA00C;
00075 *reg &= ~(0x70UL);
00076
00077 reg = (volatile uint32_t *)0x400C6020;
00078 *reg &= ~(0xE0000000UL);
00079 *reg |= ~(7UL << 25);
00080 }
00081 if ((rev >> 24) <= 3)
00082 {
00083
00084 reg = (volatile uint32_t *)0x400C6020;
00085 *reg &= ~(0x00001F80UL);
00086
00087 reg = (volatile uint32_t *)0x400C8040;
00088 *reg = 0;
00089 reg = (volatile uint32_t *)0x400C8044;
00090 *reg = 0;
00091 reg = (volatile uint32_t *)0x400C8058;
00092 *reg = 0;
00093 reg = (volatile uint32_t *)0x400C8060;
00094 *reg = 0;
00095 reg = (volatile uint32_t *)0x400C8078;
00096 *reg = 0;
00097 }
00098
00099 SYSTEM_ChipRevisionGet(&chipRev);
00100 if (chipRev.major == 0x01)
00101 {
00102
00103
00104 if (chipRev.minor == 00)
00105 {
00106 reg = (volatile uint32_t *)0x400C8040;
00107 *reg |= 0x2;
00108 }
00109
00110
00111
00112
00113 if (chipRev.minor <= 0x01)
00114 {
00115 reg = (volatile uint32_t *)0x400C8044;
00116 *reg |= 0x1;
00117 }
00118 }
00119
00120 rev = *(volatile uint32_t *)0x0FE081F0;
00121 if (rev < 0x4C8ABA00)
00122 {
00123 uint32_t cal;
00124
00125
00126 reg = (volatile uint32_t *)0x400C8044UL;
00127 *reg |= (1 << 14 | 1 << 11);
00128
00129
00130 cal = ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x00007F00UL) >>
00131 8) << 24;
00132
00133 cal |= ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x0000007FUL) >>
00134 0) << 16;
00135
00136 cal |= ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x00007F00UL) >>
00137 8) << 8;
00138
00139 cal |= ((*(volatile uint32_t *)(0x0FE081B4UL) & 0x0000007FUL) >>
00140 0) << 0;
00141
00142
00143 reg = (volatile uint32_t *)0x40002034UL;
00144 *reg = cal;
00145
00146
00147 reg = (volatile uint32_t *)(0x4000402CUL);
00148 cal = *(volatile uint32_t *)0x0FE081C8UL;
00149 *reg = cal;
00150
00151
00152 reg = (volatile uint32_t *)0x400C8044UL;
00153 *reg &= ~(1 << 14 | 1 << 11);
00154 }
00155 #endif
00156
00157 #if defined(_EFM32_GIANT_FAMILY)
00158 uint32_t rev;
00159 SYSTEM_ChipRevision_TypeDef chipRev;
00160
00161 rev = *(volatile uint32_t *)(0x0FE081FC);
00162 SYSTEM_ChipRevisionGet(&chipRev);
00163
00164 if (((rev >> 24) > 15) && (chipRev.minor == 3))
00165 {
00166
00167 *(volatile uint32_t*)0x400C80C0 =
00168 ( *(volatile uint32_t*)0x400C80C0 & ~(1<<6) ) | (1<<4);
00169 }
00170 #endif
00171 }
00172
00176 #ifdef __cplusplus
00177 }
00178 #endif
00179
00180 #endif