[!AUTOSPACING!]
[!NOCODE!]
/*!
*   @file       Pwm_NotifyCheck_Src.m
*   @version    1.0.0
*
*   @brief      AUTOSAR Pwm Macros that generate notifications handlers
*   @details    Macros that generate notifications handlers prototypes
*
*   @addtogroup PWM_MODULE
*   @{
*/
/*!==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : eMios
*   Dependencies         : none
*
*   AUTOSAR Version      : 4.3.1
*   AUTOSAR Revision     : ASR_REL_4_3_REV_0001
*   AUTOSAR Conf.Variant :
*   SW Version           : 1.0.0
*   Build Version        : MPC5777C_MCAL_1_0_0_RTM_ASR_REL_4_3_REV_0001_20190315
*
*   (c) Copyright 2006-2016 Freescale Semiconductor, Inc. 
*       Copyright 2017-2019 NXP
*   All Rights Reserved.
==================================================================================================*/
/*==================================================================================================
==================================================================================================*/


/* Avoid multiple inclusion */
[!IF "not(var:defined('PWM_NOTIFY_CHECK_SRC_M'))"!]

    [!VAR "PWM_NOTIFY_CHECK_SRC_M"="'true'"!]
    
    
    /* This macro generates the list of prototypes of PWM channel notification handlers */
    [!MACRO "GeneratePwmNotifications"!]
    [!NOCODE!]
        [!LOOP "./PwmChannel/*"!]
            [!IF "node:exists('PwmNotification')"!]
                [!IF "(PwmNotification != '"NULL_PTR"') and (PwmNotification != 'NULL_PTR') and (PwmNotification != '"NULL"') and (PwmNotification != 'NULL')"!]
                    [!CODE!]
/** @brief      Prototypes of PWM channels User Notifications */
                    [!ENDCODE!]
                
                    [!BREAK!]
                [!ENDIF!]
            [!ENDIF!]
        [!ENDLOOP!]

        [!VAR "MacOuterLoopCounter" = "0"!]
        [!VAR "MacInnerLoopCounter" = "0"!]
        
        /* Loop through all PWM channels and get name of Notification handlers for each of them. 
           Loop the channels twice because there might be channels using same MacNotification function 
           and we only want to declare it as external once */
        [!LOOP "./PwmChannel/*"!]
            [!VAR "MacOuterLoopCounter" = "$MacOuterLoopCounter + 1"!]
            [!VAR "MacInnerLoopCounter" = "0"!]
            [!VAR "MacMatchcounter" = "0"!]
            
            [!IF "node:exists('PwmNotification')"!]
                [!VAR "MacNotification" = "PwmNotification"!]
                
                [!LOOP "../../PwmChannel/*"!]
                    [!IF "(PwmNotification != '"NULL_PTR"') and (PwmNotification != 'NULL_PTR') and (PwmNotification != '"NULL"') and (PwmNotification != 'NULL')"!]
                        [!VAR "MacInnerLoopCounter" = "$MacInnerLoopCounter + 1"!]
                        
                        [!IF "$MacOuterLoopCounter >= $MacInnerLoopCounter"!]
                            [!IF "($MacNotification = PwmNotification)"!]
                                [!VAR "MacMatchcounter" = "$MacMatchcounter + 1"!]
                            [!ENDIF!]
                        [!ENDIF!]
                    [!ENDIF!]
                [!ENDLOOP!]
            [!ENDIF!]
            
            [!IF "$MacMatchcounter = 1"!]
                [!CODE!]
extern FUNC (void, PWM_CODE) [!"PwmNotification"!](void);
                [!ENDCODE!]
            [!ENDIF!]
        [!ENDLOOP!]
        
    [!ENDNOCODE!]
    [!ENDMACRO!]

[!ENDIF!] /* Avoid multiple inclusion ENDIF */

[!ENDNOCODE!]
