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