STM32G474xx HAL 用户手册
宏定义 | 函数
stm32g4xx_hal_rng.c 文件参考

RNG HAL 模块驱动程序。此文件提供固件函数,用于管理随机数发生器(RNG)外设的以下功能:+ 初始化和配置函数 + 外设控制函数 + 外设状态函数。 更多...

#include "stm32g4xx_hal.h"

转到该文件的源代码。

宏定义

#define RNG_TIMEOUT_VALUE   2U

函数

HAL_StatusTypeDef HAL_RNG_Init (RNG_HandleTypeDef *hrng)
 初始化 RNG 外设并创建关联的句柄。
HAL_StatusTypeDef HAL_RNG_DeInit (RNG_HandleTypeDef *hrng)
 反初始化 RNG 外设。
__weak void HAL_RNG_MspInit (RNG_HandleTypeDef *hrng)
 初始化 RNG MSP。
__weak void HAL_RNG_MspDeInit (RNG_HandleTypeDef *hrng)
 反初始化 RNG MSP。
HAL_StatusTypeDef HAL_RNG_RegisterCallback (RNG_HandleTypeDef *hrng, HAL_RNG_CallbackIDTypeDef CallbackID, pRNG_CallbackTypeDef pCallback)
 注册用户 RNG 回调,以替代弱预定义回调。
HAL_StatusTypeDef HAL_RNG_UnRegisterCallback (RNG_HandleTypeDef *hrng, HAL_RNG_CallbackIDTypeDef CallbackID)
 注销 RNG 回调。RNG 回调重定向到弱预定义回调。
HAL_StatusTypeDef HAL_RNG_RegisterReadyDataCallback (RNG_HandleTypeDef *hrng, pRNG_ReadyDataCallbackTypeDef pCallback)
 注册数据就绪 RNG 回调,以替代弱预定义回调 HAL_RNG_ReadyDataCallback()
HAL_StatusTypeDef HAL_RNG_UnRegisterReadyDataCallback (RNG_HandleTypeDef *hrng)
 注销数据就绪 RNG 回调。数据就绪 RNG 回调重定向到弱预定义回调 HAL_RNG_ReadyDataCallback()
HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber (RNG_HandleTypeDef *hrng, uint32_t *random32bit)
 生成一个 32 位随机数。
HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber_IT (RNG_HandleTypeDef *hrng)
 以中断模式生成一个 32 位随机数。
void HAL_RNG_IRQHandler (RNG_HandleTypeDef *hrng)
 处理 RNG 中断请求。
uint32_t HAL_RNG_ReadLastRandomNumber (const RNG_HandleTypeDef *hrng)
 读取最新生成的随机数。
__weak void HAL_RNG_ReadyDataCallback (RNG_HandleTypeDef *hrng, uint32_t random32bit)
 非阻塞模式下的数据就绪回调。
__weak void HAL_RNG_ErrorCallback (RNG_HandleTypeDef *hrng)
 RNG 错误回调。
HAL_RNG_StateTypeDef HAL_RNG_GetState (const RNG_HandleTypeDef *hrng)
 返回 RNG 状态。
uint32_t HAL_RNG_GetError (const RNG_HandleTypeDef *hrng)
 返回 RNG 句柄错误代码。

详细描述

RNG HAL 模块驱动程序。此文件提供固件函数,用于管理随机数发生器(RNG)外设的以下功能:+ 初始化和配置函数 + 外设控制函数 + 外设状态函数。

作者:
MCD 应用团队
注意:

版权所有 (c) 2019 STMicroelectronics。保留所有权利。

本软件根据可在本软件组件根目录的 LICENSE 文件中找到的条款进行许可。如果本软件没有附带 LICENSE 文件,则按“AS-IS”提供。

  ==============================================================================
                     ##### How to use this driver #####
  ==============================================================================
  [..]
      The RNG HAL driver can be used as follows:

      (#) Enable the RNG controller clock using __HAL_RCC_RNG_CLK_ENABLE() macro
          in HAL_RNG_MspInit().
      (#) Activate the RNG peripheral using HAL_RNG_Init() function.
      (#) Wait until the 32 bit Random Number Generator contains a valid
          random data using (polling/interrupt) mode.
      (#) Get the 32 bit random number using HAL_RNG_GenerateRandomNumber() function.

    ##### Callback registration #####
    ==================================

    [..]
    The compilation define USE_HAL_RNG_REGISTER_CALLBACKS when set to 1
    allows the user to configure dynamically the driver callbacks.

    [..]
    Use Function HAL_RNG_RegisterCallback() to register a user callback.
    Function HAL_RNG_RegisterCallback() allows to register following callbacks:
    (+) ErrorCallback             : RNG Error Callback.
    (+) MspInitCallback           : RNG MspInit.
    (+) MspDeInitCallback         : RNG MspDeInit.
    This function takes as parameters the HAL peripheral handle, the Callback ID
    and a pointer to the user callback function.

    [..]
    Use function HAL_RNG_UnRegisterCallback() to reset a callback to the default
    weak (overridden) function.
    HAL_RNG_UnRegisterCallback() takes as parameters the HAL peripheral handle,
    and the Callback ID.
    This function allows to reset following callbacks:
    (+) ErrorCallback             : RNG Error Callback.
    (+) MspInitCallback           : RNG MspInit.
    (+) MspDeInitCallback         : RNG MspDeInit.

    [..]
    For specific callback ReadyDataCallback, use dedicated register callbacks:
    respectively HAL_RNG_RegisterReadyDataCallback() , HAL_RNG_UnRegisterReadyDataCallback().

    [..]
    By default, after the HAL_RNG_Init() and when the state is HAL_RNG_STATE_RESET
    all callbacks are set to the corresponding weak (overridden) functions:
    example HAL_RNG_ErrorCallback().
    Exception done for MspInit and MspDeInit functions that are respectively
    reset to the legacy weak (overridden) functions in the HAL_RNG_Init()
    and HAL_RNG_DeInit() only when these callbacks are null (not registered beforehand).
    If not, MspInit or MspDeInit are not null, the HAL_RNG_Init() and HAL_RNG_DeInit()
    keep and use the user MspInit/MspDeInit callbacks (registered beforehand).

    [..]
    Callbacks can be registered/unregistered in HAL_RNG_STATE_READY state only.
    Exception done MspInit/MspDeInit that can be registered/unregistered
    in HAL_RNG_STATE_READY or HAL_RNG_STATE_RESET state, thus registered (user)
    MspInit/DeInit callbacks can be used during the Init/DeInit.
    In that case first register the MspInit/MspDeInit user callbacks
    using HAL_RNG_RegisterCallback() before calling HAL_RNG_DeInit()
    or HAL_RNG_Init() function.

    [..]
    When The compilation define USE_HAL_RNG_REGISTER_CALLBACKS is set to 0 or
    not defined, the callback registration feature is not available
    and weak (overridden) callbacks are used.

  

定义在文件 stm32g4xx_hal_rng.c 中。