/**
*   @copyright       © 2026 Microchip Technology Inc.
    Microchip Technology Inc. and its subsidiaries. You may use this
    software and any derivatives exclusively with Microchip products.

    THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
    EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
    WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
    PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
    WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.

    IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
    INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
    WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
    BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
    FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
    ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
    THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.

    MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
    TERMS. 
*
*************************************************************************/

/*************************************************************************
 *  @file           diag_interrupt.h
 *  @version       	1.0
 *  @brief     		This file has the declarations for the INTERRUPT Diagnostic functions
 *************************************************************************/

/**
 * @defgroup functions Functions
 * @defgroup macros Macros
 * @defgroup errorcodes ErrorCodes
 * @defgroup enums Enums
*/
 
#ifndef DIAG_INTERRUPT_H
#define DIAG_INTERRUPT_H

#include <stdint.h>
#include <stddef.h>
#include "diag.h"

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IVTCIF
 * @brief Interrupt Vector Table Configuration Interrupt Flag.
 */
#define DIAG_INTERRUPT_IVTCIF        0U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CPUFPUIF
 * @brief CPU Floating Point Unit Interrupt Flag.
 */
#define DIAG_INTERRUPT_CPUFPUIF     1U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_XRAMECCIF
 * @brief XRAM ECC Interrupt Flag.
 */
#define DIAG_INTERRUPT_XRAMECCIF     2U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_YRAMECCIF
 * @brief YRAM ECC Interrupt Flag.
 */
#define DIAG_INTERRUPT_YRAMECCIF     3U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PBERRIF
 * @brief Peripheral Bus Error Interrupt Flag.
 */
#define DIAG_INTERRUPT_PBERRIF       4U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_NVMECCIF
 * @brief NVM ECC Interrupt Flag.
 */
#define DIAG_INTERRUPT_NVMECCIF      5U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_NVMIF
 * @brief NVM Interrupt Flag.
 */
#define DIAG_INTERRUPT_NVMIF         6U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_NVMCRCIF
 * @brief NVM CRC Interrupt Flag.
 */
#define DIAG_INTERRUPT_NVMCRCIF      7U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLKFAILIF
 * @brief Clock Failure Interrupt Flag.
 */
#define DIAG_INTERRUPT_CLKFAILIF     9U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLKERRIF
 * @brief Clock Error Interrupt Flag.
 */
#define DIAG_INTERRUPT_CLKERRIF      10U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C1FAIL1IF
 * @brief CAN1 Failure 1 Interrupt Flag.
 */
#define DIAG_INTERRUPT_C1FAIL1IF     11U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C1WARNIF
 * @brief CAN1 Warning Interrupt Flag.
 */
#define DIAG_INTERRUPT_C1WARNIF     12U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C1MONIF
 * @brief CAN1 Monitor Interrupt Flag.
 */
#define DIAG_INTERRUPT_C1MONIF     13U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C1RDYIF
 * @brief CAN1 Ready Interrupt Flag.
 */
#define DIAG_INTERRUPT_C1RDYIF     14U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C2FAILIF
 * @brief CAN2 Failure Interrupt Flag.
 */
#define DIAG_INTERRUPT_C2FAILIF     15U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C2WARNIF
 * @brief CAN2 Warning Interrupt Flag.
 */
#define DIAG_INTERRUPT_C2WARNIF    16U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C2MONIF
 * @brief CAN2 Monitor Interrupt Flag.
 */
#define DIAG_INTERRUPT_C2MONIF    17U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C2RDYIF
 * @brief CAN2 Ready Interrupt Flag.
 */
#define DIAG_INTERRUPT_C2RDYIF    18U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C3FAILIF
 * @brief CAN3 Failure Interrupt Flag.
 */
#define DIAG_INTERRUPT_C3FAILIF    19U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C3WARNIF
 * @brief CAN3 Warning Interrupt Flag.
 */
#define DIAG_INTERRUPT_C3WARNIF    20U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C3MONIF
 * @brief CAN3 Monitor Interrupt Flag.
 */
#define DIAG_INTERRUPT_C3MONIF    21U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C3RDYIF
 * @brief CAN3 Ready Interrupt Flag.
 */
#define DIAG_INTERRUPT_C3RDYIF    22U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C4FAILIF
 * @brief CAN4 Failure Interrupt Flag.
 */
#define DIAG_INTERRUPT_C4FAILIF    23U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C4WARNIF
 * @brief CAN4 Warning Interrupt Flag.
 */
#define DIAG_INTERRUPT_C4WARNIF    24U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C4MONIF
 * @brief CAN4 Monitor Interrupt Flag.
 */
#define DIAG_INTERRUPT_C4MONIF    25U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C4RDYIF
 * @brief CAN4 Ready Interrupt Flag.
 */
#define DIAG_INTERRUPT_C4RDYIF    26U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_WDTIF
 * @brief Watchdog Timer Interrupt Flag.
 */
#define DIAG_INTERRUPT_WDTIF    28U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CRYPT1IF
 * @brief Cryptographic Module 1 Interrupt Flag.
 */
/* CRYPTO modules not available on dsPIC33AK128MC106 - use SENT1/SENT2/CRC instead */
/* DIAG_INTERRUPT_CRYPT1IF replaced by DIAG_INTERRUPT_SENT1IF (105U) */
/* DIAG_INTERRUPT_CRYPT2IF replaced by DIAG_INTERRUPT_SENT2IF (107U) */
/* DIAG_INTERRUPT_CRYPT3IF replaced by DIAG_INTERRUPT_CRCIF (131U) */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CRYPT2IF
 * @brief Cryptographic Module 2 Interrupt Flag.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CRYPT3IF
 * @brief Cryptographic Module 3 Interrupt Flag.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_INT0IF
 * @brief External Interrupt 0 Flag.
 */
#define DIAG_INTERRUPT_INT0IF    33U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_INT1IF
 * @brief External Interrupt 1 Flag.
 */
#define DIAG_INTERRUPT_INT1IF    34U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_INT2IF
 * @brief External Interrupt 2 Flag.
 */
#define DIAG_INTERRUPT_INT2IF    35U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_INT3IF
 * @brief External Interrupt 3 Flag.
 */
#define DIAG_INTERRUPT_INT3IF    36U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_INT4IF
 * @brief External Interrupt 4 Flag.
 */
#define DIAG_INTERRUPT_INT4IF    37U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PEVTAIF
 * @brief Peripheral Event A Interrupt Flag.
 */
#define DIAG_INTERRUPT_PEVTAIF    38U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PEVTBIF
 * @brief Peripheral Event B Interrupt Flag.
 */
#define DIAG_INTERRUPT_PEVTBIF    39U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PEVTCIF
 * @brief Peripheral Event C Interrupt Flag.
 */
#define DIAG_INTERRUPT_PEVTCIF    40U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PEVTDIF
 * @brief Peripheral Event D Interrupt Flag.
 */
#define DIAG_INTERRUPT_PEVTDIF    41U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PEVTEIF
 * @brief Peripheral Event E Interrupt Flag.
 */
#define DIAG_INTERRUPT_PEVTEIF    42U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PEVTFIF
 * @brief Peripheral Event F Interrupt Flag.
 */
#define DIAG_INTERRUPT_PEVTFIF    43U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PWM1IF
 * @brief PWM1 Interrupt Flag.
 */
#define DIAG_INTERRUPT_PWM1IF    44U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PWM2IF
 * @brief PWM2 Interrupt Flag.
 */
#define DIAG_INTERRUPT_PWM2IF    45U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PWM3IF
 * @brief PWM3 Interrupt Flag.
 */
