mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
226:b062af740e40
test with CLOCK_SETUP = 0

Who changed what in which revision?

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