Skip to content

Commit 6427765

Browse files
committed
TRNG: keep track of initialization status
1 parent ff9c88e commit 6427765

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cores/arduino/WMath.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ extern "C" {
4848
static long trng()
4949
{
5050
uint32_t value[4];
51-
if (HW_SCE_McuSpecificInit() != FSP_SUCCESS)
52-
return -1;
51+
static bool SCE_inited = false;
52+
if (!SCE_inited) {
53+
if (HW_SCE_McuSpecificInit() != FSP_SUCCESS) {
54+
return -1;
55+
}
56+
SCE_inited = true;
57+
}
58+
5359
HW_SCE_RNG_Read(value);
5460
return (long)value[0] >= 0 ? value[0] : -value[0];
5561
}

0 commit comments

Comments
 (0)