#define DIAG_INTERRUPT_PWM3IF    46U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PWM4IF
 * @brief PWM4 Interrupt Flag.
 */
#define DIAG_INTERRUPT_PWM4IF    47U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_T1IF
 * @brief Timer 1 Interrupt Flag.
 */
#define DIAG_INTERRUPT_T1IF    48U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_T2IF
 * @brief Timer 2 Interrupt Flag.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_T3IF
 * @brief Timer 3 Interrupt Flag.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCT1IF
 * @brief Capture/Compare Timer 1 Interrupt Flag.
 */
#define DIAG_INTERRUPT_CCT1IF    49U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCP1IF
 * @brief Capture/Compare 1 Interrupt Flag.
 */
#define DIAG_INTERRUPT_CCP1IF    50U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCT2IF
 * @brief Capture/Compare Timer 2 Interrupt Flag.
 */
#define DIAG_INTERRUPT_CCT2IF    51U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCP2IF
 * @brief Capture/Compare 2 Interrupt Flag.
 */
#define DIAG_INTERRUPT_CCP2IF    52U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCT3IF
 * @brief Capture/Compare Timer 3 Interrupt Flag.
 */
#define DIAG_INTERRUPT_CCT3IF    53U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCP3IF
 * @brief Capture/Compare 3 Interrupt Flag.
 */
#define DIAG_INTERRUPT_CCP3IF    54U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCT4IF
 * @brief Capture/Compare Timer 4 Interrupt Flag.
 */
#define DIAG_INTERRUPT_CCT4IF    55U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCP4IF
 * @brief Capture/Compare 4 Interrupt Flag.
 */
#define DIAG_INTERRUPT_CCP4IF    56U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C1RXIF
 * @brief CAN1 Receive Interrupt Flag.
 */
/* C1RXIF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C1TXIF
 * @brief CAN1 Transmit Interrupt Flag.
 */
/* C1TXIF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C1IF
 * @brief CAN1 Interrupt Flag.
 */
/* C1IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C2RXIF
 * @brief CAN2 Receive Interrupt Flag.
 */
/* C2RXIF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C2TXIF
 * @brief CAN2 Transmit Interrupt Flag.
 */
/* C2TXIF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_C2IF
 * @brief CAN2 Interrupt Flag.
 */
/* C2IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SPI1RXIF
 * @brief SPI1 Receive Interrupt Flag.
 */
#define DIAG_INTERRUPT_SPI1RXIF    63U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SPI1TXIF
 * @brief SPI1 Transmit Interrupt Flag.
 */
#define DIAG_INTERRUPT_SPI1TXIF    64U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SPI1EIF
 * @brief SPI1 Error Interrupt Flag.
 */
#define DIAG_INTERRUPT_SPI1EIF    65U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SPI2RXIF
 * @brief SPI2 Receive Interrupt Flag.
 */
#define DIAG_INTERRUPT_SPI2RXIF    66U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SPI2TXIF
 * @brief SPI2 Transmit Interrupt Flag.
 */
#define DIAG_INTERRUPT_SPI2TXIF    67U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SPI2EIF
 * @brief SPI2 Error Interrupt Flag.
 */
#define DIAG_INTERRUPT_SPI2EIF    68U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SPI3RXIF
 * @brief SPI3 Receive Interrupt Flag.
 */
#define DIAG_INTERRUPT_SPI3RXIF    69U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SPI3TXIF
 * @brief SPI3 Transmit Interrupt Flag.
 */
#define DIAG_INTERRUPT_SPI3TXIF    70U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SPI3EIF
 * @brief SPI3 Error Interrupt Flag.
 */
#define DIAG_INTERRUPT_SPI3EIF    71U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SPI4RXIF
 * @brief SPI4 Receive Interrupt Flag.
 */
/* SPI4 not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SPI4TXIF
 * @brief SPI4 Transmit Interrupt Flag.
 */
/* SPI4TXIF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SPI4EIF
 * @brief SPI4 Error Interrupt Flag.
 */
/* SPI4EIF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_DMA0IF
 * @brief DMA Channel 0 Interrupt Flag.
 */
#define DIAG_INTERRUPT_DMA0IF    72U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_DMA1IF
 * @brief DMA Channel 1 Interrupt Flag.
 */
#define DIAG_INTERRUPT_DMA1IF    73U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_DMA2IF
 * @brief DMA Channel 2 Interrupt Flag.
 */
#define DIAG_INTERRUPT_DMA2IF    74U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_DMA3IF
 * @brief DMA Channel 3 Interrupt Flag.
 */
#define DIAG_INTERRUPT_DMA3IF    75U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CMP1IF
 * @brief Comparator 1 Interrupt Flag.
 */
#define DIAG_INTERRUPT_CMP1IF    76U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CMP2IF
 * @brief Comparator 2 Interrupt Flag.
 */
#define DIAG_INTERRUPT_CMP2IF    77U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CMP3IF
 * @brief Comparator 3 Interrupt Flag.
 */
#define DIAG_INTERRUPT_CMP3IF    78U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CMP4IF
 * @brief Comparator 4 Interrupt Flag.
 */
/* CMP4IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_I2C1EIF
 * @brief I2C1 Error Interrupt Flag.
 */
#define DIAG_INTERRUPT_I2C1EIF    80U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_I2C1IF
 * @brief I2C1 Interrupt Flag.
 */
#define DIAG_INTERRUPT_I2C1IF    81U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_I2C1RXIF
 * @brief I2C1 Receive Interrupt Flag.
 */
#define DIAG_INTERRUPT_I2C1RXIF    82U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_I2C1TXIF
 * @brief I2C1 Transmit Interrupt Flag.
 */
#define DIAG_INTERRUPT_I2C1TXIF    83U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_I2C2EIF
 * @brief I2C2 Error Interrupt Flag.
 */
#define DIAG_INTERRUPT_I2C2EIF    84U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_I2C2IF
 * @brief I2C2 Interrupt Flag.
 */
#define DIAG_INTERRUPT_I2C2IF    85U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_I2C2RXIF
 * @brief I2C2 Receive Interrupt Flag.
 */
#define DIAG_INTERRUPT_I2C2RXIF    86U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_I2C2TXIF
 * @brief I2C2 Transmit Interrupt Flag.
 */
#define DIAG_INTERRUPT_I2C2TXIF    87U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_I2C3IF
 * @brief I2C3 Interrupt Flag.
 */
/* I2C3 not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_I2C3EIF
 * @brief I2C3 Error Interrupt Flag.
 */
/* I2C3EIF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_I2C3RXIF
 * @brief I2C3 Receive Interrupt Flag.
 */
/* I2C3RXIF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_I2C3TXIF
 * @brief I2C3 Transmit Interrupt Flag.
 */
/* I2C3TXIF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_U1RXIF
 * @brief UART1 Receive Interrupt Flag.
 */
#define DIAG_INTERRUPT_U1RXIF    89U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_U1TXIF
 * @brief UART1 Transmit Interrupt Flag.
 */
#define DIAG_INTERRUPT_U1TXIF    90U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_U1EIF
 * @brief UART1 Error Interrupt Flag.
 */
#define DIAG_INTERRUPT_U1EIF    91U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_U1EVTIF
 * @brief UART1 Event Interrupt Flag.
 */
#define DIAG_INTERRUPT_U1EVTIF    92U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_U2RXIF
 * @brief UART2 Receive Interrupt Flag.
 */
#define DIAG_INTERRUPT_U2RXIF    93U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_U2TXIF
 * @brief UART2 Transmit Interrupt Flag.
 */
