/** @brief Randomizes a number. @param[in] pointer to a uint32_t that will be randomized. @returns uint8_t, 0 on error, 1 on success. */ uint8_t rng_get_random(uint32_t *rand_nr) { //wait for data to get ready while ((RNG_SR & RNG_SR_DRDY) != 1); //check for clock error if (RNG_SR & RNG_SR_CECS) { //return error return 0; } //check for seed error if (RNG_SR & RNG_SR_SECS) { //disable and enable the RNG to reinitialize and restart the RNG rng_disable(); rng_enable(); //return with no errors return 0; } //set the random value *rand_nr = RNG_DR; //return with no errors return 1; }
static int rng_dev_release (struct inode *inode, struct file *filp) { rng_disable (); up (&rng_open_sem); return 0; }