You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

139 lines
3.9 KiB

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