native simulator: Get latest from upstream

Align with native_simulator's upstream main
d32b2504ad2b6d6d541bc71a0f9b16ab7b6a3831

Which includes:
* d32b250 Minor format fix
* 7b4f35b native HW counter: Provide new API to reset and control
* 4f815cb INT CNTLR: Bugfix for more than 32 interrupts
* 1d36254 Provide new 64 version of nsi_find_lsb_set

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2023-10-11 10:50:09 +02:00 committed by Carles Cufí
parent 2d5b781e99
commit bc5da1a158
4 changed files with 46 additions and 3 deletions

View file

@ -14,7 +14,6 @@ extern "C" {
#endif
/**
*
* @brief find least significant bit set in a 32-bit word
*
* This routine finds the first bit set starting from the least significant bit
@ -30,6 +29,22 @@ static inline unsigned int nsi_find_lsb_set(uint32_t op)
return __builtin_ffs(op);
}
/**
* @brief find least significant bit set in a 64-bit word
*
* This routine finds the first bit set starting from the least significant bit
* in the argument passed in and returns the index of that bit. Bits are
* numbered starting at 1 from the least significant bit. A return value of
* zero indicates that the value passed is zero.
*
* @return least significant bit set, 0 if @a op is 0
*/
static inline unsigned int nsi_find_lsb_set64(uint64_t op)
{
return __builtin_ffsll(op);
}
#ifdef __cplusplus
}
#endif

View file

@ -17,6 +17,7 @@ static bool counter_running;
static uint64_t counter_value;
static uint64_t counter_target;
static uint64_t counter_period;
static uint64_t counter_wrap;
/**
* Initialize the counter with prescaler of HW
@ -28,6 +29,7 @@ static void hw_counter_init(void)
counter_value = 0;
counter_running = false;
counter_period = NSI_NEVER;
counter_wrap = NSI_NEVER;
}
NSI_TASK(hw_counter_init, HW_INIT, 10);
@ -40,7 +42,7 @@ static void hw_counter_triggered(void)
}
hw_counter_timer = nsi_hws_get_time() + counter_period;
counter_value = counter_value + 1;
counter_value = (counter_value + 1) % counter_wrap;
if (counter_value == counter_target) {
hw_irq_ctrl_set_irq(COUNTER_EVENT_IRQ);
@ -58,6 +60,16 @@ void hw_counter_set_period(uint64_t period)
counter_period = period;
}
/*
* Set the count value at which the counter will wrap
* The counter will count up to (counter_wrap-1), i.e.:
* 0, 1, 2,.., (counter_wrap - 1), 0
*/
void hw_counter_set_wrap_value(uint64_t wrap_value)
{
counter_wrap = wrap_value;
}
/**
* Starts the counter. It must be previously configured with
* hw_counter_set_period() and hw_counter_set_target().
@ -86,6 +98,11 @@ void hw_counter_stop(void)
nsi_hws_find_next_event();
}
bool hw_counter_is_started(void)
{
return counter_running;
}
/**
* Returns the current counter value.
*/
@ -94,6 +111,14 @@ uint64_t hw_counter_get_value(void)
return counter_value;
}
/**
* Resets the counter value.
*/
void hw_counter_reset(void)
{
counter_value = 0;
}
/**
* Configures the counter to generate an interrupt
* when its count value reaches target.

View file

@ -22,9 +22,12 @@ void hw_counter_triggered(void);
void hw_counter_set_period(uint64_t period);
void hw_counter_set_target(uint64_t counter_target);
void hw_counter_set_wrap_value(uint64_t wrap_value);
void hw_counter_start(void);
void hw_counter_stop(void);
bool hw_counter_is_started(void);
uint64_t hw_counter_get_value(void);
void hw_counter_reset(void);
#ifdef __cplusplus
}

View file

@ -95,7 +95,7 @@ int hw_irq_ctrl_get_highest_prio_irq(void)
int winner_prio = 256;
while (irq_status != 0U) {
int irq_nbr = nsi_find_lsb_set(irq_status) - 1;
int irq_nbr = nsi_find_lsb_set64(irq_status) - 1;
irq_status &= ~((uint64_t) 1 << irq_nbr);
if ((winner_prio > (int)irq_prio[irq_nbr])