int ctrl: Added new API

hw_irq_ctrl_toggle_level_irq_line_if()
To facilitate writing peripherals with level interrupts,
the common logic to decide if the interupt line is toggling or
not and propagate it to the int cntrl in one go.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2023-09-19 13:17:56 +02:00
parent daaaaa06cf
commit bab6a54ad1
2 changed files with 29 additions and 0 deletions

View File

@ -455,3 +455,28 @@ const char *hw_irq_ctrl_get_name(unsigned int inst, unsigned int irq)
return NULL;
}
}
/*
* NOTE: This is not a Interrupt controller function per se, but a common function
* for all peripherals to handle evaluate if they want to raise or not
* their interrupt line
*
* int_line Previous/Current interrutp line level
* new_int_line new interrupt line level
* irq_map Interrupt mapping (interrupt controller and line)
*/
void hw_irq_ctrl_toggle_level_irq_line_if(bool *int_line,
bool new_int_line,
struct nhw_irq_mapping *irq_map)
{
if (*int_line == false && new_int_line == true) {
*int_line = true;
hw_irq_ctrl_raise_level_irq_line(irq_map->cntl_inst,
irq_map->int_nbr);
} else if (*int_line == true && new_int_line == false) {
*int_line = false;
hw_irq_ctrl_lower_level_irq_line(irq_map->cntl_inst,
irq_map->int_nbr);
}
}

View File

@ -9,6 +9,7 @@
#define _NRF_HW_MODEL_SRC_HW_MODELS_IRQ_CTRL_H
#include <stdint.h>
#include "NHW_common_types.h"
#ifdef __cplusplus
extern "C" {
@ -35,6 +36,9 @@ uint8_t hw_irq_ctrl_get_prio(unsigned int inst, unsigned int irq);
void hw_irq_ctrl_prio_set(unsigned int inst, unsigned int irq, unsigned int prio);
uint32_t hw_irq_ctrl_change_lock(unsigned int inst, uint32_t new_lock);
const char *hw_irq_ctrl_get_name(unsigned int inst, unsigned int irq);
void hw_irq_ctrl_toggle_level_irq_line_if(bool *int_line,
bool new_int_line,
struct nhw_irq_mapping *irq_map);
/*
* This interrupt will awake the CPU if IRQs are not locked,