#define DIAG_INTERRUPT_U2TXIF    94U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_U2EIF
 * @brief UART2 Error Interrupt Flag.
 */
#define DIAG_INTERRUPT_U2EIF    95U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_U2EVTIF
 * @brief UART2 Event Interrupt Flag.
 */
#define DIAG_INTERRUPT_U2EVTIF    96U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_U3RXIF
 * @brief UART3 Receive Interrupt Flag.
 */
#define DIAG_INTERRUPT_U3RXIF    97U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_U3TXIF
 * @brief UART3 Transmit Interrupt Flag.
 */
#define DIAG_INTERRUPT_U3TXIF    98U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_U3EIF
 * @brief UART3 Error Interrupt Flag.
 */
#define DIAG_INTERRUPT_U3EIF    99U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_U3EVTIF
 * @brief UART3 Event Interrupt Flag.
 */
#define DIAG_INTERRUPT_U3EVTIF    100U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SENT1IF
 * @brief SENT1 Interrupt Flag.
 */
#define DIAG_INTERRUPT_SENT1IF    105U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SENT1EIF
 * @brief SENT1 Error Interrupt Flag.
 */
#define DIAG_INTERRUPT_SENT1EIF    106U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SENT2IF
 * @brief SENT2 Interrupt Flag.
 */
#define DIAG_INTERRUPT_SENT2IF    107U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_SENT2EIF
 * @brief SENT2 Error Interrupt Flag.
 */
#define DIAG_INTERRUPT_SENT2EIF    108U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_DMA4IF
 * @brief DMA Channel 4 Interrupt Flag.
 */
#define DIAG_INTERRUPT_DMA4IF    109U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_DMA5IF
 * @brief DMA Channel 5 Interrupt Flag.
 */
#define DIAG_INTERRUPT_DMA5IF    110U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_DMA6IF
 * @brief DMA Channel 6 Interrupt Flag.
 */
/* DMA6IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_DMA7IF
 * @brief DMA Channel 7 Interrupt Flag.
 */
/* DMA7IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CNAIF
 * @brief Change Notification A Interrupt Flag.
 */
#define DIAG_INTERRUPT_CNAIF    113U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CNBIF
 * @brief Change Notification B Interrupt Flag.
 */
#define DIAG_INTERRUPT_CNBIF    114U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CNCIF
 * @brief Change Notification C Interrupt Flag.
 */
#define DIAG_INTERRUPT_CNCIF    115U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CNDIF
 * @brief Change Notification D Interrupt Flag.
 */
#define DIAG_INTERRUPT_CNDIF    116U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCT5IF
 * @brief Capture/Compare Timer 5 Interrupt Flag.
 */
/* CCT5IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCP5IF
 * @brief Capture/Compare 5 Interrupt Flag.
 */
/* CCP5IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCT6IF
 * @brief Capture/Compare Timer 6 Interrupt Flag.
 */
/* CCT6IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCP6IF
 * @brief Capture/Compare 6 Interrupt Flag.
 */
/* CCP6IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCT7IF
 * @brief Capture/Compare Timer 7 Interrupt Flag.
 */
/* CCT7IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCP7IF
 * @brief Interrupt flag for CCP7.
 */
/* CCP7IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCT8IF
 * @brief Interrupt flag for CCT8.
 */
/* CCT8IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCP8IF
 * @brief Interrupt flag for CCP8.
 */
/* CCP8IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCT9IF
 * @brief Interrupt flag for CCT9.
 */
/* CCT9IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CCP9IF
 * @brief Interrupt flag for CCP9.
 */
/* CCP9IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_QEI1IF
 * @brief Interrupt flag for QEI1.
 */
#define DIAG_INTERRUPT_QEI1IF 125U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_QEI2IF
 * @brief Interrupt flag for QEI2.
 */
/* QEI2IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_QEI3IF
 * @brief Interrupt flag for QEI3.
 */
/* QEI3IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_QEI4IF
 * @brief Interrupt flag for QEI4.
 */
/* QEI4IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_BISS1EIF
 * @brief Interrupt flag for BISS1E.
 */
#define DIAG_INTERRUPT_BISS1EIF 129U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_BISS1IF
 * @brief Interrupt flag for BISS1.
 */
#define DIAG_INTERRUPT_BISS1IF 130U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CRCIF
 * @brief Interrupt flag for CRC.
 */
#define DIAG_INTERRUPT_CRCIF 131U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_ICDIF
 * @brief Interrupt flag for ICD.
 */
/* ICDIF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PTGSTEPIF
 * @brief Interrupt flag for PTGSTEP.
 */
#define DIAG_INTERRUPT_PTGSTEPIF 134U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PTGWDTIF
 * @brief Interrupt flag for PTGWDT.
 */
#define DIAG_INTERRUPT_PTGWDTIF 135U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PTG0IF
 * @brief Interrupt flag for PTG0.
 */
#define DIAG_INTERRUPT_PTG0IF 136U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PTG1IF
 * @brief Interrupt flag for PTG1.
 */
#define DIAG_INTERRUPT_PTG1IF 137U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PTG2IF
 * @brief Interrupt flag for PTG2.
 */
#define DIAG_INTERRUPT_PTG2IF 138U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PTG3IF
 * @brief Interrupt flag for PTG3.
 */
#define DIAG_INTERRUPT_PTG3IF 139U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PWM5IF
 * @brief Interrupt flag for PWM5.
 */
/* PWM5IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PWM6IF
 * @brief Interrupt flag for PWM6.
 */
/* PWM6IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PWM7IF
 * @brief Interrupt flag for PWM7.
 */
/* PWM7IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_PWM8IF
 * @brief Interrupt flag for PWM8.
 */
/* PWM8IF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CH0IF
 * @brief Interrupt flag for AD1CH0.
 */
#define DIAG_INTERRUPT_AD1CH0IF 146U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CMP0IF
 * @brief Interrupt flag for AD1CMP0.
 */
#define DIAG_INTERRUPT_AD1CMP0IF 147U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CH1IF
 * @brief Interrupt flag for AD1CH1.
 */
#define DIAG_INTERRUPT_AD1CH1IF 148U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CMP1IF
 * @brief Interrupt flag for AD1CMP1.
 */
#define DIAG_INTERRUPT_AD1CMP1IF 149U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CH2IF
 * @brief Interrupt flag for AD1CH2.
 */
#define DIAG_INTERRUPT_AD1CH2IF 150U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CMP2IF
 * @brief Interrupt flag for AD1CMP2.
 */
#define DIAG_INTERRUPT_AD1CMP2IF 151U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CH3IF
 * @brief Interrupt flag for AD1CH3.
 */
#define DIAG_INTERRUPT_AD1CH3IF 152U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CMP3IF
 * @brief Interrupt flag for AD1CMP3.
 */
#define DIAG_INTERRUPT_AD1CMP3IF 153U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CH4IF
 * @brief Interrupt flag for AD1CH4.
 */
#define DIAG_INTERRUPT_AD1CH4IF 154U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CMP4IF
 * @brief Interrupt flag for AD1CMP4.
 */
#define DIAG_INTERRUPT_AD1CMP4IF 155U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CH5IF
 * @brief Interrupt flag for AD1CH5.
 */
#define DIAG_INTERRUPT_AD1CH5IF 156U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CMP5IF
 * @brief Interrupt flag for AD1CMP5.
 */
#define DIAG_INTERRUPT_AD1CMP5IF 157U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CH6IF
 * @brief Interrupt flag for AD1CH6.
 */
#define DIAG_INTERRUPT_AD1CH6IF 158U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CMP6IF
 * @brief Interrupt flag for AD1CMP6.
 */
