stm32g0xx_ll_rng.c 4.0 KB

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