1 /* 2 * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 * Copyright 2016-2021 NXP 4 * All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 9 #include "fsl_sim.h" 10 11 /* Component ID definition, used by tools. */ 12 #ifndef FSL_COMPONENT_ID 13 #define FSL_COMPONENT_ID "platform.drivers.sim" 14 #endif 15 16 /******************************************************************************* 17 * Codes 18 ******************************************************************************/ 19 #if (defined(FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR) && FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR) 20 /*! 21 * brief Sets the USB voltage regulator setting. 22 * 23 * This function configures whether the USB voltage regulator is enabled in 24 * normal RUN mode, STOP/VLPS/LLS/VLLS modes, and VLPR/VLPW modes. The configurations 25 * are passed in as mask value of \ref _sim_usb_volt_reg_enable_mode. For example, to enable 26 * USB voltage regulator in RUN/VLPR/VLPW modes and disable in STOP/VLPS/LLS/VLLS mode, 27 * use: 28 * 29 * SIM_SetUsbVoltRegulatorEnableMode(kSIM_UsbVoltRegEnable | kSIM_UsbVoltRegEnableInLowPower); 30 * 31 * param mask USB voltage regulator enable setting. 32 */ SIM_SetUsbVoltRegulatorEnableMode(uint32_t mask)33void SIM_SetUsbVoltRegulatorEnableMode(uint32_t mask) 34 { 35 SIM->SOPT1CFG |= (SIM_SOPT1CFG_URWE_MASK | SIM_SOPT1CFG_UVSWE_MASK | SIM_SOPT1CFG_USSWE_MASK); 36 37 SIM->SOPT1 = (SIM->SOPT1 & ~(uint32_t)kSIM_UsbVoltRegEnableInAllModes) | mask; 38 } 39 #endif /* FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR */ 40 41 /*! 42 * brief Gets the unique identification register value. 43 * 44 * param uid Pointer to the structure to save the UID value. 45 */ SIM_GetUniqueId(sim_uid_t * uid)46void SIM_GetUniqueId(sim_uid_t *uid) 47 { 48 #if (defined(FSL_FEATURE_SIM_HAS_UIDH) && FSL_FEATURE_SIM_HAS_UIDH) 49 uid->H = SIM->UIDH; 50 #elif defined(SIM_UID0_UID_MASK) 51 uid->H = SIM->UID0; 52 #endif /* FSL_FEATURE_SIM_HAS_UIDH */ 53 54 #if (defined(FSL_FEATURE_SIM_HAS_UIDM) && FSL_FEATURE_SIM_HAS_UIDM) 55 uid->M = SIM->UIDM; 56 #else 57 58 #if defined(SIM_UID1_UID_MASK) 59 uid->MH = SIM->UID1; 60 #else 61 uid->MH = SIM->UIDMH; 62 #endif /* SIM_UID1_UID_MASK */ 63 64 #if defined(SIM_UID2_UID_MASK) 65 uid->ML = SIM->UID2; 66 #else 67 uid->ML = SIM->UIDML; 68 #endif /* SIM_UID2_UID_MASK */ 69 70 #endif /* FSL_FEATURE_SIM_HAS_UIDM */ 71 72 #if defined(SIM_UID3_UID_MASK) 73 uid->L = SIM->UID3; 74 #else 75 uid->L = SIM->UIDL; 76 #endif /* SIM_UID3_UID_MASK */ 77 } 78 79 #if (defined(FSL_FEATURE_SIM_HAS_RF_MAC_ADDR) && FSL_FEATURE_SIM_HAS_RF_MAC_ADDR) 80 /*! 81 * brief Gets the RF address register value. 82 * 83 * param info Pointer to the structure to save the RF address value. 84 */ SIM_GetRfAddr(sim_rf_addr_t * info)85void SIM_GetRfAddr(sim_rf_addr_t *info) 86 { 87 info->rfAddrL = SIM->RFADDRL; 88 info->rfAddrH = SIM->RFADDRH; 89 } 90 #endif /* FSL_FEATURE_SIM_HAS_RF_MAC_ADDR */ 91