rng: header cleanup, loop codestyle

This commit is contained in:
mcudev 2017-11-05 12:08:33 -05:00 committed by Pavol Rusnak
parent 816f78c052
commit ffc16a98b5
2 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,4 @@
#include STM32_HAL_H
#include "rng.h"
#pragma GCC optimize("no-stack-protector") // applies to all functions in this file
@ -15,9 +15,7 @@ uint32_t rng_read(const uint32_t previous, const uint32_t compare_previous)
{
uint32_t temp = previous;
do {
while ((RNG->SR & (RNG_SR_SECS | RNG_SR_CECS | RNG_SR_DRDY)) != RNG_SR_DRDY) {
; // wait until TRNG is ready
}
while ((RNG->SR & (RNG_SR_SECS | RNG_SR_CECS | RNG_SR_DRDY)) != RNG_SR_DRDY); // wait until TRNG is ready
temp = RNG->DR; // read the data from the TRNG
} while (compare_previous && (temp == previous)); // RM0090 section 24.3.1 FIPS continuous random number generator test
return temp;

View File

@ -1,8 +1,10 @@
#ifndef __TREZORHAL_RNG_H__
#define __TREZORHAL_RNG_H__
#ifndef TREZORHAL_RNG_H
#define TREZORHAL_RNG_H
#include STM32_HAL_H
void rng_init(void);
uint32_t rng_get(void);
uint32_t rng_read(const uint32_t previous, const uint32_t compare_previous);
uint32_t rng_get(void);
#endif