Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
elijahorr
Date:
Thu Apr 14 07:28:54 2016 +0000
Revision:
121:672067c3ada4
Parent:
107:4f6c30876dfa
.

Who changed what in which revision?

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