The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
TARGET_RO359B/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K24F/drivers/fsl_sim.h@143:86740a56073b
mbed library. Release version 164

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 143:86740a56073b 1 /*
AnnaBridge 143:86740a56073b 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
AnnaBridge 143:86740a56073b 3 * Copyright 2016-2017 NXP
AnnaBridge 143:86740a56073b 4 *
AnnaBridge 143:86740a56073b 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 143:86740a56073b 6 * are permitted provided that the following conditions are met:
AnnaBridge 143:86740a56073b 7 *
AnnaBridge 143:86740a56073b 8 * o Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 143:86740a56073b 9 * of conditions and the following disclaimer.
AnnaBridge 143:86740a56073b 10 *
AnnaBridge 143:86740a56073b 11 * o Redistributions in binary form must reproduce the above copyright notice, this
AnnaBridge 143:86740a56073b 12 * list of conditions and the following disclaimer in the documentation and/or
AnnaBridge 143:86740a56073b 13 * other materials provided with the distribution.
AnnaBridge 143:86740a56073b 14 *
AnnaBridge 143:86740a56073b 15 * o Neither the name of the copyright holder nor the names of its
AnnaBridge 143:86740a56073b 16 * contributors may be used to endorse or promote products derived from this
AnnaBridge 143:86740a56073b 17 * software without specific prior written permission.
AnnaBridge 143:86740a56073b 18 *
AnnaBridge 143:86740a56073b 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 143:86740a56073b 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 143:86740a56073b 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 143:86740a56073b 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 143:86740a56073b 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 143:86740a56073b 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 143:86740a56073b 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 143:86740a56073b 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 143:86740a56073b 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 143:86740a56073b 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 143:86740a56073b 29 */
AnnaBridge 143:86740a56073b 30
AnnaBridge 143:86740a56073b 31 #ifndef _FSL_SIM_H_
AnnaBridge 143:86740a56073b 32 #define _FSL_SIM_H_
AnnaBridge 143:86740a56073b 33
AnnaBridge 143:86740a56073b 34 #include "fsl_common.h"
AnnaBridge 143:86740a56073b 35
AnnaBridge 143:86740a56073b 36 /*! @addtogroup sim */
AnnaBridge 143:86740a56073b 37 /*! @{*/
AnnaBridge 143:86740a56073b 38
AnnaBridge 143:86740a56073b 39
AnnaBridge 143:86740a56073b 40 /*******************************************************************************
AnnaBridge 143:86740a56073b 41 * Definitions
AnnaBridge 143:86740a56073b 42 *******************************************************************************/
AnnaBridge 143:86740a56073b 43
AnnaBridge 143:86740a56073b 44 /*! @name Driver version */
AnnaBridge 143:86740a56073b 45 /*@{*/
AnnaBridge 143:86740a56073b 46 #define FSL_SIM_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) /*!< Driver version 2.0.0 */
AnnaBridge 143:86740a56073b 47 /*@}*/
AnnaBridge 143:86740a56073b 48
AnnaBridge 143:86740a56073b 49 #if (defined(FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR) && FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR)
AnnaBridge 143:86740a56073b 50 /*!@brief USB voltage regulator enable setting. */
AnnaBridge 143:86740a56073b 51 enum _sim_usb_volt_reg_enable_mode
AnnaBridge 143:86740a56073b 52 {
AnnaBridge 143:86740a56073b 53 kSIM_UsbVoltRegEnable = SIM_SOPT1_USBREGEN_MASK, /*!< Enable voltage regulator. */
AnnaBridge 143:86740a56073b 54 kSIM_UsbVoltRegEnableInLowPower = SIM_SOPT1_USBVSTBY_MASK, /*!< Enable voltage regulator in VLPR/VLPW modes. */
AnnaBridge 143:86740a56073b 55 kSIM_UsbVoltRegEnableInStop = SIM_SOPT1_USBSSTBY_MASK, /*!< Enable voltage regulator in STOP/VLPS/LLS/VLLS modes. */
AnnaBridge 143:86740a56073b 56 kSIM_UsbVoltRegEnableInAllModes = SIM_SOPT1_USBREGEN_MASK | SIM_SOPT1_USBSSTBY_MASK |
AnnaBridge 143:86740a56073b 57 SIM_SOPT1_USBVSTBY_MASK /*!< Enable voltage regulator in all power modes. */
AnnaBridge 143:86740a56073b 58 };
AnnaBridge 143:86740a56073b 59 #endif /* (defined(FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR) && FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR) */
AnnaBridge 143:86740a56073b 60
AnnaBridge 143:86740a56073b 61 /*!@brief Unique ID. */
AnnaBridge 143:86740a56073b 62 typedef struct _sim_uid
AnnaBridge 143:86740a56073b 63 {
AnnaBridge 143:86740a56073b 64 #if defined(SIM_UIDH)
AnnaBridge 143:86740a56073b 65 uint32_t H; /*!< UIDH. */
AnnaBridge 143:86740a56073b 66 #endif
AnnaBridge 143:86740a56073b 67 uint32_t MH; /*!< UIDMH. */
AnnaBridge 143:86740a56073b 68 uint32_t ML; /*!< UIDML. */
AnnaBridge 143:86740a56073b 69 uint32_t L; /*!< UIDL. */
AnnaBridge 143:86740a56073b 70 } sim_uid_t;
AnnaBridge 143:86740a56073b 71
AnnaBridge 143:86740a56073b 72 /*!@brief Flash enable mode. */
AnnaBridge 143:86740a56073b 73 enum _sim_flash_mode
AnnaBridge 143:86740a56073b 74 {
AnnaBridge 143:86740a56073b 75 kSIM_FlashDisableInWait = SIM_FCFG1_FLASHDOZE_MASK, /*!< Disable flash in wait mode. */
AnnaBridge 143:86740a56073b 76 kSIM_FlashDisable = SIM_FCFG1_FLASHDIS_MASK /*!< Disable flash in normal mode. */
AnnaBridge 143:86740a56073b 77 };
AnnaBridge 143:86740a56073b 78
AnnaBridge 143:86740a56073b 79 /*******************************************************************************
AnnaBridge 143:86740a56073b 80 * API
AnnaBridge 143:86740a56073b 81 ******************************************************************************/
AnnaBridge 143:86740a56073b 82
AnnaBridge 143:86740a56073b 83 #if defined(__cplusplus)
AnnaBridge 143:86740a56073b 84 extern "C" {
AnnaBridge 143:86740a56073b 85 #endif /* __cplusplus*/
AnnaBridge 143:86740a56073b 86
AnnaBridge 143:86740a56073b 87 #if (defined(FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR) && FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR)
AnnaBridge 143:86740a56073b 88 /*!
AnnaBridge 143:86740a56073b 89 * @brief Sets the USB voltage regulator setting.
AnnaBridge 143:86740a56073b 90 *
AnnaBridge 143:86740a56073b 91 * This function configures whether the USB voltage regulator is enabled in
AnnaBridge 143:86740a56073b 92 * normal RUN mode, STOP/VLPS/LLS/VLLS modes, and VLPR/VLPW modes. The configurations
AnnaBridge 143:86740a56073b 93 * are passed in as mask value of \ref _sim_usb_volt_reg_enable_mode. For example, to enable
AnnaBridge 143:86740a56073b 94 * USB voltage regulator in RUN/VLPR/VLPW modes and disable in STOP/VLPS/LLS/VLLS mode,
AnnaBridge 143:86740a56073b 95 * use:
AnnaBridge 143:86740a56073b 96 *
AnnaBridge 143:86740a56073b 97 * SIM_SetUsbVoltRegulatorEnableMode(kSIM_UsbVoltRegEnable | kSIM_UsbVoltRegEnableInLowPower);
AnnaBridge 143:86740a56073b 98 *
AnnaBridge 143:86740a56073b 99 * @param mask USB voltage regulator enable setting.
AnnaBridge 143:86740a56073b 100 */
AnnaBridge 143:86740a56073b 101 void SIM_SetUsbVoltRegulatorEnableMode(uint32_t mask);
AnnaBridge 143:86740a56073b 102 #endif /* FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR */
AnnaBridge 143:86740a56073b 103
AnnaBridge 143:86740a56073b 104 /*!
AnnaBridge 143:86740a56073b 105 * @brief Gets the unique identification register value.
AnnaBridge 143:86740a56073b 106 *
AnnaBridge 143:86740a56073b 107 * @param uid Pointer to the structure to save the UID value.
AnnaBridge 143:86740a56073b 108 */
AnnaBridge 143:86740a56073b 109 void SIM_GetUniqueId(sim_uid_t *uid);
AnnaBridge 143:86740a56073b 110
AnnaBridge 143:86740a56073b 111 /*!
AnnaBridge 143:86740a56073b 112 * @brief Sets the flash enable mode.
AnnaBridge 143:86740a56073b 113 *
AnnaBridge 143:86740a56073b 114 * @param mode The mode to set; see \ref _sim_flash_mode for mode details.
AnnaBridge 143:86740a56073b 115 */
AnnaBridge 143:86740a56073b 116 static inline void SIM_SetFlashMode(uint8_t mode)
AnnaBridge 143:86740a56073b 117 {
AnnaBridge 143:86740a56073b 118 SIM->FCFG1 = mode;
AnnaBridge 143:86740a56073b 119 }
AnnaBridge 143:86740a56073b 120
AnnaBridge 143:86740a56073b 121 #if defined(__cplusplus)
AnnaBridge 143:86740a56073b 122 }
AnnaBridge 143:86740a56073b 123 #endif /* __cplusplus*/
AnnaBridge 143:86740a56073b 124
AnnaBridge 143:86740a56073b 125 /*! @}*/
AnnaBridge 143:86740a56073b 126
AnnaBridge 143:86740a56073b 127 #endif /* _FSL_SIM_H_ */