Set a delay period using one of the two microcontroller STM timer comparator

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

IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;

void core0_main(void)
{
    IfxStm_CompareConfig Stm_Cmp_Config;

    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:
     * Stm_Cmp_Config.comparator          = IfxStm_Comparator_0;
     * Stm_Cmp_Config.compareOffset       = IfxStm_ComparatorOffset_0;
     * Stm_Cmp_Config.compareSize         = IfxStm_ComparatorSize_32Bits;
     * Stm_Cmp_Config.comparatorInterrupt = IfxStm_ComparatorInterrupt_ir0;
     * Stm_Cmp_Config.ticks               = 0xFFFFFFFF;
     * Stm_Cmp_Config.triggerPriority     = 0;
     * Stm_Cmp_Config.typeOfService       = IfxSrc_Tos_cpu0;*/
    IfxStm_initCompareConfig( &Stm_Cmp_Config );

    /*set ticks to get a time value of 500ms on comparator 0*/
    Stm_Cmp_Config.ticks = IfxStm_getTicksFromMilliseconds( &MODULE_STM0, 500 );
    Stm_Cmp_Config.comparator = IfxStm_Comparator_0;
    /*set comparator values for STM0 because we are using CPU0*/
    IfxStm_initCompare( &MODULE_STM0, &Stm_Cmp_Config );
    /*disable comparator interrupt since we don't need it this time*/
    IfxStm_disableComparatorInterrupt( &MODULE_STM0, Stm_Cmp_Config.comparator );

    while(1)
    {
        /*Flip the led on port 00 pin 5*/
        IfxPort_togglePin( &MODULE_P00, 5 );
        /* we are going to wait until timer STM0 reach the same count load in comparator 0*/
        while( IfxStm_isCompareFlagSet( &MODULE_STM0, IfxStm_Comparator_0 ) == FALSE );
        /*clear comparator 0 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. remember the STM timer count does not
         * get a reset when a comparator event occures*/
        IfxStm_increaseCompare( &MODULE_STM0, Stm_Cmp_Config.comparator, Stm_Cmp_Config.ticks);
    }
}