mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Fri Aug 14 13:15:17 2015 +0100
Revision:
610:813dcc80987e
Synchronized with git revision 6d84db41c6833e0b9b024741eb0616a5f62d5599

Full URL: https://github.com/mbedmicro/mbed/commit/6d84db41c6833e0b9b024741eb0616a5f62d5599/

DISCO_F746NG - Improvements

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 610:813dcc80987e 1 /**
mbed_official 610:813dcc80987e 2 ******************************************************************************
mbed_official 610:813dcc80987e 3 * @file stm32l4xx_hal_rng.h
mbed_official 610:813dcc80987e 4 * @author MCD Application Team
mbed_official 610:813dcc80987e 5 * @version V1.0.0
mbed_official 610:813dcc80987e 6 * @date 26-June-2015
mbed_official 610:813dcc80987e 7 * @brief Header file of RNG HAL module.
mbed_official 610:813dcc80987e 8 ******************************************************************************
mbed_official 610:813dcc80987e 9 * @attention
mbed_official 610:813dcc80987e 10 *
mbed_official 610:813dcc80987e 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
mbed_official 610:813dcc80987e 12 *
mbed_official 610:813dcc80987e 13 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 610:813dcc80987e 14 * are permitted provided that the following conditions are met:
mbed_official 610:813dcc80987e 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 610:813dcc80987e 16 * this list of conditions and the following disclaimer.
mbed_official 610:813dcc80987e 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 610:813dcc80987e 18 * this list of conditions and the following disclaimer in the documentation
mbed_official 610:813dcc80987e 19 * and/or other materials provided with the distribution.
mbed_official 610:813dcc80987e 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 610:813dcc80987e 21 * may be used to endorse or promote products derived from this software
mbed_official 610:813dcc80987e 22 * without specific prior written permission.
mbed_official 610:813dcc80987e 23 *
mbed_official 610:813dcc80987e 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 610:813dcc80987e 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 610:813dcc80987e 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 610:813dcc80987e 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 610:813dcc80987e 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 610:813dcc80987e 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 610:813dcc80987e 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 610:813dcc80987e 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 610:813dcc80987e 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 610:813dcc80987e 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 610:813dcc80987e 34 *
mbed_official 610:813dcc80987e 35 ******************************************************************************
mbed_official 610:813dcc80987e 36 */
mbed_official 610:813dcc80987e 37
mbed_official 610:813dcc80987e 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 610:813dcc80987e 39 #ifndef __STM32L4xx_HAL_RNG_H
mbed_official 610:813dcc80987e 40 #define __STM32L4xx_HAL_RNG_H
mbed_official 610:813dcc80987e 41
mbed_official 610:813dcc80987e 42 #ifdef __cplusplus
mbed_official 610:813dcc80987e 43 extern "C" {
mbed_official 610:813dcc80987e 44 #endif
mbed_official 610:813dcc80987e 45
mbed_official 610:813dcc80987e 46 /* Includes ------------------------------------------------------------------*/
mbed_official 610:813dcc80987e 47 #include "stm32l4xx_hal_def.h"
mbed_official 610:813dcc80987e 48
mbed_official 610:813dcc80987e 49 /** @addtogroup STM32L4xx_HAL_Driver
mbed_official 610:813dcc80987e 50 * @{
mbed_official 610:813dcc80987e 51 */
mbed_official 610:813dcc80987e 52
mbed_official 610:813dcc80987e 53 /** @addtogroup RNG
mbed_official 610:813dcc80987e 54 * @{
mbed_official 610:813dcc80987e 55 */
mbed_official 610:813dcc80987e 56
mbed_official 610:813dcc80987e 57 /* Exported types ------------------------------------------------------------*/
mbed_official 610:813dcc80987e 58 /** @defgroup RNG_Exported_Types RNG Exported Types
mbed_official 610:813dcc80987e 59 * @{
mbed_official 610:813dcc80987e 60 */
mbed_official 610:813dcc80987e 61
mbed_official 610:813dcc80987e 62 /**
mbed_official 610:813dcc80987e 63 * @brief RNG HAL State Structure definition
mbed_official 610:813dcc80987e 64 */
mbed_official 610:813dcc80987e 65 typedef enum
mbed_official 610:813dcc80987e 66 {
mbed_official 610:813dcc80987e 67 HAL_RNG_STATE_RESET = 0x00, /*!< RNG not yet initialized or disabled */
mbed_official 610:813dcc80987e 68 HAL_RNG_STATE_READY = 0x01, /*!< RNG initialized and ready for use */
mbed_official 610:813dcc80987e 69 HAL_RNG_STATE_BUSY = 0x02, /*!< RNG internal process is ongoing */
mbed_official 610:813dcc80987e 70 HAL_RNG_STATE_TIMEOUT = 0x03, /*!< RNG timeout state */
mbed_official 610:813dcc80987e 71 HAL_RNG_STATE_ERROR = 0x04 /*!< RNG error state */
mbed_official 610:813dcc80987e 72
mbed_official 610:813dcc80987e 73 }HAL_RNG_StateTypeDef;
mbed_official 610:813dcc80987e 74
mbed_official 610:813dcc80987e 75 /**
mbed_official 610:813dcc80987e 76 * @brief RNG Handle Structure definition
mbed_official 610:813dcc80987e 77 */
mbed_official 610:813dcc80987e 78 typedef struct
mbed_official 610:813dcc80987e 79 {
mbed_official 610:813dcc80987e 80 RNG_TypeDef *Instance; /*!< Register base address */
mbed_official 610:813dcc80987e 81
mbed_official 610:813dcc80987e 82 HAL_LockTypeDef Lock; /*!< RNG locking object */
mbed_official 610:813dcc80987e 83
mbed_official 610:813dcc80987e 84 __IO HAL_RNG_StateTypeDef State; /*!< RNG communication state */
mbed_official 610:813dcc80987e 85
mbed_official 610:813dcc80987e 86 uint32_t RandomNumber; /*!< Last Generated RNG Data */
mbed_official 610:813dcc80987e 87
mbed_official 610:813dcc80987e 88 }RNG_HandleTypeDef;
mbed_official 610:813dcc80987e 89
mbed_official 610:813dcc80987e 90 /**
mbed_official 610:813dcc80987e 91 * @}
mbed_official 610:813dcc80987e 92 */
mbed_official 610:813dcc80987e 93
mbed_official 610:813dcc80987e 94 /* Exported constants --------------------------------------------------------*/
mbed_official 610:813dcc80987e 95 /** @defgroup RNG_Exported_Constants RNG Exported Constants
mbed_official 610:813dcc80987e 96 * @{
mbed_official 610:813dcc80987e 97 */
mbed_official 610:813dcc80987e 98
mbed_official 610:813dcc80987e 99 /** @defgroup RNG_Interrupt_definition RNG Interrupts Definition
mbed_official 610:813dcc80987e 100 * @{
mbed_official 610:813dcc80987e 101 */
mbed_official 610:813dcc80987e 102 #define RNG_IT_DRDY RNG_SR_DRDY /*!< Data Ready interrupt */
mbed_official 610:813dcc80987e 103 #define RNG_IT_CEI RNG_SR_CEIS /*!< Clock error interrupt */
mbed_official 610:813dcc80987e 104 #define RNG_IT_SEI RNG_SR_SEIS /*!< Seed error interrupt */
mbed_official 610:813dcc80987e 105 /**
mbed_official 610:813dcc80987e 106 * @}
mbed_official 610:813dcc80987e 107 */
mbed_official 610:813dcc80987e 108
mbed_official 610:813dcc80987e 109 /** @defgroup RNG_Flag_definition RNG Flags Definition
mbed_official 610:813dcc80987e 110 * @{
mbed_official 610:813dcc80987e 111 */
mbed_official 610:813dcc80987e 112 #define RNG_FLAG_DRDY RNG_SR_DRDY /*!< Data ready */
mbed_official 610:813dcc80987e 113 #define RNG_FLAG_CECS RNG_SR_CECS /*!< Clock error current status */
mbed_official 610:813dcc80987e 114 #define RNG_FLAG_SECS RNG_SR_SECS /*!< Seed error current status */
mbed_official 610:813dcc80987e 115 /**
mbed_official 610:813dcc80987e 116 * @}
mbed_official 610:813dcc80987e 117 */
mbed_official 610:813dcc80987e 118
mbed_official 610:813dcc80987e 119 /**
mbed_official 610:813dcc80987e 120 * @}
mbed_official 610:813dcc80987e 121 */
mbed_official 610:813dcc80987e 122
mbed_official 610:813dcc80987e 123 /* Exported macros -----------------------------------------------------------*/
mbed_official 610:813dcc80987e 124 /** @defgroup RNG_Exported_Macros RNG Exported Macros
mbed_official 610:813dcc80987e 125 * @{
mbed_official 610:813dcc80987e 126 */
mbed_official 610:813dcc80987e 127
mbed_official 610:813dcc80987e 128 /** @brief Reset RNG handle state.
mbed_official 610:813dcc80987e 129 * @param __HANDLE__: RNG Handle
mbed_official 610:813dcc80987e 130 * @retval None
mbed_official 610:813dcc80987e 131 */
mbed_official 610:813dcc80987e 132 #define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RNG_STATE_RESET)
mbed_official 610:813dcc80987e 133
mbed_official 610:813dcc80987e 134 /**
mbed_official 610:813dcc80987e 135 * @brief Enable the RNG peripheral.
mbed_official 610:813dcc80987e 136 * @param __HANDLE__: RNG Handle
mbed_official 610:813dcc80987e 137 * @retval None
mbed_official 610:813dcc80987e 138 */
mbed_official 610:813dcc80987e 139 #define __HAL_RNG_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_RNGEN)
mbed_official 610:813dcc80987e 140
mbed_official 610:813dcc80987e 141 /**
mbed_official 610:813dcc80987e 142 * @brief Disable the RNG peripheral.
mbed_official 610:813dcc80987e 143 * @param __HANDLE__: RNG Handle
mbed_official 610:813dcc80987e 144 * @retval None
mbed_official 610:813dcc80987e 145 */
mbed_official 610:813dcc80987e 146 #define __HAL_RNG_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_RNGEN)
mbed_official 610:813dcc80987e 147
mbed_official 610:813dcc80987e 148 /**
mbed_official 610:813dcc80987e 149 * @brief Check whether the specified RNG flag is set or not.
mbed_official 610:813dcc80987e 150 * @param __HANDLE__: RNG Handle
mbed_official 610:813dcc80987e 151 * @param __FLAG__: RNG flag
mbed_official 610:813dcc80987e 152 * This parameter can be one of the following values:
mbed_official 610:813dcc80987e 153 * @arg RNG_FLAG_DRDY: Data ready
mbed_official 610:813dcc80987e 154 * @arg RNG_FLAG_CECS: Clock error current status
mbed_official 610:813dcc80987e 155 * @arg RNG_FLAG_SECS: Seed error current status
mbed_official 610:813dcc80987e 156 * @retval The new state of __FLAG__ (SET or RESET).
mbed_official 610:813dcc80987e 157 */
mbed_official 610:813dcc80987e 158 #define __HAL_RNG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
mbed_official 610:813dcc80987e 159
mbed_official 610:813dcc80987e 160
mbed_official 610:813dcc80987e 161 /**
mbed_official 610:813dcc80987e 162 * @brief Clear the selected RNG flag status.
mbed_official 610:813dcc80987e 163 * @param __HANDLE__: RNG handle
mbed_official 610:813dcc80987e 164 * @param __FLAG__: RNG flag to clear
mbed_official 610:813dcc80987e 165 * @note WARNING: This is a dummy macro for HAL code alignment,
mbed_official 610:813dcc80987e 166 * flags RNG_FLAG_DRDY, RNG_FLAG_CECS and RNG_FLAG_SECS are read-only.
mbed_official 610:813dcc80987e 167 * @retval None
mbed_official 610:813dcc80987e 168 */
mbed_official 610:813dcc80987e 169 #define __HAL_RNG_CLEAR_FLAG(__HANDLE__, __FLAG__) /* dummy macro */
mbed_official 610:813dcc80987e 170
mbed_official 610:813dcc80987e 171
mbed_official 610:813dcc80987e 172
mbed_official 610:813dcc80987e 173 /**
mbed_official 610:813dcc80987e 174 * @brief Enable the RNG interrupt.
mbed_official 610:813dcc80987e 175 * @param __HANDLE__: RNG Handle
mbed_official 610:813dcc80987e 176 * @retval None
mbed_official 610:813dcc80987e 177 */
mbed_official 610:813dcc80987e 178 #define __HAL_RNG_ENABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_IE)
mbed_official 610:813dcc80987e 179
mbed_official 610:813dcc80987e 180 /**
mbed_official 610:813dcc80987e 181 * @brief Disable the RNG interrupt.
mbed_official 610:813dcc80987e 182 * @param __HANDLE__: RNG Handle
mbed_official 610:813dcc80987e 183 * @retval None
mbed_official 610:813dcc80987e 184 */
mbed_official 610:813dcc80987e 185 #define __HAL_RNG_DISABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_IE)
mbed_official 610:813dcc80987e 186
mbed_official 610:813dcc80987e 187 /**
mbed_official 610:813dcc80987e 188 * @brief Check whether the specified RNG interrupt has occurred or not.
mbed_official 610:813dcc80987e 189 * @param __HANDLE__: RNG Handle
mbed_official 610:813dcc80987e 190 * @param __INTERRUPT__: specifies the RNG interrupt status flag to check.
mbed_official 610:813dcc80987e 191 * This parameter can be one of the following values:
mbed_official 610:813dcc80987e 192 * @arg RNG_IT_DRDY: Data ready interrupt
mbed_official 610:813dcc80987e 193 * @arg RNG_IT_CEI: Clock error interrupt
mbed_official 610:813dcc80987e 194 * @arg RNG_IT_SEI: Seed error interrupt
mbed_official 610:813dcc80987e 195 * @retval The new state of __INTERRUPT__ (SET or RESET).
mbed_official 610:813dcc80987e 196 */
mbed_official 610:813dcc80987e 197 #define __HAL_RNG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__))
mbed_official 610:813dcc80987e 198
mbed_official 610:813dcc80987e 199 /**
mbed_official 610:813dcc80987e 200 * @brief Clear the RNG interrupt status flags.
mbed_official 610:813dcc80987e 201 * @param __HANDLE__: RNG Handle
mbed_official 610:813dcc80987e 202 * @param __INTERRUPT__: specifies the RNG interrupt status flag to clear.
mbed_official 610:813dcc80987e 203 * This parameter can be one of the following values:
mbed_official 610:813dcc80987e 204 * @arg RNG_IT_CEI: Clock error interrupt
mbed_official 610:813dcc80987e 205 * @arg RNG_IT_SEI: Seed error interrupt
mbed_official 610:813dcc80987e 206 * @note RNG_IT_DRDY flag is read-only, reading RNG_DR register automatically clears RNG_IT_DRDY.
mbed_official 610:813dcc80987e 207 * @retval None
mbed_official 610:813dcc80987e 208 */
mbed_official 610:813dcc80987e 209 #define __HAL_RNG_CLEAR_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR) = ~(__INTERRUPT__))
mbed_official 610:813dcc80987e 210
mbed_official 610:813dcc80987e 211 /**
mbed_official 610:813dcc80987e 212 * @}
mbed_official 610:813dcc80987e 213 */
mbed_official 610:813dcc80987e 214
mbed_official 610:813dcc80987e 215
mbed_official 610:813dcc80987e 216 /* Exported functions --------------------------------------------------------*/
mbed_official 610:813dcc80987e 217 /** @defgroup RNG_Exported_Functions RNG Exported Functions
mbed_official 610:813dcc80987e 218 * @{
mbed_official 610:813dcc80987e 219 */
mbed_official 610:813dcc80987e 220
mbed_official 610:813dcc80987e 221 /* Initialization and de-initialization functions ******************************/
mbed_official 610:813dcc80987e 222 /** @defgroup RNG_Exported_Functions_Group1 Initialization and de-initialization functions
mbed_official 610:813dcc80987e 223 * @{
mbed_official 610:813dcc80987e 224 */
mbed_official 610:813dcc80987e 225 HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng);
mbed_official 610:813dcc80987e 226 HAL_StatusTypeDef HAL_RNG_DeInit (RNG_HandleTypeDef *hrng);
mbed_official 610:813dcc80987e 227 void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng);
mbed_official 610:813dcc80987e 228 void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng);
mbed_official 610:813dcc80987e 229 /**
mbed_official 610:813dcc80987e 230 * @}
mbed_official 610:813dcc80987e 231 */
mbed_official 610:813dcc80987e 232
mbed_official 610:813dcc80987e 233 /* Peripheral Control functions ************************************************/
mbed_official 610:813dcc80987e 234 /** @defgroup RNG_Exported_Functions_Group2 Peripheral Control functions
mbed_official 610:813dcc80987e 235 * @{
mbed_official 610:813dcc80987e 236 */
mbed_official 610:813dcc80987e 237 uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng); /* Obsolete, use HAL_RNG_GenerateRandomNumber() instead */
mbed_official 610:813dcc80987e 238 uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng); /* Obsolete, use HAL_RNG_GenerateRandomNumber_IT() instead */
mbed_official 610:813dcc80987e 239
mbed_official 610:813dcc80987e 240 HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber(RNG_HandleTypeDef *hrng, uint32_t *random32bit);
mbed_official 610:813dcc80987e 241 HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber_IT(RNG_HandleTypeDef *hrng);
mbed_official 610:813dcc80987e 242 uint32_t HAL_RNG_ReadLastRandomNumber(RNG_HandleTypeDef *hrng);
mbed_official 610:813dcc80987e 243
mbed_official 610:813dcc80987e 244 void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng);
mbed_official 610:813dcc80987e 245 void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng);
mbed_official 610:813dcc80987e 246 void HAL_RNG_ReadyDataCallback(RNG_HandleTypeDef* hrng, uint32_t random32bit);
mbed_official 610:813dcc80987e 247 /**
mbed_official 610:813dcc80987e 248 * @}
mbed_official 610:813dcc80987e 249 */
mbed_official 610:813dcc80987e 250
mbed_official 610:813dcc80987e 251 /* Peripheral State functions **************************************************/
mbed_official 610:813dcc80987e 252 /** @defgroup RNG_Exported_Functions_Group3 Peripheral State functions
mbed_official 610:813dcc80987e 253 * @{
mbed_official 610:813dcc80987e 254 */
mbed_official 610:813dcc80987e 255 HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng);
mbed_official 610:813dcc80987e 256 /**
mbed_official 610:813dcc80987e 257 * @}
mbed_official 610:813dcc80987e 258 */
mbed_official 610:813dcc80987e 259
mbed_official 610:813dcc80987e 260 /**
mbed_official 610:813dcc80987e 261 * @}
mbed_official 610:813dcc80987e 262 */
mbed_official 610:813dcc80987e 263
mbed_official 610:813dcc80987e 264 /* Private types -------------------------------------------------------------*/
mbed_official 610:813dcc80987e 265 /* Private defines -----------------------------------------------------------*/
mbed_official 610:813dcc80987e 266 /* Private variables ---------------------------------------------------------*/
mbed_official 610:813dcc80987e 267 /* Private constants ---------------------------------------------------------*/
mbed_official 610:813dcc80987e 268 /* Private macros ------------------------------------------------------------*/
mbed_official 610:813dcc80987e 269 /* Private functions prototypes ----------------------------------------------*/
mbed_official 610:813dcc80987e 270
mbed_official 610:813dcc80987e 271 /**
mbed_official 610:813dcc80987e 272 * @}
mbed_official 610:813dcc80987e 273 */
mbed_official 610:813dcc80987e 274
mbed_official 610:813dcc80987e 275 /**
mbed_official 610:813dcc80987e 276 * @}
mbed_official 610:813dcc80987e 277 */
mbed_official 610:813dcc80987e 278
mbed_official 610:813dcc80987e 279 #ifdef __cplusplus
mbed_official 610:813dcc80987e 280 }
mbed_official 610:813dcc80987e 281 #endif
mbed_official 610:813dcc80987e 282
mbed_official 610:813dcc80987e 283 #endif /* __STM32L4xx_HAL_RNG_H */
mbed_official 610:813dcc80987e 284
mbed_official 610:813dcc80987e 285 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/