Skip to content

Commit

Permalink
Merge pull request #148 from PrimoDoor/master
Browse files Browse the repository at this point in the history
Added Zephyr integration
  • Loading branch information
jedisct1 authored Feb 1, 2024
2 parents 7ff9582 + 43acd64 commit 1bc201e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions impl/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ static TLS struct {
# include "random/esp32.h"
#elif defined(PARTICLE) && defined(PLATFORM_ID) && PLATFORM_ID > 2 && !defined(__unix__)
# include "random/particle.h"
#elif defined(__ZEPHYR__)
# include "random/zephyr.h"
#elif (defined(NRF52832_XXAA) || defined(NRF52832_XXAB)) && !defined(__unix__)
# include "random/nrf52832.h"
#elif defined(_WIN32)
Expand Down
13 changes: 13 additions & 0 deletions impl/random/zephyr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <zephyr/random/rand32.h>

static int
hydro_random_init(void)
{
if (sys_csrand_get(&hydro_random_context.state, sizeof hydro_random_context.state) != 0) {
return -1;
}

hydro_random_context.counter = ~LOAD64_LE(hydro_random_context.state);

return 0;
}

0 comments on commit 1bc201e

Please # to comment.