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
mbed library. Release version 164

Who changed what in which revision?

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