#define DIAG_INTERRUPT_AD1CMP6IF 159U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CH7IF
 * @brief Interrupt flag for AD1CH7.
 */
#define DIAG_INTERRUPT_AD1CH7IF 160U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD1CMP7IF
 * @brief Interrupt flag for AD1CMP7.
 */
#define DIAG_INTERRUPT_AD1CMP7IF 161U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CH0IF
 * @brief Interrupt flag for AD2CH0.
 */
#define DIAG_INTERRUPT_AD2CH0IF 188U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CMP0IF
 * @brief Interrupt flag for AD2CMP0.
 */
#define DIAG_INTERRUPT_AD2CMP0IF 189U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CH1IF
 * @brief Interrupt flag for AD2CH1.
 */
#define DIAG_INTERRUPT_AD2CH1IF 190U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CMP1IF
 * @brief Interrupt flag for AD2CMP1.
 */
#define DIAG_INTERRUPT_AD2CMP1IF 191U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CH2IF
 * @brief Interrupt flag for AD2CH2.
 */
#define DIAG_INTERRUPT_AD2CH2IF 192U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CMP2IF
 * @brief Interrupt flag for AD2CMP2.
 */
#define DIAG_INTERRUPT_AD2CMP2IF 193U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CH3IF
 * @brief Interrupt flag for AD2CH3.
 */
#define DIAG_INTERRUPT_AD2CH3IF 194U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CMP3IF
 * @brief Interrupt flag for AD2CMP3.
 */
#define DIAG_INTERRUPT_AD2CMP3IF 195U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CH4IF
 * @brief Interrupt flag for AD2CH4.
 */
#define DIAG_INTERRUPT_AD2CH4IF 196U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CMP4IF
 * @brief Interrupt flag for AD2CMP4.
 */
#define DIAG_INTERRUPT_AD2CMP4IF 197U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CH5IF
 * @brief Interrupt flag for AD2CH5.
 */
#define DIAG_INTERRUPT_AD2CH5IF 198U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CMP5IF
 * @brief Interrupt flag for AD2CMP5.
 */
#define DIAG_INTERRUPT_AD2CMP5IF 199U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CH6IF
 * @brief Interrupt flag for AD2CH6.
 */
#define DIAG_INTERRUPT_AD2CH6IF 200U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CMP6IF
 * @brief Interrupt flag for AD2CMP6.
 */
#define DIAG_INTERRUPT_AD2CMP6IF 201U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CH7IF
 * @brief Interrupt flag for AD2CH7.
 */
#define DIAG_INTERRUPT_AD2CH7IF 202U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD2CMP7IF
 * @brief Interrupt flag for AD2CMP7.
 */
#define DIAG_INTERRUPT_AD2CMP7IF 203U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CH0IF
 * @brief Interrupt flag for AD3CH0.
 */
/* AD3 not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CMP0IF
 * @brief Interrupt flag for AD3CMP0.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CH1IF
 * @brief Interrupt flag for AD3CH1.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CMP1IF
 * @brief Interrupt flag for AD3CMP1.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CH2IF
 * @brief Interrupt flag for AD3CH2.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CMP2IF
 * @brief Interrupt flag for AD3CMP2.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CH3IF
 * @brief Interrupt flag for AD3CH3.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CMP3IF
 * @brief Interrupt flag for AD3CMP3.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CH4IF
 * @brief Interrupt flag for AD3CH4.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CMP4IF
 * @brief Interrupt flag for AD3CMP4.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CH5IF
 * @brief Interrupt flag for AD3CH5.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CMP5IF
 * @brief Interrupt flag for AD3CMP5.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CH6IF
 * @brief Interrupt flag for AD3CH6.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CMP6IF
 * @brief Interrupt flag for AD3CMP6.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CH7IF
 * @brief Interrupt flag for AD3CH7.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD3CMP7IF
 * @brief Interrupt flag for AD3CMP7.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CH0IF
 * @brief Interrupt flag for AD4CH0.
 */
/* AD4 not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CMP0IF
 * @brief Interrupt flag for AD4CMP0.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CH1IF
 * @brief Interrupt flag for AD4CH1.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CMP1IF
 * @brief Interrupt flag for AD4CMP1.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CH2IF
 * @brief Interrupt flag for AD4CH2.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CMP2IF
 * @brief Interrupt flag for AD4CMP2.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CH3IF
 * @brief Interrupt flag for AD4CH3.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CMP3IF
 * @brief Interrupt flag for AD4CMP3.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CH4IF
 * @brief Interrupt flag for AD4CH4.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CMP4IF
 * @brief Interrupt flag for AD4CMP4.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CH5IF
 * @brief Interrupt flag for AD4CH5.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CMP5IF
 * @brief Interrupt flag for AD4CMP5.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CH6IF
 * @brief Interrupt flag for AD4CH6.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CMP6IF
 * @brief Interrupt flag for AD4CMP6.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CH7IF
 * @brief Interrupt flag for AD4CH7.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD4CMP7IF
 * @brief Interrupt flag for AD4CMP7.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH0IF
 * @brief Interrupt flag for AD5CH0.
 */
/* AD5 not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP0IF
 * @brief Interrupt flag for AD5CMP0.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH1IF
 * @brief Interrupt flag for AD5CH1.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP1IF
 * @brief Interrupt flag for AD5CMP1.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH2IF
 * @brief Interrupt flag for AD5CH2.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP2IF
 * @brief Interrupt flag for AD5CMP2.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH3IF
 * @brief Interrupt flag for AD5CH3.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP3IF
 * @brief Interrupt flag for AD5CMP3.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH4IF
 * @brief Interrupt flag for AD5CH4.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP4IF
 * @brief Interrupt flag for AD5CMP4.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH5IF
 * @brief Interrupt flag for AD5CH5.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP5IF
 * @brief Interrupt flag for AD5CMP5.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH6IF
 * @brief Interrupt flag for AD5CH6.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP6IF
 * @brief Interrupt flag for AD5CMP6.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH7IF
 * @brief Interrupt flag for AD5CH7.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP7IF
 * @brief Interrupt flag for AD5CMP7.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH8IF
 * @brief Interrupt flag for AD5CH8.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP8IF
 * @brief Interrupt flag for AD5CMP8.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH9IF
 * @brief Interrupt flag for AD5CH9.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP9IF
 * @brief Interrupt flag for AD5CMP9.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH10IF
 * @brief Interrupt flag for AD5CH10.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP10IF
 * @brief Interrupt flag for AD5CMP10.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH11IF
 * @brief Interrupt flag for AD5CH11.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP11IF
 * @brief Interrupt flag for AD5CMP11.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH12IF
 * @brief Interrupt flag for AD5CH12.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP12IF
 * @brief Interrupt flag for AD5CMP12.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH13IF
 * @brief Interrupt flag for AD5CH13.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP13IF
 * @brief Interrupt flag for AD5CMP13.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH14IF
 * @brief Interrupt flag for AD5CH14.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP14IF
 * @brief Interrupt flag for AD5CMP14.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CH15IF
 * @brief Interrupt flag for AD5CH15.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_AD5CMP15IF
 * @brief Interrupt flag for AD5CMP15.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CMP5IF
 * @brief Interrupt flag for CMP5.
 */
/* CMP5-8 not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CMP6IF
 * @brief Interrupt flag for CMP6.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CMP7IF
 * @brief Interrupt flag for CMP7.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CMP8IF
 * @brief Interrupt flag for CMP8.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC1PIF
 * @brief Interrupt flag for CLC1P.
 */
#define DIAG_INTERRUPT_CLC1PIF 232U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC1NIF
 * @brief Interrupt flag for CLC1N.
 */
