Set the STM comparator 0 to generate an interrupt every 500ms

#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"
#include "IfxPort.h"
#include "IfxStm.h"

/*interrupt priority number for STM0 comparator 0*/
#define IFX_INTPRIO_STM0_CMP0    10
/*Global variable to configure the STM0 Cmp0*/
IfxStm_CompareConfig Stm_Cmp_Config;

IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;

void core0_main(void)
{
    IfxCpu_enableInterrupts();
    
    /* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
     * Enable the watchdogs and service them periodically if it is required */
    IfxScuWdt_disableCpuWatchdog( IfxScuWdt_getCpuWatchdogPassword() );
    IfxScuWdt_disableSafetyWatchdog( IfxScuWdt_getSafetyWatchdogPassword() );
    
    /* Wait for CPU sync event */
    IfxCpu_emitEvent( &g_cpuSyncEvent );
    IfxCpu_waitEvent( &g_cpuSyncEvent, 1 );

    /*configure the pin */
    IfxPort_setPinMode( &MODULE_P00, 5, IfxPort_Mode_outputPushPullGeneral );
    IfxPort_setPinPadDriver( &MODULE_P00, 5, IfxPort_PadDriver_cmosAutomotiveSpeed1 );

    /*set the stm compare structure to its initial values: */
    IfxStm_initCompareConfig( &Stm_Cmp_Config );

    Stm_Cmp_Config.ticks = IfxStm_getTicksFromMilliseconds( &MODULE_STM0, 500 );
    Stm_Cmp_Config.comparator = IfxStm_Comparator_0;
    Stm_Cmp_Config.comparatorInterrupt = IfxStm_ComparatorInterrupt_ir0;
    Stm_Cmp_Config.triggerPriority = IFX_INTPRIO_STM0_CMP0;
    Stm_Cmp_Config.typeOfService = IfxSrc_Tos_cpu0;
    /*Configure the comparator to se for 500ms and enable its corresponding interrupt
     * using its corresponding Service Request Node (SRN) */
    IfxStm_initCompare( &MODULE_STM0, &Stm_Cmp_Config );

    while(1)
    {

    }
}

/*The program will jump here imediatly after the STM timer reach the ticks stablished ion CMP0.
 The interrupt service routine is declared using the macro IFX_INTERRUPT, a name Isr_Stm0_Cmp0 is given,
 indicate the vector table is the number 0 corresponding to CPU0 and the priority number
 vector table and priority is what will really match with the interrupt request*/
IFX_INTERRUPT( Isr_Stm0_Cmp0, 0, IFX_INTPRIO_STM0_CMP0 )
{
    /*we do something like flip a led */
    IfxPort_togglePin( &MODULE_P00, 5 );
    /*it is neccesary to clear the module (STM0 CMP0) interrupt flag*/
    IfxStm_clearCompareFlag( &MODULE_STM0, Stm_Cmp_Config.comparator );
    /* reload the comparator with the last value plus the same amount of ticks to keep
     * setting the comparator flag at the same frequency */
    IfxStm_increaseCompare( &MODULE_STM0, Stm_Cmp_Config.comparator, Stm_Cmp_Config.ticks );
}