blob: d787d2ba47805c3f28ff7312a127e57da453ffb6 [file] [log] [blame]
/*
* Copyright (c) 2019 - 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <platform/nrf_802154_temperature.h>
#include <zephyr/drivers/entropy.h>
static uint32_t state;
static uint32_t next(void)
{
uint32_t num = state;
state = 1664525 * num + 1013904223;
return num;
}
void nrf_802154_random_init(void)
{
const struct device *const dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_entropy));
int err;
__ASSERT_NO_MSG(device_is_ready(dev));
do {
err = entropy_get_entropy(dev, (uint8_t *)&state, sizeof(state));
__ASSERT_NO_MSG(err == 0);
} while (state == 0);
}
void nrf_802154_random_deinit(void)
{
/* Intentionally empty */
}
uint32_t nrf_802154_random_get(void)
{
return next();
}