STM32L443xx HAL User Manual
stm32l4xx_hal_rng_ex.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_hal_rng_ex.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of RNG HAL Extension module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2017 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 
00019 /* Define to prevent recursive inclusion -------------------------------------*/
00020 #ifndef STM32L4xx_HAL_RNG_EX_H
00021 #define STM32L4xx_HAL_RNG_EX_H
00022 
00023 #ifdef __cplusplus
00024  extern "C" {
00025 #endif
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm32l4xx_hal_def.h"
00029 
00030 /** @addtogroup STM32L4xx_HAL_Driver
00031   * @{
00032   */
00033 
00034 #if defined (RNG)
00035 
00036 /** @defgroup RNGEx RNGEx
00037   * @brief RNG Extension HAL module driver
00038   * @{
00039   */
00040 
00041 /* Exported types ------------------------------------------------------------*/
00042 /** @defgroup RNGEx_Exported_Types RNGEx Exported Types
00043   * @brief RNGEx Exported types
00044   * @{
00045   */
00046 
00047 /**
00048   * @brief RNGEX Configuration Structure definition
00049   */
00050 
00051 typedef struct
00052 {
00053   uint32_t        Config1;           /*!< Config1 must be a value between 0 and 0x3F */
00054   uint32_t        Config2;           /*!< Config2 must be a value between 0 and 0x7 */
00055   uint32_t        Config3;           /*!< Config3 must be a value between 0 and 0xF */
00056   uint32_t        ClockDivider;      /*!< Clock Divider factor.This parameter can
00057                                           be a value of @ref RNGEX_Clock_Divider_Factor   */
00058   uint32_t        NistCompliance;    /*!< NIST compliance.This parameter can be a
00059                                           value of @ref RNGEX_NIST_Compliance   */
00060 } RNG_ConfigTypeDef;
00061 
00062 /**
00063   * @}
00064   */
00065 
00066 /* Exported constants --------------------------------------------------------*/
00067 /** @defgroup RNGEX_Exported_Constants RNGEX Exported Constants
00068   * @{
00069   */
00070 
00071 /** @defgroup RNGEX_Clock_Divider_Factor  Value used to configure an internal
00072  *            programmable divider acting on the incoming RNG clock
00073   * @{
00074   */
00075 #define RNG_CLKDIV_BY_1       (0x00000000UL)      /*!< No clock division  */
00076 #define RNG_CLKDIV_BY_2       (RNG_CR_CLKDIV_0)
00077                            /*!< 2 RNG clock cycles per internal RNG clock    */
00078 #define RNG_CLKDIV_BY_4       (RNG_CR_CLKDIV_1)
00079                            /*!< 4 RNG clock cycles per internal RNG clock    */
00080 #define RNG_CLKDIV_BY_8       (RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0)
00081                            /*!< 8 RNG clock cycles per internal RNG clock    */
00082 #define RNG_CLKDIV_BY_16      (RNG_CR_CLKDIV_2)
00083                            /*!< 16 RNG clock cycles per internal RNG clock   */
00084 #define RNG_CLKDIV_BY_32      (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_0)
00085                            /*!< 32 RNG clock cycles per internal RNG clock   */
00086 #define RNG_CLKDIV_BY_64      (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1)
00087                            /*!< 64 RNG clock cycles per internal RNG clock   */
00088 #define RNG_CLKDIV_BY_128     (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0)
00089                            /*!< 128 RNG clock cycles per internal RNG clock  */
00090 #define RNG_CLKDIV_BY_256     (RNG_CR_CLKDIV_3)
00091                            /*!< 256 RNG clock cycles per internal RNG clock  */
00092 #define RNG_CLKDIV_BY_512     (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_0)
00093                            /*!< 512 RNG clock cycles per internal RNG clock  */
00094 #define RNG_CLKDIV_BY_1024    (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_1)
00095                            /*!< 1024 RNG clock cycles per internal RNG clock */
00096 #define RNG_CLKDIV_BY_2048    (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0)
00097                           /*!< 2048 RNG clock cycles per internal RNG clock  */
00098 #define RNG_CLKDIV_BY_4096    (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2)
00099                            /*!< 4096 RNG clock cycles per internal RNG clock  */
00100 #define RNG_CLKDIV_BY_8192    (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_0)
00101                           /*!< 8192 RNG clock cycles per internal RNG clock  */
00102 #define RNG_CLKDIV_BY_16384   (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1)
00103                           /*!< 16384 RNG clock cycles per internal RNG clock */
00104 #define RNG_CLKDIV_BY_32768   (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0)
00105                           /*!< 32768 RNG clock cycles per internal RNG clock */
00106 /**
00107   * @}
00108   */
00109 
00110 /** @defgroup RNGEX_NIST_Compliance  NIST Compliance configuration
00111   * @{
00112   */
00113 #define RNG_NIST_COMPLIANT     (0x00000000UL) /*!< NIST compliant configuration*/
00114 #define RNG_CUSTOM_NIST        (RNG_CR_NISTC) /*!< Custom NIST configuration   */
00115 
00116 /**
00117   * @}
00118   */
00119 
00120 /**
00121   * @}
00122   */
00123 
00124 /* Private types -------------------------------------------------------------*/
00125 /** @defgroup RNGEx_Private_Types RNGEx Private Types
00126   * @{
00127   */
00128 
00129 /**
00130   * @}
00131   */
00132 
00133 /* Private variables ---------------------------------------------------------*/
00134 /** @defgroup RNGEx_Private_Variables RNGEx Private Variables
00135   * @{
00136   */
00137 
00138 /**
00139   * @}
00140   */
00141 
00142 /* Private macros ------------------------------------------------------------*/
00143 /** @defgroup RNGEx_Private_Macros RNGEx Private Macros
00144   * @{
00145   */
00146 
00147 #define IS_RNG_CLOCK_DIVIDER(__CLOCK_DIV__) (((__CLOCK_DIV__) == RNG_CLKDIV_BY_1)     || \
00148                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_2)     || \
00149                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_4)     || \
00150                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_8)     || \
00151                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_16)    || \
00152                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_32)    || \
00153                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_64)    || \
00154                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_128)   || \
00155                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_256)   || \
00156                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_512)   || \
00157                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_1024)  || \
00158                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_2048)  || \
00159                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_4096)  || \
00160                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_8192)  || \
00161                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_16384) || \
00162                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_32768))
00163 
00164 
00165 #define IS_RNG_NIST_COMPLIANCE(__NIST_COMPLIANCE__) (((__NIST_COMPLIANCE__) == RNG_NIST_COMPLIANT) || \
00166                                                      ((__NIST_COMPLIANCE__) == RNG_CUSTOM_NIST))
00167 
00168 #define IS_RNG_CONFIG1(__CONFIG1__) ((__CONFIG1__) <= 0x3FUL)
00169 
00170 #define IS_RNG_CONFIG2(__CONFIG2__) ((__CONFIG2__) <= 0x07UL)
00171 
00172 #define IS_RNG_CONFIG3(__CONFIG3__) ((__CONFIG3__) <= 0xFUL)
00173 
00174 
00175 /**
00176  * @}
00177  */
00178 
00179 /* Private functions ---------------------------------------------------------*/
00180 /** @defgroup RNGEx_Private_Functions RNGEx Private Functions
00181   * @{
00182   */
00183 
00184 /**
00185   * @}
00186   */
00187 
00188 /* Exported functions --------------------------------------------------------*/
00189 /** @defgroup RNGEx_Exported_Functions RNGEx Exported Functions
00190   * @{
00191   */
00192 
00193 /** @addtogroup RNGEx_Exported_Functions_Group1
00194   * @{
00195   */
00196 HAL_StatusTypeDef HAL_RNGEx_SetConfig(RNG_HandleTypeDef *hrng, RNG_ConfigTypeDef *pConf);
00197 HAL_StatusTypeDef HAL_RNGEx_GetConfig(RNG_HandleTypeDef *hrng, RNG_ConfigTypeDef *pConf);
00198 HAL_StatusTypeDef HAL_RNGEx_LockConfig(RNG_HandleTypeDef *hrng);
00199 
00200 /**
00201   * @}
00202   */
00203 
00204 /**
00205   * @}
00206   */
00207 
00208 /**
00209   * @}
00210   */
00211 
00212 /**
00213   * @}
00214   */
00215 
00216 #endif /* RNG */
00217 
00218 /**
00219   * @}
00220   */
00221 
00222 #ifdef __cplusplus
00223 }
00224 #endif
00225 
00226 
00227 #endif /* STM32L4xx_HAL_RNGEX_H */