/*
* @file    Intm_Lld.h
*==================================================================================================
*   Project              : YTMicro AUTOSAR 4.4.0 MCAL
*   Platform             : ARM
*   Peripheral           : Intm_Lld
*   Dependencies         : none
*
*   Autosar Version      : V4.4.0
*   Autosar Revision     : ASR_REL_4_4_REV_0000
*   SW Version           : V0.8.0
*
*   (c) Copyright 2020-2026 Yuntu Microelectronics co.,ltd.
*   All Rights Reserved.
==================================================================================================*/

#ifndef INTM_LLD_H
#define INTM_LLD_H

#ifdef __cplusplus
extern "C" {
#endif

/*==================================================================================================
                                              INCLUDE FILES
==================================================================================================*/

#include "Intm_Lld_Cfg.h"
#include "Devassert.h"

/*==================================================================================================
                                      HEADER FILE VERSION INFORMATION
==================================================================================================*/
#define INTM_LLD_VENDOR_ID                      (180)
#define INTM_LLD_AR_RELEASE_MAJOR_VERSION       (4)
#define INTM_LLD_AR_RELEASE_MINOR_VERSION       (4)
#define INTM_LLD_AR_RELEASE_REVISION_VERSION    (0)
#define INTM_LLD_SW_MAJOR_VERSION               (0)
#define INTM_LLD_SW_MINOR_VERSION               (8)
#define INTM_LLD_SW_PATCH_VERSION               (0)
/*==================================================================================================
                                                DEFINES AND MACROS
==================================================================================================*/
/*==================================================================================================
                                                EXTERNAL CONSTANTS
==================================================================================================*/
/*==================================================================================================
                                                ENUMS
==================================================================================================*/
/*==================================================================================================
                                                FUNCTION PROTOTYPES
==================================================================================================*/

/**
 * @brief         Enables interrupt monitoring feature.
 *                This function enables all interrupt monitors in the
 *                system by setting the global enable bit in the INTM
 *                controller.
 * @autosar       N/A
 *
 * @details       Service ID: N/A
 *                Sync/Async: Synchronous
 *                Reentrancy: Non Reentrant
 *                Available via: Intm_Lld.h
 *
 * @return No return value.
 */
void Intm_Lld_EnableMonitor(void);

/**
 * @brief         Disables interrupt monitoring feature.
 *                This function disables all interrupt monitors in the
 *                system by clearing the global enable bit in the INTM
 *                controller.
 * @autosar       N/A
 *
 * @details       Service ID: N/A
 *                Sync/Async: Synchronous
 *                Reentrancy: Non Reentrant
 *                Available via: Intm_Lld.h
 *
 * @return No return value.
 */
void Intm_Lld_DisableMonitor(void);

/**
 * @brief         Acknowledges a monitored interrupt.
 *                This function acknowledges that a monitored interrupt
 *                has been served by writing the interrupt number to the
 *                INTM acknowledge register and then clearing it.
 * @autosar       N/A
 *
 * @details       Service ID: N/A
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Intm_Lld.h
 *
 * @param[in] IrqNumber The interrupt vector number to be acknowledged.
 * @return No return value.
 */
void Intm_Lld_AckIrq(IRQn_Type IrqNumber);

/**
 * @brief         Selects an interrupt to be monitored on a specific
 *                interrupt monitor.
 *                This function configures which interrupt vector will
 *                be monitored by the specified monitor channel.
 * @autosar       N/A
 *
 * @details       Service ID: N/A
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Intm_Lld.h
 *
 * @param[in] MonitorIdx The index or identifier of the interrupt monitor
 *                       channel to be configured.
 * @param[in] IrqNumber  The interrupt vector number to be monitored by
 *                       the specified monitor channel.
 * @return No return value.
 */
void Intm_Lld_SelectMonitoredIrq(Intm_Lld_MonitorType MonitorIdx, IRQn_Type IrqNumber);

/**
 * @brief         Sets the accepted latency threshold for a monitored
 *                interrupt.
 *                This function configures the maximum acceptable
 *                latency time (in clock cycles) for the monitored
 *                interrupt to be serviced before a timeout is detected.
 * @autosar       N/A
 *
 * @details       Service ID: N/A
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Intm_Lld.h
 *
 * @param[in] MonitorIdx The index or identifier of the interrupt monitor
 *                       channel for which the latency threshold is
 *                       configured.
 * @param[in] Latency    The accepted latency value in clock cycles.
 *                       This represents the maximum time allowed for
 *                       the monitored interrupt to be serviced.
 * @return No return value.
 */
void Intm_Lld_SetLatency(Intm_Lld_MonitorType MonitorIdx, uint32 Latency);

/**
 * @brief         Resets the timer for an interrupt monitor.
 *                This function clears the timer counter for the
 *                specified monitor channel, typically used after
 *                acknowledging an interrupt or when reinitializing
 *                monitoring.
 * @autosar       N/A
 *
 * @details       Service ID: N/A
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Intm_Lld.h
 *
 * @param[in] MonitorIdx The index or identifier of the interrupt monitor
 *                       channel whose timer will be reset.
 * @return No return value.
 */
void Intm_Lld_ResetTimer(Intm_Lld_MonitorType MonitorIdx);

/**
 * @brief         Returns the status of an interrupt monitor.
 *                This function reads the status register of the
 *                specified monitor channel to determine if the
 *                monitored interrupt has exceeded its latency threshold.
 * @autosar       N/A
 *
 * @details       Service ID: N/A
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Intm_Lld.h
 *
 * @param[in] MonitorIdx The index or identifier of the interrupt monitor
 *                       channel for which the status is queried.
 * @return uint8        Returns 0 if latency has not been exceeded
 *                       (timer is running normally); returns 1 if the
 *                       timer has exceeded the latency threshold,
 *                       indicating a potential issue.
 */
uint8 Intm_Lld_GetStatus(Intm_Lld_MonitorType MonitorIdx);

#ifdef __cplusplus
}
#endif

#endif /* End of file Intm_Lld.h */

