【简介】
S32K3 系列芯片中集成了 INTM 的IP 模块,该模块可以用来监测中断的响应时间,对应的IP的框图如下:

以下是INTM 模块的功能概述和配置流程说明。


结合以上的框图和功能描述可知,INTM 的使用也比较简单,只需要简单的配置几个寄存器通过INTM->IRQSELX 寄存器配置要监测的IRQ index 信息,选择好要监测的IRQ 信号后,通过INTM->LATENCYX 寄存器来配置允许的最大的中断延迟,当对应的IRQ 中断信号被拉起时INTM->TIMERX 开始计数,当中断函数响应的时候通过INTM->IACK 寄存器写1 停止INTM->TIMERX 的计数器,此时如果INTM->TIMERX 数值 大于INTM->IRQSELX 寄存器就会触发异常状态。
原理我们介绍的差不多了,我们在S32DS 的 config tool 中加载INTM IP 就会把对应的驱动程序加入到工程中。


更新代码后INTM 的驱动代码就被加入到工程中了。

以下是INTM 的驱动代码,从驱动代码配置也可以看出这个IP的功能还是很精简的没有复杂的寄存器配置,驱动接口只是对寄存器进行了一层封装。
**
* @brief Enables interrupt monitoring feature.
*
* @details This function is non-reentrant and enables the interrupt monitors.
*
* @return void
*
* @api
*
* @implements Intm_Ip_EnableMonitor_Activity
*
* */
static inline void Intm_Ip_EnableMonitor(void)
{
IP_INTM->INTM_MM |= INTM_INTM_MM_MM_MASK;
}
/**
* @brief Disables interrupt monitoring feature.
*
* @details This function is non-reentrant and disables the interrupt monitors.
*
* @return void
*
* @api
*
* @implements Intm_Ip_DisableMonitor_Activity
*
* */
static inline void Intm_Ip_DisableMonitor(void)
{
IP_INTM->INTM_MM &= ~(INTM_INTM_MM_MM_MASK);
}
/**
* @brief Acknowledges a monitored interrupt.
*
* @details This function is reentrant; it acknowledges that a monitored interrupt
* has been been served.
*
* @param[in] eIrqNumber: The interrupt vector acknowledged.
* @return void
*
* @api
*
* @implements Intm_Ip_AckIrq_Activity
*
* */
static inline void Intm_Ip_AckIrq(IRQn_Type eIrqNumber)
{
#if (INTM_IP_DEV_ERROR_DETECT == STD_ON)
sint32 s32DevIrqNumber = (sint32)eIrqNumber;
DevAssert((sint32)INTM_IP_MIN_IRQ <= s32DevIrqNumber);
DevAssert(s32DevIrqNumber <= (sint32)INTM_IP_MAX_IRQ);
#endif /*(INTM_IP_DEV_ERROR_DETECT == STD_ON) */
IP_INTM->INTM_IACK = ((uint32)eIrqNumber) & INTM_INTM_IACK_IRQ_MASK;
}
/**
* @brief Selects an interrupt to monitor.
*
* @details This function is reentrant; it selects which interrupt is monitored on
* a specific interrupt monitor.
*
* @param[in] eMonitorIdx: The index of the interrupt monitor used.
* @param[in] eIrqNumber: The interrupt vector to be monitored.
* @return void
*
* @api
*
* @implements Intm_Ip_SelectMonitoredIrq_Activity
*
* */
static inline void Intm_Ip_SelectMonitoredIrq(Intm_Ip_MonitorType eMonitorIdx, IRQn_Type eIrqNumber)
{
#if (INTM_IP_DEV_ERROR_DETECT == STD_ON)
sint32 s32DevIrqNumber = (sint32)eIrqNumber;
DevAssert((sint32)INTM_IP_MIN_IRQ <= s32DevIrqNumber);
DevAssert(s32DevIrqNumber <= (sint32)INTM_IP_MAX_IRQ);
#endif /*(INTM_IP_DEV_ERROR_DETECT == STD_ON) */
IP_INTM->MON[(uint8)eMonitorIdx].INTM_IRQSEL = ((uint32)eIrqNumber) & INTM_INTM_IRQSEL_IRQ_MASK;
}
/**
* @brief Sets the latency for a monitored interrupt.
*
* @details This function is reentrant; it sets the accepted latency for the
* monitored interrupt.
*
* @param[in] eMonitorIdx: The index of the interrupt monitor used.
* @param[in] u32Latency: The accepted latency for the monitored interrupt.
* @return void
*
* @api
*
* @implements Intm_Ip_SetLatency_Activity
*
* */
static inline void Intm_Ip_SetLatency(Intm_Ip_MonitorType eMonitorIdx, uint32 u32Latency)
{
IP_INTM->MON[(uint8)eMonitorIdx].INTM_LATENCY = (u32Latency & INTM_INTM_LATENCY_LAT_MASK);
}
/**
* @brief Resets the timer for an interrupt monitor.
*
* @details This function is reentrant; it resets the timer for the interrupt monitor.
*
* @param[in] eMonitorIdx: The index of the interrupt monitor used.
* @return void
*
* @api
*
* @implements Intm_Ip_ResetTimer_Activity
*
* */
static inline void Intm_Ip_ResetTimer(Intm_Ip_MonitorType eMonitorIdx)
{
IP_INTM->MON[(uint8)eMonitorIdx].INTM_TIMER = 0UL;
}
/**
* @brief Returns the status of an interrupt monitor.
*
* @details This function is reentrant; it returns the status of an interrupt monitor:
* 0 - latency not exceeded; 1 - timer exceeded latency.
*
* @param[in] eMonitorIdx: The index of the interrupt monitor used.
* @return uint8: 0 - latency not exceeded; 1 - timer exceeded latency.
*
* @api
*
* @implements Intm_Ip_GetStatus_Activity
*
* */
static inline uint8 Intm_Ip_GetStatus(Intm_Ip_MonitorType eMonitorIdx)
{
return (uint8)(IP_INTM->MON[(uint8)eMonitorIdx].INTM_STATUS & INTM_INTM_STATUS_STATUS_MASK);
}
我要赚赏金
