Create release.yml
[betaflight.git] / lib / main / STM32H7 / Drivers / STM32H7xx_HAL_Driver / Src / stm32h7xx_ll_rng.c
blobd3d34521cb676409d0a626de3ec604d73675617d
1 /**
2 ******************************************************************************
3 * @file stm32h7xx_ll_rng.c
4 * @author MCD Application Team
5 * @brief RNG LL module driver.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
17 ******************************************************************************
19 #if defined(USE_FULL_LL_DRIVER)
21 /* Includes ------------------------------------------------------------------*/
22 #include "stm32h7xx_ll_rng.h"
23 #include "stm32h7xx_ll_bus.h"
25 #ifdef USE_FULL_ASSERT
26 #include "stm32_assert.h"
27 #else
28 #define assert_param(expr) ((void)0U)
29 #endif
31 /** @addtogroup STM32H7xx_LL_Driver
32 * @{
35 #if defined (RNG)
37 /** @addtogroup RNG_LL
38 * @{
41 /* Private types -------------------------------------------------------------*/
42 /* Private variables ---------------------------------------------------------*/
43 /* Private constants ---------------------------------------------------------*/
44 /* Private macros ------------------------------------------------------------*/
45 /** @addtogroup RNG_LL_Private_Macros
46 * @{
48 #define IS_LL_RNG_CED(__MODE__) (((__MODE__) == LL_RNG_CED_ENABLE) || \
49 ((__MODE__) == LL_RNG_CED_DISABLE))
51 #if defined(RNG_CR_CONDRST)
52 #define IS_LL_RNG_CLOCK_DIVIDER(__CLOCK_DIV__) ((__CLOCK_DIV__) <=0x0Fu)
55 #define IS_LL_RNG_NIST_COMPLIANCE(__NIST_COMPLIANCE__) (((__NIST_COMPLIANCE__) == LL_RNG_NIST_COMPLIANT) || \
56 ((__NIST_COMPLIANCE__) == LL_RNG_NOTNIST_COMPLIANT))
58 #define IS_LL_RNG_CONFIG1 (__CONFIG1__) ((__CONFIG1__) <= 0x3FUL)
60 #define IS_LL_RNG_CONFIG2 (__CONFIG2__) ((__CONFIG2__) <= 0x07UL)
62 #define IS_LL_RNG_CONFIG3 (__CONFIG3__) ((__CONFIG3__) <= 0xFUL)
63 #endif /* RNG_CR_CONDRST*/
64 /**
65 * @}
67 /* Private function prototypes -----------------------------------------------*/
69 /* Exported functions --------------------------------------------------------*/
70 /** @addtogroup RNG_LL_Exported_Functions
71 * @{
74 /** @addtogroup RNG_LL_EF_Init
75 * @{
78 /**
79 * @brief De-initialize RNG registers (Registers restored to their default values).
80 * @param RNGx RNG Instance
81 * @retval An ErrorStatus enumeration value:
82 * - SUCCESS: RNG registers are de-initialized
83 * - ERROR: not applicable
85 ErrorStatus LL_RNG_DeInit(RNG_TypeDef *RNGx)
87 /* Check the parameters */
88 assert_param(IS_RNG_ALL_INSTANCE(RNGx));
89 /* Enable RNG reset state */
90 LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_RNG);
92 /* Release RNG from reset state */
93 LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_RNG);
94 return (SUCCESS);
97 /**
98 * @brief Initialize RNG registers according to the specified parameters in RNG_InitStruct.
99 * @param RNGx RNG Instance
100 * @param RNG_InitStruct pointer to a LL_RNG_InitTypeDef structure
101 * that contains the configuration information for the specified RNG peripheral.
102 * @retval An ErrorStatus enumeration value:
103 * - SUCCESS: RNG registers are initialized according to RNG_InitStruct content
104 * - ERROR: not applicable
106 ErrorStatus LL_RNG_Init(RNG_TypeDef *RNGx, LL_RNG_InitTypeDef *RNG_InitStruct)
108 /* Check the parameters */
109 assert_param(IS_RNG_ALL_INSTANCE(RNGx));
110 assert_param(IS_LL_RNG_CED(RNG_InitStruct->ClockErrorDetection));
112 #if defined(RNG_CR_CONDRST)
113 /* Clock Error Detection Configuration when CONDRT bit is set to 1 */
114 MODIFY_REG(RNGx->CR, RNG_CR_CED | RNG_CR_CONDRST, RNG_InitStruct->ClockErrorDetection | RNG_CR_CONDRST);
115 /* Writing bits CONDRST=0*/
116 CLEAR_BIT(RNGx->CR, RNG_CR_CONDRST);
117 #else
118 /* Clock Error Detection configuration */
119 MODIFY_REG(RNGx->CR, RNG_CR_CED, RNG_InitStruct->ClockErrorDetection);
120 #endif /* RNG_CR_CONDRST */
122 return (SUCCESS);
126 * @brief Set each @ref LL_RNG_InitTypeDef field to default value.
127 * @param RNG_InitStruct pointer to a @ref LL_RNG_InitTypeDef structure
128 * whose fields will be set to default values.
129 * @retval None
131 void LL_RNG_StructInit(LL_RNG_InitTypeDef *RNG_InitStruct)
133 /* Set RNG_InitStruct fields to default values */
134 RNG_InitStruct->ClockErrorDetection = LL_RNG_CED_ENABLE;
138 * @}
142 * @}
146 * @}
149 #endif /* RNG */
152 * @}
155 #endif /* USE_FULL_LL_DRIVER */
157 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/