#define DIAG_INTERRUPT_CLC1NIF 233U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC2PIF
 * @brief Interrupt flag for CLC2P.
 */
#define INTERRUPRICT_CLC2PIF 279U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC2NIF
 * @brief Interrupt flag for CLC2N.
 */
#define DIAG_INTERRUPT_CLC2NIF 235U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC3PIF
 * @brief Interrupt flag for CLC3P.
 */
#define DIAG_INTERRUPT_CLC3PIF 236U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC3NIF
 * @brief Interrupt flag for CLC3N.
 */
#define DIAG_INTERRUPT_CLC3NIF 237U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC4PIF
 * @brief Interrupt flag for CLC4P.
 */
#define DIAG_INTERRUPT_CLC4PIF 238U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC4NIF
 * @brief Interrupt flag for CLC4N.
 */
#define DIAG_INTERRUPT_CLC4NIF 239U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC5PIF
 * @brief Interrupt flag for CLC5P.
 */
/* CLC5-10 not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC5NIF
 * @brief Interrupt flag for CLC5N.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC6PIF
 * @brief Interrupt flag for CLC6P.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC6NIF
 * @brief Interrupt flag for CLC6N.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC7PIF
 * @brief Interrupt flag for CLC7P.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC7NIF
 * @brief Interrupt flag for CLC7N.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC8PIF
 * @brief Interrupt flag for CLC8P.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC8NIF
 * @brief Interrupt flag for CLC8N.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC9PIF
 * @brief Interrupt flag for CLC9P.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC9NIF
 * @brief Interrupt flag for CLC9N.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC10PIF
 * @brief Interrupt flag for CLC10P.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CLC10NIF
 * @brief Interrupt flag for CLC10N.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CNEIF
 * @brief Interrupt flag for CNE.
 */
/* CNE-CNH not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CNFIF
 * @brief Interrupt flag for CNF.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CNGIF
 * @brief Interrupt flag for CNG.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_CNHIF
 * @brief Interrupt flag for CNH.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_ITCIF
 * @brief Interrupt flag for ITC.
 */
/* ITCIF not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM1IF
 * @brief Interrupt flag for IOM1.
 */
#define DIAG_INTERRUPT_IOM1IF 275U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM2IF
 * @brief Interrupt flag for IOM2.
 */
#define DIAG_INTERRUPT_IOM2IF 276U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM3IF
 * @brief Interrupt flag for IOM3.
 */
#define DIAG_INTERRUPT_IOM3IF 277U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM4IF
 * @brief Interrupt flag for IOM4.
 */
#define DIAG_INTERRUPT_IOM4IF 278U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM5IF
 * @brief Interrupt flag for IOM5.
 */
/* IOM5-16 not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM6IF
 * @brief Interrupt flag for IOM6.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM7IF
 * @brief Interrupt flag for IOM7.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM8IF
 * @brief Interrupt flag for IOM8.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM9IF
 * @brief Interrupt flag for IOM9.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM10IF
 * @brief Interrupt flag for IOM10.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM11IF
 * @brief Interrupt flag for IOM11.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM12IF
 * @brief Interrupt flag for IOM12.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM13IF
 * @brief Interrupt flag for IOM13.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM14IF
 * @brief Interrupt flag for IOM14.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM15IF
 * @brief Interrupt flag for IOM15.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_IOM16IF
 * @brief Interrupt flag for IOM16.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_APWM1IF
 * @brief Interrupt flag for APWM1.
 */
/* APWM not available on dsPIC33AK128MC106 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_APWM2IF
 * @brief Interrupt flag for APWM2.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_APWM3IF
 * @brief Interrupt flag for APWM3.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_APWM4IF
 * @brief Interrupt flag for APWM4.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_APEVT1IF
 * @brief Interrupt flag for APEVT1.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_APEVT2IF
 * @brief Interrupt flag for APEVT2.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_APEVT3IF
 * @brief Interrupt flag for APEVT3.
 */

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_APEVT4IF
 * @brief Interrupt flag for APEVT4.
 */

/**
 * @ingroup macros
 * @def DIAG_INVALID_MODULE_ID
 * @brief Invalid module ID.
 */
#define DIAG_INVALID_MODULE_ID 0xFFFU

/**
 * @ingroup macros
 * @def DIAG_INVALID_MODULE_INDEX
 * @brief Invalid module index.
 */
#define DIAG_INVALID_MODULE_INDEX (DIAG_INVALID_MODULE_ID - 1U)





/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_EXTR_TEST_COMPLETED
 * @brief Diagnostic interrupt flag indicating that the external test has been completed.
 */
#define DIAG_INTERRUPT_EXTR_TEST_COMPLETED 0xAAAAAAAAU

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_EXTR_TEST_IN_PROGRESS
 * @brief Diagnostic interrupt flag indicating that the external test is in progress.
 */
#define DIAG_INTERRUPT_EXTR_TEST_IN_PROGRESS 0x55555555U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_ISR_BIT_CLEARED_TRUE
 * @brief Diagnostic interrupt isr bit clear true
 */
#define DIAG_INTERRUPT_ISR_BIT_CLEARED_TRUE 0x77777777U

/**
 * @ingroup macros
 * @def DIAG_INTERRUPT_ISR_BIT_CLEARED_FALSE
 * @brief Diagnostic interrupt isr bit clear false
 */
#define DIAG_INTERRUPT_ISR_BIT_CLEARED_FALSE 0x88888888U

/**
 * @ingroup enums
 * @enum DIAG_INTERRUPT_SERVICING_RUN_STATUS
 * @brief Enumeration for diagnostic interrupt servicing run status.
 *
 * This enumeration defines the possible states for diagnostic interrupt servicing.
 */
typedef enum
{
    INTR_SERVICING_DIAG_RUN_FALSE,
    INTR_SERVICING_DIAG_RUN_TRUE
}DIAG_INTERRUPT_SERVICING_RUN_STATUS;

/**
 * @ingroup enums
 * @enum DIAG_INTERRUPT_HARDTRAP_RUN_STATUS
 * @brief Enumeration for the diagnostic interrupt hard trap run status.
 * 
 * This enumeration defines the possible states for the diagnostic interrupt
 * hard trap run status.
 */
typedef enum
{
    INTR_HARDTRAP_DIAG_RUN_TRUE,
    INTR_HARDTRAP_DIAG_RUN_FALSE
}DIAG_INTERRUPT_HARDTRAP_RUN_STATUS;

/**
 * @ingroup enums
 * @enum DIAG_INTERRUPT_ISRCLEAREDCHECK_RUN_STATUS
 * @brief Enumeration for interrupt ISR cleared check run status.
 * 
 * This enumeration defines the possible statuses for checking if the ISR has been cleared.
 * 
 * @var DIAG_INTERRUPT_ISRCLEAREDCHECK_RUN_STATUS::INTR_ISR_CLEARED_CHECK_RUN_TRUE
 * Indicates that the ISR cleared check run status is true.
 * 
 * @var DIAG_INTERRUPT_ISRCLEAREDCHECK_RUN_STATUS::INTR_ISR_CLEARED_CHECK_RUN_FALSE
 * Indicates that the ISR cleared check run status is false.
 */
typedef enum
{
    INTR_ISR_CLEARED_CHECK_RUN_TRUE,
    INTR_ISR_CLEARED_CHECK_RUN_FALSE
}DIAG_INTERRUPT_ISRCLEAREDCHECK_RUN_STATUS;

/**
 * @ingroup enums
 * @enum DIAG_INTERRUPT_ISR_FLAG_CHECK_STATUS
 * @brief Enumeration for interrupt ISR flag check status.
 * 
 * This enum defines the possible statuses for the interrupt ISR flag check.
 * 
 * @var INTR_ISR_FLAG_CHECK_STATUS_NOT_COMPLETE
 * Status indicating that the interrupt ISR flag check is not complete.
 * 
 * @var INTR_ISR_FLAG_CHECK_STATUS_COMPLETE
 * Status indicating that the interrupt ISR flag check is complete.
 */
typedef enum
{
    INTR_ISR_FLAG_CHECK_STATUS_NOT_COMPLETE,
    INTR_ISR_FLAG_CHECK_STATUS_COMPLETE
}DIAG_INTERRUPT_ISR_FLAG_CHECK_STATUS;

/**
 * @ingroup enums
 * @enum DIAG_INTERRUPT_EXTERNAL_INTR_NUM
 * @brief Enumeration for external interrupt numbers.
 * 
 * This enum defines the possible external interrupt numbers.
 * 
 * @var EXTERNAL_INTERRUPT_0
 * External interrupt number 0.
 * 
 * @var EXTERNAL_INTERRUPT_1
 * External interrupt number 1.
 * 
 * @var EXTERNAL_INTERRUPT_2
 * External interrupt number 2.
 * 
 * @var EXTERNAL_INTERRUPT_3
 * External interrupt number 3.
 * 
 * @var EXTERNAL_INTERRUPT_4
 * External interrupt number 4.
 */
typedef enum
{
    EXTERNAL_INTERRUPT_0,
    EXTERNAL_INTERRUPT_1,
    EXTERNAL_INTERRUPT_2,
    EXTERNAL_INTERRUPT_3,
    EXTERNAL_INTERRUPT_4
}DIAG_INTERRUPT_EXTERNAL_INTR_NUM;

/*This enum values are set based on the value of corresponding polarity; 
 *POS_EDGE = 0, NEG_EDGE = 1*/

/**
 * @ingroup enums
 * @enum DIAG_INTERRUPT_POLARITY
 * @brief Enumeration for interrupt polarity.
 * 
 * This enum defines the possible polarities for interrupts.
 * 
 * @var INTERRUPT_ON_POSITIVE_EDGE
 * Interrupt triggered on the positive edge.
 * 
 * @var INTERRUPT_ON_NEGATIVE_EDGE
 * Interrupt triggered on the negative edge.
 */
typedef enum
{
    INTERRUPT_ON_POSITIVE_EDGE,
    INTERRUPT_ON_NEGATIVE_EDGE
}DIAG_INTERRUPT_POLARITY;

/**
 * @ingroup enums
 * @enum DIAG_INTERRUPT_FREQ_RUN_STATUS
 * @brief Enumeration for interrupt frequency diagnostic run status.
 * 
 * This enum defines the possible statuses for the interrupt frequency diagnostic run.
 * 
 * @var INTR_FREQ_DIAG_RUN_FALSE
 * Diagnostic run status is false.
 * 
 * @var INTR_FREQ_DIAG_RUN_TRUE
 * Diagnostic run status is true.
 */
typedef enum
{
    INTR_FREQ_DIAG_RUN_FALSE,
    INTR_FREQ_DIAG_RUN_TRUE        
}DIAG_INTERRUPT_FREQ_RUN_STATUS;

/**
 * @ingroup enums
 * @enum DIAG_INTERRUPT_EXT_INTR_RUN_STATUS
 * @brief Enumeration for external interrupt diagnostic run status.
 * 
 * This enum defines the possible statuses for the external interrupt diagnostic run.
 * 
 * @var INTR_EXT_DIAG_RUN_FALSE
 * Diagnostic run status is false.
 * 
 * @var INTR_EXT_DIAG_RUN_TRUE
 * Diagnostic run status is true.
 */
typedef enum
{
    INTR_EXT_DIAG_RUN_FALSE,
    INTR_EXT_DIAG_RUN_TRUE
}DIAG_INTERRUPT_EXT_INTR_RUN_STATUS;


/**
 * @ingroup enums
 * @enum DIAG_INTERRUPT_IRQ_STATUS
 * @brief Enumeration for interrupt IRQ status.
 * 
 * This enum defines the possible statuses for the interrupt IRQ.
 * 
 * @var MODULE_FREQ_TEST_PASSED
 * The frequency test has passed.
 * 
 * @var MODULE_FREQ_TEST_IN_PROGRESS
 * The frequency test is in progress.
 * 
 * @var MODULE_FREQ_TEST_FAILED
 * The frequency test has failed.
 */
typedef enum
{
    MODULE_FREQ_TEST_PASSED = 0,
    MODULE_FREQ_TEST_IN_PROGRESS,
    MODULE_FREQ_TEST_FAILED            
}DIAG_INTERRUPT_IRQ_STATUS;

/**
 * @struct DIAG_INTERRUPT_IRQ_MODEL
 * @brief Structure for interrupt IRQ model.
 * 
 * This structure defines the model for interrupt IRQ, including various counters and status indicators.
 * 
 * @var DIAG_INTERRUPT_IRQ_MODEL::moduleIrq
 * The IRQ number for the module.
 * 
 * @var DIAG_INTERRUPT_IRQ_MODEL::moduleInterruptCounter
 * Counter for the number of interrupts that have occurred.
 * 
 * @var DIAG_INTERRUPT_IRQ_MODEL::moduleExpectedInterruptCount
 * Expected number of interrupts.
 * 
 * @var DIAG_INTERRUPT_IRQ_MODEL::moduleInterruptToleranceBand
 * Tolerance band for the interrupt count.
 * 
 * @var DIAG_INTERRUPT_IRQ_MODEL::moduleInterruptFTTI
 * First Time To Interrupt (FTTI) value.
 * 
 * @var DIAG_INTERRUPT_IRQ_MODEL::moduleInterruptFTTICounter
 * Counter for the FTTI.
 * 
 * @var DIAG_INTERRUPT_IRQ_MODEL::moduleIntrStatus
 * Status of the interrupt IRQ.
 */
typedef struct 
{
    uint32_t moduleIrq;
    int32_t moduleInterruptCounter;
    int32_t moduleExpectedInterruptCount;
    int32_t moduleInterruptToleranceBand;
    uint32_t moduleInterruptFTTI;
    uint32_t moduleInterruptFTTICounter;
    DIAG_INTERRUPT_IRQ_STATUS moduleIntrStatus;
}DIAG_INTERRUPT_IRQ_MODEL;

/**
 * @struct DIAG_INTERRUPT_MODULE_STATUS
 * @brief Structure for interrupt module status.
 * 
 * This structure defines the status of an interrupt module, including the IRQ number, interrupt status, and interrupt counter.
 * 
 * @var DIAG_INTERRUPT_MODULE_STATUS::IrqNumber
 * The IRQ number for the interrupt module.
 * 
 * @var DIAG_INTERRUPT_MODULE_STATUS::interruptStatus
 * The status of the interrupt.
 * 
 * @var DIAG_INTERRUPT_MODULE_STATUS::intrCounter
 * Counter for the number of interrupts.
 */
typedef struct
{
    uint32_t IrqNumber;
    DIAG_INTERRUPT_IRQ_STATUS interruptStatus;
    int32_t intrCounter;
}DIAG_INTERRUPT_MODULE_STATUS;

