123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- #include "stm32f4xx_rng.h"
- #include "stm32f4xx_rcc.h"
-
- #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F410xx) || defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F429_439xx) || defined(STM32F469_479xx)
-
- void RNG_DeInit(void)
- {
- #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F469_479xx)
-
- RCC_AHB2PeriphResetCmd(RCC_AHB2Periph_RNG, ENABLE);
-
- RCC_AHB2PeriphResetCmd(RCC_AHB2Periph_RNG, DISABLE);
- #endif
- #if defined(STM32F410xx)
-
- RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_RNG, ENABLE);
-
- RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_RNG, DISABLE);
- #endif
- }
- void RNG_Cmd(FunctionalState NewState)
- {
-
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
-
- RNG->CR |= RNG_CR_RNGEN;
- }
- else
- {
-
- RNG->CR &= ~RNG_CR_RNGEN;
- }
- }
- uint32_t RNG_GetRandomNumber(void)
- {
-
- return RNG->DR;
- }
-
- void RNG_ITConfig(FunctionalState NewState)
- {
-
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
-
- RNG->CR |= RNG_CR_IE;
- }
- else
- {
-
- RNG->CR &= ~RNG_CR_IE;
- }
- }
- FlagStatus RNG_GetFlagStatus(uint8_t RNG_FLAG)
- {
- FlagStatus bitstatus = RESET;
-
- assert_param(IS_RNG_GET_FLAG(RNG_FLAG));
-
- if ((RNG->SR & RNG_FLAG) != (uint8_t)RESET)
- {
-
- bitstatus = SET;
- }
- else
- {
-
- bitstatus = RESET;
- }
-
- return bitstatus;
- }
- void RNG_ClearFlag(uint8_t RNG_FLAG)
- {
-
- assert_param(IS_RNG_CLEAR_FLAG(RNG_FLAG));
-
- RNG->SR = ~(uint32_t)(((uint32_t)RNG_FLAG) << 4);
- }
- ITStatus RNG_GetITStatus(uint8_t RNG_IT)
- {
- ITStatus bitstatus = RESET;
-
- assert_param(IS_RNG_GET_IT(RNG_IT));
-
- if ((RNG->SR & RNG_IT) != (uint8_t)RESET)
- {
-
- bitstatus = SET;
- }
- else
- {
-
- bitstatus = RESET;
- }
-
- return bitstatus;
- }
- void RNG_ClearITPendingBit(uint8_t RNG_IT)
- {
-
- assert_param(IS_RNG_IT(RNG_IT));
-
- RNG->SR = (uint8_t)~RNG_IT;
- }
-
-
-
- #endif
-
-
|