/* Basic Configuration of TRNG and PRNG. 
The function is used to set the basic configuration for TRNG and PRNG.  */
static void RNG_BasicConfig()
/* Basic Configuration of TRNG and PRNG. 
The function is used to set the basic configuration for TRNG and PRNG.  */
static void RNG_BasicConfig()
{
    int32_t i;
    int32_t timeout = 0x1000000;
    CLK->AHBCLK0 |= CLK_AHBCLK0_CRPTCKEN_Msk;
    CLK->APBCLK1 |= CLK_APBCLK1_TRNGCKEN_Msk;
    CLK->PWRCTL |= CLK_PWRCTL_LIRCEN_Msk;
    while ((CLK->STATUS & CLK_STATUS_LIRCSTB_Msk) == 0)
    {
        if (i++ > timeout) break;
    }
    CLK->CLKSEL2 = (CLK->CLKSEL2 & (~CLK_CLKSEL2_TRNGSEL_Msk)) | CLK_CLKSEL2_TRNGSEL_LIRC;
}