mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_Silicon_Labs/TARGET_EFM32/emlib/src/em_system.c@189:f392fc9709a3, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 22:31:08 2019 +0000
- Revision:
- 189:f392fc9709a3
- Parent:
- 188:bcfe06ba3d64
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 149:156823d33999 | 1 | /***************************************************************************//** |
<> | 149:156823d33999 | 2 | * @file em_system.c |
<> | 149:156823d33999 | 3 | * @brief System Peripheral API |
AnnaBridge | 179:b0033dcd6934 | 4 | * @version 5.3.3 |
<> | 149:156823d33999 | 5 | ******************************************************************************* |
AnnaBridge | 179:b0033dcd6934 | 6 | * # License |
<> | 150:02e0a0aed4ec | 7 | * <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b> |
<> | 149:156823d33999 | 8 | ******************************************************************************* |
<> | 149:156823d33999 | 9 | * |
<> | 149:156823d33999 | 10 | * Permission is granted to anyone to use this software for any purpose, |
<> | 149:156823d33999 | 11 | * including commercial applications, and to alter it and redistribute it |
<> | 149:156823d33999 | 12 | * freely, subject to the following restrictions: |
<> | 149:156823d33999 | 13 | * |
<> | 149:156823d33999 | 14 | * 1. The origin of this software must not be misrepresented; you must not |
<> | 149:156823d33999 | 15 | * claim that you wrote the original software. |
<> | 149:156823d33999 | 16 | * 2. Altered source versions must be plainly marked as such, and must not be |
<> | 149:156823d33999 | 17 | * misrepresented as being the original software. |
<> | 149:156823d33999 | 18 | * 3. This notice may not be removed or altered from any source distribution. |
<> | 149:156823d33999 | 19 | * |
<> | 149:156823d33999 | 20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no |
<> | 149:156823d33999 | 21 | * obligation to support this Software. Silicon Labs is providing the |
<> | 149:156823d33999 | 22 | * Software "AS IS", with no express or implied warranties of any kind, |
<> | 149:156823d33999 | 23 | * including, but not limited to, any implied warranties of merchantability |
<> | 149:156823d33999 | 24 | * or fitness for any particular purpose or warranties against infringement |
<> | 149:156823d33999 | 25 | * of any proprietary rights of a third party. |
<> | 149:156823d33999 | 26 | * |
<> | 149:156823d33999 | 27 | * Silicon Labs will not be liable for any consequential, incidental, or |
<> | 149:156823d33999 | 28 | * special damages, or any other relief, or for any claim by any third party, |
<> | 149:156823d33999 | 29 | * arising from your use of this Software. |
<> | 149:156823d33999 | 30 | * |
<> | 149:156823d33999 | 31 | ******************************************************************************/ |
<> | 149:156823d33999 | 32 | |
<> | 149:156823d33999 | 33 | #include "em_system.h" |
<> | 149:156823d33999 | 34 | #include "em_assert.h" |
<> | 150:02e0a0aed4ec | 35 | #include <stddef.h> |
<> | 149:156823d33999 | 36 | |
<> | 149:156823d33999 | 37 | /***************************************************************************//** |
<> | 150:02e0a0aed4ec | 38 | * @addtogroup emlib |
<> | 149:156823d33999 | 39 | * @{ |
<> | 149:156823d33999 | 40 | ******************************************************************************/ |
<> | 149:156823d33999 | 41 | |
<> | 149:156823d33999 | 42 | /***************************************************************************//** |
<> | 149:156823d33999 | 43 | * @addtogroup SYSTEM |
<> | 149:156823d33999 | 44 | * @{ |
<> | 149:156823d33999 | 45 | ******************************************************************************/ |
<> | 149:156823d33999 | 46 | |
<> | 149:156823d33999 | 47 | /******************************************************************************* |
<> | 149:156823d33999 | 48 | ************************** GLOBAL FUNCTIONS ******************************* |
<> | 149:156823d33999 | 49 | ******************************************************************************/ |
<> | 149:156823d33999 | 50 | |
<> | 149:156823d33999 | 51 | /***************************************************************************//** |
<> | 149:156823d33999 | 52 | * @brief |
<> | 149:156823d33999 | 53 | * Get chip major/minor revision. |
<> | 149:156823d33999 | 54 | * |
<> | 149:156823d33999 | 55 | * @param[out] rev |
<> | 149:156823d33999 | 56 | * Location to place chip revision info. |
<> | 149:156823d33999 | 57 | ******************************************************************************/ |
<> | 149:156823d33999 | 58 | void SYSTEM_ChipRevisionGet(SYSTEM_ChipRevision_TypeDef *rev) |
<> | 149:156823d33999 | 59 | { |
<> | 149:156823d33999 | 60 | uint8_t tmp; |
<> | 149:156823d33999 | 61 | |
<> | 149:156823d33999 | 62 | EFM_ASSERT(rev); |
AnnaBridge | 179:b0033dcd6934 | 63 | |
<> | 149:156823d33999 | 64 | /* CHIP FAMILY bit [5:2] */ |
AnnaBridge | 188:bcfe06ba3d64 | 65 | tmp = (((ROMTABLE->PID1 & _ROMTABLE_PID1_FAMILYMSB_MASK) >> _ROMTABLE_PID1_FAMILYMSB_SHIFT) << 2); |
<> | 149:156823d33999 | 66 | /* CHIP FAMILY bit [1:0] */ |
AnnaBridge | 188:bcfe06ba3d64 | 67 | tmp |= ((ROMTABLE->PID0 & _ROMTABLE_PID0_FAMILYLSB_MASK) >> _ROMTABLE_PID0_FAMILYLSB_SHIFT); |
<> | 149:156823d33999 | 68 | rev->family = tmp; |
<> | 149:156823d33999 | 69 | |
<> | 149:156823d33999 | 70 | /* CHIP MAJOR bit [3:0] */ |
AnnaBridge | 188:bcfe06ba3d64 | 71 | rev->major = (ROMTABLE->PID0 & _ROMTABLE_PID0_REVMAJOR_MASK) >> _ROMTABLE_PID0_REVMAJOR_SHIFT; |
<> | 149:156823d33999 | 72 | |
<> | 149:156823d33999 | 73 | /* CHIP MINOR bit [7:4] */ |
AnnaBridge | 188:bcfe06ba3d64 | 74 | tmp = (((ROMTABLE->PID2 & _ROMTABLE_PID2_REVMINORMSB_MASK) >> _ROMTABLE_PID2_REVMINORMSB_SHIFT) << 4); |
<> | 149:156823d33999 | 75 | /* CHIP MINOR bit [3:0] */ |
AnnaBridge | 188:bcfe06ba3d64 | 76 | tmp |= ((ROMTABLE->PID3 & _ROMTABLE_PID3_REVMINORLSB_MASK) >> _ROMTABLE_PID3_REVMINORLSB_SHIFT); |
<> | 149:156823d33999 | 77 | rev->minor = tmp; |
<> | 149:156823d33999 | 78 | } |
<> | 149:156823d33999 | 79 | |
<> | 149:156823d33999 | 80 | /***************************************************************************//** |
<> | 149:156823d33999 | 81 | * @brief |
<> | 149:156823d33999 | 82 | * Get factory calibration value for a given peripheral register. |
<> | 149:156823d33999 | 83 | * |
<> | 149:156823d33999 | 84 | * @param[in] regAddress |
<> | 150:02e0a0aed4ec | 85 | * Peripheral calibration register address to get calibration value for. If |
<> | 150:02e0a0aed4ec | 86 | * a calibration value is found then this register is updated with the |
<> | 150:02e0a0aed4ec | 87 | * calibration value. |
<> | 149:156823d33999 | 88 | * |
<> | 149:156823d33999 | 89 | * @return |
<> | 150:02e0a0aed4ec | 90 | * True if a calibration value exists, false otherwise. |
<> | 149:156823d33999 | 91 | ******************************************************************************/ |
<> | 150:02e0a0aed4ec | 92 | bool SYSTEM_GetCalibrationValue(volatile uint32_t *regAddress) |
<> | 149:156823d33999 | 93 | { |
<> | 150:02e0a0aed4ec | 94 | SYSTEM_CalAddrVal_TypeDef * p, * end; |
<> | 149:156823d33999 | 95 | |
<> | 150:02e0a0aed4ec | 96 | p = (SYSTEM_CalAddrVal_TypeDef *)(DEVINFO_BASE & 0xFFFFF000); |
<> | 150:02e0a0aed4ec | 97 | end = (SYSTEM_CalAddrVal_TypeDef *)DEVINFO_BASE; |
<> | 149:156823d33999 | 98 | |
AnnaBridge | 179:b0033dcd6934 | 99 | for (; p < end; p++) { |
AnnaBridge | 179:b0033dcd6934 | 100 | if (p->address == (uint32_t)regAddress) { |
<> | 150:02e0a0aed4ec | 101 | *regAddress = p->calValue; |
<> | 150:02e0a0aed4ec | 102 | return true; |
<> | 149:156823d33999 | 103 | } |
<> | 149:156823d33999 | 104 | } |
<> | 150:02e0a0aed4ec | 105 | /* Nothing found for regAddress */ |
<> | 150:02e0a0aed4ec | 106 | return false; |
<> | 149:156823d33999 | 107 | } |
<> | 149:156823d33999 | 108 | |
<> | 149:156823d33999 | 109 | /** @} (end addtogroup SYSTEM) */ |
<> | 150:02e0a0aed4ec | 110 | /** @} (end addtogroup emlib) */ |