diff --git a/mcux/mcux-sdk/drivers/irqsteer/fsl_irqsteer.c b/mcux/mcux-sdk/drivers/irqsteer/fsl_irqsteer.c index 08bbc1fc1..caf7f9eea 100644 --- a/mcux/mcux-sdk/drivers/irqsteer/fsl_irqsteer.c +++ b/mcux/mcux-sdk/drivers/irqsteer/fsl_irqsteer.c @@ -168,15 +168,16 @@ uint32_t IRQSTEER_GetMasterIrqCount(IRQSTEER_Type *base, irqsteer_int_master_t i return count; } -static uint32_t IRQSTEER_GetRegIndex(irqsteer_int_master_t intMasterIndex, uint32_t slice) +static uint32_t IRQSTEER_GetRegIndex(irqsteer_int_master_t intMasterIndex, + uint32_t slice, uint32_t sliceNum) { uint32_t base = FSL_FEATURE_IRQSTEER_CHn_MASK_COUNT - 1 - intMasterIndex * 2; if (FSL_FEATURE_IRQSTEER_CHn_MASK_COUNT % 2) { - return base + slice; - } else { - return base - slice; + base += sliceNum - 1; } + + return base - slice; } /*! @@ -225,7 +226,7 @@ IRQn_Type IRQSTEER_GetMasterNextInterrupt(IRQSTEER_Type *base, irqsteer_int_mast bitOffset = 0; /* compute the index of the register to be queried */ - regIndex = IRQSTEER_GetRegIndex(intMasterIndex, i); + regIndex = IRQSTEER_GetRegIndex(intMasterIndex, i, sliceNum + 1); /* get register's value */ chanStatus = base->CHn_STATUS[regIndex]; @@ -255,7 +256,7 @@ uint64_t IRQSTEER_GetMasterInterruptsStatus(IRQSTEER_Type *base, irqsteer_int_ma sliceNum = IRQSTEER_GetMasterIrqCount(base, intMasterIndex) / 32 - 1; for (i = 0; i <= sliceNum; i++) { - regIndex = IRQSTEER_GetRegIndex(intMasterIndex, i); + regIndex = IRQSTEER_GetRegIndex(intMasterIndex, i, sliceNum + 1); chanStatus = base->CHn_STATUS[regIndex];