/* Get a random number and block until it works. Unless you have a clock problem, this should always return "promptly" If you have a clock problem, you will wait here forever! Check device RM for clock requirements (usually fRNGCLK > fHCLK/16 or fRNGCLK > fHCLK/32 */
uint32_t rng_get_random_blocking(void)
/* Get a random number and block until it works. Unless you have a clock problem, this should always return "promptly" If you have a clock problem, you will wait here forever! Check device RM for clock requirements (usually fRNGCLK > fHCLK/16 or fRNGCLK > fHCLK/32 */
uint32_t rng_get_random_blocking(void)
{
        uint32_t rv;
        bool done;
        do {
                if (RNG_SR & RNG_SR_SEIS) {
                        RNG_SR = RNG_SR & ~RNG_SR_SEIS;
                        for (int i = 12; i != 0; i--) {
                                rv = RNG_DR;
                        }
                        RNG_CR &= ~RNG_CR_RNGEN;
                        RNG_CR |= RNG_CR_RNGEN;
                }
                if (RNG_SR & RNG_SR_CEIS) {
                        RNG_SR = RNG_SR & ~RNG_SR_CEIS;
                }
                done = rng_get_random(&rv);
        } while (!done);
        return rv;
}