RNG: Rename functions to match new naming convention
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
parent
a3dbb38acc
commit
4404106985
|
@ -24,7 +24,7 @@ src/HW_models/bs_compat.c
|
|||
src/HW_models/NRF_FICR.c
|
||||
src/HW_models/NRF_RADIO_timings.c
|
||||
src/HW_models/NRF_GPIOTE.c
|
||||
src/HW_models/NRF_RNG.c
|
||||
src/HW_models/NHW_RNG.c
|
||||
src/HW_models/weak_stubs.c
|
||||
src/HW_models/NHW_CLOCK.c
|
||||
src/HW_models/NRF_RADIO_signals.c
|
||||
|
|
|
@ -9,7 +9,7 @@ src/HW_models/bs_compat.c
|
|||
src/HW_models/NHW_DPPI.c
|
||||
src/HW_models/NHW_CLOCK.c
|
||||
src/HW_models/NHW_EGU.c
|
||||
src/HW_models/NRF_RNG.c
|
||||
src/HW_models/NHW_RNG.c
|
||||
src/HW_models/NHW_RTC.c
|
||||
src/HW_models/NHW_TIMER.c
|
||||
src/HW_models/weak_stubs.c
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "NHW_config.h"
|
||||
#include "NHW_peri_types.h"
|
||||
#include "NHW_common_types.h"
|
||||
#include "NRF_RNG.h"
|
||||
#include "NHW_RNG.h"
|
||||
#include "NHW_xPPI.h"
|
||||
#include "nsi_hw_scheduler.h"
|
||||
#include "irq_ctrl.h"
|
||||
|
@ -52,16 +52,16 @@ static uint nhw_rng_dppi_map[NHW_RNG_TOTAL_INST] = NHW_RNG_DPPI_MAP;
|
|||
/**
|
||||
* Initialize the RNG model
|
||||
*/
|
||||
static void nrf_rng_init(void) {
|
||||
static void nhw_rng_init(void) {
|
||||
memset(&NRF_RNG_regs, 0, sizeof(NRF_RNG_regs));
|
||||
RNG_hw_started = false;
|
||||
RNG_INTEN = false;
|
||||
Timer_RNG = TIME_NEVER;
|
||||
}
|
||||
|
||||
NSI_TASK(nrf_rng_init, HW_INIT, 100);
|
||||
NSI_TASK(nhw_rng_init, HW_INIT, 100);
|
||||
|
||||
static void nrf_rng_schedule_next(bool first_time){
|
||||
static void nhw_rng_schedule_next(bool first_time){
|
||||
bs_time_t delay = 0;
|
||||
|
||||
if (first_time) {
|
||||
|
@ -101,61 +101,61 @@ static void nhw_rng_eval_interrupt(uint inst) {
|
|||
/**
|
||||
* TASK_START triggered handler
|
||||
*/
|
||||
void nrf_rng_task_start(void) {
|
||||
void nhw_rng_task_start(void) {
|
||||
if (RNG_hw_started) {
|
||||
return;
|
||||
}
|
||||
RNG_hw_started = true;
|
||||
nrf_rng_schedule_next(true);
|
||||
nhw_rng_schedule_next(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* TASK_STOP triggered handler
|
||||
*/
|
||||
void nrf_rng_task_stop(void) {
|
||||
void nhw_rng_task_stop(void) {
|
||||
RNG_hw_started = false;
|
||||
Timer_RNG = TIME_NEVER;
|
||||
nsi_hws_find_next_event();
|
||||
}
|
||||
|
||||
|
||||
void nrf_rng_regw_sideeffects_TASK_START(void) {
|
||||
void nhw_rng_regw_sideeffects_TASK_START(void) {
|
||||
if (NRF_RNG_regs.TASKS_START) { /* LCOV_EXCL_BR_LINE */
|
||||
NRF_RNG_regs.TASKS_START = 0;
|
||||
nrf_rng_task_start();
|
||||
nhw_rng_task_start();
|
||||
}
|
||||
}
|
||||
|
||||
void nrf_rng_regw_sideeffects_TASK_STOP(void) {
|
||||
void nhw_rng_regw_sideeffects_TASK_STOP(void) {
|
||||
if (NRF_RNG_regs.TASKS_STOP) { /* LCOV_EXCL_BR_LINE */
|
||||
NRF_RNG_regs.TASKS_STOP = 0;
|
||||
nrf_rng_task_stop();
|
||||
nhw_rng_task_stop();
|
||||
}
|
||||
}
|
||||
|
||||
#if (NHW_HAS_DPPI)
|
||||
void nrf_rng_regw_sideeffects_SUBSCRIBE_START(unsigned int inst) {
|
||||
void nhw_rng_regw_sideeffects_SUBSCRIBE_START(unsigned int inst) {
|
||||
static struct nhw_subsc_mem START_subscribed[NHW_RNG_TOTAL_INST];
|
||||
|
||||
nhw_dppi_common_subscribe_sideeffect(nhw_rng_dppi_map[inst],
|
||||
NRF_RNG_regs.SUBSCRIBE_START,
|
||||
&START_subscribed[inst],
|
||||
(dppi_callback_t)nrf_rng_task_start,
|
||||
(dppi_callback_t)nhw_rng_task_start,
|
||||
DPPI_CB_NO_PARAM);
|
||||
}
|
||||
|
||||
void nrf_rng_regw_sideeffects_SUBSCRIBE_STOP(unsigned int inst) {
|
||||
void nhw_rng_regw_sideeffects_SUBSCRIBE_STOP(unsigned int inst) {
|
||||
static struct nhw_subsc_mem STOP_subscribed[NHW_RNG_TOTAL_INST];
|
||||
|
||||
nhw_dppi_common_subscribe_sideeffect(nhw_rng_dppi_map[inst],
|
||||
NRF_RNG_regs.SUBSCRIBE_START,
|
||||
&STOP_subscribed[inst],
|
||||
(dppi_callback_t)nrf_rng_task_stop,
|
||||
(dppi_callback_t)nhw_rng_task_stop,
|
||||
DPPI_CB_NO_PARAM);
|
||||
}
|
||||
#endif /* NHW_HAS_DPPI */
|
||||
|
||||
void nrf_rng_regw_sideeffects_INTENSET(void) {
|
||||
void nhw_rng_regw_sideeffects_INTENSET(void) {
|
||||
if (NRF_RNG_regs.INTENSET) { /* LCOV_EXCL_BR_LINE */
|
||||
RNG_INTEN |= NRF_RNG_regs.INTENSET;
|
||||
NRF_RNG_regs.INTENSET = RNG_INTEN;
|
||||
|
@ -163,7 +163,7 @@ void nrf_rng_regw_sideeffects_INTENSET(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void nrf_rng_regw_sideeffects_INTENCLEAR(void) {
|
||||
void nhw_rng_regw_sideeffects_INTENCLEAR(void) {
|
||||
if (NRF_RNG_regs.INTENCLR) { /* LCOV_EXCL_BR_LINE */
|
||||
RNG_INTEN &= ~NRF_RNG_regs.INTENCLR;
|
||||
NRF_RNG_regs.INTENSET = RNG_INTEN;
|
||||
|
@ -172,13 +172,13 @@ void nrf_rng_regw_sideeffects_INTENCLEAR(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void nrf_rng_regw_sideeffects_EVENTS_all(void) {
|
||||
void nhw_rng_regw_sideeffects_EVENTS_all(void) {
|
||||
nhw_rng_eval_interrupt(0);
|
||||
}
|
||||
|
||||
static void nhw_rng_signal_VALRDY(uint periph_inst) {
|
||||
if (NRF_RNG_regs.SHORTS & RNG_SHORTS_VALRDY_STOP_Msk) {
|
||||
nrf_rng_task_stop();
|
||||
nhw_rng_task_stop();
|
||||
}
|
||||
|
||||
NRF_RNG_regs.EVENTS_VALRDY = 1;
|
||||
|
@ -196,13 +196,13 @@ static void nhw_rng_signal_VALRDY(uint periph_inst) {
|
|||
/**
|
||||
* Time has come when a new random number is ready
|
||||
*/
|
||||
static void nrf_rng_timer_triggered(void) {
|
||||
static void nhw_rng_timer_triggered(void) {
|
||||
//We generate a proper random number even if CONFIG is not set to correct the bias:
|
||||
NRF_RNG_regs.VALUE = bs_random_uint32();
|
||||
|
||||
nrf_rng_schedule_next(false);
|
||||
nhw_rng_schedule_next(false);
|
||||
|
||||
nhw_rng_signal_VALRDY(0);
|
||||
}
|
||||
|
||||
NSI_HW_EVENT(Timer_RNG, nrf_rng_timer_triggered, 50);
|
||||
NSI_HW_EVENT(Timer_RNG, nhw_rng_timer_triggered, 50);
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Oticon A/S
|
||||
* Copyright (c) 2023, Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef _NRF_HW_MODEL_RNG_H
|
||||
#define _NRF_HW_MODEL_RNG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
void nhw_rng_regw_sideeffects_TASK_START(void);
|
||||
void nhw_rng_regw_sideeffects_TASK_STOP(void);
|
||||
void nhw_rng_regw_sideeffects_INTENSET(void);
|
||||
void nhw_rng_regw_sideeffects_INTENCLEAR(void);
|
||||
void nhw_rng_regw_sideeffects_EVENTS_all(void);
|
||||
void nhw_rng_regw_sideeffects_SUBSCRIBE_START(unsigned int inst);
|
||||
void nhw_rng_regw_sideeffects_SUBSCRIBE_STOP(unsigned int inst);
|
||||
void nhw_rng_task_start(void);
|
||||
void nhw_rng_task_stop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -24,7 +24,7 @@
|
|||
#include "NRF_AAR.h"
|
||||
#include "NRF_AES_CCM.h"
|
||||
#include "NRF_GPIOTE.h"
|
||||
#include "NRF_RNG.h"
|
||||
#include "NHW_RNG.h"
|
||||
#include "NRF_PPI.h"
|
||||
#include "NHW_RTC.h"
|
||||
#include "NHW_TIMER.h"
|
||||
|
@ -218,8 +218,8 @@ static const ppi_tasks_table_t ppi_tasks_table[]={ //just the ones we may use
|
|||
//{ (void*)&(NRF_RTC_regs[2]).TASKS_TRIGOVRFLW , nhw_rtc2_TASKS_TRIGOVRFLW},
|
||||
|
||||
//RNG:
|
||||
{ (void*)&NRF_RNG_regs.TASKS_START, nrf_rng_task_start},
|
||||
{ (void*)&NRF_RNG_regs.TASKS_STOP , nrf_rng_task_stop},
|
||||
{ (void*)&NRF_RNG_regs.TASKS_START, nhw_rng_task_start},
|
||||
{ (void*)&NRF_RNG_regs.TASKS_STOP , nhw_rng_task_stop},
|
||||
|
||||
//ECB
|
||||
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Oticon A/S
|
||||
* Copyright (c) 2023, Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef _NRF_HW_MODEL_RNG_H
|
||||
#define _NRF_HW_MODEL_RNG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
void nrf_rng_regw_sideeffects_TASK_START(void);
|
||||
void nrf_rng_regw_sideeffects_TASK_STOP(void);
|
||||
void nrf_rng_regw_sideeffects_INTENSET(void);
|
||||
void nrf_rng_regw_sideeffects_INTENCLEAR(void);
|
||||
void nrf_rng_regw_sideeffects_EVENTS_all(void);
|
||||
void nrf_rng_regw_sideeffects_SUBSCRIBE_START(unsigned int inst);
|
||||
void nrf_rng_regw_sideeffects_SUBSCRIBE_STOP(unsigned int inst);
|
||||
void nrf_rng_task_start(void);
|
||||
void nrf_rng_task_stop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
#include "hal/nrf_rng.h"
|
||||
#include "bs_tracing.h"
|
||||
#include "NRF_RNG.h"
|
||||
#include "NHW_RNG.h"
|
||||
|
||||
extern NRF_RNG_Type NRF_RNG_regs;
|
||||
|
||||
|
@ -17,10 +17,10 @@ void nrf_rng_task_trigger(NRF_RNG_Type * p_reg, nrf_rng_task_t rng_task)
|
|||
|
||||
if ( rng_task == NRF_RNG_TASK_START ) {
|
||||
NRF_RNG_regs.TASKS_START = 1;
|
||||
nrf_rng_regw_sideeffects_TASK_START();
|
||||
nhw_rng_regw_sideeffects_TASK_START();
|
||||
} else if ( rng_task == NRF_RNG_TASK_STOP ) {
|
||||
NRF_RNG_regs.TASKS_STOP = 1;
|
||||
nrf_rng_regw_sideeffects_TASK_STOP();
|
||||
nhw_rng_regw_sideeffects_TASK_STOP();
|
||||
} else {
|
||||
bs_trace_error_line_time("Not supported task started in nrf_rng\n");
|
||||
}
|
||||
|
@ -29,19 +29,19 @@ void nrf_rng_task_trigger(NRF_RNG_Type * p_reg, nrf_rng_task_t rng_task)
|
|||
void nrf_rng_int_enable(NRF_RNG_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_RNG_regs.INTENSET = mask;
|
||||
nrf_rng_regw_sideeffects_INTENSET();
|
||||
nhw_rng_regw_sideeffects_INTENSET();
|
||||
}
|
||||
|
||||
void nrf_rng_int_disable(NRF_RNG_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_RNG_regs.INTENCLR = mask;
|
||||
nrf_rng_regw_sideeffects_INTENCLEAR();
|
||||
nhw_rng_regw_sideeffects_INTENCLEAR();
|
||||
}
|
||||
|
||||
void nrf_rng_event_clear(NRF_RNG_Type * p_reg, nrf_rng_event_t rng_event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)rng_event)) = 0x0UL;
|
||||
nrf_rng_regw_sideeffects_EVENTS_all();
|
||||
nhw_rng_regw_sideeffects_EVENTS_all();
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
|
@ -50,9 +50,9 @@ static void nrf_rng_subscribe_common(NRF_RNG_Type * p_reg,
|
|||
nrf_rng_task_t task)
|
||||
{
|
||||
if (task == NRF_RNG_TASK_START) {
|
||||
nrf_rng_regw_sideeffects_SUBSCRIBE_START(0);
|
||||
nhw_rng_regw_sideeffects_SUBSCRIBE_START(0);
|
||||
} else if ( task == NRF_RNG_TASK_STOP ) {
|
||||
nrf_rng_regw_sideeffects_SUBSCRIBE_STOP(0);
|
||||
nhw_rng_regw_sideeffects_SUBSCRIBE_STOP(0);
|
||||
} else {
|
||||
bs_trace_error_line_time("Attempted to subscribe to an not-supported task in the nrf_rng (%i)\n",
|
||||
task);
|
||||
|
|
Loading…
Reference in New Issue