初始化加载RandomNumbersGeneration函数,无法正常广播 static void MX_RNG_Init(void)
{
/* Peripheral clock enable */
LL_AHB_EnableClock(LL_AHB_PERIPH_RNG);
LL_RNG_Enable(RNG);
} /**
* @brief This function performs several random numbers generation.
* @NOTE Generated random numbers are stored in global variable array, so that
* generated values could be observed by user by watching variable content
* in specific debugger window
* @param None
* @retval None
*/
void RandomNumbersGeneration(void)
{
register uint8_t index = 0;
/* Initialize random numbers generation */
LL_RNG_Enable(RNG);
/* Generate Random 16bit Numbers */
for(index = 0; index < NB_OF_GENERATED_RANDOM_NUMBERS; index++)
{
#if (USE_TIMEOUT == 1)
Timeout = RNG_GENERATION_TIMEOUT;
#endif /* USE_TIMEOUT */
/* Wait for DRDY flag to be raised */
while (!LL_RNG_IsActiveFlag_RNGRDY(RNG))
{
#if (USE_TIMEOUT == 1)
/* Check Systick counter flag to decrement the time-out value */
if (LL_SYSTICK_IsActiveCounterFlag())
{
if(Timeout-- == 0)
{
/* Time-out occurred. Set LED to blinking mode */
LED_Blinking(LED_BLINK_SLOW);
}
}
#endif /* USE_TIMEOUT */
}
/* Check if error occurs */
if ( LL_RNG_IsActiveFlag_FAULT(RNG) )
{
/* Clock or Seed Error detected. Set LED to blinking mode (Error type)*/
LED_Blinking(LED_BLINK_ERROR);
}
/* Otherwise, no error detected : Value of generated random number could be retrieved
and stored in dedicated array */
aRandom16bit[index] = LL_RNG_ReadRandData16(RNG);
}
/* Stop random numbers generation */
LL_RNG_Disable(RNG);
/* Values of Generated Random numbers are now available in aRandom16bit array.
LED2 is turned on */
LED_On();
printf("Value of generated random number: %#X\n\r", *aRandom16bit);
}
|