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
TARGET_ARCH_MAX/stm32f4xx_hal_rng.h@89:552587b429a1, 2014-09-12 (annotated)
- Committer:
- bogdanm
- Date:
- Fri Sep 12 16:41:52 2014 +0100
- Revision:
- 89:552587b429a1
- Child:
- 92:4fc01daae5a5
Release 89 of the mbed library
Main changes:
- low power optimizations for Nordic targets
- code structure changes for Freescale K64F targets
- bug fixes in various backends
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 89:552587b429a1 | 1 | /** |
bogdanm | 89:552587b429a1 | 2 | ****************************************************************************** |
bogdanm | 89:552587b429a1 | 3 | * @file stm32f4xx_hal_rng.h |
bogdanm | 89:552587b429a1 | 4 | * @author MCD Application Team |
bogdanm | 89:552587b429a1 | 5 | * @version V1.1.0RC2 |
bogdanm | 89:552587b429a1 | 6 | * @date 14-May-2014 |
bogdanm | 89:552587b429a1 | 7 | * @brief Header file of RNG HAL module. |
bogdanm | 89:552587b429a1 | 8 | ****************************************************************************** |
bogdanm | 89:552587b429a1 | 9 | * @attention |
bogdanm | 89:552587b429a1 | 10 | * |
bogdanm | 89:552587b429a1 | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
bogdanm | 89:552587b429a1 | 12 | * |
bogdanm | 89:552587b429a1 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 89:552587b429a1 | 14 | * are permitted provided that the following conditions are met: |
bogdanm | 89:552587b429a1 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
bogdanm | 89:552587b429a1 | 16 | * this list of conditions and the following disclaimer. |
bogdanm | 89:552587b429a1 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bogdanm | 89:552587b429a1 | 18 | * this list of conditions and the following disclaimer in the documentation |
bogdanm | 89:552587b429a1 | 19 | * and/or other materials provided with the distribution. |
bogdanm | 89:552587b429a1 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bogdanm | 89:552587b429a1 | 21 | * may be used to endorse or promote products derived from this software |
bogdanm | 89:552587b429a1 | 22 | * without specific prior written permission. |
bogdanm | 89:552587b429a1 | 23 | * |
bogdanm | 89:552587b429a1 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 89:552587b429a1 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 89:552587b429a1 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 89:552587b429a1 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bogdanm | 89:552587b429a1 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bogdanm | 89:552587b429a1 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bogdanm | 89:552587b429a1 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bogdanm | 89:552587b429a1 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bogdanm | 89:552587b429a1 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bogdanm | 89:552587b429a1 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 89:552587b429a1 | 34 | * |
bogdanm | 89:552587b429a1 | 35 | ****************************************************************************** |
bogdanm | 89:552587b429a1 | 36 | */ |
bogdanm | 89:552587b429a1 | 37 | |
bogdanm | 89:552587b429a1 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bogdanm | 89:552587b429a1 | 39 | #ifndef __STM32F4xx_HAL_RNG_H |
bogdanm | 89:552587b429a1 | 40 | #define __STM32F4xx_HAL_RNG_H |
bogdanm | 89:552587b429a1 | 41 | |
bogdanm | 89:552587b429a1 | 42 | #ifdef __cplusplus |
bogdanm | 89:552587b429a1 | 43 | extern "C" { |
bogdanm | 89:552587b429a1 | 44 | #endif |
bogdanm | 89:552587b429a1 | 45 | |
bogdanm | 89:552587b429a1 | 46 | /* Includes ------------------------------------------------------------------*/ |
bogdanm | 89:552587b429a1 | 47 | #include "stm32f4xx_hal_def.h" |
bogdanm | 89:552587b429a1 | 48 | |
bogdanm | 89:552587b429a1 | 49 | /** @addtogroup STM32F4xx_HAL_Driver |
bogdanm | 89:552587b429a1 | 50 | * @{ |
bogdanm | 89:552587b429a1 | 51 | */ |
bogdanm | 89:552587b429a1 | 52 | |
bogdanm | 89:552587b429a1 | 53 | /** @addtogroup RNG |
bogdanm | 89:552587b429a1 | 54 | * @{ |
bogdanm | 89:552587b429a1 | 55 | */ |
bogdanm | 89:552587b429a1 | 56 | |
bogdanm | 89:552587b429a1 | 57 | /* Exported types ------------------------------------------------------------*/ |
bogdanm | 89:552587b429a1 | 58 | |
bogdanm | 89:552587b429a1 | 59 | /** |
bogdanm | 89:552587b429a1 | 60 | * @brief RNG HAL State Structure definition |
bogdanm | 89:552587b429a1 | 61 | */ |
bogdanm | 89:552587b429a1 | 62 | typedef enum |
bogdanm | 89:552587b429a1 | 63 | { |
bogdanm | 89:552587b429a1 | 64 | HAL_RNG_STATE_RESET = 0x00, /*!< RNG not yet initialized or disabled */ |
bogdanm | 89:552587b429a1 | 65 | HAL_RNG_STATE_READY = 0x01, /*!< RNG initialized and ready for use */ |
bogdanm | 89:552587b429a1 | 66 | HAL_RNG_STATE_BUSY = 0x02, /*!< RNG internal process is ongoing */ |
bogdanm | 89:552587b429a1 | 67 | HAL_RNG_STATE_TIMEOUT = 0x03, /*!< RNG timeout state */ |
bogdanm | 89:552587b429a1 | 68 | HAL_RNG_STATE_ERROR = 0x04 /*!< RNG error state */ |
bogdanm | 89:552587b429a1 | 69 | |
bogdanm | 89:552587b429a1 | 70 | }HAL_RNG_StateTypeDef; |
bogdanm | 89:552587b429a1 | 71 | |
bogdanm | 89:552587b429a1 | 72 | /** |
bogdanm | 89:552587b429a1 | 73 | * @brief RNG Handle Structure definition |
bogdanm | 89:552587b429a1 | 74 | */ |
bogdanm | 89:552587b429a1 | 75 | typedef struct |
bogdanm | 89:552587b429a1 | 76 | { |
bogdanm | 89:552587b429a1 | 77 | RNG_TypeDef *Instance; /*!< Register base address */ |
bogdanm | 89:552587b429a1 | 78 | |
bogdanm | 89:552587b429a1 | 79 | HAL_LockTypeDef Lock; /*!< RNG locking object */ |
bogdanm | 89:552587b429a1 | 80 | |
bogdanm | 89:552587b429a1 | 81 | __IO HAL_RNG_StateTypeDef State; /*!< RNG communication state */ |
bogdanm | 89:552587b429a1 | 82 | |
bogdanm | 89:552587b429a1 | 83 | }RNG_HandleTypeDef; |
bogdanm | 89:552587b429a1 | 84 | |
bogdanm | 89:552587b429a1 | 85 | /* Exported constants --------------------------------------------------------*/ |
bogdanm | 89:552587b429a1 | 86 | |
bogdanm | 89:552587b429a1 | 87 | /** @defgroup RNG_Exported_Constants |
bogdanm | 89:552587b429a1 | 88 | * @{ |
bogdanm | 89:552587b429a1 | 89 | */ |
bogdanm | 89:552587b429a1 | 90 | |
bogdanm | 89:552587b429a1 | 91 | /** @defgroup RNG_Interrupt_definition |
bogdanm | 89:552587b429a1 | 92 | * @{ |
bogdanm | 89:552587b429a1 | 93 | */ |
bogdanm | 89:552587b429a1 | 94 | #define RNG_IT_CEI ((uint32_t)0x20) /*!< Clock error interrupt */ |
bogdanm | 89:552587b429a1 | 95 | #define RNG_IT_SEI ((uint32_t)0x40) /*!< Seed error interrupt */ |
bogdanm | 89:552587b429a1 | 96 | |
bogdanm | 89:552587b429a1 | 97 | #define IS_RNG_IT(IT) (((IT) == RNG_IT_CEI) || \ |
bogdanm | 89:552587b429a1 | 98 | ((IT) == RNG_IT_SEI)) |
bogdanm | 89:552587b429a1 | 99 | /** |
bogdanm | 89:552587b429a1 | 100 | * @} |
bogdanm | 89:552587b429a1 | 101 | */ |
bogdanm | 89:552587b429a1 | 102 | |
bogdanm | 89:552587b429a1 | 103 | |
bogdanm | 89:552587b429a1 | 104 | /** @defgroup RNG_Flag_definition |
bogdanm | 89:552587b429a1 | 105 | * @{ |
bogdanm | 89:552587b429a1 | 106 | */ |
bogdanm | 89:552587b429a1 | 107 | #define RNG_FLAG_DRDY ((uint32_t)0x0001) /*!< Data ready */ |
bogdanm | 89:552587b429a1 | 108 | #define RNG_FLAG_CECS ((uint32_t)0x0002) /*!< Clock error current status */ |
bogdanm | 89:552587b429a1 | 109 | #define RNG_FLAG_SECS ((uint32_t)0x0004) /*!< Seed error current status */ |
bogdanm | 89:552587b429a1 | 110 | |
bogdanm | 89:552587b429a1 | 111 | #define IS_RNG_FLAG(FLAG) (((FLAG) == RNG_FLAG_DRDY) || \ |
bogdanm | 89:552587b429a1 | 112 | ((FLAG) == RNG_FLAG_CECS) || \ |
bogdanm | 89:552587b429a1 | 113 | ((FLAG) == RNG_FLAG_SECS)) |
bogdanm | 89:552587b429a1 | 114 | /** |
bogdanm | 89:552587b429a1 | 115 | * @} |
bogdanm | 89:552587b429a1 | 116 | */ |
bogdanm | 89:552587b429a1 | 117 | |
bogdanm | 89:552587b429a1 | 118 | /** |
bogdanm | 89:552587b429a1 | 119 | * @} |
bogdanm | 89:552587b429a1 | 120 | */ |
bogdanm | 89:552587b429a1 | 121 | |
bogdanm | 89:552587b429a1 | 122 | /* Exported macro ------------------------------------------------------------*/ |
bogdanm | 89:552587b429a1 | 123 | |
bogdanm | 89:552587b429a1 | 124 | /** @brief Reset RNG handle state |
bogdanm | 89:552587b429a1 | 125 | * @param __HANDLE__: RNG Handle |
bogdanm | 89:552587b429a1 | 126 | * @retval None |
bogdanm | 89:552587b429a1 | 127 | */ |
bogdanm | 89:552587b429a1 | 128 | #define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RNG_STATE_RESET) |
bogdanm | 89:552587b429a1 | 129 | |
bogdanm | 89:552587b429a1 | 130 | /** |
bogdanm | 89:552587b429a1 | 131 | * @brief Enables the RNG peripheral. |
bogdanm | 89:552587b429a1 | 132 | * @param __HANDLE__: RNG Handle |
bogdanm | 89:552587b429a1 | 133 | * @retval None |
bogdanm | 89:552587b429a1 | 134 | */ |
bogdanm | 89:552587b429a1 | 135 | #define __HAL_RNG_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_RNGEN) |
bogdanm | 89:552587b429a1 | 136 | |
bogdanm | 89:552587b429a1 | 137 | /** |
bogdanm | 89:552587b429a1 | 138 | * @brief Disables the RNG peripheral. |
bogdanm | 89:552587b429a1 | 139 | * @param __HANDLE__: RNG Handle |
bogdanm | 89:552587b429a1 | 140 | * @retval None |
bogdanm | 89:552587b429a1 | 141 | */ |
bogdanm | 89:552587b429a1 | 142 | #define __HAL_RNG_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_RNGEN) |
bogdanm | 89:552587b429a1 | 143 | |
bogdanm | 89:552587b429a1 | 144 | /** |
bogdanm | 89:552587b429a1 | 145 | * @brief Gets the selected RNG's flag status. |
bogdanm | 89:552587b429a1 | 146 | * @param __HANDLE__: RNG Handle |
bogdanm | 89:552587b429a1 | 147 | * @param __FLAG__: RNG flag |
bogdanm | 89:552587b429a1 | 148 | * @retval The new state of RNG_FLAG (SET or RESET). |
bogdanm | 89:552587b429a1 | 149 | */ |
bogdanm | 89:552587b429a1 | 150 | #define __HAL_RNG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) |
bogdanm | 89:552587b429a1 | 151 | |
bogdanm | 89:552587b429a1 | 152 | /** |
bogdanm | 89:552587b429a1 | 153 | * @brief Clears the RNG's pending flags. |
bogdanm | 89:552587b429a1 | 154 | * @param __HANDLE__: RNG Handle |
bogdanm | 89:552587b429a1 | 155 | * @param __FLAG__: RNG flag |
bogdanm | 89:552587b429a1 | 156 | * @retval None |
bogdanm | 89:552587b429a1 | 157 | */ |
bogdanm | 89:552587b429a1 | 158 | #define __HAL_RNG_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) &= ~(__FLAG__)) |
bogdanm | 89:552587b429a1 | 159 | |
bogdanm | 89:552587b429a1 | 160 | /** |
bogdanm | 89:552587b429a1 | 161 | * @brief Enables the RNG interrupts. |
bogdanm | 89:552587b429a1 | 162 | * @param __HANDLE__: RNG Handle |
bogdanm | 89:552587b429a1 | 163 | * @retval None |
bogdanm | 89:552587b429a1 | 164 | */ |
bogdanm | 89:552587b429a1 | 165 | #define __HAL_RNG_ENABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_IE) |
bogdanm | 89:552587b429a1 | 166 | |
bogdanm | 89:552587b429a1 | 167 | /** |
bogdanm | 89:552587b429a1 | 168 | * @brief Disables the RNG interrupts. |
bogdanm | 89:552587b429a1 | 169 | * @param __HANDLE__: RNG Handle |
bogdanm | 89:552587b429a1 | 170 | * @retval None |
bogdanm | 89:552587b429a1 | 171 | */ |
bogdanm | 89:552587b429a1 | 172 | #define __HAL_RNG_DISABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_IE) |
bogdanm | 89:552587b429a1 | 173 | |
bogdanm | 89:552587b429a1 | 174 | /** |
bogdanm | 89:552587b429a1 | 175 | * @brief Checks whether the specified RNG interrupt has occurred or not. |
bogdanm | 89:552587b429a1 | 176 | * @param __HANDLE__: RNG Handle |
bogdanm | 89:552587b429a1 | 177 | * @param __INTERRUPT__: specifies the RNG interrupt source to check. |
bogdanm | 89:552587b429a1 | 178 | * This parameter can be one of the following values: |
bogdanm | 89:552587b429a1 | 179 | * @arg RNG_FLAG_DRDY: Data ready interrupt |
bogdanm | 89:552587b429a1 | 180 | * @arg RNG_FLAG_CECS: Clock error interrupt |
bogdanm | 89:552587b429a1 | 181 | * @arg RNG_FLAG_SECS: Seed error interrupt |
bogdanm | 89:552587b429a1 | 182 | * @retval The new state of RNG_FLAG (SET or RESET). |
bogdanm | 89:552587b429a1 | 183 | */ |
bogdanm | 89:552587b429a1 | 184 | #define __HAL_RNG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__)) |
bogdanm | 89:552587b429a1 | 185 | |
bogdanm | 89:552587b429a1 | 186 | /* Exported functions --------------------------------------------------------*/ |
bogdanm | 89:552587b429a1 | 187 | |
bogdanm | 89:552587b429a1 | 188 | /* Initialization/de-initialization functions **********************************/ |
bogdanm | 89:552587b429a1 | 189 | HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng); |
bogdanm | 89:552587b429a1 | 190 | HAL_StatusTypeDef HAL_RNG_DeInit (RNG_HandleTypeDef *hrng); |
bogdanm | 89:552587b429a1 | 191 | void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng); |
bogdanm | 89:552587b429a1 | 192 | void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng); |
bogdanm | 89:552587b429a1 | 193 | |
bogdanm | 89:552587b429a1 | 194 | /* Peripheral Control functions ************************************************/ |
bogdanm | 89:552587b429a1 | 195 | uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng); |
bogdanm | 89:552587b429a1 | 196 | uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng); |
bogdanm | 89:552587b429a1 | 197 | void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng); |
bogdanm | 89:552587b429a1 | 198 | void HAL_RNG_ReadyCallback(RNG_HandleTypeDef* hrng); |
bogdanm | 89:552587b429a1 | 199 | void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng); |
bogdanm | 89:552587b429a1 | 200 | |
bogdanm | 89:552587b429a1 | 201 | /* Peripheral State functions **************************************************/ |
bogdanm | 89:552587b429a1 | 202 | HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng); |
bogdanm | 89:552587b429a1 | 203 | |
bogdanm | 89:552587b429a1 | 204 | /** |
bogdanm | 89:552587b429a1 | 205 | * @} |
bogdanm | 89:552587b429a1 | 206 | */ |
bogdanm | 89:552587b429a1 | 207 | |
bogdanm | 89:552587b429a1 | 208 | /** |
bogdanm | 89:552587b429a1 | 209 | * @} |
bogdanm | 89:552587b429a1 | 210 | */ |
bogdanm | 89:552587b429a1 | 211 | |
bogdanm | 89:552587b429a1 | 212 | #ifdef __cplusplus |
bogdanm | 89:552587b429a1 | 213 | } |
bogdanm | 89:552587b429a1 | 214 | #endif |
bogdanm | 89:552587b429a1 | 215 | |
bogdanm | 89:552587b429a1 | 216 | #endif /* __STM32F4xx_HAL_RNG_H */ |
bogdanm | 89:552587b429a1 | 217 | |
bogdanm | 89:552587b429a1 | 218 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |