S32K344 STM&pit MCAL 回调调用过程

EB的配置

1,PLATFORM使能中断,并且配置文件已经定义好的中断处理函数(如ISR(PIT_0_ISR),ISR(STM_0_ISR))

2,配置MCU时钟,不理解(STM的时钟源是唯一的,mcu配置好后在gpt应该没必要配置了,但是可以通过mcu设置时钟源给不同定时器选,AIPS_SLOW_CLK是24M ,GPT可以给它选STM的时钟源48M,这就有点离谱)

3,定时到达后的回调

EB配置PIT0_CH0,STM_CH0来看回调的调用过程

初始化函数

Gpt_Init(&Gpt_Config_VS_0);
Gpt_StartTimer(GptConf_GptChannelConfiguration_GptChannelConfiguration_0, 240000000U);
Gpt_EnableNotification(GptConf_GptChannelConfiguration_GptChannelConfiguration_0);


Gpt_Init(&Gpt_Config_VS_0);分析

const Gpt_ConfigType Gpt_Config_VS_0 =
{
    /** @brief Number of GPT channels (configured in tresos plugin builder)*/
    (Gpt_ChannelType)2U,//两种定时器
    /** @brief Pointer to the GPT channel configuration */
    &Gpt_InitChannelPB_VS_0,//两个定时器的配置
    /** @brief Number of GPT instances (configured in tresos plugin builder)*/
    2U,//通道数PIT0_0,STM0_0
    /** @brief Pointer to the GPT instance configuration */
    &Gpt_Ipw_HwInstanceConfig_PB_VS_0,
    /** @brief channel index in each partition map table*/
    &u8GptChannelIdToIndexMap_VS_0
};

 Gpt_InitChannelPB_VS_0包含EB配置的回调函数名

static const Gpt_ChannelConfigType Gpt_InitChannelPB_VS_0[GPT_CONF_CHANNELS_PB_VS_0] =
{
    {   /*GptChannelConfiguration_0 configuration data*/
        (boolean)FALSE, /* Wakeup capability */
        &PIT0_CALL, /* Channel notification */
        (Gpt_ValueType)(4294967295U), /* Maximum ticks value*/
        (GPT_CH_MODE_ONESHOT), /* Timer mode:continous/one-shot */
        &Gpt_Ipw_ChannelConfig_PB_VS_0[0U]
    }
,
    {   /*GptChannelConfiguration_1 configuration data*/
        (boolean)FALSE, /* Wakeup capability */
        &stm_notifacation, /* Channel notification */
        (Gpt_ValueType)(4294967295U), /* Maximum ticks value*/
        (GPT_CH_MODE_ONESHOT), /* Timer mode:continous/one-shot */
        &Gpt_Ipw_ChannelConfig_PB_VS_0[1U]
    }
};

 Gpt_Ipw_ChannelConfig_PB_VS_0 重要的参数定时器类型以及结构体

Gpt_Ipw_HwChannelConfigType Gpt_Ipw_ChannelConfig_PB_VS_0[2U] =
{
    /** @brief GptChannelConfiguration_0 */
    {
        /** @brief IP type  */
        GPT_PIT_MODULE,
        /** @brief IP instance */
        0U,
        /** @brief IP channel */
        0U,
        /** @brief IP channel pointer */
        {
            &PIT_0_ChannelConfig_PB_VS_0[0U],
            NULL_PTR,
            NULL_PTR,
            NULL_PTR
        }
    }
    ,
    /** @brief GptChannelConfiguration_1 */
    {
        /** @brief IP type  */
        GPT_STM_MODULE,
        /** @brief IP instance */
        0U,
        /** @brief IP channel */
        0U,
        /** @brief IP instance config pointer */
        {
            NULL_PTR,
            &STM_0_ChannelConfig_PB_VS_0[0U],
            NULL_PTR,
            NULL_PTR
        }
    }

};

&PIT_0_ChannelConfig_PB_VS_0,&STM_0_ChannelConfig_PB_VS_0

const Pit_Ip_ChannelConfigType PIT_0_ChannelConfig_PB_VS_0[1U] = 
{
    /** @brief GptPitChannels_PIT0_0 */
    {
        /** @brief PIT Channel Id */
        0U,
        /** @brief PIT Enable Interrupt */
        (boolean)(TRUE), /* Interrupt enabled */
        /** @brief PIT callback name */
        &Gpt_ProcessCommonInterrupt,
        /** @brief PIT callbackparam */
        (uint8)0U,
        /** @brief PIT channel mode */
        PIT_IP_CH_MODE_ONESHOT
    }
};

//Gpt_ProcessCommonInterrupt中断处理函数

const Stm_Ip_ChannelConfigType STM_0_ChannelConfig_PB_VS_0[1U] = 
{
    /** @brief GptStmChannels_0 */
    {
        /** @brief STM Channel Id */
        0U,
        /** @brief STM callback name */
        &Gpt_ProcessCommonInterrupt,
        /** @brief STM callbackparam */
        (uint8)1U,
        /** @brief STM channel mode */
        STM_IP_CH_MODE_ONESHOT
    }
};

函数调用

 此时PIT的中断回调函数是Gpt_ProcessCommonInterrupt

 

void Gpt_ProcessCommonInterrupt(uint8 channel)
{
    uint32 coreID;
    uint8 ChannelIndex;

    coreID = (uint32)Gpt_GetCoreID();

    if (Gpt_pConfig[coreID] != NULL_PTR)
    {
        /* Extract the logical channel from the hardware to logic map table */
        ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];

        /* Change the channel status for one-shot mode */
        if (GPT_CH_MODE_ONESHOT == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_eChannelMode)
        {
            /* Change the channel status to expired */
            Gpt_aChannelInfo[channel].eChannelStatus = GPT_STATUS_EXPIRED;
        }
#if (GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON)
        if ((GPT_MODE_NORMAL == Gpt_eMode) && (TRUE == Gpt_aChannelInfo[channel].bNotificationEnabled))
        {

            (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_pfNotification();

        }

#endif

#if (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON)
#if (GPT_REPORT_WAKEUP_SOURCE == STD_ON)
        if ((GPT_MODE_SLEEP == Gpt_eMode) && (TRUE == Gpt_aChannelInfo[channel].bWakeupEnabled))
        {
            Gpt_aChannelInfo[channel].bWakeupGenerated =TRUE;
            EcuM_CheckWakeup((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_uWakeupSource);
        }
#endif
#endif
    }
    return;
}

(*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_pfNotification();
        Gpt_pChannelConfig

》》》static const Gpt_ChannelConfigType Gpt_InitChannelPB_VS_0[GPT_CONF_CHANNELS_PB_VS_0] =
{
    {   /*GptChannelConfiguration_0 configuration data*/
        (boolean)FALSE, /* Wakeup capability */
        &PIT0_CALL, /* Channel notification */
#if ((GPT_WAKEUP_FUNCTIONALITY_API == STD_ON) && (GPT_REPORT_WAKEUP_SOURCE == STD_ON))
        (EcuM_WakeupSourceType)0U, /* Wakeup information */
#endif
        (Gpt_ValueType)(4294967295U), /* Maximum ticks value*/
        (GPT_CH_MODE_ONESHOT), /* Timer mode:continous/one-shot */
        &Gpt_Ipw_ChannelConfig_PB_VS_0[0U]
    }
,
    {   /*GptChannelConfiguration_1 configuration data*/
        (boolean)FALSE, /* Wakeup capability */
        &stm_notifacation, /* Channel notification */
#if ((GPT_WAKEUP_FUNCTIONALITY_API == STD_ON) && (GPT_REPORT_WAKEUP_SOURCE == STD_ON))
        (EcuM_WakeupSourceType)0U, /* Wakeup information */
#endif
        (Gpt_ValueType)(4294967295U), /* Maximum ticks value*/
        (GPT_CH_MODE_ONESHOT), /* Timer mode:continous/one-shot */
        &Gpt_Ipw_ChannelConfig_PB_VS_0[1U]
    }
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值