Line 45... |
Line 45... |
|
|
|
|
/**********************************************************************//**
|
/**********************************************************************//**
|
* >Private< helper functions.
|
* >Private< helper functions.
|
**************************************************************************/
|
**************************************************************************/
|
|
static int __neorv32_cpu_irq_id_check(uint8_t irq_sel);
|
static uint32_t __neorv32_cpu_pmp_cfg_read(uint32_t index);
|
static uint32_t __neorv32_cpu_pmp_cfg_read(uint32_t index);
|
static void __neorv32_cpu_pmp_cfg_write(uint32_t index, uint32_t data);
|
static void __neorv32_cpu_pmp_cfg_write(uint32_t index, uint32_t data);
|
|
|
|
|
/**********************************************************************//**
|
/**********************************************************************//**
|
|
* Private function: Check IRQ id.
|
|
*
|
|
* @param[in] irq_sel CPU interrupt select. See #NEORV32_CSR_MIE_enum.
|
|
* @return 0 if success, 1 if error (invalid irq_sel).
|
|
**************************************************************************/
|
|
static int __neorv32_cpu_irq_id_check(uint8_t irq_sel) {
|
|
|
|
if ((irq_sel == CSR_MIE_MSIE) || (irq_sel == CSR_MIE_MTIE) || (irq_sel == CSR_MIE_MEIE) ||
|
|
(irq_sel == CSR_MIE_FIRQ0E) || (irq_sel == CSR_MIE_FIRQ1E) || (irq_sel == CSR_MIE_FIRQ2E) || (irq_sel == CSR_MIE_FIRQ3E) ||
|
|
(irq_sel == CSR_MIE_FIRQ4E) || (irq_sel == CSR_MIE_FIRQ5E) || (irq_sel == CSR_MIE_FIRQ6E) || (irq_sel == CSR_MIE_FIRQ7E)) {
|
|
return 0;
|
|
}
|
|
else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
/**********************************************************************//**
|
* Enable specific CPU interrupt.
|
* Enable specific CPU interrupt.
|
*
|
*
|
* @note Interrupts have to be globally enabled via neorv32_cpu_eint(void), too.
|
* @note Interrupts have to be globally enabled via neorv32_cpu_eint(void), too.
|
*
|
*
|
* @param[in] irq_sel CPU interrupt select. See #NEORV32_CSR_MIE_enum.
|
* @param[in] irq_sel CPU interrupt select. See #NEORV32_CSR_MIE_enum.
|
* @return 0 if success, 1 if error (invalid irq_sel).
|
* @return 0 if success, 1 if error (invalid irq_sel).
|
**************************************************************************/
|
**************************************************************************/
|
int neorv32_cpu_irq_enable(uint8_t irq_sel) {
|
int neorv32_cpu_irq_enable(uint8_t irq_sel) {
|
|
|
if ((irq_sel != CSR_MIE_MSIE) && (irq_sel != CSR_MIE_MTIE) && (irq_sel != CSR_MIE_MEIE) &&
|
// check IRQ id
|
(irq_sel != CSR_MIE_FIRQ0E) && (irq_sel != CSR_MIE_FIRQ1E) && (irq_sel != CSR_MIE_FIRQ2E) && (irq_sel != CSR_MIE_FIRQ3E)) {
|
if (__neorv32_cpu_irq_id_check(irq_sel)) {
|
return 1;
|
return 1;
|
}
|
}
|
|
|
register uint32_t mask = (uint32_t)(1 << irq_sel);
|
register uint32_t mask = (uint32_t)(1 << irq_sel);
|
asm volatile ("csrrs zero, mie, %0" : : "r" (mask));
|
asm volatile ("csrrs zero, mie, %0" : : "r" (mask));
|
Line 78... |
Line 98... |
* @param[in] irq_sel CPU interrupt select. See #NEORV32_CSR_MIE_enum.
|
* @param[in] irq_sel CPU interrupt select. See #NEORV32_CSR_MIE_enum.
|
* @return 0 if success, 1 if error (invalid irq_sel).
|
* @return 0 if success, 1 if error (invalid irq_sel).
|
**************************************************************************/
|
**************************************************************************/
|
int neorv32_cpu_irq_disable(uint8_t irq_sel) {
|
int neorv32_cpu_irq_disable(uint8_t irq_sel) {
|
|
|
if ((irq_sel != CSR_MIE_MSIE) && (irq_sel != CSR_MIE_MTIE) && (irq_sel != CSR_MIE_MEIE) &&
|
// check IRQ id
|
(irq_sel != CSR_MIE_FIRQ0E) && (irq_sel != CSR_MIE_FIRQ1E) && (irq_sel != CSR_MIE_FIRQ2E) && (irq_sel != CSR_MIE_FIRQ3E)) {
|
if (__neorv32_cpu_irq_id_check(irq_sel)) {
|
return 1;
|
return 1;
|
}
|
}
|
|
|
register uint32_t mask = (uint32_t)(1 << irq_sel);
|
register uint32_t mask = (uint32_t)(1 << irq_sel);
|
asm volatile ("csrrc zero, mie, %0" : : "r" (mask));
|
asm volatile ("csrrc zero, mie, %0" : : "r" (mask));
|