|
STM32G474xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32g4xx_ll_rng.c 00004 * @author MCD Application Team 00005 * @brief RNG LL模块驱动程序。 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2019 STMicroelectronics. 00010 * All rights reserved. 00012 * 00014 * This software is licensed under terms that can be found in the LICENSE file 00016 * in the root directory of this software component. 00018 * If no LICENSE file comes with this software, it is provided AS-IS. 00020 * 00022 ****************************************************************************** 00024 */ 00025 #if defined(USE_FULL_LL_DRIVER) 00026 00027 /* 包含文件 ------------------------------------------------------------------*/ 00028 #include "stm32g4xx_ll_rng.h" 00029 #include "stm32g4xx_ll_bus.h" 00030 00031 #ifdef USE_FULL_ASSERT 00032 #include "stm32_assert.h" 00033 #else 00034 #define assert_param(expr) ((void)0U) 00035 #endif /* USE_FULL_ASSERT */ 00036 00037 /** @addtogroup STM32G4xx_LL_Driver 00038 * @{ 00039 */ 00040 00041 #if defined (RNG) 00042 00043 /** @addtogroup RNG_LL 00044 * @{ 00046 */ 00047 00048 /* 私有类型定义 -------------------------------------------------------------*/ 00049 /* 私有变量 -----------------------------------------------------------------*/ 00050 /* 私有常量 -----------------------------------------------------------------*/ 00051 /* 私有宏定义 --------------------------------------------------------------*/ 00052 /** @defgroup RNG_LL_Private_Macros RNG私有宏定义 00053 * @{ 00054 */ 00055 00055 #define IS_LL_RNG_CED(__MODE__) (((__MODE__) == LL_RNG_CED_ENABLE) || \ 00056 ((__MODE__) == LL_RNG_CED_DISABLE)) 00057 00058 /** 00059 * @} 00060 */ 00061 /* 私有函数原型声明 ---------------------------------------------------------*/ 00062 00063 /* 导出函数 ----------------------------------------------------------------*/ 00064 /** @addtogroup RNG_LL_Exported_Functions 00065 * @{ 00066 */ 00067 00068 /** @addtogroup RNG_LL_EF_Init 00069 * @{ 00070 */ 00071 00072 /** 00073 * @brief 反初始化RNG寄存器(寄存器恢复为默认值)。 00074 * @param RNGx RNG实例 00075 * @retval ErrorStatus枚举值: 00076 * - SUCCESS: RNG寄存器已反初始化 00077 * - ERROR: 不适用 00078 */ 00079 ErrorStatus LL_RNG_DeInit(const RNG_TypeDef *RNGx) 00080 { 00081 ErrorStatus status = SUCCESS; 00082 00083 /* 检查参数 */ 00084 assert_param(IS_RNG_ALL_INSTANCE(RNGx)); 00085 if (RNGx == RNG) 00086 { 00087 /* 启用RNG复位状态 */ 00088 LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_RNG); 00089 00090 /* 释放RNG复位状态 */ 00091 LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_RNG); 00092 } 00093 else 00094 { 00095 status = ERROR; 00096 } 00097 00098 return status; 00099 } 00100 00101 /** 00102 * @brief 根据RNG_InitStruct中指定的参数初始化RNG寄存器。 00103 * @param RNGx RNG实例 00104 * @param RNG_InitStruct 指向LL_RNG_InitTypeDef结构的指针 00105 * 该结构包含指定RNG外设的配置信息。 00106 * @retval ErrorStatus枚举值: 00107 * - SUCCESS: RNG寄存器已根据RNG_InitStruct内容初始化 00108 * - ERROR: 不适用 00109 */ 00110 ErrorStatus LL_RNG_Init(RNG_TypeDef *RNGx, const LL_RNG_InitTypeDef *RNG_InitStruct) 00111 { 00112 /* 检查参数 */ 00113 assert_param(IS_RNG_ALL_INSTANCE(RNGx)); 00114 assert_param(IS_LL_RNG_CED(RNG_InitStruct->ClockErrorDetection)); 00115 00116 /* 时钟错误检测配置 */ 00117 MODIFY_REG(RNGx->CR, RNG_CR_CED, RNG_InitStruct->ClockErrorDetection); 00118 00119 return (SUCCESS); 00120 } 00121 00122 /** 00123 * @brief 将每个 @ref LL_RNG_InitTypeDef 字段设置为默认值。 00124 * @param RNG_InitStruct 指向 @ref LL_RNG_InitTypeDef 结构的指针 00125 * 其字段将被设置为默认值。 00126 * @retval 无 00127 */ 00128 void LL_RNG_StructInit(LL_RNG_InitTypeDef *RNG_InitStruct) 00129 { 00130 /* 将RNG_InitStruct字段设置为默认值 */ 00131 RNG_InitStruct->ClockErrorDetection = LL_RNG_CED_ENABLE; 00132 00133 } 00134 /** 00135 * @} 00137 */ 00138 00139 /** 00140 * @} 00141 */ 00142 00143 /** 00144 * @} 00145 */ 00146 00147 #endif /* RNG */ 00148 00149 /** 00150 * @} 00152 */ 00153 00154 #endif /* USE_FULL_LL_DRIVER */ 00155
1.7.6.1