lzbp li / mbed-stm32l0l1-src-1

Fork of mbed-stm32l0/l1-src by lzbp li

Committer:
mbed_official
Date:
Fri Oct 31 11:00:10 2014 +0000
Revision:
376:cb4d9db17537
Synchronized with git revision 07b49da75eac883fc8916d3d6b6962664b8db29e

Full URL: https://github.com/mbedmicro/mbed/commit/07b49da75eac883fc8916d3d6b6962664b8db29e/

Targets: DISCO_L053C8 - new platform - STM32L0 Discovery board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 376:cb4d9db17537 1 /**
mbed_official 376:cb4d9db17537 2 ******************************************************************************
mbed_official 376:cb4d9db17537 3 * @file stm32l0xx_hal_rng.c
mbed_official 376:cb4d9db17537 4 * @author MCD Application Team
mbed_official 376:cb4d9db17537 5 * @version V1.1.0
mbed_official 376:cb4d9db17537 6 * @date 18-June-2014
mbed_official 376:cb4d9db17537 7 * @brief RNG HAL module driver.
mbed_official 376:cb4d9db17537 8 * This file provides firmware functions to manage the following
mbed_official 376:cb4d9db17537 9 * functionalities of the Random Number Generator (RNG) peripheral:
mbed_official 376:cb4d9db17537 10 * + Initialization/de-initialization functions
mbed_official 376:cb4d9db17537 11 * + Peripheral Control functions
mbed_official 376:cb4d9db17537 12 * + Peripheral State functions
mbed_official 376:cb4d9db17537 13 *
mbed_official 376:cb4d9db17537 14 @verbatim
mbed_official 376:cb4d9db17537 15 ==============================================================================
mbed_official 376:cb4d9db17537 16 ##### How to use this driver #####
mbed_official 376:cb4d9db17537 17 ==============================================================================
mbed_official 376:cb4d9db17537 18 [..]
mbed_official 376:cb4d9db17537 19 The RNG HAL driver can be used as follows:
mbed_official 376:cb4d9db17537 20
mbed_official 376:cb4d9db17537 21 (#) Enable the RNG controller clock using __RNG_CLK_ENABLE() macro.
mbed_official 376:cb4d9db17537 22 (#) Activate the RNG peripheral using __HAL_RNG_ENABLE() macro.
mbed_official 376:cb4d9db17537 23 (#) Wait until the 32 bit Random Number Generator contains a valid
mbed_official 376:cb4d9db17537 24 random data using (polling/interrupt) mode.
mbed_official 376:cb4d9db17537 25 (#) Get the 32 bit random number using HAL_RNG_GetRandomNumber() function.
mbed_official 376:cb4d9db17537 26
mbed_official 376:cb4d9db17537 27 @endverbatim
mbed_official 376:cb4d9db17537 28 ******************************************************************************
mbed_official 376:cb4d9db17537 29 * @attention
mbed_official 376:cb4d9db17537 30 *
mbed_official 376:cb4d9db17537 31 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 376:cb4d9db17537 32 *
mbed_official 376:cb4d9db17537 33 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 376:cb4d9db17537 34 * are permitted provided that the following conditions are met:
mbed_official 376:cb4d9db17537 35 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 376:cb4d9db17537 36 * this list of conditions and the following disclaimer.
mbed_official 376:cb4d9db17537 37 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 376:cb4d9db17537 38 * this list of conditions and the following disclaimer in the documentation
mbed_official 376:cb4d9db17537 39 * and/or other materials provided with the distribution.
mbed_official 376:cb4d9db17537 40 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 376:cb4d9db17537 41 * may be used to endorse or promote products derived from this software
mbed_official 376:cb4d9db17537 42 * without specific prior written permission.
mbed_official 376:cb4d9db17537 43 *
mbed_official 376:cb4d9db17537 44 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 376:cb4d9db17537 45 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 376:cb4d9db17537 46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 376:cb4d9db17537 47 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 376:cb4d9db17537 48 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 376:cb4d9db17537 49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 376:cb4d9db17537 50 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 376:cb4d9db17537 51 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 376:cb4d9db17537 52 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 376:cb4d9db17537 53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 376:cb4d9db17537 54 *
mbed_official 376:cb4d9db17537 55 ******************************************************************************
mbed_official 376:cb4d9db17537 56 */
mbed_official 376:cb4d9db17537 57
mbed_official 376:cb4d9db17537 58 /* Includes ------------------------------------------------------------------*/
mbed_official 376:cb4d9db17537 59 #include "stm32l0xx_hal.h"
mbed_official 376:cb4d9db17537 60
mbed_official 376:cb4d9db17537 61 /** @addtogroup STM32L0xx_HAL_Driver
mbed_official 376:cb4d9db17537 62 * @{
mbed_official 376:cb4d9db17537 63 */
mbed_official 376:cb4d9db17537 64
mbed_official 376:cb4d9db17537 65 /** @defgroup RNG
mbed_official 376:cb4d9db17537 66 * @brief RNG HAL module driver.
mbed_official 376:cb4d9db17537 67 * @{
mbed_official 376:cb4d9db17537 68 */
mbed_official 376:cb4d9db17537 69
mbed_official 376:cb4d9db17537 70 #ifdef HAL_RNG_MODULE_ENABLED
mbed_official 376:cb4d9db17537 71 #if !defined (STM32L051xx) && !defined (STM32L061xx)
mbed_official 376:cb4d9db17537 72
mbed_official 376:cb4d9db17537 73 /* Private typedef -----------------------------------------------------------*/
mbed_official 376:cb4d9db17537 74 /* Private define ------------------------------------------------------------*/
mbed_official 376:cb4d9db17537 75 #define RNG_TIMEOUT_VALUE 1000
mbed_official 376:cb4d9db17537 76 /* Private macro -------------------------------------------------------------*/
mbed_official 376:cb4d9db17537 77 /* Private variables ---------------------------------------------------------*/
mbed_official 376:cb4d9db17537 78 /* Private function prototypes -----------------------------------------------*/
mbed_official 376:cb4d9db17537 79 /* Private functions ---------------------------------------------------------*/
mbed_official 376:cb4d9db17537 80
mbed_official 376:cb4d9db17537 81 /** @defgroup RNG_Private_Functions
mbed_official 376:cb4d9db17537 82 * @{
mbed_official 376:cb4d9db17537 83 */
mbed_official 376:cb4d9db17537 84
mbed_official 376:cb4d9db17537 85 /** @defgroup RNG_Group1 Initialization and de-initialization functions
mbed_official 376:cb4d9db17537 86 * @brief Initialization and Configuration functions.
mbed_official 376:cb4d9db17537 87 *
mbed_official 376:cb4d9db17537 88 @verbatim
mbed_official 376:cb4d9db17537 89 ===============================================================================
mbed_official 376:cb4d9db17537 90 ##### Initialization and de-initialization functions #####
mbed_official 376:cb4d9db17537 91 ===============================================================================
mbed_official 376:cb4d9db17537 92 [..] This section provides functions allowing to:
mbed_official 376:cb4d9db17537 93 (+) Initialize the RNG according to the specified parameters
mbed_official 376:cb4d9db17537 94 in the RNG_InitTypeDef and create the associated handle
mbed_official 376:cb4d9db17537 95 (+) DeInitialize the RNG peripheral
mbed_official 376:cb4d9db17537 96 (+) Initialize the RNG MSP
mbed_official 376:cb4d9db17537 97 (+) DeInitialize RNG MSP
mbed_official 376:cb4d9db17537 98
mbed_official 376:cb4d9db17537 99 @endverbatim
mbed_official 376:cb4d9db17537 100 * @{
mbed_official 376:cb4d9db17537 101 */
mbed_official 376:cb4d9db17537 102
mbed_official 376:cb4d9db17537 103 /**
mbed_official 376:cb4d9db17537 104 * @brief Initializes the RNG according to the specified
mbed_official 376:cb4d9db17537 105 * parameters in the RNG_InitTypeDef and creates the associated handle.
mbed_official 376:cb4d9db17537 106 * @param hrng: pointer to a RNG_HandleTypeDef structure that contains
mbed_official 376:cb4d9db17537 107 * the configuration information for RNG.
mbed_official 376:cb4d9db17537 108 * @retval HAL status
mbed_official 376:cb4d9db17537 109 */
mbed_official 376:cb4d9db17537 110 HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng)
mbed_official 376:cb4d9db17537 111 {
mbed_official 376:cb4d9db17537 112 /* Check the RNG handle allocation */
mbed_official 376:cb4d9db17537 113 if(hrng == NULL)
mbed_official 376:cb4d9db17537 114 {
mbed_official 376:cb4d9db17537 115 return HAL_ERROR;
mbed_official 376:cb4d9db17537 116 }
mbed_official 376:cb4d9db17537 117
mbed_official 376:cb4d9db17537 118 if(hrng->State == HAL_RNG_STATE_RESET)
mbed_official 376:cb4d9db17537 119 {
mbed_official 376:cb4d9db17537 120 /* Init the low level hardware */
mbed_official 376:cb4d9db17537 121 HAL_RNG_MspInit(hrng);
mbed_official 376:cb4d9db17537 122 }
mbed_official 376:cb4d9db17537 123
mbed_official 376:cb4d9db17537 124 /* Change RNG peripheral state */
mbed_official 376:cb4d9db17537 125 hrng->State = HAL_RNG_STATE_BUSY;
mbed_official 376:cb4d9db17537 126
mbed_official 376:cb4d9db17537 127 /* Enable the RNG Peripheral */
mbed_official 376:cb4d9db17537 128 __HAL_RNG_ENABLE(hrng);
mbed_official 376:cb4d9db17537 129
mbed_official 376:cb4d9db17537 130 /* Initialize the RNG state */
mbed_official 376:cb4d9db17537 131 hrng->State = HAL_RNG_STATE_READY;
mbed_official 376:cb4d9db17537 132
mbed_official 376:cb4d9db17537 133 /* Return function status */
mbed_official 376:cb4d9db17537 134 return HAL_OK;
mbed_official 376:cb4d9db17537 135 }
mbed_official 376:cb4d9db17537 136
mbed_official 376:cb4d9db17537 137 /**
mbed_official 376:cb4d9db17537 138 * @brief DeInitializes the RNG peripheral.
mbed_official 376:cb4d9db17537 139 * @param hrng: pointer to a RNG_HandleTypeDef structure that contains
mbed_official 376:cb4d9db17537 140 * the configuration information for RNG.
mbed_official 376:cb4d9db17537 141 * @retval HAL status
mbed_official 376:cb4d9db17537 142 */
mbed_official 376:cb4d9db17537 143 HAL_StatusTypeDef HAL_RNG_DeInit(RNG_HandleTypeDef *hrng)
mbed_official 376:cb4d9db17537 144 {
mbed_official 376:cb4d9db17537 145 /* Check the RNG peripheral state */
mbed_official 376:cb4d9db17537 146 if(hrng->State == HAL_RNG_STATE_BUSY)
mbed_official 376:cb4d9db17537 147 {
mbed_official 376:cb4d9db17537 148 return HAL_BUSY;
mbed_official 376:cb4d9db17537 149 }
mbed_official 376:cb4d9db17537 150
mbed_official 376:cb4d9db17537 151 /* Update the RNG state */
mbed_official 376:cb4d9db17537 152 hrng->State = HAL_RNG_STATE_BUSY;
mbed_official 376:cb4d9db17537 153
mbed_official 376:cb4d9db17537 154 /* Disable the RNG Peripheral */
mbed_official 376:cb4d9db17537 155 __HAL_RNG_DISABLE(hrng);
mbed_official 376:cb4d9db17537 156
mbed_official 376:cb4d9db17537 157 /* Set the RNG registers to their reset values */
mbed_official 376:cb4d9db17537 158 hrng->Instance->CR &= 0xFFFFFFF3;
mbed_official 376:cb4d9db17537 159 hrng->Instance->SR &= 0xFFFFFF98;
mbed_official 376:cb4d9db17537 160 hrng->Instance->DR &= 0x0;
mbed_official 376:cb4d9db17537 161
mbed_official 376:cb4d9db17537 162 /* DeInit the low level hardware */
mbed_official 376:cb4d9db17537 163 HAL_RNG_MspDeInit(hrng);
mbed_official 376:cb4d9db17537 164
mbed_official 376:cb4d9db17537 165 /* Update the RNG state */
mbed_official 376:cb4d9db17537 166 hrng->State = HAL_RNG_STATE_RESET;
mbed_official 376:cb4d9db17537 167
mbed_official 376:cb4d9db17537 168 /* Release Lock */
mbed_official 376:cb4d9db17537 169 __HAL_UNLOCK(hrng);
mbed_official 376:cb4d9db17537 170
mbed_official 376:cb4d9db17537 171 /* Return the function status */
mbed_official 376:cb4d9db17537 172 return HAL_OK;
mbed_official 376:cb4d9db17537 173 }
mbed_official 376:cb4d9db17537 174
mbed_official 376:cb4d9db17537 175 /**
mbed_official 376:cb4d9db17537 176 * @brief Initializes the RNG MSP.
mbed_official 376:cb4d9db17537 177 * @param hrng: pointer to a RNG_HandleTypeDef structure that contains
mbed_official 376:cb4d9db17537 178 * the configuration information for RNG.
mbed_official 376:cb4d9db17537 179 * @retval None
mbed_official 376:cb4d9db17537 180 */
mbed_official 376:cb4d9db17537 181 __weak void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng)
mbed_official 376:cb4d9db17537 182 {
mbed_official 376:cb4d9db17537 183 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 376:cb4d9db17537 184 the HAL_RNG_MspInit could be implemented in the user file
mbed_official 376:cb4d9db17537 185 */
mbed_official 376:cb4d9db17537 186 }
mbed_official 376:cb4d9db17537 187
mbed_official 376:cb4d9db17537 188 /**
mbed_official 376:cb4d9db17537 189 * @brief DeInitializes the RNG MSP.
mbed_official 376:cb4d9db17537 190 * @param hrng: pointer to a RNG_HandleTypeDef structure that contains
mbed_official 376:cb4d9db17537 191 * the configuration information for RNG.
mbed_official 376:cb4d9db17537 192 * @retval None
mbed_official 376:cb4d9db17537 193 */
mbed_official 376:cb4d9db17537 194 __weak void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng)
mbed_official 376:cb4d9db17537 195 {
mbed_official 376:cb4d9db17537 196 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 376:cb4d9db17537 197 the HAL_RNG_MspDeInit could be implemented in the user file
mbed_official 376:cb4d9db17537 198 */
mbed_official 376:cb4d9db17537 199 }
mbed_official 376:cb4d9db17537 200
mbed_official 376:cb4d9db17537 201 /**
mbed_official 376:cb4d9db17537 202 * @}
mbed_official 376:cb4d9db17537 203 */
mbed_official 376:cb4d9db17537 204
mbed_official 376:cb4d9db17537 205 /** @defgroup RNG_Group2 Peripheral Control functions
mbed_official 376:cb4d9db17537 206 * @brief management functions.
mbed_official 376:cb4d9db17537 207 *
mbed_official 376:cb4d9db17537 208 @verbatim
mbed_official 376:cb4d9db17537 209 ===============================================================================
mbed_official 376:cb4d9db17537 210 ##### Peripheral Control functions #####
mbed_official 376:cb4d9db17537 211 ===============================================================================
mbed_official 376:cb4d9db17537 212 [..] This section provides functions allowing to:
mbed_official 376:cb4d9db17537 213 (+) Get the 32 bit Random number
mbed_official 376:cb4d9db17537 214 (+) Get the 32 bit Random number with interrupt enabled
mbed_official 376:cb4d9db17537 215 (+) Handle RNG interrupt request
mbed_official 376:cb4d9db17537 216
mbed_official 376:cb4d9db17537 217
mbed_official 376:cb4d9db17537 218 @endverbatim
mbed_official 376:cb4d9db17537 219 * @{
mbed_official 376:cb4d9db17537 220 */
mbed_official 376:cb4d9db17537 221
mbed_official 376:cb4d9db17537 222 /**
mbed_official 376:cb4d9db17537 223 * @brief Returns a 32-bit random number.
mbed_official 376:cb4d9db17537 224 * @note Each time the random number data is read the RNG_FLAG_DRDY flag
mbed_official 376:cb4d9db17537 225 * is automatically cleared.
mbed_official 376:cb4d9db17537 226 * @param hrng: pointer to a RNG_HandleTypeDef structure that contains
mbed_official 376:cb4d9db17537 227 * the configuration information for RNG.
mbed_official 376:cb4d9db17537 228 * @retval 32-bit random number
mbed_official 376:cb4d9db17537 229 */
mbed_official 376:cb4d9db17537 230 uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng)
mbed_official 376:cb4d9db17537 231 {
mbed_official 376:cb4d9db17537 232 uint32_t random32bit = 0;
mbed_official 376:cb4d9db17537 233 uint32_t tickstart = 0;
mbed_official 376:cb4d9db17537 234
mbed_official 376:cb4d9db17537 235 /* Process Locked */
mbed_official 376:cb4d9db17537 236 __HAL_LOCK(hrng);
mbed_official 376:cb4d9db17537 237
mbed_official 376:cb4d9db17537 238 /* Get timeout */
mbed_official 376:cb4d9db17537 239 tickstart = HAL_GetTick();
mbed_official 376:cb4d9db17537 240
mbed_official 376:cb4d9db17537 241 /* Check if data register contains valid random data */
mbed_official 376:cb4d9db17537 242 while(__HAL_RNG_GET_FLAG(hrng, RNG_FLAG_DRDY) == RESET)
mbed_official 376:cb4d9db17537 243 {
mbed_official 376:cb4d9db17537 244 if((HAL_GetTick() - tickstart ) > RNG_TIMEOUT_VALUE)
mbed_official 376:cb4d9db17537 245 {
mbed_official 376:cb4d9db17537 246 return HAL_TIMEOUT;
mbed_official 376:cb4d9db17537 247 }
mbed_official 376:cb4d9db17537 248 }
mbed_official 376:cb4d9db17537 249
mbed_official 376:cb4d9db17537 250 /* Get a 32bit Random number */
mbed_official 376:cb4d9db17537 251 random32bit = hrng->Instance->DR;
mbed_official 376:cb4d9db17537 252
mbed_official 376:cb4d9db17537 253 /* Process Unlocked */
mbed_official 376:cb4d9db17537 254 __HAL_UNLOCK(hrng);
mbed_official 376:cb4d9db17537 255
mbed_official 376:cb4d9db17537 256 /* Return the 32 bit random number */
mbed_official 376:cb4d9db17537 257 return random32bit;
mbed_official 376:cb4d9db17537 258 }
mbed_official 376:cb4d9db17537 259
mbed_official 376:cb4d9db17537 260 /**
mbed_official 376:cb4d9db17537 261 * @brief Returns a 32-bit random number with interrupt enabled.
mbed_official 376:cb4d9db17537 262 * @param hrng: pointer to a RNG_HandleTypeDef structure that contains
mbed_official 376:cb4d9db17537 263 * the configuration information for RNG.
mbed_official 376:cb4d9db17537 264 * @retval 32-bit random number
mbed_official 376:cb4d9db17537 265 */
mbed_official 376:cb4d9db17537 266 uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng)
mbed_official 376:cb4d9db17537 267 {
mbed_official 376:cb4d9db17537 268 uint32_t random32bit = 0;
mbed_official 376:cb4d9db17537 269
mbed_official 376:cb4d9db17537 270 /* Process Locked */
mbed_official 376:cb4d9db17537 271 __HAL_LOCK(hrng);
mbed_official 376:cb4d9db17537 272
mbed_official 376:cb4d9db17537 273 /* Change RNG peripheral state */
mbed_official 376:cb4d9db17537 274 hrng->State = HAL_RNG_STATE_BUSY;
mbed_official 376:cb4d9db17537 275
mbed_official 376:cb4d9db17537 276 /* Get a 32bit Random number */
mbed_official 376:cb4d9db17537 277 random32bit = hrng->Instance->DR;
mbed_official 376:cb4d9db17537 278
mbed_official 376:cb4d9db17537 279 /* Enable the RNG Interrupts: Data Ready, Clock error, Seed error */
mbed_official 376:cb4d9db17537 280 __HAL_RNG_ENABLE_IT(hrng);
mbed_official 376:cb4d9db17537 281
mbed_official 376:cb4d9db17537 282 /* Return the 32 bit random number */
mbed_official 376:cb4d9db17537 283 return random32bit;
mbed_official 376:cb4d9db17537 284 }
mbed_official 376:cb4d9db17537 285
mbed_official 376:cb4d9db17537 286 /**
mbed_official 376:cb4d9db17537 287 * @brief Handles RNG interrupt request.
mbed_official 376:cb4d9db17537 288 * @note In the case of a clock error, the RNG is no more able to generate
mbed_official 376:cb4d9db17537 289 * random numbers because the PLL48CLK clock is not correct. User has
mbed_official 376:cb4d9db17537 290 * to check that the clock controller is correctly configured to provide
mbed_official 376:cb4d9db17537 291 * the RNG clock and clear the CEIS bit using __HAL_RNG_CLEAR_FLAG().
mbed_official 376:cb4d9db17537 292 * The clock error has no impact on the previously generated
mbed_official 376:cb4d9db17537 293 * random numbers, and the RNG_DR register contents can be used.
mbed_official 376:cb4d9db17537 294 * @note In the case of a seed error, the generation of random numbers is
mbed_official 376:cb4d9db17537 295 * interrupted as long as the SECS bit is '1'. If a number is
mbed_official 376:cb4d9db17537 296 * available in the RNG_DR register, it must not be used because it may
mbed_official 376:cb4d9db17537 297 * not have enough entropy. In this case, it is recommended to clear the
mbed_official 376:cb4d9db17537 298 * SEIS bit using __HAL_RNG_CLEAR_FLAG(), then disable and enable
mbed_official 376:cb4d9db17537 299 * the RNG peripheral to reinitialize and restart the RNG.
mbed_official 376:cb4d9db17537 300 * @param hrng: pointer to a RNG_HandleTypeDef structure that contains
mbed_official 376:cb4d9db17537 301 * the configuration information for RNG.
mbed_official 376:cb4d9db17537 302 * @retval None
mbed_official 376:cb4d9db17537 303
mbed_official 376:cb4d9db17537 304 */
mbed_official 376:cb4d9db17537 305 void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng)
mbed_official 376:cb4d9db17537 306 {
mbed_official 376:cb4d9db17537 307 /* RNG clock error interrupt occurred */
mbed_official 376:cb4d9db17537 308 if(__HAL_RNG_GET_FLAG(hrng, RNG_IT_CEI) != RESET)
mbed_official 376:cb4d9db17537 309 {
mbed_official 376:cb4d9db17537 310 HAL_RNG_ErrorCallback(hrng);
mbed_official 376:cb4d9db17537 311
mbed_official 376:cb4d9db17537 312 /* Clear the clock error flag */
mbed_official 376:cb4d9db17537 313 __HAL_RNG_CLEAR_FLAG(hrng, RNG_IT_CEI);
mbed_official 376:cb4d9db17537 314
mbed_official 376:cb4d9db17537 315 /* Change RNG peripheral state */
mbed_official 376:cb4d9db17537 316 hrng->State = HAL_RNG_STATE_ERROR;
mbed_official 376:cb4d9db17537 317
mbed_official 376:cb4d9db17537 318 /* Process Unlocked */
mbed_official 376:cb4d9db17537 319 __HAL_UNLOCK(hrng);
mbed_official 376:cb4d9db17537 320 }
mbed_official 376:cb4d9db17537 321
mbed_official 376:cb4d9db17537 322 /* RNG seed error interrupt occurred */
mbed_official 376:cb4d9db17537 323 if(__HAL_RNG_GET_FLAG(hrng, RNG_IT_SEI) != RESET)
mbed_official 376:cb4d9db17537 324 {
mbed_official 376:cb4d9db17537 325 HAL_RNG_ErrorCallback(hrng);
mbed_official 376:cb4d9db17537 326
mbed_official 376:cb4d9db17537 327 /* Clear the seed error flag */
mbed_official 376:cb4d9db17537 328 __HAL_RNG_CLEAR_FLAG(hrng, RNG_IT_SEI);
mbed_official 376:cb4d9db17537 329
mbed_official 376:cb4d9db17537 330 /* Change RNG peripheral state */
mbed_official 376:cb4d9db17537 331 hrng->State = HAL_RNG_STATE_ERROR;
mbed_official 376:cb4d9db17537 332
mbed_official 376:cb4d9db17537 333 /* Process Unlocked */
mbed_official 376:cb4d9db17537 334 __HAL_UNLOCK(hrng);
mbed_official 376:cb4d9db17537 335 }
mbed_official 376:cb4d9db17537 336
mbed_official 376:cb4d9db17537 337 /* Check RNG data ready flag */
mbed_official 376:cb4d9db17537 338 if(__HAL_RNG_GET_FLAG(hrng, RNG_FLAG_DRDY) != RESET)
mbed_official 376:cb4d9db17537 339 {
mbed_official 376:cb4d9db17537 340 /* Data Ready callback */
mbed_official 376:cb4d9db17537 341 HAL_RNG_ReadyCallback(hrng);
mbed_official 376:cb4d9db17537 342
mbed_official 376:cb4d9db17537 343 /* Change RNG peripheral state */
mbed_official 376:cb4d9db17537 344 hrng->State = HAL_RNG_STATE_READY;
mbed_official 376:cb4d9db17537 345
mbed_official 376:cb4d9db17537 346 /* Clear the RNG Data Ready flag */
mbed_official 376:cb4d9db17537 347 __HAL_RNG_CLEAR_FLAG(hrng, RNG_FLAG_DRDY);
mbed_official 376:cb4d9db17537 348
mbed_official 376:cb4d9db17537 349 /* Process Unlocked */
mbed_official 376:cb4d9db17537 350 __HAL_UNLOCK(hrng);
mbed_official 376:cb4d9db17537 351 }
mbed_official 376:cb4d9db17537 352 }
mbed_official 376:cb4d9db17537 353
mbed_official 376:cb4d9db17537 354 /**
mbed_official 376:cb4d9db17537 355 * @brief Data Ready callback in non-blocking mode.
mbed_official 376:cb4d9db17537 356 * @param hrng: pointer to a RNG_HandleTypeDef structure that contains
mbed_official 376:cb4d9db17537 357 * the configuration information for RNG.
mbed_official 376:cb4d9db17537 358 * @retval None
mbed_official 376:cb4d9db17537 359 */
mbed_official 376:cb4d9db17537 360
mbed_official 376:cb4d9db17537 361 __weak void HAL_RNG_ReadyCallback(RNG_HandleTypeDef* hrng)
mbed_official 376:cb4d9db17537 362 {
mbed_official 376:cb4d9db17537 363 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 376:cb4d9db17537 364 the HAL_RNG_ReadyCallback could be implemented in the user file
mbed_official 376:cb4d9db17537 365 */
mbed_official 376:cb4d9db17537 366 }
mbed_official 376:cb4d9db17537 367
mbed_official 376:cb4d9db17537 368 /**
mbed_official 376:cb4d9db17537 369 * @brief RNG error callbacks.
mbed_official 376:cb4d9db17537 370 * @param hrng: pointer to a RNG_HandleTypeDef structure that contains
mbed_official 376:cb4d9db17537 371 * the configuration information for RNG.
mbed_official 376:cb4d9db17537 372 * @retval None
mbed_official 376:cb4d9db17537 373 */
mbed_official 376:cb4d9db17537 374 __weak void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng)
mbed_official 376:cb4d9db17537 375 {
mbed_official 376:cb4d9db17537 376 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 376:cb4d9db17537 377 the HAL_RNG_ErrorCallback could be implemented in the user file
mbed_official 376:cb4d9db17537 378 */
mbed_official 376:cb4d9db17537 379 }
mbed_official 376:cb4d9db17537 380
mbed_official 376:cb4d9db17537 381 /**
mbed_official 376:cb4d9db17537 382 * @}
mbed_official 376:cb4d9db17537 383 */
mbed_official 376:cb4d9db17537 384
mbed_official 376:cb4d9db17537 385 /** @defgroup RNG_Group3 Peripheral State functions
mbed_official 376:cb4d9db17537 386 * @brief Peripheral State functions.
mbed_official 376:cb4d9db17537 387 *
mbed_official 376:cb4d9db17537 388 @verbatim
mbed_official 376:cb4d9db17537 389 ===============================================================================
mbed_official 376:cb4d9db17537 390 ##### Peripheral State functions #####
mbed_official 376:cb4d9db17537 391 ===============================================================================
mbed_official 376:cb4d9db17537 392 [..]
mbed_official 376:cb4d9db17537 393 This subsection permits to get in run-time the status of the peripheral
mbed_official 376:cb4d9db17537 394 and the data flow.
mbed_official 376:cb4d9db17537 395
mbed_official 376:cb4d9db17537 396 @endverbatim
mbed_official 376:cb4d9db17537 397 * @{
mbed_official 376:cb4d9db17537 398 */
mbed_official 376:cb4d9db17537 399
mbed_official 376:cb4d9db17537 400 /**
mbed_official 376:cb4d9db17537 401 * @brief Returns the RNG state.
mbed_official 376:cb4d9db17537 402 * @param hrng: pointer to a RNG_HandleTypeDef structure that contains
mbed_official 376:cb4d9db17537 403 * the configuration information for RNG.
mbed_official 376:cb4d9db17537 404 * @retval HAL state
mbed_official 376:cb4d9db17537 405 */
mbed_official 376:cb4d9db17537 406 HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng)
mbed_official 376:cb4d9db17537 407 {
mbed_official 376:cb4d9db17537 408 return hrng->State;
mbed_official 376:cb4d9db17537 409 }
mbed_official 376:cb4d9db17537 410
mbed_official 376:cb4d9db17537 411 /**
mbed_official 376:cb4d9db17537 412 * @}
mbed_official 376:cb4d9db17537 413 */
mbed_official 376:cb4d9db17537 414
mbed_official 376:cb4d9db17537 415 /**
mbed_official 376:cb4d9db17537 416 * @}
mbed_official 376:cb4d9db17537 417 */
mbed_official 376:cb4d9db17537 418 #endif /* STM32L051xx && STM32L061xx*/
mbed_official 376:cb4d9db17537 419 #endif /* HAL_RNG_MODULE_ENABLED */
mbed_official 376:cb4d9db17537 420 /**
mbed_official 376:cb4d9db17537 421 * @}
mbed_official 376:cb4d9db17537 422 */
mbed_official 376:cb4d9db17537 423
mbed_official 376:cb4d9db17537 424 /**
mbed_official 376:cb4d9db17537 425 * @}
mbed_official 376:cb4d9db17537 426 */
mbed_official 376:cb4d9db17537 427
mbed_official 376:cb4d9db17537 428 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
mbed_official 376:cb4d9db17537 429