L4 HAL Drivers
Embed:
(wiki syntax)
Show/hide line numbers
stm32l4xx_hal_rng.h
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal_rng.h 00004 * @author MCD Application Team 00005 * @version V1.1.0 00006 * @date 16-September-2015 00007 * @brief Header file of RNG HAL module. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 /* Define to prevent recursive inclusion -------------------------------------*/ 00039 #ifndef __STM32L4xx_HAL_RNG_H 00040 #define __STM32L4xx_HAL_RNG_H 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 /* Includes ------------------------------------------------------------------*/ 00047 #include "stm32l4xx_hal_def.h" 00048 00049 /** @addtogroup STM32L4xx_HAL_Driver 00050 * @{ 00051 */ 00052 00053 /** @addtogroup RNG 00054 * @{ 00055 */ 00056 00057 /* Exported types ------------------------------------------------------------*/ 00058 /** @defgroup RNG_Exported_Types RNG Exported Types 00059 * @{ 00060 */ 00061 00062 /** 00063 * @brief RNG HAL State Structure definition 00064 */ 00065 typedef enum 00066 { 00067 HAL_RNG_STATE_RESET = 0x00, /*!< RNG not yet initialized or disabled */ 00068 HAL_RNG_STATE_READY = 0x01, /*!< RNG initialized and ready for use */ 00069 HAL_RNG_STATE_BUSY = 0x02, /*!< RNG internal process is ongoing */ 00070 HAL_RNG_STATE_TIMEOUT = 0x03, /*!< RNG timeout state */ 00071 HAL_RNG_STATE_ERROR = 0x04 /*!< RNG error state */ 00072 00073 }HAL_RNG_StateTypeDef; 00074 00075 /** 00076 * @brief RNG Handle Structure definition 00077 */ 00078 typedef struct 00079 { 00080 RNG_TypeDef *Instance; /*!< Register base address */ 00081 00082 HAL_LockTypeDef Lock; /*!< RNG locking object */ 00083 00084 __IO HAL_RNG_StateTypeDef State; /*!< RNG communication state */ 00085 00086 uint32_t RandomNumber; /*!< Last Generated RNG Data */ 00087 00088 }RNG_HandleTypeDef; 00089 00090 /** 00091 * @} 00092 */ 00093 00094 /* Exported constants --------------------------------------------------------*/ 00095 /** @defgroup RNG_Exported_Constants RNG Exported Constants 00096 * @{ 00097 */ 00098 00099 /** @defgroup RNG_Interrupt_definition RNG Interrupts Definition 00100 * @{ 00101 */ 00102 #define RNG_IT_DRDY RNG_SR_DRDY /*!< Data Ready interrupt */ 00103 #define RNG_IT_CEI RNG_SR_CEIS /*!< Clock error interrupt */ 00104 #define RNG_IT_SEI RNG_SR_SEIS /*!< Seed error interrupt */ 00105 /** 00106 * @} 00107 */ 00108 00109 /** @defgroup RNG_Flag_definition RNG Flags Definition 00110 * @{ 00111 */ 00112 #define RNG_FLAG_DRDY RNG_SR_DRDY /*!< Data ready */ 00113 #define RNG_FLAG_CECS RNG_SR_CECS /*!< Clock error current status */ 00114 #define RNG_FLAG_SECS RNG_SR_SECS /*!< Seed error current status */ 00115 /** 00116 * @} 00117 */ 00118 00119 /** 00120 * @} 00121 */ 00122 00123 /* Exported macros -----------------------------------------------------------*/ 00124 /** @defgroup RNG_Exported_Macros RNG Exported Macros 00125 * @{ 00126 */ 00127 00128 /** @brief Reset RNG handle state. 00129 * @param __HANDLE__: RNG Handle 00130 * @retval None 00131 */ 00132 #define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RNG_STATE_RESET) 00133 00134 /** 00135 * @brief Enable the RNG peripheral. 00136 * @param __HANDLE__: RNG Handle 00137 * @retval None 00138 */ 00139 #define __HAL_RNG_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_RNGEN) 00140 00141 /** 00142 * @brief Disable the RNG peripheral. 00143 * @param __HANDLE__: RNG Handle 00144 * @retval None 00145 */ 00146 #define __HAL_RNG_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_RNGEN) 00147 00148 /** 00149 * @brief Check whether the specified RNG flag is set or not. 00150 * @param __HANDLE__: RNG Handle 00151 * @param __FLAG__: RNG flag 00152 * This parameter can be one of the following values: 00153 * @arg RNG_FLAG_DRDY: Data ready 00154 * @arg RNG_FLAG_CECS: Clock error current status 00155 * @arg RNG_FLAG_SECS: Seed error current status 00156 * @retval The new state of __FLAG__ (SET or RESET). 00157 */ 00158 #define __HAL_RNG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) 00159 00160 00161 /** 00162 * @brief Clear the selected RNG flag status. 00163 * @param __HANDLE__: RNG handle 00164 * @param __FLAG__: RNG flag to clear 00165 * @note WARNING: This is a dummy macro for HAL code alignment, 00166 * flags RNG_FLAG_DRDY, RNG_FLAG_CECS and RNG_FLAG_SECS are read-only. 00167 * @retval None 00168 */ 00169 #define __HAL_RNG_CLEAR_FLAG(__HANDLE__, __FLAG__) /* dummy macro */ 00170 00171 00172 00173 /** 00174 * @brief Enable the RNG interrupt. 00175 * @param __HANDLE__: RNG Handle 00176 * @retval None 00177 */ 00178 #define __HAL_RNG_ENABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_IE) 00179 00180 /** 00181 * @brief Disable the RNG interrupt. 00182 * @param __HANDLE__: RNG Handle 00183 * @retval None 00184 */ 00185 #define __HAL_RNG_DISABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_IE) 00186 00187 /** 00188 * @brief Check whether the specified RNG interrupt has occurred or not. 00189 * @param __HANDLE__: RNG Handle 00190 * @param __INTERRUPT__: specifies the RNG interrupt status flag to check. 00191 * This parameter can be one of the following values: 00192 * @arg RNG_IT_DRDY: Data ready interrupt 00193 * @arg RNG_IT_CEI: Clock error interrupt 00194 * @arg RNG_IT_SEI: Seed error interrupt 00195 * @retval The new state of __INTERRUPT__ (SET or RESET). 00196 */ 00197 #define __HAL_RNG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__)) 00198 00199 /** 00200 * @brief Clear the RNG interrupt status flags. 00201 * @param __HANDLE__: RNG Handle 00202 * @param __INTERRUPT__: specifies the RNG interrupt status flag to clear. 00203 * This parameter can be one of the following values: 00204 * @arg RNG_IT_CEI: Clock error interrupt 00205 * @arg RNG_IT_SEI: Seed error interrupt 00206 * @note RNG_IT_DRDY flag is read-only, reading RNG_DR register automatically clears RNG_IT_DRDY. 00207 * @retval None 00208 */ 00209 #define __HAL_RNG_CLEAR_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR) = ~(__INTERRUPT__)) 00210 00211 /** 00212 * @} 00213 */ 00214 00215 00216 /* Exported functions --------------------------------------------------------*/ 00217 /** @defgroup RNG_Exported_Functions RNG Exported Functions 00218 * @{ 00219 */ 00220 00221 /* Initialization and de-initialization functions ******************************/ 00222 /** @defgroup RNG_Exported_Functions_Group1 Initialization and de-initialization functions 00223 * @{ 00224 */ 00225 HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng); 00226 HAL_StatusTypeDef HAL_RNG_DeInit (RNG_HandleTypeDef *hrng); 00227 void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng); 00228 void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng); 00229 /** 00230 * @} 00231 */ 00232 00233 /* Peripheral Control functions ************************************************/ 00234 /** @defgroup RNG_Exported_Functions_Group2 Peripheral Control functions 00235 * @{ 00236 */ 00237 uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng); /* Obsolete, use HAL_RNG_GenerateRandomNumber() instead */ 00238 uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng); /* Obsolete, use HAL_RNG_GenerateRandomNumber_IT() instead */ 00239 00240 HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber(RNG_HandleTypeDef *hrng, uint32_t *random32bit); 00241 HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber_IT(RNG_HandleTypeDef *hrng); 00242 uint32_t HAL_RNG_ReadLastRandomNumber(RNG_HandleTypeDef *hrng); 00243 00244 void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng); 00245 void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng); 00246 void HAL_RNG_ReadyDataCallback(RNG_HandleTypeDef* hrng, uint32_t random32bit); 00247 /** 00248 * @} 00249 */ 00250 00251 /* Peripheral State functions **************************************************/ 00252 /** @defgroup RNG_Exported_Functions_Group3 Peripheral State functions 00253 * @{ 00254 */ 00255 HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng); 00256 /** 00257 * @} 00258 */ 00259 00260 /** 00261 * @} 00262 */ 00263 00264 /* Private types -------------------------------------------------------------*/ 00265 /* Private defines -----------------------------------------------------------*/ 00266 /* Private variables ---------------------------------------------------------*/ 00267 /* Private constants ---------------------------------------------------------*/ 00268 /* Private macros ------------------------------------------------------------*/ 00269 /* Private functions prototypes ----------------------------------------------*/ 00270 00271 /** 00272 * @} 00273 */ 00274 00275 /** 00276 * @} 00277 */ 00278 00279 #ifdef __cplusplus 00280 } 00281 #endif 00282 00283 #endif /* __STM32L4xx_HAL_RNG_H */ 00284 00285 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00286
Generated on Tue Jul 12 2022 10:58:10 by 1.7.2