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.
TARGET_KL27Z/TOOLCHAIN_IAR/fsl_vref.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 20:53:29 2019 +0000
- Revision:
- 172:65be27845400
- Parent:
- 171:3a7713b1edbc
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New 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_VREF_H_ |
AnnaBridge | 171:3a7713b1edbc | 32 | #define _FSL_VREF_H_ |
AnnaBridge | 171:3a7713b1edbc | 33 | |
AnnaBridge | 171:3a7713b1edbc | 34 | #include "fsl_common.h" |
AnnaBridge | 171:3a7713b1edbc | 35 | |
AnnaBridge | 171:3a7713b1edbc | 36 | /*! |
AnnaBridge | 171:3a7713b1edbc | 37 | * @addtogroup vref |
AnnaBridge | 171:3a7713b1edbc | 38 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 39 | */ |
AnnaBridge | 171:3a7713b1edbc | 40 | |
AnnaBridge | 171:3a7713b1edbc | 41 | /*! @file */ |
AnnaBridge | 171:3a7713b1edbc | 42 | |
AnnaBridge | 171:3a7713b1edbc | 43 | /****************************************************************************** |
AnnaBridge | 171:3a7713b1edbc | 44 | * Definitions |
AnnaBridge | 171:3a7713b1edbc | 45 | ******************************************************************************/ |
AnnaBridge | 171:3a7713b1edbc | 46 | |
AnnaBridge | 171:3a7713b1edbc | 47 | /*! @name Driver version */ |
AnnaBridge | 171:3a7713b1edbc | 48 | /*@{*/ |
AnnaBridge | 171:3a7713b1edbc | 49 | #define FSL_VREF_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) /*!< Version 2.0.0. */ |
AnnaBridge | 171:3a7713b1edbc | 50 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 51 | |
AnnaBridge | 171:3a7713b1edbc | 52 | /* Those macros below defined to support SoC family which have VREFL (0.4V) reference */ |
AnnaBridge | 171:3a7713b1edbc | 53 | #if defined(FSL_FEATURE_VREF_HAS_LOW_REFERENCE) && FSL_FEATURE_VREF_HAS_LOW_REFERENCE |
AnnaBridge | 171:3a7713b1edbc | 54 | #define SC VREFH_SC |
AnnaBridge | 171:3a7713b1edbc | 55 | #define VREF_SC_MODE_LV VREF_VREFH_SC_MODE_LV |
AnnaBridge | 171:3a7713b1edbc | 56 | #define VREF_SC_REGEN VREF_VREFH_SC_REGEN |
AnnaBridge | 171:3a7713b1edbc | 57 | #define VREF_SC_VREFEN VREF_VREFH_SC_VREFEN |
AnnaBridge | 171:3a7713b1edbc | 58 | #define VREF_SC_ICOMPEN VREF_VREFH_SC_ICOMPEN |
AnnaBridge | 171:3a7713b1edbc | 59 | #define VREF_SC_REGEN_MASK VREF_VREFH_SC_REGEN_MASK |
AnnaBridge | 171:3a7713b1edbc | 60 | #define VREF_SC_VREFST_MASK VREF_VREFH_SC_VREFST_MASK |
AnnaBridge | 171:3a7713b1edbc | 61 | #define VREF_SC_VREFEN_MASK VREF_VREFH_SC_VREFEN_MASK |
AnnaBridge | 171:3a7713b1edbc | 62 | #define VREF_SC_MODE_LV_MASK VREF_VREFH_SC_MODE_LV_MASK |
AnnaBridge | 171:3a7713b1edbc | 63 | #define VREF_SC_ICOMPEN_MASK VREF_VREFH_SC_ICOMPEN_MASK |
AnnaBridge | 171:3a7713b1edbc | 64 | #define TRM VREFH_TRM |
AnnaBridge | 171:3a7713b1edbc | 65 | #define VREF_TRM_TRIM VREF_VREFH_TRM_TRIM |
AnnaBridge | 171:3a7713b1edbc | 66 | #define VREF_TRM_CHOPEN_MASK VREF_VREFH_TRM_CHOPEN_MASK |
AnnaBridge | 171:3a7713b1edbc | 67 | #define VREF_TRM_TRIM_MASK VREF_VREFH_TRM_TRIM_MASK |
AnnaBridge | 171:3a7713b1edbc | 68 | #define VREF_TRM_CHOPEN_SHIFT VREF_VREFH_TRM_CHOPEN_SHIFT |
AnnaBridge | 171:3a7713b1edbc | 69 | #define VREF_TRM_TRIM_SHIFT VREF_VREFH_TRM_TRIM_SHIFT |
AnnaBridge | 171:3a7713b1edbc | 70 | #define VREF_SC_MODE_LV_SHIFT VREF_VREFH_SC_MODE_LV_SHIFT |
AnnaBridge | 171:3a7713b1edbc | 71 | #define VREF_SC_REGEN_SHIFT VREF_VREFH_SC_REGEN_SHIFT |
AnnaBridge | 171:3a7713b1edbc | 72 | #define VREF_SC_VREFST_SHIFT VREF_VREFH_SC_VREFST_SHIFT |
AnnaBridge | 171:3a7713b1edbc | 73 | #define VREF_SC_ICOMPEN_SHIFT VREF_VREFH_SC_ICOMPEN_SHIFT |
AnnaBridge | 171:3a7713b1edbc | 74 | #endif /* FSL_FEATURE_VREF_HAS_LOW_REFERENCE */ |
AnnaBridge | 171:3a7713b1edbc | 75 | |
AnnaBridge | 171:3a7713b1edbc | 76 | /*! |
AnnaBridge | 171:3a7713b1edbc | 77 | * @brief VREF modes. |
AnnaBridge | 171:3a7713b1edbc | 78 | */ |
AnnaBridge | 171:3a7713b1edbc | 79 | typedef enum _vref_buffer_mode |
AnnaBridge | 171:3a7713b1edbc | 80 | { |
AnnaBridge | 171:3a7713b1edbc | 81 | kVREF_ModeBandgapOnly = 0U, /*!< Bandgap on only, for stabilization and startup */ |
AnnaBridge | 171:3a7713b1edbc | 82 | #if defined(FSL_FEATURE_VREF_MODE_LV_TYPE) && FSL_FEATURE_VREF_MODE_LV_TYPE |
AnnaBridge | 171:3a7713b1edbc | 83 | kVREF_ModeHighPowerBuffer = 1U, /*!< High power buffer mode enabled */ |
AnnaBridge | 171:3a7713b1edbc | 84 | kVREF_ModeLowPowerBuffer = 2U /*!< Low power buffer mode enabled */ |
AnnaBridge | 171:3a7713b1edbc | 85 | #else |
AnnaBridge | 171:3a7713b1edbc | 86 | kVREF_ModeTightRegulationBuffer = 2U /*!< Tight regulation buffer enabled */ |
AnnaBridge | 171:3a7713b1edbc | 87 | #endif /* FSL_FEATURE_VREF_MODE_LV_TYPE */ |
AnnaBridge | 171:3a7713b1edbc | 88 | } vref_buffer_mode_t; |
AnnaBridge | 171:3a7713b1edbc | 89 | |
AnnaBridge | 171:3a7713b1edbc | 90 | /*! |
AnnaBridge | 171:3a7713b1edbc | 91 | * @brief The description structure for the VREF module. |
AnnaBridge | 171:3a7713b1edbc | 92 | */ |
AnnaBridge | 171:3a7713b1edbc | 93 | typedef struct _vref_config |
AnnaBridge | 171:3a7713b1edbc | 94 | { |
AnnaBridge | 171:3a7713b1edbc | 95 | vref_buffer_mode_t bufferMode; /*!< Buffer mode selection */ |
AnnaBridge | 171:3a7713b1edbc | 96 | #if defined(FSL_FEATURE_VREF_HAS_LOW_REFERENCE) && FSL_FEATURE_VREF_HAS_LOW_REFERENCE |
AnnaBridge | 171:3a7713b1edbc | 97 | bool enableLowRef; /*!< Set VREFL (0.4 V) reference buffer enable or disable */ |
AnnaBridge | 171:3a7713b1edbc | 98 | bool enableExternalVoltRef; /*!< Select external voltage reference or not (internal) */ |
AnnaBridge | 171:3a7713b1edbc | 99 | #endif /* FSL_FEATURE_VREF_HAS_LOW_REFERENCE */ |
AnnaBridge | 171:3a7713b1edbc | 100 | } vref_config_t; |
AnnaBridge | 171:3a7713b1edbc | 101 | |
AnnaBridge | 171:3a7713b1edbc | 102 | /****************************************************************************** |
AnnaBridge | 171:3a7713b1edbc | 103 | * API |
AnnaBridge | 171:3a7713b1edbc | 104 | ******************************************************************************/ |
AnnaBridge | 171:3a7713b1edbc | 105 | |
AnnaBridge | 171:3a7713b1edbc | 106 | #if defined(__cplusplus) |
AnnaBridge | 171:3a7713b1edbc | 107 | extern "C" { |
AnnaBridge | 171:3a7713b1edbc | 108 | #endif /* __cplusplus */ |
AnnaBridge | 171:3a7713b1edbc | 109 | |
AnnaBridge | 171:3a7713b1edbc | 110 | /*! |
AnnaBridge | 171:3a7713b1edbc | 111 | * @name VREF functional operation |
AnnaBridge | 171:3a7713b1edbc | 112 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 113 | */ |
AnnaBridge | 171:3a7713b1edbc | 114 | |
AnnaBridge | 171:3a7713b1edbc | 115 | /*! |
AnnaBridge | 171:3a7713b1edbc | 116 | * @brief Enables the clock gate and configures the VREF module according to the configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 117 | * |
AnnaBridge | 171:3a7713b1edbc | 118 | * This function must be called before calling all the other VREF driver functions, |
AnnaBridge | 171:3a7713b1edbc | 119 | * read/write registers, and configurations with user-defined settings. |
AnnaBridge | 171:3a7713b1edbc | 120 | * The example below shows how to set up vref_config_t parameters and |
AnnaBridge | 171:3a7713b1edbc | 121 | * how to call the VREF_Init function by passing in these parameters: |
AnnaBridge | 171:3a7713b1edbc | 122 | * Example: |
AnnaBridge | 171:3a7713b1edbc | 123 | * @code |
AnnaBridge | 171:3a7713b1edbc | 124 | * vref_config_t vrefConfig; |
AnnaBridge | 171:3a7713b1edbc | 125 | * vrefConfig.bufferMode = kVREF_ModeHighPowerBuffer; |
AnnaBridge | 171:3a7713b1edbc | 126 | * vrefConfig.enableExternalVoltRef = false; |
AnnaBridge | 171:3a7713b1edbc | 127 | * vrefConfig.enableLowRef = false; |
AnnaBridge | 171:3a7713b1edbc | 128 | * VREF_Init(VREF, &vrefConfig); |
AnnaBridge | 171:3a7713b1edbc | 129 | * @endcode |
AnnaBridge | 171:3a7713b1edbc | 130 | * |
AnnaBridge | 171:3a7713b1edbc | 131 | * @param base VREF peripheral address. |
AnnaBridge | 171:3a7713b1edbc | 132 | * @param config Pointer to the configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 133 | */ |
AnnaBridge | 171:3a7713b1edbc | 134 | void VREF_Init(VREF_Type *base, const vref_config_t *config); |
AnnaBridge | 171:3a7713b1edbc | 135 | |
AnnaBridge | 171:3a7713b1edbc | 136 | /*! |
AnnaBridge | 171:3a7713b1edbc | 137 | * @brief Stops and disables the clock for the VREF module. |
AnnaBridge | 171:3a7713b1edbc | 138 | * |
AnnaBridge | 171:3a7713b1edbc | 139 | * This function should be called to shut down the module. |
AnnaBridge | 171:3a7713b1edbc | 140 | * Example: |
AnnaBridge | 171:3a7713b1edbc | 141 | * @code |
AnnaBridge | 171:3a7713b1edbc | 142 | * vref_config_t vrefUserConfig; |
AnnaBridge | 171:3a7713b1edbc | 143 | * VREF_Init(VREF); |
AnnaBridge | 171:3a7713b1edbc | 144 | * VREF_GetDefaultConfig(&vrefUserConfig); |
AnnaBridge | 171:3a7713b1edbc | 145 | * ... |
AnnaBridge | 171:3a7713b1edbc | 146 | * VREF_Deinit(VREF); |
AnnaBridge | 171:3a7713b1edbc | 147 | * @endcode |
AnnaBridge | 171:3a7713b1edbc | 148 | * |
AnnaBridge | 171:3a7713b1edbc | 149 | * @param base VREF peripheral address. |
AnnaBridge | 171:3a7713b1edbc | 150 | */ |
AnnaBridge | 171:3a7713b1edbc | 151 | void VREF_Deinit(VREF_Type *base); |
AnnaBridge | 171:3a7713b1edbc | 152 | |
AnnaBridge | 171:3a7713b1edbc | 153 | /*! |
AnnaBridge | 171:3a7713b1edbc | 154 | * @brief Initializes the VREF configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 155 | * |
AnnaBridge | 171:3a7713b1edbc | 156 | * This function initializes the VREF configuration structure to a default value. |
AnnaBridge | 171:3a7713b1edbc | 157 | * Example: |
AnnaBridge | 171:3a7713b1edbc | 158 | * @code |
AnnaBridge | 171:3a7713b1edbc | 159 | * vrefConfig->bufferMode = kVREF_ModeHighPowerBuffer; |
AnnaBridge | 171:3a7713b1edbc | 160 | * vrefConfig->enableExternalVoltRef = false; |
AnnaBridge | 171:3a7713b1edbc | 161 | * vrefConfig->enableLowRef = false; |
AnnaBridge | 171:3a7713b1edbc | 162 | * @endcode |
AnnaBridge | 171:3a7713b1edbc | 163 | * |
AnnaBridge | 171:3a7713b1edbc | 164 | * @param config Pointer to the initialization structure. |
AnnaBridge | 171:3a7713b1edbc | 165 | */ |
AnnaBridge | 171:3a7713b1edbc | 166 | void VREF_GetDefaultConfig(vref_config_t *config); |
AnnaBridge | 171:3a7713b1edbc | 167 | |
AnnaBridge | 171:3a7713b1edbc | 168 | /*! |
AnnaBridge | 171:3a7713b1edbc | 169 | * @brief Sets a TRIM value for reference voltage. |
AnnaBridge | 171:3a7713b1edbc | 170 | * |
AnnaBridge | 171:3a7713b1edbc | 171 | * This function sets a TRIM value for reference voltage. |
AnnaBridge | 171:3a7713b1edbc | 172 | * Note that the TRIM value maximum is 0x3F. |
AnnaBridge | 171:3a7713b1edbc | 173 | * |
AnnaBridge | 171:3a7713b1edbc | 174 | * @param base VREF peripheral address. |
AnnaBridge | 171:3a7713b1edbc | 175 | * @param trimValue Value of the trim register to set the output reference voltage (maximum 0x3F (6-bit)). |
AnnaBridge | 171:3a7713b1edbc | 176 | */ |
AnnaBridge | 171:3a7713b1edbc | 177 | void VREF_SetTrimVal(VREF_Type *base, uint8_t trimValue); |
AnnaBridge | 171:3a7713b1edbc | 178 | |
AnnaBridge | 171:3a7713b1edbc | 179 | /*! |
AnnaBridge | 171:3a7713b1edbc | 180 | * @brief Reads the value of the TRIM meaning output voltage. |
AnnaBridge | 171:3a7713b1edbc | 181 | * |
AnnaBridge | 171:3a7713b1edbc | 182 | * This function gets the TRIM value from the TRM register. |
AnnaBridge | 171:3a7713b1edbc | 183 | * |
AnnaBridge | 171:3a7713b1edbc | 184 | * @param base VREF peripheral address. |
AnnaBridge | 171:3a7713b1edbc | 185 | * @return Six-bit value of trim setting. |
AnnaBridge | 171:3a7713b1edbc | 186 | */ |
AnnaBridge | 171:3a7713b1edbc | 187 | static inline uint8_t VREF_GetTrimVal(VREF_Type *base) |
AnnaBridge | 171:3a7713b1edbc | 188 | { |
AnnaBridge | 171:3a7713b1edbc | 189 | return (base->TRM & VREF_TRM_TRIM_MASK); |
AnnaBridge | 171:3a7713b1edbc | 190 | } |
AnnaBridge | 171:3a7713b1edbc | 191 | #if defined(FSL_FEATURE_VREF_HAS_LOW_REFERENCE) && FSL_FEATURE_VREF_HAS_LOW_REFERENCE |
AnnaBridge | 171:3a7713b1edbc | 192 | |
AnnaBridge | 171:3a7713b1edbc | 193 | /*! |
AnnaBridge | 171:3a7713b1edbc | 194 | * @brief Sets the TRIM value for low voltage reference. |
AnnaBridge | 171:3a7713b1edbc | 195 | * |
AnnaBridge | 171:3a7713b1edbc | 196 | * This function sets the TRIM value for low reference voltage. |
AnnaBridge | 171:3a7713b1edbc | 197 | * NOTE: |
AnnaBridge | 171:3a7713b1edbc | 198 | * - The TRIM value maximum is 0x05U |
AnnaBridge | 171:3a7713b1edbc | 199 | * - The values 111b and 110b are not valid/allowed. |
AnnaBridge | 171:3a7713b1edbc | 200 | * |
AnnaBridge | 171:3a7713b1edbc | 201 | * @param base VREF peripheral address. |
AnnaBridge | 171:3a7713b1edbc | 202 | * @param trimValue Value of the trim register to set output low reference voltage (maximum 0x05U (3-bit)). |
AnnaBridge | 171:3a7713b1edbc | 203 | */ |
AnnaBridge | 171:3a7713b1edbc | 204 | void VREF_SetLowReferenceTrimVal(VREF_Type *base, uint8_t trimValue); |
AnnaBridge | 171:3a7713b1edbc | 205 | |
AnnaBridge | 171:3a7713b1edbc | 206 | /*! |
AnnaBridge | 171:3a7713b1edbc | 207 | * @brief Reads the value of the TRIM meaning output voltage. |
AnnaBridge | 171:3a7713b1edbc | 208 | * |
AnnaBridge | 171:3a7713b1edbc | 209 | * This function gets the TRIM value from the VREFL_TRM register. |
AnnaBridge | 171:3a7713b1edbc | 210 | * |
AnnaBridge | 171:3a7713b1edbc | 211 | * @param base VREF peripheral address. |
AnnaBridge | 171:3a7713b1edbc | 212 | * @return Three-bit value of the trim setting. |
AnnaBridge | 171:3a7713b1edbc | 213 | */ |
AnnaBridge | 171:3a7713b1edbc | 214 | static inline uint8_t VREF_GetLowReferenceTrimVal(VREF_Type *base) |
AnnaBridge | 171:3a7713b1edbc | 215 | { |
AnnaBridge | 171:3a7713b1edbc | 216 | return (base->VREFL_TRM & VREF_VREFL_TRM_VREFL_TRIM_MASK); |
AnnaBridge | 171:3a7713b1edbc | 217 | } |
AnnaBridge | 171:3a7713b1edbc | 218 | #endif /* FSL_FEATURE_VREF_HAS_LOW_REFERENCE */ |
AnnaBridge | 171:3a7713b1edbc | 219 | |
AnnaBridge | 171:3a7713b1edbc | 220 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 221 | |
AnnaBridge | 171:3a7713b1edbc | 222 | #if defined(__cplusplus) |
AnnaBridge | 171:3a7713b1edbc | 223 | } |
AnnaBridge | 171:3a7713b1edbc | 224 | #endif /* __cplusplus */ |
AnnaBridge | 171:3a7713b1edbc | 225 | |
AnnaBridge | 171:3a7713b1edbc | 226 | /*! @}*/ |
AnnaBridge | 171:3a7713b1edbc | 227 | |
AnnaBridge | 171:3a7713b1edbc | 228 | #endif /* _FSL_VREF_H_ */ |