1 /**
2   ******************************************************************************
3   * @file    stm32wbxx_ll_rng.c
4   * @author  MCD Application Team
5   * @brief   RNG LL module driver.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2019 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 #if defined(USE_FULL_LL_DRIVER)
19 
20 /* Includes ------------------------------------------------------------------*/
21 #include "stm32wbxx_ll_rng.h"
22 #include "stm32wbxx_ll_bus.h"
23 
24 #ifdef  USE_FULL_ASSERT
25 #include "stm32_assert.h"
26 #else
27 #define assert_param(expr) ((void)0U)
28 #endif /* USE_FULL_ASSERT */
29 
30 /** @addtogroup STM32WBxx_LL_Driver
31   * @{
32   */
33 
34 #if defined (RNG)
35 
36 /** @addtogroup RNG_LL
37   * @{
38   */
39 
40 /* Private types -------------------------------------------------------------*/
41 /* Private variables ---------------------------------------------------------*/
42 /* Private constants ---------------------------------------------------------*/
43 /* Private macros ------------------------------------------------------------*/
44 /** @defgroup RNG_LL_Private_Macros RNG Private Macros
45   * @{
46   */
47 #define IS_LL_RNG_CED(__MODE__) (((__MODE__) == LL_RNG_CED_ENABLE) || \
48                                  ((__MODE__) == LL_RNG_CED_DISABLE))
49 
50 /**
51   * @}
52   */
53 /* Private function prototypes -----------------------------------------------*/
54 
55 /* Exported functions --------------------------------------------------------*/
56 /** @addtogroup RNG_LL_Exported_Functions
57   * @{
58   */
59 
60 /** @addtogroup RNG_LL_EF_Init
61   * @{
62   */
63 
64 /**
65   * @brief  De-initialize RNG registers (Registers restored to their default values).
66   * @param  RNGx RNG Instance
67   * @retval An ErrorStatus enumeration value:
68   *          - SUCCESS: RNG registers are de-initialized
69   *          - ERROR: not applicable
70   */
LL_RNG_DeInit(const RNG_TypeDef * RNGx)71 ErrorStatus LL_RNG_DeInit(const RNG_TypeDef *RNGx)
72 {
73   ErrorStatus status = SUCCESS;
74 
75   /* Check the parameters */
76   assert_param(IS_RNG_ALL_INSTANCE(RNGx));
77   if (RNGx == RNG)
78   {
79     /* Enable RNG reset state */
80     LL_AHB3_GRP1_ForceReset(LL_AHB3_GRP1_PERIPH_RNG);
81 
82     /* Release RNG from reset state */
83     LL_AHB3_GRP1_ReleaseReset(LL_AHB3_GRP1_PERIPH_RNG);
84   }
85   else
86   {
87     status = ERROR;
88   }
89 
90   return status;
91 }
92 
93 /**
94   * @brief  Initialize RNG registers according to the specified parameters in RNG_InitStruct.
95   * @param  RNGx RNG Instance
96   * @param  RNG_InitStruct pointer to a LL_RNG_InitTypeDef structure
97   *         that contains the configuration information for the specified RNG peripheral.
98   * @retval An ErrorStatus enumeration value:
99   *          - SUCCESS: RNG registers are initialized according to RNG_InitStruct content
100   *          - ERROR: not applicable
101   */
LL_RNG_Init(RNG_TypeDef * RNGx,LL_RNG_InitTypeDef * RNG_InitStruct)102 ErrorStatus LL_RNG_Init(RNG_TypeDef *RNGx, LL_RNG_InitTypeDef *RNG_InitStruct)
103 {
104   /* Check the parameters */
105   assert_param(IS_RNG_ALL_INSTANCE(RNGx));
106   assert_param(IS_LL_RNG_CED(RNG_InitStruct->ClockErrorDetection));
107 
108   /* Clock Error Detection configuration */
109   MODIFY_REG(RNGx->CR, RNG_CR_CED, RNG_InitStruct->ClockErrorDetection);
110 
111   return (SUCCESS);
112 }
113 
114 /**
115   * @brief Set each @ref LL_RNG_InitTypeDef field to default value.
116   * @param RNG_InitStruct pointer to a @ref LL_RNG_InitTypeDef structure
117   *                       whose fields will be set to default values.
118   * @retval None
119   */
LL_RNG_StructInit(LL_RNG_InitTypeDef * RNG_InitStruct)120 void LL_RNG_StructInit(LL_RNG_InitTypeDef *RNG_InitStruct)
121 {
122   /* Set RNG_InitStruct fields to default values */
123   RNG_InitStruct->ClockErrorDetection = LL_RNG_CED_ENABLE;
124 
125 }
126 /**
127   * @}
128   */
129 
130 /**
131   * @}
132   */
133 
134 /**
135   * @}
136   */
137 
138 #endif /* RNG */
139 
140 /**
141   * @}
142   */
143 
144 #endif /* USE_FULL_LL_DRIVER */
145 
146