Skip to content

Commit a4780cf

Browse files
committed
zephyrCommon: Implement random and randomSeed
- Using zephyr random api - Using a stub for randomSeed since it is not present in Zephyr Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
1 parent 347a80d commit a4780cf

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cores/arduino/zephyrCommon.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,23 @@ void detachInterrupt(pin_size_t pinNumber)
328328
{
329329
setInterruptHandler(pinNumber, nullptr);
330330
}
331+
332+
#ifndef CONFIG_RNG_GENERATOR_CHOICE
333+
334+
#include <zephyr/random/random.h>
335+
336+
void randomSeed(unsigned long) {}
337+
338+
long random(long min, long max) {
339+
long temp;
340+
341+
sys_rand_get(&temp, sizeof(temp));
342+
343+
return temp % (max - min) + min;
344+
}
345+
346+
long random(long max) {
347+
return random(0, max);
348+
}
349+
350+
#endif

0 commit comments

Comments
 (0)