stm32f4xx_rng.c
Go to the documentation of this file.
1 
55 /* Includes ------------------------------------------------------------------*/
56 #include "stm32f4xx_rng.h"
57 #include "stm32f4xx_rcc.h"
58 
68 /* Private typedef -----------------------------------------------------------*/
69 /* Private define ------------------------------------------------------------*/
70 /* Private macro -------------------------------------------------------------*/
71 /* Private variables ---------------------------------------------------------*/
72 /* Private function prototypes -----------------------------------------------*/
73 /* Private functions ---------------------------------------------------------*/
74 
99 void RNG_DeInit(void)
100 {
101  /* Enable RNG reset state */
103 
104  /* Release RNG from reset state */
106 }
107 
114 void RNG_Cmd(FunctionalState NewState)
115 {
116  /* Check the parameters */
118 
119  if (NewState != DISABLE)
120  {
121  /* Enable the RNG */
122  RNG->CR |= RNG_CR_RNGEN;
123  }
124  else
125  {
126  /* Disable the RNG */
127  RNG->CR &= ~RNG_CR_RNGEN;
128  }
129 }
176 uint32_t RNG_GetRandomNumber(void)
177 {
178  /* Return the 32 bit random number from the DR register */
179  return RNG->DR;
180 }
181 
182 
268 {
269  /* Check the parameters */
271 
272  if (NewState != DISABLE)
273  {
274  /* Enable the RNG interrupt */
275  RNG->CR |= RNG_CR_IE;
276  }
277  else
278  {
279  /* Disable the RNG interrupt */
280  RNG->CR &= ~RNG_CR_IE;
281  }
282 }
283 
293 FlagStatus RNG_GetFlagStatus(uint8_t RNG_FLAG)
294 {
295  FlagStatus bitstatus = RESET;
296  /* Check the parameters */
297  assert_param(IS_RNG_GET_FLAG(RNG_FLAG));
298 
299  /* Check the status of the specified RNG flag */
300  if ((RNG->SR & RNG_FLAG) != (uint8_t)RESET)
301  {
302  /* RNG_FLAG is set */
303  bitstatus = SET;
304  }
305  else
306  {
307  /* RNG_FLAG is reset */
308  bitstatus = RESET;
309  }
310  /* Return the RNG_FLAG status */
311  return bitstatus;
312 }
313 
314 
326 void RNG_ClearFlag(uint8_t RNG_FLAG)
327 {
328  /* Check the parameters */
329  assert_param(IS_RNG_CLEAR_FLAG(RNG_FLAG));
330  /* Clear the selected RNG flags */
331  RNG->SR = ~(uint32_t)(((uint32_t)RNG_FLAG) << 4);
332 }
333 
342 ITStatus RNG_GetITStatus(uint8_t RNG_IT)
343 {
344  ITStatus bitstatus = RESET;
345  /* Check the parameters */
346  assert_param(IS_RNG_GET_IT(RNG_IT));
347 
348  /* Check the status of the specified RNG interrupt */
349  if ((RNG->SR & RNG_IT) != (uint8_t)RESET)
350  {
351  /* RNG_IT is set */
352  bitstatus = SET;
353  }
354  else
355  {
356  /* RNG_IT is reset */
357  bitstatus = RESET;
358  }
359  /* Return the RNG_IT status */
360  return bitstatus;
361 }
362 
363 
372 void RNG_ClearITPendingBit(uint8_t RNG_IT)
373 {
374  /* Check the parameters */
375  assert_param(IS_RNG_IT(RNG_IT));
376 
377  /* Clear the selected RNG interrupt pending bit */
378  RNG->SR = (uint8_t)~RNG_IT;
379 }
397 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
FlagStatus
Definition: stm32f4xx.h:706
FunctionalState
Definition: stm32f4xx.h:708
#define RNG
Definition: stm32f4xx.h:2148
void assert_param(int val)
void RNG_DeInit(void)
De-initializes the RNG peripheral registers to their default reset values.
Definition: stm32f4xx_rng.c:99
#define IS_FUNCTIONAL_STATE(STATE)
Definition: stm32f4xx.h:709
Definition: stm32f4xx.h:706
#define IS_RNG_GET_IT(RNG_IT)
Definition: stm32f4xx_rng.h:78
enum FlagStatus ITStatus
#define RNG_CR_RNGEN
Definition: stm32f4xx.h:9269
#define IS_RNG_CLEAR_FLAG(RNG_FLAG)
Definition: stm32f4xx_rng.h:65
void RNG_ClearITPendingBit(uint8_t RNG_IT)
Clears the RNG interrupt pending bit(s).
This file contains all the functions prototypes for the Random Number Generator(RNG) firmware library...
void RNG_ITConfig(FunctionalState NewState)
Enables or disables the RNG interrupt.
void RNG_ClearFlag(uint8_t RNG_FLAG)
Clears the RNG flags.
#define IS_RNG_IT(IT)
Definition: stm32f4xx_rng.h:77
#define RNG_CR_IE
Definition: stm32f4xx.h:9270
ITStatus RNG_GetITStatus(uint8_t RNG_IT)
Checks whether the specified RNG interrupt has occurred or not.
uint32_t RNG_GetRandomNumber(void)
Returns a 32-bit random number.
void RNG_Cmd(FunctionalState NewState)
Enables or disables the RNG peripheral.
void RCC_AHB2PeriphResetCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState)
Forces or releases AHB2 peripheral reset.
FlagStatus RNG_GetFlagStatus(uint8_t RNG_FLAG)
Checks whether the specified RNG flag is set or not.
#define IS_RNG_GET_FLAG(RNG_FLAG)
Definition: stm32f4xx_rng.h:62


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:49