/**
 * @ingroup functions
 * @brief **Software Requirement Reference ID : SW_INTERRUPT_SERVICING_TEST_01**\n
 * Services the interrupt test by checking the interrupt request flag registers.
 * 
 * This function performs the servicing of the interrupt test by iterating through the interrupt request flag registers.
 * It checks if the interrupts supported by the device match the requested interrupts and calls other functions to check
 * and get the status of the interrupt flag registers.
 * 
 * @param intrReqFlagRegArr[] Array of interrupt request flag registers.
 * @return uint32_t The result of the interrupt servicing test.
 *         - DIAG_PASS: The test passed.
 *         - DIAG_FAIL: The test failed.
 * 
 * The function implementation details:
 * - Initializes the return value to a failure state.
 * - Sets the interrupt servicing check running status to true.
 * - Iterates through the interrupt request flag registers.
 * - Checks if the requested interrupts are supported by the device.
 * - If the requested interrupts are not supported, sets the temporary return value to an invalid parameter state and breaks the loop.
 * - If the requested interrupts are non-zero, calls the function to check the IFS register.
 * - Calls the function to get the status of the interrupt flag registers.
 * - Gets the final return value.
 * - Sets the interrupt servicing check running status to false.
 * - Returns the final result of the interrupt servicing test.
 * @par
   Imageref DIAG_INTERRUPT_ServicingTest_UML.svg "Interrupt Servicing Test Sequence Diagram"
   Imageref DIAG_INTERRUPT_ServicingTest_ActivityDiagram.svg "Interrupt Servicing Test Activity Diagram"
 */
uint32_t DIAG_INTERRUPT_ServicingTest(uint32_t intrReqFlagRegArr[]);

/**
 * @ingroup functions
 * @brief **Software Requirement Reference ID : SW_HARD_TRAP_TEST_01**
 * 
 * Performs a hard trap diagnostic test on the interrupt control register.
 * 
 * This function induces a software-generated hard trap and verifies if the interrupt
 * control register responds correctly. It sets a software trap bit, waits for the bit
 * to be cleared by the ISR, and checks the result.
 * 
 * @return uint32_t Status value indicating the result of the hard trap test.
 *         - DIAG_PASS: The test passed.
 *         - DIAG_FAIL: The test failed.
 * 
 * The function implementation details:
 * - Initializes the return value and timeout variable.
 * - Sets a pointer to the interrupt control register.
 * - Sets the `diagInduceHardTrap` flag to indicate the diagnostic test is running.
 * - Sets the software trap bit in the interrupt control register.
 * - Waits for the software trap bit to be cleared or for the timeout to occur.
 * - Checks if the loop exited because the software trap bit was cleared by the ISR.
 * - Sets the return value to `DIAG_PASS` if the bit was cleared, otherwise sets it to `DIAG_FAIL`.
 * - Retrieves the final return value using `DIAG_INTERRUPT_GetRetValue`.
 * - Returns the final status value.
 * @par
   Imageref DIAG_INTERRUPT_HardTrapTest_UML.svg "Interrupt Hard Trap test sequence diagram"
   Imageref DIAG_INTERRUPT_HardTrapTest_ActivityDiagram.svg "Interrupt Hard trap test activity diagram"
 */
uint32_t DIAG_INTERRUPT_HardTrapTest(void);

/**
 * @ingroup functions
 * @brief Resets the diagnostic induced trap status.
 *
 * This function sets the `diagInduceHardTrap` variable to `INTR_HARDTRAP_DIAG_RUN_FALSE`,
 * effectively resetting the diagnostic induced trap status.
 */
void DIAG_INTERRUPT_resetDiagInducedTrapStatus(void);

/**
 * @ingroup functions
 * @brief Checks if the hard trap was induced by diagnostics.
 * This function returns the status indicating whether the hard trap was induced by diagnostics.
 * @return The status of the diagnostic induced hard trap.
 *         - DIAG_PASS: The test passed.
 *         - DIAG_FAIL: The test failed.
 * @par
 */

DIAG_INTERRUPT_HARDTRAP_RUN_STATUS DIAG_INTERRUPT_isTrapInducedByDiag(void);

/**
 * @ingroup functions
 * @brief Checks if the IFS flag has been cleared from the ISR for the specified interrupt number.
 * 
 * This function verifies if the interrupt flag status (IFS) bit has been cleared for a given interrupt number
 * from within the interrupt service routine (ISR). It performs several checks and updates relevant status flags
 * based on the results.
 * 
 * @param[in] irqNum The interrupt number to be checked.
 * 
 * The function implementation details:
 * - Initializes the register index and bit position based on the interrupt number.
 * - Retrieves the interrupt control status register pointer and the IFS and IEC register pointers.
 * - Calculates the register index and bit position for the given interrupt number.
 * - Checks if the ISR cleared check is running.
 * - Compares the current interrupt vector number with the expected value.
 * - If the vector number does not match, sets the ISR cleared check status to not complete.
 * - If the vector number matches, checks if the corresponding IFS bit is cleared.
 * - If the IFS bit is cleared, sets the IFSBitCleared flag to 1.
 * - If the IFS bit is not cleared, sets the IFSBitCleared flag to 0 and clears the corresponding IEC bit.
 * - Sets the ISR cleared check status to complete.
 * - Resets the ISR cleared check flag to prevent repeated checks.
 */
void DIAG_INTERRUPT_IfsFlagClearedCheckFromIsr(uint16_t irqNum);

/**
 * @ingroup functions
 * @brief **Software Requirement Reference ID : SW_ISR_CLEARED_CHECK_01**\n
 * Checks if the ISR has been cleared for the specified interrupt number.
 * 
 * This function checks if the interrupt service routine (ISR) has been cleared for a given interrupt number.
 * It sets the ISR cleared check status to running, then enters a loop to wait for the ISR cleared check to complete
 * or for a timeout to occur. If the timeout occurs, it sets the return value to `DIAG_INVALID_PARAM`. If the check
 * completes, it sets the return value to `DIAG_PASS` if the interrupt flag status bit is cleared, or `DIAG_FAIL` otherwise.
 * 
 * @param[in] irqNum The interrupt number to be checked.
 * 
 * @return uint32_t Status value indicating the result of the ISR cleared check.
 *         - DIAG_PASS: The test passed.
 *         - DIAG_FAIL: The test failed.
 * 
 * The function implementation details:
 * - Initializes the timeout value to `ISR_CLEARED_CHECK_TIMEOUT`.
 * - Sets the ISR cleared check status to running.
 * - Enters a loop to wait for the ISR cleared check to complete or for the timeout to occur.
 * - If the timeout occurs, sets the return value to `DIAG_INVALID_PARAM`.
 * - If the check completes, sets the return value to `DIAG_PASS` if the interrupt flag status bit is cleared, or `DIAG_FAIL` otherwise.
 * - Retrieves the final return value using `DIAG_INTERRUPT_GetRetValue`.
 * - Returns the final status value.
 * @par 
   Imageref DIAG_INTERRUPT_IsrClearedCheck_UML.svg "Interrupt Isr Cleared Check Sequence Diagram"
   Imageref DIAG_INTERRUPT_IsrClearedCheck_ActivityDiagram.svg "Interrupt Isr Cleared Check Activity Diagram"
 */
uint32_t DIAG_INTERRUPT_IsrClearedCheck(uint16_t irqNum);

