/* Example code for ITC for  ST72F521 */
#include "ST7lib_config.h" 

//prototype declarations
void TLI_IT_Routine (void);
void EI0_IT_Routine(void);
void EI2_IT_Routine(void);
void main(void);

void main (void)
{   
      unsigned char Pin = 0;
      ITC_LEVEL Priority = IT_LEVEL_2;                /*Variable Declaration*/
        
      ITC_Init ();                                   /* Initialise ITC */
      EnableInterrupts                              /*Reset Interrupt mask*/                                             
      ITC_SetPriority (((unsigned char)IT_TIMERA | ((unsigned char)IT_EI0)),
                                        IT_LEVEL_2); 
                                                       
                    /* Sets Interrupt Priority FOR EI0 AS LEVEL 2*/
      ITC_SetPriority (IT_EI2, IT_LEVEL_1);
                          /* Sets Interrupt Priority FOR EI2 AS LEVEL 1*/
      Priority = ITC_GetPriority (IT_EI0);                                                          /* Gets Priority */
      while (!(ITC_Get_CurrentLevel () == IT_LEVEL_3));
                                        /* Checks Current interrupt priority*/
      ITC_ConfigureInterrupt(IT_PortA,Pin, IT_EDGE_F);
                                       /*Set falling edge sensitivity for EI0*/
      ITC_ConfigureInterrupt(IT_PortB,Pin, IT_EDGE_F);
                                       /*Set falling edge sensitivity for EI2*/
      ITC_DisableTLI ();                         /*Disables TLI interrupt */
      ITC_TLISensitivity (IT_EDGE_R);           /* Sets Rising edge for TLI */
      ITC_EnableTLI ();                              /* Enables TLI interrupt */
}
/*******************************************************************************
  Interrupt Subroutine for TLI
*******************************************************************************/
#ifdef _HIWARE_                                  /* Test for HIWARE Compiler */
#pragma TRAP_PROC SAVE_REGS            /* Additional registers will be saved */
#else
#ifdef _COSMIC_                                  /* Test for Cosmic Compiler */
@interrupt                                                                                           /* Cosmic interrupt handling */
#else
#error "Unsupported Compiler!"                /* Compiler Defines not found! */
#endif
#endif

void TLI_IT_Routine (void)
{
       unsigned int i;
       PDDDR  |= 0x04;
       PDOR |= 0x04;
       PDDR |= 0x04;
       for (i = 0; i < 5000; i++)
       {
             Nop
       }
        PDDR &= 0xFB;
}
/*******************************************************************************
  Interrupt Subroutine for EI0
*******************************************************************************/
#ifdef _HIWARE_                                 /* Test for HIWARE Compiler */
#pragma TRAP_PROC SAVE_REGS           /* Additional registers will be saved */
#else
#ifdef _COSMIC_                                 /* Test for Cosmic Compiler */
@interrupt                                     /* Cosmic interrupt handling */
#else
#error"Unsupported Compiler!"                /* Compiler Defines not found! */
#endif
#endif

void EI0_IT_Routine (void)
{
       unsigned int i; 
       PDDDR  |= 0x01;
       PDOR |= 0x01; 
       PDDR |= 0x01;
       for (i = 0; i < 5000; i++)
       {
             Nop
       }
        PDDR &= 0xFE;
}
/*******************************************************************************
  Interrupt Subroutine for EI2
*******************************************************************************/
#ifdef _HIWARE_                                  /* Test for HIWARE Compiler */
#pragma TRAP_PROC SAVE_REGS            /* Additional registers will be saved */
#else
#ifdef _COSMIC_                                  /* Test for Cosmic Compiler */
@interrupt                                                                                           /* Cosmic interrupt handling */
#else
#error"Unsupported Compiler!"                /* Compiler Defines not found! */
#endif
#endif

void EI2_IT_Routine (void)
{
       unsigned int i; 
       PDDDR  |= 0x02;
       PDOR |= 0x02; 
       PDDR |= 0x02;
       for (i = 0; i < 5000; i++)
       {
             Nop
       }
        PDDR &= 0xFd;
}      
                                                                                                                                                                                                              
      























