mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Thu Dec 07 14:01:42 2017 +0000
Revision:
179:b0033dcd6934
Parent:
161:2cc1468da177
Child:
188:bcfe06ba3d64
mbed-dev library. Release version 157

Who changed what in which revision?

UserRevisionLine numberNew 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 #include "core_cmSecureAccess.h"
<> 149:156823d33999 37
<> 149:156823d33999 38 /***************************************************************************//**
<> 150:02e0a0aed4ec 39 * @addtogroup emlib
<> 149:156823d33999 40 * @{
<> 149:156823d33999 41 ******************************************************************************/
<> 149:156823d33999 42
<> 149:156823d33999 43 /***************************************************************************//**
<> 149:156823d33999 44 * @addtogroup SYSTEM
<> 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);
AnnaBridge 179:b0033dcd6934 64
AnnaBridge 179:b0033dcd6934 65 uint32_t pid0 = SECURE_READ(&(ROMTABLE->PID0));
AnnaBridge 179:b0033dcd6934 66 uint32_t pid1 = SECURE_READ(&(ROMTABLE->PID1));
AnnaBridge 179:b0033dcd6934 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 * @brief
<> 149:156823d33999 88 * Get factory calibration value for a given peripheral register.
<> 149:156823d33999 89 *
<> 149:156823d33999 90 * @param[in] regAddress
<> 150:02e0a0aed4ec 91 * Peripheral calibration register address to get calibration value for. If
<> 150:02e0a0aed4ec 92 * a calibration value is found then this register is updated with the
<> 150:02e0a0aed4ec 93 * calibration value.
<> 149:156823d33999 94 *
<> 149:156823d33999 95 * @return
<> 150:02e0a0aed4ec 96 * True if a calibration value exists, false otherwise.
<> 149:156823d33999 97 ******************************************************************************/
<> 150:02e0a0aed4ec 98 bool SYSTEM_GetCalibrationValue(volatile uint32_t *regAddress)
<> 149:156823d33999 99 {
<> 150:02e0a0aed4ec 100 SYSTEM_CalAddrVal_TypeDef * p, * end;
<> 149:156823d33999 101
<> 150:02e0a0aed4ec 102 p = (SYSTEM_CalAddrVal_TypeDef *)(DEVINFO_BASE & 0xFFFFF000);
<> 150:02e0a0aed4ec 103 end = (SYSTEM_CalAddrVal_TypeDef *)DEVINFO_BASE;
<> 149:156823d33999 104
AnnaBridge 179:b0033dcd6934 105 for (; p < end; p++) {
AnnaBridge 179:b0033dcd6934 106 if (p->address == (uint32_t)regAddress) {
<> 150:02e0a0aed4ec 107 *regAddress = p->calValue;
<> 150:02e0a0aed4ec 108 return true;
<> 149:156823d33999 109 }
<> 149:156823d33999 110 }
<> 150:02e0a0aed4ec 111 /* Nothing found for regAddress */
<> 150:02e0a0aed4ec 112 return false;
<> 149:156823d33999 113 }
<> 149:156823d33999 114
<> 149:156823d33999 115 /** @} (end addtogroup SYSTEM) */
<> 150:02e0a0aed4ec 116 /** @} (end addtogroup emlib) */