![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL43Z/drivers/fsl_vref.h@0:8fdf9a60065b, 2018-10-10 (annotated)
- Committer:
- kadonotakashi
- Date:
- Wed Oct 10 00:33:53 2018 +0000
- Revision:
- 0:8fdf9a60065b
how to make mbed librry
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | /* |
kadonotakashi | 0:8fdf9a60065b | 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. |
kadonotakashi | 0:8fdf9a60065b | 3 | * All rights reserved. |
kadonotakashi | 0:8fdf9a60065b | 4 | * |
kadonotakashi | 0:8fdf9a60065b | 5 | * Redistribution and use in source and binary forms, with or without modification, |
kadonotakashi | 0:8fdf9a60065b | 6 | * are permitted provided that the following conditions are met: |
kadonotakashi | 0:8fdf9a60065b | 7 | * |
kadonotakashi | 0:8fdf9a60065b | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
kadonotakashi | 0:8fdf9a60065b | 9 | * of conditions and the following disclaimer. |
kadonotakashi | 0:8fdf9a60065b | 10 | * |
kadonotakashi | 0:8fdf9a60065b | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
kadonotakashi | 0:8fdf9a60065b | 12 | * list of conditions and the following disclaimer in the documentation and/or |
kadonotakashi | 0:8fdf9a60065b | 13 | * other materials provided with the distribution. |
kadonotakashi | 0:8fdf9a60065b | 14 | * |
kadonotakashi | 0:8fdf9a60065b | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
kadonotakashi | 0:8fdf9a60065b | 16 | * contributors may be used to endorse or promote products derived from this |
kadonotakashi | 0:8fdf9a60065b | 17 | * software without specific prior written permission. |
kadonotakashi | 0:8fdf9a60065b | 18 | * |
kadonotakashi | 0:8fdf9a60065b | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
kadonotakashi | 0:8fdf9a60065b | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
kadonotakashi | 0:8fdf9a60065b | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
kadonotakashi | 0:8fdf9a60065b | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
kadonotakashi | 0:8fdf9a60065b | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
kadonotakashi | 0:8fdf9a60065b | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
kadonotakashi | 0:8fdf9a60065b | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
kadonotakashi | 0:8fdf9a60065b | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
kadonotakashi | 0:8fdf9a60065b | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
kadonotakashi | 0:8fdf9a60065b | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
kadonotakashi | 0:8fdf9a60065b | 29 | */ |
kadonotakashi | 0:8fdf9a60065b | 30 | |
kadonotakashi | 0:8fdf9a60065b | 31 | #ifndef _FSL_VREF_H_ |
kadonotakashi | 0:8fdf9a60065b | 32 | #define _FSL_VREF_H_ |
kadonotakashi | 0:8fdf9a60065b | 33 | |
kadonotakashi | 0:8fdf9a60065b | 34 | #include "fsl_common.h" |
kadonotakashi | 0:8fdf9a60065b | 35 | |
kadonotakashi | 0:8fdf9a60065b | 36 | /*! |
kadonotakashi | 0:8fdf9a60065b | 37 | * @addtogroup vref |
kadonotakashi | 0:8fdf9a60065b | 38 | * @{ |
kadonotakashi | 0:8fdf9a60065b | 39 | */ |
kadonotakashi | 0:8fdf9a60065b | 40 | |
kadonotakashi | 0:8fdf9a60065b | 41 | /*! @file */ |
kadonotakashi | 0:8fdf9a60065b | 42 | |
kadonotakashi | 0:8fdf9a60065b | 43 | /****************************************************************************** |
kadonotakashi | 0:8fdf9a60065b | 44 | * Definitions |
kadonotakashi | 0:8fdf9a60065b | 45 | ******************************************************************************/ |
kadonotakashi | 0:8fdf9a60065b | 46 | |
kadonotakashi | 0:8fdf9a60065b | 47 | /*! @name Driver version */ |
kadonotakashi | 0:8fdf9a60065b | 48 | /*@{*/ |
kadonotakashi | 0:8fdf9a60065b | 49 | #define FSL_VREF_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) /*!< Version 2.0.0. */ |
kadonotakashi | 0:8fdf9a60065b | 50 | /*@}*/ |
kadonotakashi | 0:8fdf9a60065b | 51 | |
kadonotakashi | 0:8fdf9a60065b | 52 | /* Those macros below defined to support SoC family which have VREFL (0.4V) reference */ |
kadonotakashi | 0:8fdf9a60065b | 53 | #if defined(FSL_FEATURE_VREF_HAS_LOW_REFERENCE) && FSL_FEATURE_VREF_HAS_LOW_REFERENCE |
kadonotakashi | 0:8fdf9a60065b | 54 | #define SC VREFH_SC |
kadonotakashi | 0:8fdf9a60065b | 55 | #define VREF_SC_MODE_LV VREF_VREFH_SC_MODE_LV |
kadonotakashi | 0:8fdf9a60065b | 56 | #define VREF_SC_REGEN VREF_VREFH_SC_REGEN |
kadonotakashi | 0:8fdf9a60065b | 57 | #define VREF_SC_VREFEN VREF_VREFH_SC_VREFEN |
kadonotakashi | 0:8fdf9a60065b | 58 | #define VREF_SC_ICOMPEN VREF_VREFH_SC_ICOMPEN |
kadonotakashi | 0:8fdf9a60065b | 59 | #define VREF_SC_REGEN_MASK VREF_VREFH_SC_REGEN_MASK |
kadonotakashi | 0:8fdf9a60065b | 60 | #define VREF_SC_VREFST_MASK VREF_VREFH_SC_VREFST_MASK |
kadonotakashi | 0:8fdf9a60065b | 61 | #define VREF_SC_VREFEN_MASK VREF_VREFH_SC_VREFEN_MASK |
kadonotakashi | 0:8fdf9a60065b | 62 | #define VREF_SC_MODE_LV_MASK VREF_VREFH_SC_MODE_LV_MASK |
kadonotakashi | 0:8fdf9a60065b | 63 | #define VREF_SC_ICOMPEN_MASK VREF_VREFH_SC_ICOMPEN_MASK |
kadonotakashi | 0:8fdf9a60065b | 64 | #define TRM VREFH_TRM |
kadonotakashi | 0:8fdf9a60065b | 65 | #define VREF_TRM_TRIM VREF_VREFH_TRM_TRIM |
kadonotakashi | 0:8fdf9a60065b | 66 | #define VREF_TRM_CHOPEN_MASK VREF_VREFH_TRM_CHOPEN_MASK |
kadonotakashi | 0:8fdf9a60065b | 67 | #define VREF_TRM_TRIM_MASK VREF_VREFH_TRM_TRIM_MASK |
kadonotakashi | 0:8fdf9a60065b | 68 | #define VREF_TRM_CHOPEN_SHIFT VREF_VREFH_TRM_CHOPEN_SHIFT |
kadonotakashi | 0:8fdf9a60065b | 69 | #define VREF_TRM_TRIM_SHIFT VREF_VREFH_TRM_TRIM_SHIFT |
kadonotakashi | 0:8fdf9a60065b | 70 | #define VREF_SC_MODE_LV_SHIFT VREF_VREFH_SC_MODE_LV_SHIFT |
kadonotakashi | 0:8fdf9a60065b | 71 | #define VREF_SC_REGEN_SHIFT VREF_VREFH_SC_REGEN_SHIFT |
kadonotakashi | 0:8fdf9a60065b | 72 | #define VREF_SC_VREFST_SHIFT VREF_VREFH_SC_VREFST_SHIFT |
kadonotakashi | 0:8fdf9a60065b | 73 | #define VREF_SC_ICOMPEN_SHIFT VREF_VREFH_SC_ICOMPEN_SHIFT |
kadonotakashi | 0:8fdf9a60065b | 74 | #endif /* FSL_FEATURE_VREF_HAS_LOW_REFERENCE */ |
kadonotakashi | 0:8fdf9a60065b | 75 | |
kadonotakashi | 0:8fdf9a60065b | 76 | /*! |
kadonotakashi | 0:8fdf9a60065b | 77 | * @brief VREF modes. |
kadonotakashi | 0:8fdf9a60065b | 78 | */ |
kadonotakashi | 0:8fdf9a60065b | 79 | typedef enum _vref_buffer_mode |
kadonotakashi | 0:8fdf9a60065b | 80 | { |
kadonotakashi | 0:8fdf9a60065b | 81 | kVREF_ModeBandgapOnly = 0U, /*!< Bandgap on only, for stabilization and startup */ |
kadonotakashi | 0:8fdf9a60065b | 82 | #if defined(FSL_FEATURE_VREF_MODE_LV_TYPE) && FSL_FEATURE_VREF_MODE_LV_TYPE |
kadonotakashi | 0:8fdf9a60065b | 83 | kVREF_ModeHighPowerBuffer = 1U, /*!< High power buffer mode enabled */ |
kadonotakashi | 0:8fdf9a60065b | 84 | kVREF_ModeLowPowerBuffer = 2U /*!< Low power buffer mode enabled */ |
kadonotakashi | 0:8fdf9a60065b | 85 | #else |
kadonotakashi | 0:8fdf9a60065b | 86 | kVREF_ModeTightRegulationBuffer = 2U /*!< Tight regulation buffer enabled */ |
kadonotakashi | 0:8fdf9a60065b | 87 | #endif /* FSL_FEATURE_VREF_MODE_LV_TYPE */ |
kadonotakashi | 0:8fdf9a60065b | 88 | } vref_buffer_mode_t; |
kadonotakashi | 0:8fdf9a60065b | 89 | |
kadonotakashi | 0:8fdf9a60065b | 90 | /*! |
kadonotakashi | 0:8fdf9a60065b | 91 | * @brief The description structure for the VREF module. |
kadonotakashi | 0:8fdf9a60065b | 92 | */ |
kadonotakashi | 0:8fdf9a60065b | 93 | typedef struct _vref_config |
kadonotakashi | 0:8fdf9a60065b | 94 | { |
kadonotakashi | 0:8fdf9a60065b | 95 | vref_buffer_mode_t bufferMode; /*!< Buffer mode selection */ |
kadonotakashi | 0:8fdf9a60065b | 96 | #if defined(FSL_FEATURE_VREF_HAS_LOW_REFERENCE) && FSL_FEATURE_VREF_HAS_LOW_REFERENCE |
kadonotakashi | 0:8fdf9a60065b | 97 | bool enableLowRef; /*!< Set VREFL (0.4 V) reference buffer enable or disable */ |
kadonotakashi | 0:8fdf9a60065b | 98 | bool enableExternalVoltRef; /*!< Select external voltage reference or not (internal) */ |
kadonotakashi | 0:8fdf9a60065b | 99 | #endif /* FSL_FEATURE_VREF_HAS_LOW_REFERENCE */ |
kadonotakashi | 0:8fdf9a60065b | 100 | } vref_config_t; |
kadonotakashi | 0:8fdf9a60065b | 101 | |
kadonotakashi | 0:8fdf9a60065b | 102 | /****************************************************************************** |
kadonotakashi | 0:8fdf9a60065b | 103 | * API |
kadonotakashi | 0:8fdf9a60065b | 104 | ******************************************************************************/ |
kadonotakashi | 0:8fdf9a60065b | 105 | |
kadonotakashi | 0:8fdf9a60065b | 106 | #if defined(__cplusplus) |
kadonotakashi | 0:8fdf9a60065b | 107 | extern "C" { |
kadonotakashi | 0:8fdf9a60065b | 108 | #endif /* __cplusplus */ |
kadonotakashi | 0:8fdf9a60065b | 109 | |
kadonotakashi | 0:8fdf9a60065b | 110 | /*! |
kadonotakashi | 0:8fdf9a60065b | 111 | * @name VREF functional operation |
kadonotakashi | 0:8fdf9a60065b | 112 | * @{ |
kadonotakashi | 0:8fdf9a60065b | 113 | */ |
kadonotakashi | 0:8fdf9a60065b | 114 | |
kadonotakashi | 0:8fdf9a60065b | 115 | /*! |
kadonotakashi | 0:8fdf9a60065b | 116 | * @brief Enables the clock gate and configures the VREF module according to the configuration structure. |
kadonotakashi | 0:8fdf9a60065b | 117 | * |
kadonotakashi | 0:8fdf9a60065b | 118 | * This function must be called before calling all the other VREF driver functions, |
kadonotakashi | 0:8fdf9a60065b | 119 | * read/write registers, and configurations with user-defined settings. |
kadonotakashi | 0:8fdf9a60065b | 120 | * The example below shows how to set up vref_config_t parameters and |
kadonotakashi | 0:8fdf9a60065b | 121 | * how to call the VREF_Init function by passing in these parameters: |
kadonotakashi | 0:8fdf9a60065b | 122 | * Example: |
kadonotakashi | 0:8fdf9a60065b | 123 | * @code |
kadonotakashi | 0:8fdf9a60065b | 124 | * vref_config_t vrefConfig; |
kadonotakashi | 0:8fdf9a60065b | 125 | * vrefConfig.bufferMode = kVREF_ModeHighPowerBuffer; |
kadonotakashi | 0:8fdf9a60065b | 126 | * vrefConfig.enableExternalVoltRef = false; |
kadonotakashi | 0:8fdf9a60065b | 127 | * vrefConfig.enableLowRef = false; |
kadonotakashi | 0:8fdf9a60065b | 128 | * VREF_Init(VREF, &vrefConfig); |
kadonotakashi | 0:8fdf9a60065b | 129 | * @endcode |
kadonotakashi | 0:8fdf9a60065b | 130 | * |
kadonotakashi | 0:8fdf9a60065b | 131 | * @param base VREF peripheral address. |
kadonotakashi | 0:8fdf9a60065b | 132 | * @param config Pointer to the configuration structure. |
kadonotakashi | 0:8fdf9a60065b | 133 | */ |
kadonotakashi | 0:8fdf9a60065b | 134 | void VREF_Init(VREF_Type *base, const vref_config_t *config); |
kadonotakashi | 0:8fdf9a60065b | 135 | |
kadonotakashi | 0:8fdf9a60065b | 136 | /*! |
kadonotakashi | 0:8fdf9a60065b | 137 | * @brief Stops and disables the clock for the VREF module. |
kadonotakashi | 0:8fdf9a60065b | 138 | * |
kadonotakashi | 0:8fdf9a60065b | 139 | * This function should be called to shut down the module. |
kadonotakashi | 0:8fdf9a60065b | 140 | * Example: |
kadonotakashi | 0:8fdf9a60065b | 141 | * @code |
kadonotakashi | 0:8fdf9a60065b | 142 | * vref_config_t vrefUserConfig; |
kadonotakashi | 0:8fdf9a60065b | 143 | * VREF_Init(VREF); |
kadonotakashi | 0:8fdf9a60065b | 144 | * VREF_GetDefaultConfig(&vrefUserConfig); |
kadonotakashi | 0:8fdf9a60065b | 145 | * ... |
kadonotakashi | 0:8fdf9a60065b | 146 | * VREF_Deinit(VREF); |
kadonotakashi | 0:8fdf9a60065b | 147 | * @endcode |
kadonotakashi | 0:8fdf9a60065b | 148 | * |
kadonotakashi | 0:8fdf9a60065b | 149 | * @param base VREF peripheral address. |
kadonotakashi | 0:8fdf9a60065b | 150 | */ |
kadonotakashi | 0:8fdf9a60065b | 151 | void VREF_Deinit(VREF_Type *base); |
kadonotakashi | 0:8fdf9a60065b | 152 | |
kadonotakashi | 0:8fdf9a60065b | 153 | /*! |
kadonotakashi | 0:8fdf9a60065b | 154 | * @brief Initializes the VREF configuration structure. |
kadonotakashi | 0:8fdf9a60065b | 155 | * |
kadonotakashi | 0:8fdf9a60065b | 156 | * This function initializes the VREF configuration structure to a default value. |
kadonotakashi | 0:8fdf9a60065b | 157 | * Example: |
kadonotakashi | 0:8fdf9a60065b | 158 | * @code |
kadonotakashi | 0:8fdf9a60065b | 159 | * vrefConfig->bufferMode = kVREF_ModeHighPowerBuffer; |
kadonotakashi | 0:8fdf9a60065b | 160 | * vrefConfig->enableExternalVoltRef = false; |
kadonotakashi | 0:8fdf9a60065b | 161 | * vrefConfig->enableLowRef = false; |
kadonotakashi | 0:8fdf9a60065b | 162 | * @endcode |
kadonotakashi | 0:8fdf9a60065b | 163 | * |
kadonotakashi | 0:8fdf9a60065b | 164 | * @param config Pointer to the initialization structure. |
kadonotakashi | 0:8fdf9a60065b | 165 | */ |
kadonotakashi | 0:8fdf9a60065b | 166 | void VREF_GetDefaultConfig(vref_config_t *config); |
kadonotakashi | 0:8fdf9a60065b | 167 | |
kadonotakashi | 0:8fdf9a60065b | 168 | /*! |
kadonotakashi | 0:8fdf9a60065b | 169 | * @brief Sets a TRIM value for reference voltage. |
kadonotakashi | 0:8fdf9a60065b | 170 | * |
kadonotakashi | 0:8fdf9a60065b | 171 | * This function sets a TRIM value for reference voltage. |
kadonotakashi | 0:8fdf9a60065b | 172 | * Note that the TRIM value maximum is 0x3F. |
kadonotakashi | 0:8fdf9a60065b | 173 | * |
kadonotakashi | 0:8fdf9a60065b | 174 | * @param base VREF peripheral address. |
kadonotakashi | 0:8fdf9a60065b | 175 | * @param trimValue Value of the trim register to set the output reference voltage (maximum 0x3F (6-bit)). |
kadonotakashi | 0:8fdf9a60065b | 176 | */ |
kadonotakashi | 0:8fdf9a60065b | 177 | void VREF_SetTrimVal(VREF_Type *base, uint8_t trimValue); |
kadonotakashi | 0:8fdf9a60065b | 178 | |
kadonotakashi | 0:8fdf9a60065b | 179 | /*! |
kadonotakashi | 0:8fdf9a60065b | 180 | * @brief Reads the value of the TRIM meaning output voltage. |
kadonotakashi | 0:8fdf9a60065b | 181 | * |
kadonotakashi | 0:8fdf9a60065b | 182 | * This function gets the TRIM value from the TRM register. |
kadonotakashi | 0:8fdf9a60065b | 183 | * |
kadonotakashi | 0:8fdf9a60065b | 184 | * @param base VREF peripheral address. |
kadonotakashi | 0:8fdf9a60065b | 185 | * @return Six-bit value of trim setting. |
kadonotakashi | 0:8fdf9a60065b | 186 | */ |
kadonotakashi | 0:8fdf9a60065b | 187 | static inline uint8_t VREF_GetTrimVal(VREF_Type *base) |
kadonotakashi | 0:8fdf9a60065b | 188 | { |
kadonotakashi | 0:8fdf9a60065b | 189 | return (base->TRM & VREF_TRM_TRIM_MASK); |
kadonotakashi | 0:8fdf9a60065b | 190 | } |
kadonotakashi | 0:8fdf9a60065b | 191 | #if defined(FSL_FEATURE_VREF_HAS_LOW_REFERENCE) && FSL_FEATURE_VREF_HAS_LOW_REFERENCE |
kadonotakashi | 0:8fdf9a60065b | 192 | |
kadonotakashi | 0:8fdf9a60065b | 193 | /*! |
kadonotakashi | 0:8fdf9a60065b | 194 | * @brief Sets the TRIM value for low voltage reference. |
kadonotakashi | 0:8fdf9a60065b | 195 | * |
kadonotakashi | 0:8fdf9a60065b | 196 | * This function sets the TRIM value for low reference voltage. |
kadonotakashi | 0:8fdf9a60065b | 197 | * NOTE: |
kadonotakashi | 0:8fdf9a60065b | 198 | * - The TRIM value maximum is 0x05U |
kadonotakashi | 0:8fdf9a60065b | 199 | * - The values 111b and 110b are not valid/allowed. |
kadonotakashi | 0:8fdf9a60065b | 200 | * |
kadonotakashi | 0:8fdf9a60065b | 201 | * @param base VREF peripheral address. |
kadonotakashi | 0:8fdf9a60065b | 202 | * @param trimValue Value of the trim register to set output low reference voltage (maximum 0x05U (3-bit)). |
kadonotakashi | 0:8fdf9a60065b | 203 | */ |
kadonotakashi | 0:8fdf9a60065b | 204 | void VREF_SetLowReferenceTrimVal(VREF_Type *base, uint8_t trimValue); |
kadonotakashi | 0:8fdf9a60065b | 205 | |
kadonotakashi | 0:8fdf9a60065b | 206 | /*! |
kadonotakashi | 0:8fdf9a60065b | 207 | * @brief Reads the value of the TRIM meaning output voltage. |
kadonotakashi | 0:8fdf9a60065b | 208 | * |
kadonotakashi | 0:8fdf9a60065b | 209 | * This function gets the TRIM value from the VREFL_TRM register. |
kadonotakashi | 0:8fdf9a60065b | 210 | * |
kadonotakashi | 0:8fdf9a60065b | 211 | * @param base VREF peripheral address. |
kadonotakashi | 0:8fdf9a60065b | 212 | * @return Three-bit value of the trim setting. |
kadonotakashi | 0:8fdf9a60065b | 213 | */ |
kadonotakashi | 0:8fdf9a60065b | 214 | static inline uint8_t VREF_GetLowReferenceTrimVal(VREF_Type *base) |
kadonotakashi | 0:8fdf9a60065b | 215 | { |
kadonotakashi | 0:8fdf9a60065b | 216 | return (base->VREFL_TRM & VREF_VREFL_TRM_VREFL_TRIM_MASK); |
kadonotakashi | 0:8fdf9a60065b | 217 | } |
kadonotakashi | 0:8fdf9a60065b | 218 | #endif /* FSL_FEATURE_VREF_HAS_LOW_REFERENCE */ |
kadonotakashi | 0:8fdf9a60065b | 219 | |
kadonotakashi | 0:8fdf9a60065b | 220 | /*@}*/ |
kadonotakashi | 0:8fdf9a60065b | 221 | |
kadonotakashi | 0:8fdf9a60065b | 222 | #if defined(__cplusplus) |
kadonotakashi | 0:8fdf9a60065b | 223 | } |
kadonotakashi | 0:8fdf9a60065b | 224 | #endif /* __cplusplus */ |
kadonotakashi | 0:8fdf9a60065b | 225 | |
kadonotakashi | 0:8fdf9a60065b | 226 | /*! @}*/ |
kadonotakashi | 0:8fdf9a60065b | 227 | |
kadonotakashi | 0:8fdf9a60065b | 228 | #endif /* _FSL_VREF_H_ */ |