/**
 * @ingroup functions
 * @brief **Software Requirement Reference ID : SW_INTERRUPT_FREQUENCY_CHECK_01**\n
 * Performs a frequency check diagnostic test on interrupt modules.
 * 
 * This function checks the interrupt frequency for a given set of modules. It iterates through the 
 * module interrupt request (IRQ) structure to verify the interrupt counter status for each module 
 * involved in the frequency test. The function returns a status value indicating the result of the test.
 * 
 * @param[in] modulePtr Pointer to the structure containing module IRQ information.
 * @param[in] modulesForFreqCheck Number of modules to be checked for interrupt frequency.
 * 
 * @return uint32_t Status value indicating the result of the frequency check test.
 *         - DIAG_PASS: The test passed.
 *         - DIAG_FAIL: The test failed.
 * 
 * The function implementation details:
 * - Initializes the return value.
 * - Iterates through the module IRQ structure to check the interrupt counter status for each module.
 * - Skips modules that have been removed from the structure.
 * - Decrements the individual module interrupt frequency test counter.
 * - Calls `DIAG_INTERRUPT_CheckModuleInterruptCounter` to check the interrupt counter for each module.
 * - Resets the module index and checks if the API should return pass or fail.
 * - Sets the return value to `DIAG_FAIL` if any module fails the frequency test, otherwise sets it to `DIAG_PASS`.
 * - Retrieves the final return value using `DIAG_INTERRUPT_GetRetValue`.
 * - Returns the final status value.
 *	@par
	Imageref DIAG_INTERRUPT_FrequencyCheck_UML.svg "Interrupt Frequency Check Sequence Diagram"
	Imageref DIAG_INTERRUPT_FrequencyCheck_ActivityDiagram.svg "Interrupt Frequency Check Activity Diagram"
 */
uint32_t DIAG_INTERRUPT_FrequencyCheck(DIAG_INTERRUPT_IRQ_MODEL *modulePtr,uint32_t modulesForFreqCheck);

/**
 * @ingroup functions
 * @brief Retrieves the frequency test results for diagnostic interrupts.
 *
 * This function updates the interrupt status, IRQ number, and interrupt counter for each module
 * being monitored. It also increments the fail count for modules that have failed the frequency test.
 *
 * @param[out] failCount Pointer to the variable that will store the count of failed modules.
 * @param[out] IrqDataTable Pointer to the array that will store the interrupt status data for each module.
 * @param[in] modulePtr Pointer to the array of modules being monitored.
 * @param[in] size The number of modules in the modulePtr array.
 * @par
 */
void DIAG_INTERRUPT_GetFreqTestResults(uint32_t *failCount, DIAG_INTERRUPT_MODULE_STATUS *IrqDataTable,DIAG_INTERRUPT_IRQ_MODEL *modulePtr,uint32_t size);


/**
 * @ingroup functions
 * @brief Updates the ISR notifications for a specified interrupt.
 * 
 * This function updates the interrupt service routine (ISR) notifications for a given interrupt number.
 * It checks if the interrupt frequency test is running, scans through the interrupt module structure to 
 * find the module index, and updates the module interrupt counter if the module interrupt status is not failed.
 * 
 * @param[in] irqNum The interrupt number to be updated.
 * @param[in] modulePtr Pointer to the structure containing module interrupt information.
 * @param[in] modsize The size of the module interrupt structure.
 * 
 * The function implementation details:
 * - Retrieves the current diagnostic status of the interrupt frequency test.
 * - If the frequency test is running, it scans through the module structure to find the module index.
 * - If the module index is found, it updates the module interrupt counter if the module interrupt status is not failed.
 * - If the module index is not found, it sets the index to `INVALID_MODULE_INDEX`.
 * - The module interrupt model structure is updated only if the module interrupt status is `MODULE_FREQ_TEST_PASSED` 
 *   or `MODULE_FREQ_TEST_IN_PROGRESS`.
 * - If the module interrupt status is `MODULE_FREQ_TEST_FAILED`, the module interrupt counter is not updated.
 */
void DIAG_INTERRUPT_UpdateISRNotifications(uint32_t irqNum,DIAG_INTERRUPT_IRQ_MODEL *modulePtr, uint32_t modsize);

/**
 * @ingroup functions
 * @brief Starts the frequency test for diagnostic interrupts.
 *
 * This function sets the `intrFreqRunFlag` to `INTR_FREQ_DIAG_RUN_TRUE`,
 * indicating that the frequency test for diagnostic interrupts has started.
 */
void DIAG_INTERRUPT_StartFrequencyTest(void);

/**
 * @ingroup functions
 * @brief Stops the frequency test for diagnostic interrupts.
 *
 * This function sets the `intrFreqRunFlag` to `INTR_FREQ_DIAG_RUN_FALSE`,
 * indicating that the frequency test for diagnostic interrupts has stopped.
 */
void DIAG_INTERRUPT_StopFrequencyTest(void);


/**
 * @ingroup functions
 * @brief Checks if the interrupt servicing check is currently running.
 * This function returns the current status of the interrupt servicing check.
 * @return The status indicating whether the interrupt servicing check is running.
 *         - DIAG_PASS: The test passed.
 *         - DIAG_FAIL: The test failed.
 * @par
 */
DIAG_INTERRUPT_SERVICING_RUN_STATUS DIAG_INTERRUPT_IsInterruptServicingCheckRunning(void);

/**
 * @ingroup functions
 * @brief **Software Requirement Reference ID : SW_EXTERNAL_INTERRUPT_TEST_01**\n
 * Performs an external input test on the specified interrupt.
 * 
 * This function tests an external interrupt by triggering it and checking the result.
 * It sets the test status to in-progress, verifies the trigger function pointer, and
 * then calls the function to trigger and test the external interrupt.
 * 
 * @param[in] interruptNum The external interrupt number to be tested.
 * @param[in] interruptPol The polarity of the external interrupt.
 * @param[in] trigForInterrupt Pointer to the function that triggers the interrupt.
 * 
 * @return uint32_t Status value indicating the result of the external input test.
 *         - DIAG_PASS: The test passed.
 *         - DIAG_FAIL: The test failed.
 * 
 * The function implementation details:
 * - Sets the external interrupt test status to in-progress.
 * - Sets the running status flag to true.
 * - Checks if the trigger function pointer is NULL.
 * - If the trigger function pointer is NULL, sets the return value to `DIAG_INVALID_PARAM`.
 * - If the trigger function pointer is not NULL, calls `DIAG_INTERRUPT_TriggerAndTestExternalInterrupts` with the interrupt number, polarity, and trigger function.
 * - Retrieves the final return value using `DIAG_INTERRUPT_GetRetValue`.
 * - Sets the running status flag to false.
 * - Returns the final status value.
 * @par
   Imageref DIAG_INTERRUPT_ExternalInputTest_UML.svg "Interrupt external input test sequence diagram"
   Imageref DIAG_INTERRUPT_ExternalInputTest_ClassDiagram.svg "Interrupt external input test class diagram"
 */
uint32_t DIAG_INTERRUPT_ExternalInputTest(DIAG_INTERRUPT_EXTERNAL_INTR_NUM interruptNum, 
                                                                                DIAG_INTERRUPT_POLARITY interruptPol, 
                                                                                void (*trigForInterrupt)());

/**
 * @ingroup functions
 * @brief Sets the status of the external interrupt test.
 * This function updates the status of the external interrupt test by setting the
 * `extIntrTestCompleted` variable to the provided status.
 * @param[in] extIntrTestStatus The status to set for the external interrupt test.
 * @par
 */
void DIAG_INTERRUPT_ExternalSetIntrTestCompleted(uint32_t extIntrTestStatus);

/**
 * @ingroup functions
 * @brief Checks if the external interrupt test is running.
 * This function returns the current status of the external interrupt test.
 * @return The status indicating whether the external interrupt test is running.
 *         - DIAG_PASS: The test passed.
 *         - DIAG_FAIL: The test failed.
 * @par
 */
DIAG_INTERRUPT_EXT_INTR_RUN_STATUS DIAG_INTERRUPT_IsExtIntrTestRunning(void);

#endif //DIAG_INTERRUPT_H


