【STM32】随机数发生器相关函数和类型
生活随笔
收集整理的這篇文章主要介紹了
【STM32】随机数发生器相关函数和类型
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
00. 目錄
文章目錄
- 00. 目錄
- 01. RNG概述
- 02. 相關(guān)類型
- 03. 相關(guān)函數(shù)
- 04. 結(jié)構(gòu)體封裝
- 05. 預(yù)留
- 06. 附錄
- 07. 聲明
01. RNG概述
RNG 處理器是一個以連續(xù)模擬噪聲為基礎(chǔ)的隨機數(shù)發(fā)生器,在主機讀數(shù)時提供一個 32 位的隨機數(shù)。
RNG 已通過 FIPS PUB 140-2(2001 年 10 月 10 日)測試,成功率達 99%。
隨機數(shù)發(fā)生器支持庫函數(shù)stm32f4xx_rng.c 和對應(yīng)的頭文件 stm32f4xx_rng.h。
02. 相關(guān)類型
/** @defgroup RNG_flags_definition * @{*/ #define RNG_FLAG_DRDY ((uint8_t)0x0001) /*!< Data ready */ #define RNG_FLAG_CECS ((uint8_t)0x0002) /*!< Clock error current status */ #define RNG_FLAG_SECS ((uint8_t)0x0004) /*!< Seed error current status */#define IS_RNG_GET_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_DRDY) || \((RNG_FLAG) == RNG_FLAG_CECS) || \((RNG_FLAG) == RNG_FLAG_SECS)) #define IS_RNG_CLEAR_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_CECS) || \((RNG_FLAG) == RNG_FLAG_SECS)) /*** @}*/ /** @defgroup RNG_interrupts_definition * @{*/ #define RNG_IT_CEI ((uint8_t)0x20) /*!< Clock error interrupt */ #define RNG_IT_SEI ((uint8_t)0x40) /*!< Seed error interrupt */#define IS_RNG_IT(IT) ((((IT) & (uint8_t)0x9F) == 0x00) && ((IT) != 0x00)) #define IS_RNG_GET_IT(RNG_IT) (((RNG_IT) == RNG_IT_CEI) || ((RNG_IT) == RNG_IT_SEI))03. 相關(guān)函數(shù)
/* Function used to set the RNG configuration to the default reset state *****/ void RNG_DeInit(void);/* Configuration function *****************************************************/ void RNG_Cmd(FunctionalState NewState);/* Get 32 bit Random number function ******************************************/ uint32_t RNG_GetRandomNumber(void);/* Interrupts and flags management functions **********************************/ void RNG_ITConfig(FunctionalState NewState); FlagStatus RNG_GetFlagStatus(uint8_t RNG_FLAG); void RNG_ClearFlag(uint8_t RNG_FLAG); ITStatus RNG_GetITStatus(uint8_t RNG_IT); void RNG_ClearITPendingBit(uint8_t RNG_IT);04. 結(jié)構(gòu)體封裝
/** * @brief RNG*/typedef struct {__IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */__IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */__IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ } RNG_TypeDef;05. 預(yù)留
06. 附錄
6.1 【STM32】STM32系列教程匯總
網(wǎng)址:【STM32】STM32系列教程匯總
07. 聲明
該教程參考了正點原子的《STM32 F4 開發(fā)指南》
總結(jié)
以上是生活随笔為你收集整理的【STM32】随机数发生器相关函数和类型的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【STM32】随机数发生器详解
- 下一篇: 【STM32】硬件随机数程序示例