mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_L053R8/stm32l0xx_hal.c@310:6188e0254baa, 2014-09-16 (annotated)
- Committer:
- janekm
- Date:
- Tue Sep 16 22:42:01 2014 +0000
- Revision:
- 310:6188e0254baa
- Parent:
- 181:a4cbdfbbd2f4
N/A
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 181:a4cbdfbbd2f4 | 1 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 2 | ****************************************************************************** |
mbed_official | 181:a4cbdfbbd2f4 | 3 | * @file stm32l0xx_hal.c |
mbed_official | 181:a4cbdfbbd2f4 | 4 | * @author MCD Application Team |
mbed_official | 181:a4cbdfbbd2f4 | 5 | * @version V1.0.0 |
mbed_official | 181:a4cbdfbbd2f4 | 6 | * @date 22-April-2014 |
mbed_official | 181:a4cbdfbbd2f4 | 7 | * @brief HAL module driver. |
mbed_official | 181:a4cbdfbbd2f4 | 8 | * This is the common part of the HAL initialization |
mbed_official | 181:a4cbdfbbd2f4 | 9 | * |
mbed_official | 181:a4cbdfbbd2f4 | 10 | @verbatim |
mbed_official | 181:a4cbdfbbd2f4 | 11 | ============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 12 | ##### How to use this driver ##### |
mbed_official | 181:a4cbdfbbd2f4 | 13 | ============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 14 | [..] |
mbed_official | 181:a4cbdfbbd2f4 | 15 | The common HAL driver contains a set of generic and common APIs that can be |
mbed_official | 181:a4cbdfbbd2f4 | 16 | used by the PPP peripheral drivers and the user to start using the HAL. |
mbed_official | 181:a4cbdfbbd2f4 | 17 | [..] |
mbed_official | 181:a4cbdfbbd2f4 | 18 | The HAL contains two APIs' categories: |
mbed_official | 181:a4cbdfbbd2f4 | 19 | (+) Common HAL APIs |
mbed_official | 181:a4cbdfbbd2f4 | 20 | (+) Services HAL APIs |
mbed_official | 181:a4cbdfbbd2f4 | 21 | |
mbed_official | 181:a4cbdfbbd2f4 | 22 | @endverbatim |
mbed_official | 181:a4cbdfbbd2f4 | 23 | ****************************************************************************** |
mbed_official | 181:a4cbdfbbd2f4 | 24 | * @attention |
mbed_official | 181:a4cbdfbbd2f4 | 25 | * |
mbed_official | 181:a4cbdfbbd2f4 | 26 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 181:a4cbdfbbd2f4 | 27 | * |
mbed_official | 181:a4cbdfbbd2f4 | 28 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 181:a4cbdfbbd2f4 | 29 | * are permitted provided that the following conditions are met: |
mbed_official | 181:a4cbdfbbd2f4 | 30 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 181:a4cbdfbbd2f4 | 31 | * this list of conditions and the following disclaimer. |
mbed_official | 181:a4cbdfbbd2f4 | 32 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 181:a4cbdfbbd2f4 | 33 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 181:a4cbdfbbd2f4 | 34 | * and/or other materials provided with the distribution. |
mbed_official | 181:a4cbdfbbd2f4 | 35 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 181:a4cbdfbbd2f4 | 36 | * may be used to endorse or promote products derived from this software |
mbed_official | 181:a4cbdfbbd2f4 | 37 | * without specific prior written permission. |
mbed_official | 181:a4cbdfbbd2f4 | 38 | * |
mbed_official | 181:a4cbdfbbd2f4 | 39 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 181:a4cbdfbbd2f4 | 40 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 181:a4cbdfbbd2f4 | 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 181:a4cbdfbbd2f4 | 42 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 181:a4cbdfbbd2f4 | 43 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 181:a4cbdfbbd2f4 | 44 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 181:a4cbdfbbd2f4 | 45 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 181:a4cbdfbbd2f4 | 46 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 181:a4cbdfbbd2f4 | 47 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 181:a4cbdfbbd2f4 | 48 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 181:a4cbdfbbd2f4 | 49 | * |
mbed_official | 181:a4cbdfbbd2f4 | 50 | ****************************************************************************** |
mbed_official | 181:a4cbdfbbd2f4 | 51 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 52 | |
mbed_official | 181:a4cbdfbbd2f4 | 53 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 54 | #include "stm32l0xx_hal.h" |
mbed_official | 181:a4cbdfbbd2f4 | 55 | |
mbed_official | 181:a4cbdfbbd2f4 | 56 | /** @addtogroup STM32L0xx_HAL_Driver |
mbed_official | 181:a4cbdfbbd2f4 | 57 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 58 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 59 | |
mbed_official | 181:a4cbdfbbd2f4 | 60 | /** @defgroup HAL |
mbed_official | 181:a4cbdfbbd2f4 | 61 | * @brief HAL module driver. |
mbed_official | 181:a4cbdfbbd2f4 | 62 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 63 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 64 | |
mbed_official | 181:a4cbdfbbd2f4 | 65 | #ifdef HAL_MODULE_ENABLED |
mbed_official | 181:a4cbdfbbd2f4 | 66 | |
mbed_official | 181:a4cbdfbbd2f4 | 67 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 68 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 69 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 70 | * @brief STM32L0xx HAL Driver version number V1.0.0 |
mbed_official | 181:a4cbdfbbd2f4 | 71 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 72 | #define __STM32L0xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */ |
mbed_official | 181:a4cbdfbbd2f4 | 73 | #define __STM32L0xx_HAL_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */ |
mbed_official | 181:a4cbdfbbd2f4 | 74 | #define __STM32L0xx_HAL_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ |
mbed_official | 181:a4cbdfbbd2f4 | 75 | #define __STM32L0xx_HAL_VERSION_RC (0x00) /*!< [7:0] release candidate */ |
mbed_official | 181:a4cbdfbbd2f4 | 76 | #define __STM32L0xx_HAL_VERSION ((__STM32L0xx_HAL_VERSION_MAIN << 24)\ |
mbed_official | 181:a4cbdfbbd2f4 | 77 | |(__STM32L0xx_HAL_VERSION_SUB1 << 16)\ |
mbed_official | 181:a4cbdfbbd2f4 | 78 | |(__STM32L0xx_HAL_VERSION_SUB2 << 8 )\ |
mbed_official | 181:a4cbdfbbd2f4 | 79 | |(__STM32L0xx_HAL_VERSION_RC)) |
mbed_official | 181:a4cbdfbbd2f4 | 80 | |
mbed_official | 181:a4cbdfbbd2f4 | 81 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) |
mbed_official | 181:a4cbdfbbd2f4 | 82 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 83 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 84 | static __IO uint32_t uwTick; |
mbed_official | 181:a4cbdfbbd2f4 | 85 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 86 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 87 | |
mbed_official | 181:a4cbdfbbd2f4 | 88 | /** @defgroup HAL_Private_Functions |
mbed_official | 181:a4cbdfbbd2f4 | 89 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 90 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 91 | |
mbed_official | 181:a4cbdfbbd2f4 | 92 | /** @defgroup HAL_Group1 Initialization and de-initialization Functions |
mbed_official | 181:a4cbdfbbd2f4 | 93 | * @brief Initialization and de-initialization functions |
mbed_official | 181:a4cbdfbbd2f4 | 94 | * |
mbed_official | 181:a4cbdfbbd2f4 | 95 | @verbatim |
mbed_official | 181:a4cbdfbbd2f4 | 96 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 97 | ##### Initialization and de-initialization functions ##### |
mbed_official | 181:a4cbdfbbd2f4 | 98 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 99 | [..] This section provides functions allowing to: |
mbed_official | 181:a4cbdfbbd2f4 | 100 | (+) Initializes the Flash interface, the NVIC allocation and initial clock |
mbed_official | 181:a4cbdfbbd2f4 | 101 | configuration. It initializes the source of time base also when timeout |
mbed_official | 181:a4cbdfbbd2f4 | 102 | is needed and the backup domain when enabled. |
mbed_official | 181:a4cbdfbbd2f4 | 103 | (+) de-Initializes common part of the HAL. |
mbed_official | 181:a4cbdfbbd2f4 | 104 | (+) Configure The time base source to have 1ms time base with a dedicated |
mbed_official | 181:a4cbdfbbd2f4 | 105 | Tick interrupt priority. |
mbed_official | 181:a4cbdfbbd2f4 | 106 | (++) Systick timer is used by default as source of time base, but user |
mbed_official | 181:a4cbdfbbd2f4 | 107 | can eventually implement his proper time base source (a general purpose |
mbed_official | 181:a4cbdfbbd2f4 | 108 | timer for example or other time source), keeping in mind that Time base |
mbed_official | 181:a4cbdfbbd2f4 | 109 | duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and |
mbed_official | 181:a4cbdfbbd2f4 | 110 | handled in milliseconds basis. |
mbed_official | 181:a4cbdfbbd2f4 | 111 | (++) Time base configuration function (HAL_InitTick ()) is called automatically |
mbed_official | 181:a4cbdfbbd2f4 | 112 | at the beginning of the program after reset by HAL_Init() or at any time |
mbed_official | 181:a4cbdfbbd2f4 | 113 | when clock is configured, by HAL_RCC_ClockConfig(). |
mbed_official | 181:a4cbdfbbd2f4 | 114 | (++) Source of time base is configured to generate interrupts at regular |
mbed_official | 181:a4cbdfbbd2f4 | 115 | time intervals. Care must be taken if HAL_Delay() is called from a |
mbed_official | 181:a4cbdfbbd2f4 | 116 | peripheral ISR process, the Tick interrupt line must have higher priority |
mbed_official | 181:a4cbdfbbd2f4 | 117 | (numerically lower) than the peripheral interrupt. Otherwise the caller |
mbed_official | 181:a4cbdfbbd2f4 | 118 | ISR process will be blocked. |
mbed_official | 181:a4cbdfbbd2f4 | 119 | (++) functions affecting time base configurations are declared as __Weak |
mbed_official | 181:a4cbdfbbd2f4 | 120 | to make override possible in case of other implementations in user file. |
mbed_official | 181:a4cbdfbbd2f4 | 121 | |
mbed_official | 181:a4cbdfbbd2f4 | 122 | @endverbatim |
mbed_official | 181:a4cbdfbbd2f4 | 123 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 124 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 125 | |
mbed_official | 181:a4cbdfbbd2f4 | 126 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 127 | * @brief This function configures the Flash prefetch, Flash preread and Buffer cache, |
mbed_official | 181:a4cbdfbbd2f4 | 128 | * Configures time base source, NVIC and Low level hardware |
mbed_official | 181:a4cbdfbbd2f4 | 129 | * @note This function is called at the beginning of program after reset and before |
mbed_official | 181:a4cbdfbbd2f4 | 130 | * the clock configuration |
mbed_official | 181:a4cbdfbbd2f4 | 131 | * @note The time base configuration is based on MSI clock when exiting from Reset. |
mbed_official | 181:a4cbdfbbd2f4 | 132 | * Once done, time base tick start incrementing. |
mbed_official | 181:a4cbdfbbd2f4 | 133 | * In the default implementation,Systick is used as source of time base. |
mbed_official | 181:a4cbdfbbd2f4 | 134 | * the tick variable is incremented each 1ms in its ISR. |
mbed_official | 181:a4cbdfbbd2f4 | 135 | * @param None |
mbed_official | 181:a4cbdfbbd2f4 | 136 | * @retval HAL status |
mbed_official | 181:a4cbdfbbd2f4 | 137 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 138 | HAL_StatusTypeDef HAL_Init(void) |
mbed_official | 181:a4cbdfbbd2f4 | 139 | { |
mbed_official | 181:a4cbdfbbd2f4 | 140 | /* Configure Buffer cache, Flash prefetch, Flash preread */ |
mbed_official | 181:a4cbdfbbd2f4 | 141 | #if (BUFFER_CACHE_DISABLE != 0) |
mbed_official | 181:a4cbdfbbd2f4 | 142 | __HAL_FLASH_BUFFER_CACHE_DISABLE(); |
mbed_official | 181:a4cbdfbbd2f4 | 143 | #endif /* BUFFER_CACHE_DISABLE */ |
mbed_official | 181:a4cbdfbbd2f4 | 144 | |
mbed_official | 181:a4cbdfbbd2f4 | 145 | #if (PREREAD_ENABLE != 0) |
mbed_official | 181:a4cbdfbbd2f4 | 146 | __HAL_FLASH_PREREAD_BUFFER_ENABLE(); |
mbed_official | 181:a4cbdfbbd2f4 | 147 | #endif /* PREREAD_ENABLE */ |
mbed_official | 181:a4cbdfbbd2f4 | 148 | |
mbed_official | 181:a4cbdfbbd2f4 | 149 | #if (PREFETCH_ENABLE != 0) |
mbed_official | 181:a4cbdfbbd2f4 | 150 | __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); |
mbed_official | 181:a4cbdfbbd2f4 | 151 | #endif /* PREFETCH_ENABLE */ |
mbed_official | 181:a4cbdfbbd2f4 | 152 | |
mbed_official | 181:a4cbdfbbd2f4 | 153 | /* Use systick as time base source and configure 1ms tick (default clock after Reset is MSI) */ |
mbed_official | 181:a4cbdfbbd2f4 | 154 | |
mbed_official | 181:a4cbdfbbd2f4 | 155 | HAL_InitTick(TICK_INT_PRIORITY); |
mbed_official | 181:a4cbdfbbd2f4 | 156 | |
mbed_official | 181:a4cbdfbbd2f4 | 157 | /* Init the low level hardware */ |
mbed_official | 181:a4cbdfbbd2f4 | 158 | HAL_MspInit(); |
mbed_official | 181:a4cbdfbbd2f4 | 159 | |
mbed_official | 181:a4cbdfbbd2f4 | 160 | /* Return function status */ |
mbed_official | 181:a4cbdfbbd2f4 | 161 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 162 | } |
mbed_official | 181:a4cbdfbbd2f4 | 163 | |
mbed_official | 181:a4cbdfbbd2f4 | 164 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 165 | * @brief This function de-Initializes common part of the HAL and stops the source |
mbed_official | 181:a4cbdfbbd2f4 | 166 | * of time base. |
mbed_official | 181:a4cbdfbbd2f4 | 167 | * @note This function is optional. |
mbed_official | 181:a4cbdfbbd2f4 | 168 | * @param None |
mbed_official | 181:a4cbdfbbd2f4 | 169 | * @retval HAL status |
mbed_official | 181:a4cbdfbbd2f4 | 170 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 171 | HAL_StatusTypeDef HAL_DeInit(void) |
mbed_official | 181:a4cbdfbbd2f4 | 172 | { |
mbed_official | 181:a4cbdfbbd2f4 | 173 | /* Reset of all peripherals */ |
mbed_official | 181:a4cbdfbbd2f4 | 174 | __APB1_FORCE_RESET(); |
mbed_official | 181:a4cbdfbbd2f4 | 175 | __APB1_RELEASE_RESET(); |
mbed_official | 181:a4cbdfbbd2f4 | 176 | |
mbed_official | 181:a4cbdfbbd2f4 | 177 | __APB2_FORCE_RESET(); |
mbed_official | 181:a4cbdfbbd2f4 | 178 | __APB2_RELEASE_RESET(); |
mbed_official | 181:a4cbdfbbd2f4 | 179 | |
mbed_official | 181:a4cbdfbbd2f4 | 180 | __AHB_FORCE_RESET(); |
mbed_official | 181:a4cbdfbbd2f4 | 181 | __AHB_RELEASE_RESET(); |
mbed_official | 181:a4cbdfbbd2f4 | 182 | |
mbed_official | 181:a4cbdfbbd2f4 | 183 | __IOP_FORCE_RESET(); |
mbed_official | 181:a4cbdfbbd2f4 | 184 | __IOP_RELEASE_RESET(); |
mbed_official | 181:a4cbdfbbd2f4 | 185 | |
mbed_official | 181:a4cbdfbbd2f4 | 186 | /* De-Init the low level hardware */ |
mbed_official | 181:a4cbdfbbd2f4 | 187 | HAL_MspDeInit(); |
mbed_official | 181:a4cbdfbbd2f4 | 188 | |
mbed_official | 181:a4cbdfbbd2f4 | 189 | /* Return function status */ |
mbed_official | 181:a4cbdfbbd2f4 | 190 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 191 | } |
mbed_official | 181:a4cbdfbbd2f4 | 192 | |
mbed_official | 181:a4cbdfbbd2f4 | 193 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 194 | * @brief Initializes the MSP. |
mbed_official | 181:a4cbdfbbd2f4 | 195 | * @param None |
mbed_official | 181:a4cbdfbbd2f4 | 196 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 197 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 198 | __weak void HAL_MspInit(void) |
mbed_official | 181:a4cbdfbbd2f4 | 199 | { |
mbed_official | 181:a4cbdfbbd2f4 | 200 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 181:a4cbdfbbd2f4 | 201 | the HAL_MspInit could be implemented in the user file |
mbed_official | 181:a4cbdfbbd2f4 | 202 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 203 | } |
mbed_official | 181:a4cbdfbbd2f4 | 204 | |
mbed_official | 181:a4cbdfbbd2f4 | 205 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 206 | * @brief DeInitializes the MSP. |
mbed_official | 181:a4cbdfbbd2f4 | 207 | * @param None |
mbed_official | 181:a4cbdfbbd2f4 | 208 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 209 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 210 | __weak void HAL_MspDeInit(void) |
mbed_official | 181:a4cbdfbbd2f4 | 211 | { |
mbed_official | 181:a4cbdfbbd2f4 | 212 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 181:a4cbdfbbd2f4 | 213 | the HAL_MspDeInit could be implemented in the user file |
mbed_official | 181:a4cbdfbbd2f4 | 214 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 215 | } |
mbed_official | 181:a4cbdfbbd2f4 | 216 | |
mbed_official | 181:a4cbdfbbd2f4 | 217 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 218 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 219 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 220 | |
mbed_official | 181:a4cbdfbbd2f4 | 221 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 222 | * @brief This function configures the source of the time base. |
mbed_official | 181:a4cbdfbbd2f4 | 223 | * The time source is configured to have 1ms time base with a dedicated |
mbed_official | 181:a4cbdfbbd2f4 | 224 | * Tick interrupt priority. |
mbed_official | 181:a4cbdfbbd2f4 | 225 | * @note This function is called automatically at the beginning of program after |
mbed_official | 181:a4cbdfbbd2f4 | 226 | * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig(). |
mbed_official | 181:a4cbdfbbd2f4 | 227 | * @note In the default implementation, SysTick timer is the source of time base. |
mbed_official | 181:a4cbdfbbd2f4 | 228 | * It is used to generate interrupts at regular time intervals. |
mbed_official | 181:a4cbdfbbd2f4 | 229 | * Care must be taken if HAL_Delay() is called from a peripheral ISR process, |
mbed_official | 181:a4cbdfbbd2f4 | 230 | * The the SysTick interrupt must have higher priority (numerically lower) |
mbed_official | 181:a4cbdfbbd2f4 | 231 | * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. |
mbed_official | 181:a4cbdfbbd2f4 | 232 | * The function is declared as __Weak to be overwritten in case of other |
mbed_official | 181:a4cbdfbbd2f4 | 233 | * implementation in user file. |
mbed_official | 181:a4cbdfbbd2f4 | 234 | * @param TickPriority: Tick interrupt priority. |
mbed_official | 181:a4cbdfbbd2f4 | 235 | * @retval HAL status |
mbed_official | 181:a4cbdfbbd2f4 | 236 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 237 | __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) |
mbed_official | 181:a4cbdfbbd2f4 | 238 | { |
mbed_official | 181:a4cbdfbbd2f4 | 239 | /*Configure the SysTick to have interrupt in 1ms time basis*/ |
mbed_official | 181:a4cbdfbbd2f4 | 240 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); |
mbed_official | 181:a4cbdfbbd2f4 | 241 | |
mbed_official | 181:a4cbdfbbd2f4 | 242 | /*Configure the SysTick IRQ priority */ |
mbed_official | 181:a4cbdfbbd2f4 | 243 | HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0); |
mbed_official | 181:a4cbdfbbd2f4 | 244 | |
mbed_official | 181:a4cbdfbbd2f4 | 245 | /* Return function status */ |
mbed_official | 181:a4cbdfbbd2f4 | 246 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 247 | } |
mbed_official | 181:a4cbdfbbd2f4 | 248 | |
mbed_official | 181:a4cbdfbbd2f4 | 249 | /** @defgroup HAL_Group2 HAL Control functions |
mbed_official | 181:a4cbdfbbd2f4 | 250 | * @brief HAL Control functions |
mbed_official | 181:a4cbdfbbd2f4 | 251 | * |
mbed_official | 181:a4cbdfbbd2f4 | 252 | @verbatim |
mbed_official | 181:a4cbdfbbd2f4 | 253 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 254 | ##### HAL Control functions ##### |
mbed_official | 181:a4cbdfbbd2f4 | 255 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 256 | [..] This section provides functions allowing to: |
mbed_official | 181:a4cbdfbbd2f4 | 257 | (+) Provide a tick value in millisecond |
mbed_official | 181:a4cbdfbbd2f4 | 258 | (+) Provide a blocking delay in millisecond |
mbed_official | 181:a4cbdfbbd2f4 | 259 | (+) Suspend the time base source interrupt |
mbed_official | 181:a4cbdfbbd2f4 | 260 | (+) Resume the time base source interrupt |
mbed_official | 181:a4cbdfbbd2f4 | 261 | (+) Get the HAL API driver version |
mbed_official | 181:a4cbdfbbd2f4 | 262 | (+) Get the device identifier |
mbed_official | 181:a4cbdfbbd2f4 | 263 | (+) Get the device revision identifier |
mbed_official | 181:a4cbdfbbd2f4 | 264 | (+) Configures low power mode behavior when the MCU is in Debug mode |
mbed_official | 181:a4cbdfbbd2f4 | 265 | |
mbed_official | 181:a4cbdfbbd2f4 | 266 | @endverbatim |
mbed_official | 181:a4cbdfbbd2f4 | 267 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 268 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 269 | |
mbed_official | 181:a4cbdfbbd2f4 | 270 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 271 | * @brief This function is called to increment a global variable "uwTick" |
mbed_official | 181:a4cbdfbbd2f4 | 272 | * used as application time base. |
mbed_official | 181:a4cbdfbbd2f4 | 273 | * @note In the default implementation, this variable is incremented each 1ms |
mbed_official | 181:a4cbdfbbd2f4 | 274 | * in Systick ISR. |
mbed_official | 181:a4cbdfbbd2f4 | 275 | * @note This function is declared as __weak to be overwritten in case of other |
mbed_official | 181:a4cbdfbbd2f4 | 276 | * implementations in user file. |
mbed_official | 181:a4cbdfbbd2f4 | 277 | * @param None |
mbed_official | 181:a4cbdfbbd2f4 | 278 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 279 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 280 | __weak void HAL_IncTick(void) |
mbed_official | 181:a4cbdfbbd2f4 | 281 | { |
mbed_official | 181:a4cbdfbbd2f4 | 282 | uwTick++; |
mbed_official | 181:a4cbdfbbd2f4 | 283 | } |
mbed_official | 181:a4cbdfbbd2f4 | 284 | |
mbed_official | 181:a4cbdfbbd2f4 | 285 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 286 | * @brief Provides a tick value in millisecond. |
mbed_official | 181:a4cbdfbbd2f4 | 287 | * @note This function is declared as __weak to be overwritten in case of other |
mbed_official | 181:a4cbdfbbd2f4 | 288 | * implementations in user file. |
mbed_official | 181:a4cbdfbbd2f4 | 289 | * @param None |
mbed_official | 181:a4cbdfbbd2f4 | 290 | * @retval tick value |
mbed_official | 181:a4cbdfbbd2f4 | 291 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 292 | __weak uint32_t HAL_GetTick(void) |
mbed_official | 181:a4cbdfbbd2f4 | 293 | { |
mbed_official | 181:a4cbdfbbd2f4 | 294 | return uwTick; |
mbed_official | 181:a4cbdfbbd2f4 | 295 | } |
mbed_official | 181:a4cbdfbbd2f4 | 296 | |
mbed_official | 181:a4cbdfbbd2f4 | 297 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 298 | * @brief This function provides accurate delay (in milliseconds) based |
mbed_official | 181:a4cbdfbbd2f4 | 299 | * on variable incremented. |
mbed_official | 181:a4cbdfbbd2f4 | 300 | * @note In the default implementation , SysTick timer is the source of time base. |
mbed_official | 181:a4cbdfbbd2f4 | 301 | * It is used to generate interrupts at regular time intervals where uwTick |
mbed_official | 181:a4cbdfbbd2f4 | 302 | * is incremented. |
mbed_official | 181:a4cbdfbbd2f4 | 303 | * @note ThiS function is declared as __weak to be overwritten in case of other |
mbed_official | 181:a4cbdfbbd2f4 | 304 | * implementations in user file. |
mbed_official | 181:a4cbdfbbd2f4 | 305 | * @param Delay: specifies the delay time length, in milliseconds. |
mbed_official | 181:a4cbdfbbd2f4 | 306 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 307 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 308 | __weak void HAL_Delay(__IO uint32_t Delay) |
mbed_official | 181:a4cbdfbbd2f4 | 309 | { |
mbed_official | 181:a4cbdfbbd2f4 | 310 | uint32_t tickstart = 0; |
mbed_official | 181:a4cbdfbbd2f4 | 311 | tickstart = HAL_GetTick(); |
mbed_official | 181:a4cbdfbbd2f4 | 312 | while((HAL_GetTick() - tickstart) < Delay) |
mbed_official | 181:a4cbdfbbd2f4 | 313 | { |
mbed_official | 181:a4cbdfbbd2f4 | 314 | } |
mbed_official | 181:a4cbdfbbd2f4 | 315 | } |
mbed_official | 181:a4cbdfbbd2f4 | 316 | |
mbed_official | 181:a4cbdfbbd2f4 | 317 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 318 | * @brief Suspend Tick increment. |
mbed_official | 181:a4cbdfbbd2f4 | 319 | * @note In the default implementation , SysTick timer is the source of time base. It is |
mbed_official | 181:a4cbdfbbd2f4 | 320 | * used to generate interrupts at regular time intervals. Once HAL_SuspendTick() |
mbed_official | 181:a4cbdfbbd2f4 | 321 | * is called, the the SysTick interrupt will be disabled and so Tick increment |
mbed_official | 181:a4cbdfbbd2f4 | 322 | * is suspended. |
mbed_official | 181:a4cbdfbbd2f4 | 323 | * @note This function is declared as __weak to be overwritten in case of other |
mbed_official | 181:a4cbdfbbd2f4 | 324 | * implementations in user file. |
mbed_official | 181:a4cbdfbbd2f4 | 325 | * @param None |
mbed_official | 181:a4cbdfbbd2f4 | 326 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 327 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 328 | __weak void HAL_SuspendTick(void) |
mbed_official | 181:a4cbdfbbd2f4 | 329 | { |
mbed_official | 181:a4cbdfbbd2f4 | 330 | /* Disable SysTick Interrupt */ |
mbed_official | 181:a4cbdfbbd2f4 | 331 | SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; |
mbed_official | 181:a4cbdfbbd2f4 | 332 | } |
mbed_official | 181:a4cbdfbbd2f4 | 333 | |
mbed_official | 181:a4cbdfbbd2f4 | 334 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 335 | * @brief Resume Tick increment. |
mbed_official | 181:a4cbdfbbd2f4 | 336 | * @note In the default implementation , SysTick timer is the source of time base. It is |
mbed_official | 181:a4cbdfbbd2f4 | 337 | * used to generate interrupts at regular time intervals. Once HAL_ResumeTick() |
mbed_official | 181:a4cbdfbbd2f4 | 338 | * is called, the the SysTick interrupt will be enabled and so Tick increment |
mbed_official | 181:a4cbdfbbd2f4 | 339 | * is resumed. |
mbed_official | 181:a4cbdfbbd2f4 | 340 | * @note This function is declared as __weak to be overwritten in case of other |
mbed_official | 181:a4cbdfbbd2f4 | 341 | * implementations in user file. |
mbed_official | 181:a4cbdfbbd2f4 | 342 | * @param None |
mbed_official | 181:a4cbdfbbd2f4 | 343 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 344 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 345 | __weak void HAL_ResumeTick(void) |
mbed_official | 181:a4cbdfbbd2f4 | 346 | { |
mbed_official | 181:a4cbdfbbd2f4 | 347 | /* Enable SysTick Interrupt */ |
mbed_official | 181:a4cbdfbbd2f4 | 348 | SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; |
mbed_official | 181:a4cbdfbbd2f4 | 349 | } |
mbed_official | 181:a4cbdfbbd2f4 | 350 | |
mbed_official | 181:a4cbdfbbd2f4 | 351 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 352 | * @brief Returns the HAL revision |
mbed_official | 181:a4cbdfbbd2f4 | 353 | * @param None |
mbed_official | 181:a4cbdfbbd2f4 | 354 | * @retval version: 0xXYZR (8bits for each decimal, R for RC) |
mbed_official | 181:a4cbdfbbd2f4 | 355 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 356 | uint32_t HAL_GetHalVersion(void) |
mbed_official | 181:a4cbdfbbd2f4 | 357 | { |
mbed_official | 181:a4cbdfbbd2f4 | 358 | return __STM32L0xx_HAL_VERSION; |
mbed_official | 181:a4cbdfbbd2f4 | 359 | } |
mbed_official | 181:a4cbdfbbd2f4 | 360 | |
mbed_official | 181:a4cbdfbbd2f4 | 361 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 362 | * @brief Returns the device revision identifier. |
mbed_official | 181:a4cbdfbbd2f4 | 363 | * @param None |
mbed_official | 181:a4cbdfbbd2f4 | 364 | * @retval Device revision identifier |
mbed_official | 181:a4cbdfbbd2f4 | 365 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 366 | uint32_t HAL_GetREVID(void) |
mbed_official | 181:a4cbdfbbd2f4 | 367 | { |
mbed_official | 181:a4cbdfbbd2f4 | 368 | return((DBGMCU->IDCODE) >> 16); |
mbed_official | 181:a4cbdfbbd2f4 | 369 | } |
mbed_official | 181:a4cbdfbbd2f4 | 370 | |
mbed_official | 181:a4cbdfbbd2f4 | 371 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 372 | * @brief Returns the device identifier. |
mbed_official | 181:a4cbdfbbd2f4 | 373 | * @param None |
mbed_official | 181:a4cbdfbbd2f4 | 374 | * @retval Device identifier |
mbed_official | 181:a4cbdfbbd2f4 | 375 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 376 | uint32_t HAL_GetDEVID(void) |
mbed_official | 181:a4cbdfbbd2f4 | 377 | { |
mbed_official | 181:a4cbdfbbd2f4 | 378 | return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK); |
mbed_official | 181:a4cbdfbbd2f4 | 379 | } |
mbed_official | 181:a4cbdfbbd2f4 | 380 | |
mbed_official | 181:a4cbdfbbd2f4 | 381 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 382 | * @brief Configures low power mode behavior when the MCU is in Debug mode. |
mbed_official | 181:a4cbdfbbd2f4 | 383 | * @param Periph: specifies the low power mode. |
mbed_official | 181:a4cbdfbbd2f4 | 384 | * This parameter can be any combination of the following values: |
mbed_official | 181:a4cbdfbbd2f4 | 385 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode |
mbed_official | 181:a4cbdfbbd2f4 | 386 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode |
mbed_official | 181:a4cbdfbbd2f4 | 387 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode |
mbed_official | 181:a4cbdfbbd2f4 | 388 | * @param NewState: new state of the specified low power mode in Debug mode. |
mbed_official | 181:a4cbdfbbd2f4 | 389 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 181:a4cbdfbbd2f4 | 390 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 391 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 392 | void HAL_DBG_LowPowerConfig(uint32_t Periph, FunctionalState NewState) |
mbed_official | 181:a4cbdfbbd2f4 | 393 | { |
mbed_official | 181:a4cbdfbbd2f4 | 394 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 395 | assert_param(IS_DBGMCU_PERIPH(Periph)); |
mbed_official | 181:a4cbdfbbd2f4 | 396 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 181:a4cbdfbbd2f4 | 397 | if (NewState != DISABLE) |
mbed_official | 181:a4cbdfbbd2f4 | 398 | { |
mbed_official | 181:a4cbdfbbd2f4 | 399 | DBGMCU->CR |= Periph; |
mbed_official | 181:a4cbdfbbd2f4 | 400 | } |
mbed_official | 181:a4cbdfbbd2f4 | 401 | else |
mbed_official | 181:a4cbdfbbd2f4 | 402 | { |
mbed_official | 181:a4cbdfbbd2f4 | 403 | DBGMCU->CR &= ~Periph; |
mbed_official | 181:a4cbdfbbd2f4 | 404 | } |
mbed_official | 181:a4cbdfbbd2f4 | 405 | } |
mbed_official | 181:a4cbdfbbd2f4 | 406 | |
mbed_official | 181:a4cbdfbbd2f4 | 407 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 408 | * @brief Returns the boot mode as configured by user. |
mbed_official | 181:a4cbdfbbd2f4 | 409 | * @param None. |
mbed_official | 181:a4cbdfbbd2f4 | 410 | * @retval The boot mode as configured by user. The returned value can be one |
mbed_official | 181:a4cbdfbbd2f4 | 411 | * of the following values: |
mbed_official | 181:a4cbdfbbd2f4 | 412 | * - 0x00000000: Boot is configured in Main Flash memory |
mbed_official | 181:a4cbdfbbd2f4 | 413 | * - 0x00000100: Boot is configured in System Flash memory |
mbed_official | 181:a4cbdfbbd2f4 | 414 | * - 0x00000300: Boot is configured in Embedded SRAM memory |
mbed_official | 181:a4cbdfbbd2f4 | 415 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 416 | uint32_t HAL_GetBootMode(void) |
mbed_official | 181:a4cbdfbbd2f4 | 417 | { |
mbed_official | 181:a4cbdfbbd2f4 | 418 | return (SYSCFG->CFGR1 & SYSCFG_CFGR1_BOOT_MODE); |
mbed_official | 181:a4cbdfbbd2f4 | 419 | } |
mbed_official | 181:a4cbdfbbd2f4 | 420 | |
mbed_official | 181:a4cbdfbbd2f4 | 421 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 422 | * @brief Configures the I2C fast mode plus driving capability. |
mbed_official | 181:a4cbdfbbd2f4 | 423 | * @param SYSCFG_I2CFastModePlus: selects the pin. |
mbed_official | 181:a4cbdfbbd2f4 | 424 | * This parameter can be one of the following values: |
mbed_official | 181:a4cbdfbbd2f4 | 425 | * @arg SYSCFG_I2CFastModePlus_PB6: Configure fast mode plus driving capability for PB6 |
mbed_official | 181:a4cbdfbbd2f4 | 426 | * @arg SYSCFG_I2CFastModePlus_PB7: Configure fast mode plus driving capability for PB7 |
mbed_official | 181:a4cbdfbbd2f4 | 427 | * @arg SYSCFG_I2CFastModePlus_PB8: Configure fast mode plus driving capability for PB8 |
mbed_official | 181:a4cbdfbbd2f4 | 428 | * @arg SYSCFG_I2CFastModePlus_PB9: Configure fast mode plus driving capability for PB9 |
mbed_official | 181:a4cbdfbbd2f4 | 429 | * @arg SYSCFG_I2CFastModePlus_I2C1: Configure fast mode plus driving capability for I2C1 pins |
mbed_official | 181:a4cbdfbbd2f4 | 430 | * @arg SYSCFG_I2CFastModePlus_I2C2: Configure fast mode plus driving capability for I2C2 pins |
mbed_official | 181:a4cbdfbbd2f4 | 431 | * @param NewState: This parameter can be: |
mbed_official | 181:a4cbdfbbd2f4 | 432 | * @arg ENABLE: Enable fast mode plus driving capability for selected I2C pin |
mbed_official | 181:a4cbdfbbd2f4 | 433 | * @arg DISABLE: Disable fast mode plus driving capability for selected I2C pin |
mbed_official | 181:a4cbdfbbd2f4 | 434 | * @note For I2C1, fast mode plus driving capability can be enabled on all selected |
mbed_official | 181:a4cbdfbbd2f4 | 435 | * I2C1 pins using SYSCFG_I2CFastModePlus_I2C1 parameter or independently |
mbed_official | 181:a4cbdfbbd2f4 | 436 | * on each one of the following pins PB6, PB7, PB8 and PB9. |
mbed_official | 181:a4cbdfbbd2f4 | 437 | * @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability |
mbed_official | 181:a4cbdfbbd2f4 | 438 | * can be enabled only by using SYSCFG_I2CFastModePlus_I2C1 parameter. |
mbed_official | 181:a4cbdfbbd2f4 | 439 | * @note For all I2C2 pins fast mode plus driving capability can be enabled |
mbed_official | 181:a4cbdfbbd2f4 | 440 | * only by using SYSCFG_I2CFastModePlus_I2C2 parameter. |
mbed_official | 181:a4cbdfbbd2f4 | 441 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 442 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 443 | void HAL_I2CFastModePlusConfig(uint32_t SYSCFG_I2CFastModePlus, FunctionalState NewState) |
mbed_official | 181:a4cbdfbbd2f4 | 444 | { |
mbed_official | 181:a4cbdfbbd2f4 | 445 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 446 | assert_param(IS_SYSCFG_I2C_FMP(SYSCFG_I2CFastModePlus)); |
mbed_official | 181:a4cbdfbbd2f4 | 447 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 181:a4cbdfbbd2f4 | 448 | |
mbed_official | 181:a4cbdfbbd2f4 | 449 | if (NewState != DISABLE) |
mbed_official | 181:a4cbdfbbd2f4 | 450 | { |
mbed_official | 181:a4cbdfbbd2f4 | 451 | /* Enable fast mode plus driving capability for selected pin */ |
mbed_official | 181:a4cbdfbbd2f4 | 452 | SYSCFG->CFGR2 |= (uint32_t)SYSCFG_I2CFastModePlus; |
mbed_official | 181:a4cbdfbbd2f4 | 453 | } |
mbed_official | 181:a4cbdfbbd2f4 | 454 | else |
mbed_official | 181:a4cbdfbbd2f4 | 455 | { |
mbed_official | 181:a4cbdfbbd2f4 | 456 | /* Disable fast mode plus driving capability for selected pin */ |
mbed_official | 181:a4cbdfbbd2f4 | 457 | SYSCFG->CFGR2 &= (uint32_t)(~SYSCFG_I2CFastModePlus); |
mbed_official | 181:a4cbdfbbd2f4 | 458 | } |
mbed_official | 181:a4cbdfbbd2f4 | 459 | } |
mbed_official | 181:a4cbdfbbd2f4 | 460 | |
mbed_official | 181:a4cbdfbbd2f4 | 461 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 462 | * @brief Enables or disables the VREFINT. |
mbed_official | 181:a4cbdfbbd2f4 | 463 | * @param NewState: new state of the Vrefint. |
mbed_official | 181:a4cbdfbbd2f4 | 464 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 181:a4cbdfbbd2f4 | 465 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 466 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 467 | void HAL_VREFINT_Cmd(FunctionalState NewState) |
mbed_official | 181:a4cbdfbbd2f4 | 468 | { |
mbed_official | 181:a4cbdfbbd2f4 | 469 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 470 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 181:a4cbdfbbd2f4 | 471 | |
mbed_official | 181:a4cbdfbbd2f4 | 472 | if (NewState != DISABLE) |
mbed_official | 181:a4cbdfbbd2f4 | 473 | { |
mbed_official | 181:a4cbdfbbd2f4 | 474 | /* Enable the VREFINT by setting EN_VREFINT bit in the CFGR3 register */ |
mbed_official | 181:a4cbdfbbd2f4 | 475 | SYSCFG->CFGR3 |= SYSCFG_CFGR3_EN_VREFINT; |
mbed_official | 181:a4cbdfbbd2f4 | 476 | } |
mbed_official | 181:a4cbdfbbd2f4 | 477 | else |
mbed_official | 181:a4cbdfbbd2f4 | 478 | { |
mbed_official | 181:a4cbdfbbd2f4 | 479 | /* Disable the VREFINT by setting EN_VREFINT bit in the CFGR3 register */ |
mbed_official | 181:a4cbdfbbd2f4 | 480 | SYSCFG->CFGR3 &= (uint32_t)~((uint32_t)SYSCFG_CFGR3_EN_VREFINT); |
mbed_official | 181:a4cbdfbbd2f4 | 481 | } |
mbed_official | 181:a4cbdfbbd2f4 | 482 | } |
mbed_official | 181:a4cbdfbbd2f4 | 483 | |
mbed_official | 181:a4cbdfbbd2f4 | 484 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 485 | * @brief Selects the output of internal reference voltage (VREFINT). |
mbed_official | 181:a4cbdfbbd2f4 | 486 | * The VREFINT output can be routed to(PB0) or |
mbed_official | 181:a4cbdfbbd2f4 | 487 | * (PB1) or both. |
mbed_official | 181:a4cbdfbbd2f4 | 488 | * @param SYSCFG_Vrefint_OUTPUT: new state of the Vrefint output. |
mbed_official | 181:a4cbdfbbd2f4 | 489 | * This parameter can be one of the following values: |
mbed_official | 181:a4cbdfbbd2f4 | 490 | * @arg SYSCFG_VREFINT_OUT_NONE |
mbed_official | 181:a4cbdfbbd2f4 | 491 | * @arg SYSCFG_VREFINT_OUT_PB0 |
mbed_official | 181:a4cbdfbbd2f4 | 492 | * @arg SYSCFG_VREFINT_OUT_PB1 |
mbed_official | 181:a4cbdfbbd2f4 | 493 | * @arg SYSCFG_VREFINT_OUT_PB0_PB1 |
mbed_official | 181:a4cbdfbbd2f4 | 494 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 495 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 496 | void HAL_VREFINT_OutputSelect(uint32_t SYSCFG_Vrefint_OUTPUT) |
mbed_official | 181:a4cbdfbbd2f4 | 497 | { |
mbed_official | 181:a4cbdfbbd2f4 | 498 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 499 | assert_param(IS_SYSCFG_VREFINT_OUT_SELECT(SYSCFG_Vrefint_OUTPUT)); |
mbed_official | 181:a4cbdfbbd2f4 | 500 | |
mbed_official | 181:a4cbdfbbd2f4 | 501 | /* Set the output Vrefint pin */ |
mbed_official | 181:a4cbdfbbd2f4 | 502 | SYSCFG->CFGR3 &= ~(SYSCFG_CFGR3_VREF_OUT); |
mbed_official | 181:a4cbdfbbd2f4 | 503 | SYSCFG->CFGR3 |= (uint32_t)(SYSCFG_Vrefint_OUTPUT); |
mbed_official | 181:a4cbdfbbd2f4 | 504 | } |
mbed_official | 181:a4cbdfbbd2f4 | 505 | |
mbed_official | 181:a4cbdfbbd2f4 | 506 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 507 | * @brief Enables or disables the Buffer Vrefint for the ADC. |
mbed_official | 181:a4cbdfbbd2f4 | 508 | * @param NewState: new state of the Vrefint. |
mbed_official | 181:a4cbdfbbd2f4 | 509 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 181:a4cbdfbbd2f4 | 510 | * @note This is functional only if the LOCK is not set |
mbed_official | 181:a4cbdfbbd2f4 | 511 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 512 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 513 | void HAL_ADC_EnableBuffer_Cmd(FunctionalState NewState) |
mbed_official | 181:a4cbdfbbd2f4 | 514 | { |
mbed_official | 181:a4cbdfbbd2f4 | 515 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 516 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 181:a4cbdfbbd2f4 | 517 | |
mbed_official | 181:a4cbdfbbd2f4 | 518 | if (NewState != DISABLE) |
mbed_official | 181:a4cbdfbbd2f4 | 519 | { |
mbed_official | 181:a4cbdfbbd2f4 | 520 | /* Enable the Buffer for the ADC by setting EN_VREFINT bit and the ENBUF_VREFINT_ADC in the CFGR3 register */ |
mbed_official | 181:a4cbdfbbd2f4 | 521 | SYSCFG->CFGR3 |= (SYSCFG_CFGR3_ENBUF_VREFINT_ADC | SYSCFG_CFGR3_EN_VREFINT); |
mbed_official | 181:a4cbdfbbd2f4 | 522 | } |
mbed_official | 181:a4cbdfbbd2f4 | 523 | else |
mbed_official | 181:a4cbdfbbd2f4 | 524 | { |
mbed_official | 181:a4cbdfbbd2f4 | 525 | /* Disable the Vrefint by resetting ENBUF_BGAP_ADC bit and the EN_VREFINT bit in the CFGR3 register */ |
mbed_official | 181:a4cbdfbbd2f4 | 526 | SYSCFG->CFGR3 &= (uint32_t)~((uint32_t)(SYSCFG_CFGR3_ENBUF_VREFINT_ADC | SYSCFG_CFGR3_EN_VREFINT)); |
mbed_official | 181:a4cbdfbbd2f4 | 527 | } |
mbed_official | 181:a4cbdfbbd2f4 | 528 | } |
mbed_official | 181:a4cbdfbbd2f4 | 529 | |
mbed_official | 181:a4cbdfbbd2f4 | 530 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 531 | * @brief Enables or disables the Buffer Sensor for the ADC. |
mbed_official | 181:a4cbdfbbd2f4 | 532 | * @param NewState: new state of the Vrefint. |
mbed_official | 181:a4cbdfbbd2f4 | 533 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 181:a4cbdfbbd2f4 | 534 | * @note This is functional only if the LOCK is not set. |
mbed_official | 181:a4cbdfbbd2f4 | 535 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 536 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 537 | void HAL_ADC_EnableBufferSensor_Cmd(FunctionalState NewState) |
mbed_official | 181:a4cbdfbbd2f4 | 538 | { |
mbed_official | 181:a4cbdfbbd2f4 | 539 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 540 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 181:a4cbdfbbd2f4 | 541 | |
mbed_official | 181:a4cbdfbbd2f4 | 542 | if (NewState != DISABLE) |
mbed_official | 181:a4cbdfbbd2f4 | 543 | { |
mbed_official | 181:a4cbdfbbd2f4 | 544 | /* Enable the Buffer for the ADC by setting EN_VREFINT bit and the ENBUF_SENSOR_ADC in the CFGR3 register */ |
mbed_official | 181:a4cbdfbbd2f4 | 545 | SYSCFG->CFGR3 |= (SYSCFG_CFGR3_ENBUF_SENSOR_ADC | SYSCFG_CFGR3_EN_VREFINT); |
mbed_official | 181:a4cbdfbbd2f4 | 546 | } |
mbed_official | 181:a4cbdfbbd2f4 | 547 | else |
mbed_official | 181:a4cbdfbbd2f4 | 548 | { |
mbed_official | 181:a4cbdfbbd2f4 | 549 | /* Disable the Vrefint by resetting EN_VREFINT bit and the ENBUF_SENSOR_ADC in the CFGR3 register */ |
mbed_official | 181:a4cbdfbbd2f4 | 550 | SYSCFG->CFGR3 &= (uint32_t)~((uint32_t)(SYSCFG_CFGR3_ENBUF_SENSOR_ADC | SYSCFG_CFGR3_EN_VREFINT)); |
mbed_official | 181:a4cbdfbbd2f4 | 551 | } |
mbed_official | 181:a4cbdfbbd2f4 | 552 | } |
mbed_official | 181:a4cbdfbbd2f4 | 553 | |
mbed_official | 181:a4cbdfbbd2f4 | 554 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 555 | * @brief Enables or disables the Buffer Vrefint for the COMP. |
mbed_official | 181:a4cbdfbbd2f4 | 556 | * @param NewState: new state of the Vrefint. |
mbed_official | 181:a4cbdfbbd2f4 | 557 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 181:a4cbdfbbd2f4 | 558 | * @note This is functional only if the LOCK is not set |
mbed_official | 181:a4cbdfbbd2f4 | 559 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 560 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 561 | void HAL_COMP_EnableBuffer_Cmd(FunctionalState NewState) |
mbed_official | 181:a4cbdfbbd2f4 | 562 | { |
mbed_official | 181:a4cbdfbbd2f4 | 563 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 564 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 181:a4cbdfbbd2f4 | 565 | |
mbed_official | 181:a4cbdfbbd2f4 | 566 | if (NewState != DISABLE) |
mbed_official | 181:a4cbdfbbd2f4 | 567 | { |
mbed_official | 181:a4cbdfbbd2f4 | 568 | /* Enable the Buffer for the COMP by setting EN_VREFINT bit and the ENBUFLP_VREFINT_COMP in the CFGR3 register */ |
mbed_official | 181:a4cbdfbbd2f4 | 569 | SYSCFG->CFGR3 |= (SYSCFG_CFGR3_ENBUFLP_VREFINT_COMP | SYSCFG_CFGR3_EN_VREFINT); |
mbed_official | 181:a4cbdfbbd2f4 | 570 | } |
mbed_official | 181:a4cbdfbbd2f4 | 571 | else |
mbed_official | 181:a4cbdfbbd2f4 | 572 | { |
mbed_official | 181:a4cbdfbbd2f4 | 573 | /* Disable the Vrefint by resetting ENBUFLP_BGAP_COMP bit and the EN_VREFINT bit in the CFGR3 register */ |
mbed_official | 181:a4cbdfbbd2f4 | 574 | SYSCFG->CFGR3 &= (uint32_t)~((uint32_t)(SYSCFG_CFGR3_ENBUFLP_VREFINT_COMP | SYSCFG_CFGR3_EN_VREFINT)); |
mbed_official | 181:a4cbdfbbd2f4 | 575 | } |
mbed_official | 181:a4cbdfbbd2f4 | 576 | } |
mbed_official | 181:a4cbdfbbd2f4 | 577 | |
mbed_official | 181:a4cbdfbbd2f4 | 578 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 579 | * @brief Enables or disables the Buffer Vrefint for the RC48. |
mbed_official | 181:a4cbdfbbd2f4 | 580 | * @param NewState: new state of the Vrefint. |
mbed_official | 181:a4cbdfbbd2f4 | 581 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 181:a4cbdfbbd2f4 | 582 | * @note This is functional only if the LOCK is not set |
mbed_official | 181:a4cbdfbbd2f4 | 583 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 584 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 585 | void HAL_RC48_EnableBuffer_Cmd(FunctionalState NewState) |
mbed_official | 181:a4cbdfbbd2f4 | 586 | { |
mbed_official | 181:a4cbdfbbd2f4 | 587 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 588 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 181:a4cbdfbbd2f4 | 589 | |
mbed_official | 181:a4cbdfbbd2f4 | 590 | if (NewState != DISABLE) |
mbed_official | 181:a4cbdfbbd2f4 | 591 | { |
mbed_official | 181:a4cbdfbbd2f4 | 592 | /* Enable the Buffer for the ADC by setting EN_VREFINT bit and the SYSCFG_CFGR3_ENREF_HSI48 in the CFGR3 register */ |
mbed_official | 181:a4cbdfbbd2f4 | 593 | SYSCFG->CFGR3 |= (SYSCFG_CFGR3_ENREF_HSI48 | SYSCFG_CFGR3_EN_VREFINT); |
mbed_official | 181:a4cbdfbbd2f4 | 594 | } |
mbed_official | 181:a4cbdfbbd2f4 | 595 | else |
mbed_official | 181:a4cbdfbbd2f4 | 596 | { |
mbed_official | 181:a4cbdfbbd2f4 | 597 | /* Disable the Vrefint by resetting SYSCFG_CFGR3_ENREF_HSI48 bit and the EN_VREFINT bit in the CFGR3 register */ |
mbed_official | 181:a4cbdfbbd2f4 | 598 | SYSCFG->CFGR3 &= (uint32_t)~((uint32_t)(SYSCFG_CFGR3_ENREF_HSI48 | SYSCFG_CFGR3_EN_VREFINT)); |
mbed_official | 181:a4cbdfbbd2f4 | 599 | } |
mbed_official | 181:a4cbdfbbd2f4 | 600 | } |
mbed_official | 181:a4cbdfbbd2f4 | 601 | |
mbed_official | 181:a4cbdfbbd2f4 | 602 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 603 | * @brief Enables or disables the Lock. |
mbed_official | 181:a4cbdfbbd2f4 | 604 | * @param NewState: new state of the Lock. |
mbed_official | 181:a4cbdfbbd2f4 | 605 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 181:a4cbdfbbd2f4 | 606 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 607 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 608 | void HAL_Lock_Cmd(FunctionalState NewState) |
mbed_official | 181:a4cbdfbbd2f4 | 609 | { |
mbed_official | 181:a4cbdfbbd2f4 | 610 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 611 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 181:a4cbdfbbd2f4 | 612 | |
mbed_official | 181:a4cbdfbbd2f4 | 613 | if (NewState != DISABLE) |
mbed_official | 181:a4cbdfbbd2f4 | 614 | { |
mbed_official | 181:a4cbdfbbd2f4 | 615 | /* Enable the LOCK by setting REF_LOCK bit in the CFGR3 register */ |
mbed_official | 181:a4cbdfbbd2f4 | 616 | SYSCFG->CFGR3 |= SYSCFG_CFGR3_REF_LOCK; |
mbed_official | 181:a4cbdfbbd2f4 | 617 | } |
mbed_official | 181:a4cbdfbbd2f4 | 618 | else |
mbed_official | 181:a4cbdfbbd2f4 | 619 | { |
mbed_official | 181:a4cbdfbbd2f4 | 620 | /* Disable the LOCK by setting REF_LOCK bit in the CFGR3 register */ |
mbed_official | 181:a4cbdfbbd2f4 | 621 | SYSCFG->CFGR3 &= (uint32_t)~((uint32_t)SYSCFG_CFGR3_REF_LOCK); |
mbed_official | 181:a4cbdfbbd2f4 | 622 | } |
mbed_official | 181:a4cbdfbbd2f4 | 623 | } |
mbed_official | 181:a4cbdfbbd2f4 | 624 | |
mbed_official | 181:a4cbdfbbd2f4 | 625 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 626 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 627 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 628 | |
mbed_official | 181:a4cbdfbbd2f4 | 629 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 630 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 631 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 632 | |
mbed_official | 181:a4cbdfbbd2f4 | 633 | #endif /* HAL_MODULE_ENABLED */ |
mbed_official | 181:a4cbdfbbd2f4 | 634 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 635 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 636 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 637 | |
mbed_official | 181:a4cbdfbbd2f4 | 638 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 639 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 640 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 641 | |
mbed_official | 181:a4cbdfbbd2f4 | 642 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |