1 /* 2 * Copyright (c) 2019 - 2021 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 8 #include <platform/nrf_802154_temperature.h> 9 #include <zephyr/drivers/entropy.h> 10 11 static uint32_t state; 12 next(void)13static uint32_t next(void) 14 { 15 state ^= (state<<13); 16 state ^= (state>>17); 17 return state ^= (state<<5); 18 } 19 nrf_802154_random_init(void)20void nrf_802154_random_init(void) 21 { 22 const struct device *const dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_entropy)); 23 int err; 24 25 __ASSERT_NO_MSG(device_is_ready(dev)); 26 27 do { 28 err = entropy_get_entropy(dev, (uint8_t *)&state, sizeof(state)); 29 __ASSERT_NO_MSG(err == 0); 30 } while (state == 0); 31 } 32 nrf_802154_random_deinit(void)33void nrf_802154_random_deinit(void) 34 { 35 /* Intentionally empty */ 36 } 37 nrf_802154_random_get(void)38uint32_t nrf_802154_random_get(void) 39 { 40 return next(); 41 } 42