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@149:156823d33999, 2016-10-28 (annotated)
- Committer:
- <>
- Date:
- Fri Oct 28 11:17:30 2016 +0100
- Revision:
- 149:156823d33999
- Child:
- 150:02e0a0aed4ec
This updates the lib to the mbed lib v128
NOTE: This release includes a restructuring of the file and directory locations and thus some
include paths in your code may need updating accordingly.
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 |
<> | 149:156823d33999 | 4 | * @version 4.2.1 |
<> | 149:156823d33999 | 5 | ******************************************************************************* |
<> | 149:156823d33999 | 6 | * @section License |
<> | 149:156823d33999 | 7 | * <b>(C) Copyright 2015 Silicon Labs, 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" |
<> | 149:156823d33999 | 35 | #include "core_cmSecureAccess.h" |
<> | 149:156823d33999 | 36 | |
<> | 149:156823d33999 | 37 | /***************************************************************************//** |
<> | 149:156823d33999 | 38 | * @addtogroup EM_Library |
<> | 149:156823d33999 | 39 | * @{ |
<> | 149:156823d33999 | 40 | ******************************************************************************/ |
<> | 149:156823d33999 | 41 | |
<> | 149:156823d33999 | 42 | /***************************************************************************//** |
<> | 149:156823d33999 | 43 | * @addtogroup SYSTEM |
<> | 149:156823d33999 | 44 | * @brief System Peripheral API |
<> | 149:156823d33999 | 45 | * @{ |
<> | 149:156823d33999 | 46 | ******************************************************************************/ |
<> | 149:156823d33999 | 47 | |
<> | 149:156823d33999 | 48 | /******************************************************************************* |
<> | 149:156823d33999 | 49 | ************************** GLOBAL FUNCTIONS ******************************* |
<> | 149:156823d33999 | 50 | ******************************************************************************/ |
<> | 149:156823d33999 | 51 | |
<> | 149:156823d33999 | 52 | /***************************************************************************//** |
<> | 149:156823d33999 | 53 | * @brief |
<> | 149:156823d33999 | 54 | * Get chip major/minor revision. |
<> | 149:156823d33999 | 55 | * |
<> | 149:156823d33999 | 56 | * @param[out] rev |
<> | 149:156823d33999 | 57 | * Location to place chip revision info. |
<> | 149:156823d33999 | 58 | ******************************************************************************/ |
<> | 149:156823d33999 | 59 | void SYSTEM_ChipRevisionGet(SYSTEM_ChipRevision_TypeDef *rev) |
<> | 149:156823d33999 | 60 | { |
<> | 149:156823d33999 | 61 | uint8_t tmp; |
<> | 149:156823d33999 | 62 | |
<> | 149:156823d33999 | 63 | EFM_ASSERT(rev); |
<> | 149:156823d33999 | 64 | |
<> | 149:156823d33999 | 65 | uint32_t pid0 = SECURE_READ(&(ROMTABLE->PID0)); |
<> | 149:156823d33999 | 66 | uint32_t pid1 = SECURE_READ(&(ROMTABLE->PID1)); |
<> | 149:156823d33999 | 67 | uint32_t pid2 = SECURE_READ(&(ROMTABLE->PID2)); |
<> | 149:156823d33999 | 68 | uint32_t pid3 = SECURE_READ(&(ROMTABLE->PID3)); |
<> | 149:156823d33999 | 69 | |
<> | 149:156823d33999 | 70 | /* CHIP FAMILY bit [5:2] */ |
<> | 149:156823d33999 | 71 | tmp = (((pid1 & _ROMTABLE_PID1_FAMILYMSB_MASK) >> _ROMTABLE_PID1_FAMILYMSB_SHIFT) << 2); |
<> | 149:156823d33999 | 72 | /* CHIP FAMILY bit [1:0] */ |
<> | 149:156823d33999 | 73 | tmp |= ((pid0 & _ROMTABLE_PID0_FAMILYLSB_MASK) >> _ROMTABLE_PID0_FAMILYLSB_SHIFT); |
<> | 149:156823d33999 | 74 | rev->family = tmp; |
<> | 149:156823d33999 | 75 | |
<> | 149:156823d33999 | 76 | /* CHIP MAJOR bit [3:0] */ |
<> | 149:156823d33999 | 77 | rev->major = (pid0 & _ROMTABLE_PID0_REVMAJOR_MASK) >> _ROMTABLE_PID0_REVMAJOR_SHIFT; |
<> | 149:156823d33999 | 78 | |
<> | 149:156823d33999 | 79 | /* CHIP MINOR bit [7:4] */ |
<> | 149:156823d33999 | 80 | tmp = (((pid2 & _ROMTABLE_PID2_REVMINORMSB_MASK) >> _ROMTABLE_PID2_REVMINORMSB_SHIFT) << 4); |
<> | 149:156823d33999 | 81 | /* CHIP MINOR bit [3:0] */ |
<> | 149:156823d33999 | 82 | tmp |= ((pid3 & _ROMTABLE_PID3_REVMINORLSB_MASK) >> _ROMTABLE_PID3_REVMINORLSB_SHIFT); |
<> | 149:156823d33999 | 83 | rev->minor = tmp; |
<> | 149:156823d33999 | 84 | } |
<> | 149:156823d33999 | 85 | |
<> | 149:156823d33999 | 86 | |
<> | 149:156823d33999 | 87 | #if defined(CALIBRATE) |
<> | 149:156823d33999 | 88 | /***************************************************************************//** |
<> | 149:156823d33999 | 89 | * @brief |
<> | 149:156823d33999 | 90 | * Get factory calibration value for a given peripheral register. |
<> | 149:156823d33999 | 91 | * |
<> | 149:156823d33999 | 92 | * @param[in] regAddress |
<> | 149:156823d33999 | 93 | * Address of register to get a calibration value for. |
<> | 149:156823d33999 | 94 | * |
<> | 149:156823d33999 | 95 | * @return |
<> | 149:156823d33999 | 96 | * Calibration value for the requested register. |
<> | 149:156823d33999 | 97 | ******************************************************************************/ |
<> | 149:156823d33999 | 98 | uint32_t SYSTEM_GetCalibrationValue(volatile uint32_t *regAddress) |
<> | 149:156823d33999 | 99 | { |
<> | 149:156823d33999 | 100 | int regCount; |
<> | 149:156823d33999 | 101 | CALIBRATE_TypeDef *p; |
<> | 149:156823d33999 | 102 | |
<> | 149:156823d33999 | 103 | regCount = 1; |
<> | 149:156823d33999 | 104 | p = CALIBRATE; |
<> | 149:156823d33999 | 105 | |
<> | 149:156823d33999 | 106 | for (;; ) |
<> | 149:156823d33999 | 107 | { |
<> | 149:156823d33999 | 108 | if ((regCount > CALIBRATE_MAX_REGISTERS) || |
<> | 149:156823d33999 | 109 | (p->VALUE == 0xFFFFFFFF)) |
<> | 149:156823d33999 | 110 | { |
<> | 149:156823d33999 | 111 | EFM_ASSERT(false); |
<> | 149:156823d33999 | 112 | return 0; /* End of device calibration table reached. */ |
<> | 149:156823d33999 | 113 | } |
<> | 149:156823d33999 | 114 | |
<> | 149:156823d33999 | 115 | if (p->ADDRESS == (uint32_t)regAddress) |
<> | 149:156823d33999 | 116 | { |
<> | 149:156823d33999 | 117 | return p->VALUE; /* Calibration value found ! */ |
<> | 149:156823d33999 | 118 | } |
<> | 149:156823d33999 | 119 | |
<> | 149:156823d33999 | 120 | p++; |
<> | 149:156823d33999 | 121 | regCount++; |
<> | 149:156823d33999 | 122 | } |
<> | 149:156823d33999 | 123 | } |
<> | 149:156823d33999 | 124 | #endif /* defined (CALIBRATE) */ |
<> | 149:156823d33999 | 125 | |
<> | 149:156823d33999 | 126 | /** @} (end addtogroup SYSTEM) */ |
<> | 149:156823d33999 | 127 | /** @} (end addtogroup EM_Library) */ |