Exemplo n.º 1
0
/* handle received messages */
static uint8_t sRxCallback(linkID_t port)
{
  uint8_t msg[2], len, tid;

  /* is the callback for the link ID we want to handle? */
  if (port == sLinkID2)
  {
    /* yes. go get the frame. we know this call will succeed. */
     if ((SMPL_SUCCESS == SMPL_Receive(sLinkID2, msg, &len)) && len)
     {
       /* Check the application sequence number to detect
        * late or missing frames...
        */
       tid = *(msg+1);
       if (tid)
       {
         if (tid > sRxTid)
         {
           /* we're good. toggle LED */
	   if ((*msg) == 0)
	   {
	     LedToggle(&led_red);
	   }
	   else
	   {
	     LedToggle(&led_green);
	   }
           sRxTid = tid;
         }
       }
       else
       {
         /* wrap case... */
         if (sRxTid)
         {
           /* we're good. toggle LED */
           if ((*msg) == 0)
	   {
	     LedToggle(&led_red);
	   }
	   else
	   {
	     LedToggle(&led_green);
	   }
           sRxTid = tid;
         }
       }
       /* Post to the semaphore to let application know so it sends
        * the reply
        */
       sSemaphore = 1;
       /* drop frame. we're done with it. */
       return 1;
     }
  }
  /* keep frame for later handling */
  return 0;
}
Exemplo n.º 2
0
void TIM2_IRQHandler(void)
{


	if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
	{
LedToggle(LED_BUTTON1);

LedToggle(LED_BUTTON4);

		TIM_ClearFlag(TIM2, TIM_FLAG_Update);	     //ÇåÖжϱê¼Ç
		TIM_ClearITPendingBit(TIM2, TIM_IT_Update);	 //Çå³ý¶¨Ê±Æ÷T3Òç³öÖжϱê־λ
		//TIM_SetCounter(TIM2, 0);
	}
//	rt_interrupt_leave();
}
Exemplo n.º 3
0
// Blink the onboard LED to indicate the teensy is running.
void PIT1_IRQHandler() {
  LedToggle(0);
  //StartControllerCommandSend();
  
  // Reset the interrupt flag.
  PIT_TFLG1 |= PIT_TFLG_TIF_MASK;
}
Exemplo n.º 4
0
/***************************************************************************************************
*FunctionName:vSysLedTask
*Description:系统指示灯闪烁表面程序正常运行
*Input:None
*Output:None
*Author:xsx
*Data:2015年8月26日16:58:46
***************************************************************************************************/
static void vUniversalTask( void *pvParameters )
{
	static unsigned int count = 0;
	
	while(1)
	{
		/*读取时间,500ms采集一次*/
		if(count % 5 == 0)
			UpDateGB_Time();
		
		/*检测卡状态,500ms间隔*/
		if(count % 5 == 0)
			CheckCardStatues();
		
		/*系统状态灯*/
		LedToggle();
		
		//读取环境温度
		if(count % 2 == 0)
			ReadEnvironmentTemperature();
		
		//控制排队模块状态
		ChangeOutModelStatues();
		
		count++;
		
		vTaskDelay(100 / portTICK_RATE_MS);
	}
}
Exemplo n.º 5
0
int main(void)
{
  Timer_t timer;                // Create our timer object!
  Led_t led;                    // Create the LED Object on P1.0! 

  /* Watchdog timer disabled */
  WDTCTL = WDTPW + WDTHOLD;
  
  BspInit();    // Set up
  
  (void) TimerMasterInit(100); //100 *10us = 1ms
  
  TimerCtor(&timer);  
  LedCtor(&led, kPort1, kPin0); //P1.0 (red)

  __eint();        // Enable global interrupts
  while(true)
  {
    if (TimerGet(&timer)>100)  // 0.2s period (1ms*20)
    {
      LedToggle(&led);
      TimerReset(&timer);
    }
  }
}
Exemplo n.º 6
0
/*----------------------------------------------------------------------------------------------------------------------
Function: LedUpdate

Description:
Update all LEDs for the current cycle.

Requires:
 - G_u32SystemTime1ms is counting

Promises:
   - All LEDs updated based on their counters
*/
void LedUpdate(void)
{
	/* Loop through each LED */
  for(u8 i = 0; i < TOTAL_LEDS; i++)
  {
    /* Check if LED is PWMing */
    if(Leds_asLedArray[(LedNumberType)i].eMode == LED_PWM_MODE)
    {
      /* Handle special case of 0% duty cycle */
      if( Leds_asLedArray[i].eRate == LED_PWM_0 )
      {
        LedOff( (LedNumberType)i );
      }
      
      /* Handle special case of 100% duty cycle */
      else if( Leds_asLedArray[i].eRate == LED_PWM_100 )
      {
        LedOn( (LedNumberType)i );
      }
  
      /* Otherwise, regular PWM: decrement counter; toggle and reload if counter reaches 0 */
      else
      {
        if(--Leds_asLedArray[(LedNumberType)i].u16Count == 0)
        {
          if(Leds_asLedArray[(LedNumberType)i].eCurrentDuty == LED_PWM_DUTY_HIGH)
          {
            /* Turn the LED off and update the counters for the next cycle */
            LedOff( (LedNumberType)i );
            Leds_asLedArray[(LedNumberType)i].u16Count = LED_PWM_PERIOD - Leds_asLedArray[(LedNumberType)i].eRate;
            Leds_asLedArray[(LedNumberType)i].eCurrentDuty = LED_PWM_DUTY_LOW;
          }
          else
          {
            /* Turn the LED on and update the counters for the next cycle */
            LedOn( (LedNumberType)i );
            Leds_asLedArray[i].u16Count = Leds_asLedArray[i].eRate;
            Leds_asLedArray[i].eCurrentDuty = LED_PWM_DUTY_HIGH;
          }
        }
      }

      /* Set the LED back to PWM mode since LedOff and LedOn set it to normal mode */
     	Leds_asLedArray[(LedNumberType)i].eMode = LED_PWM_MODE;
      
    } /* end if PWM mode */
    
    /* LED is in LED_BLINK_MODE mode */
    else if(Leds_asLedArray[(LedNumberType)i].eMode == LED_BLINK_MODE)
    {
      /* Decrement counter; toggle and reload if counter reaches 0 */
      if( --Leds_asLedArray[(LedNumberType)i].u16Count == 0)
      {
        LedToggle( (LedNumberType)i );
        Leds_asLedArray[(LedNumberType)i].u16Count = Leds_asLedArray[(LedNumberType)i].eRate;
      }
    }
  } /* end for */
} /* end LedUpdate() */
Exemplo n.º 7
0
static void UartCbf(uint8_t byte)
{
  if (byte != 0)
  {
    LedToggle(&led_green);
    byte = byte + 1;
    (void) UartSend(&byte, 1);
  }
}
Exemplo n.º 8
0
static void UartTransmitNumber(uint16_t num)
{
  uint8_t buf[5];
  buf[0]='0'; //+ num/1000;
  buf[1]='2'; //+ ((num/100) % 10);
  buf[2]='5'; //+ ((num/10) % 10);
  buf[3]='6';// + ((num) % 10);
  buf[4]=' ';
  if (UartSend(buf,1) == false)
  {
    LedToggle(&led_green);
  }
}
Exemplo n.º 9
0
void LedAllToggle() {
	LedToggle(LED_TRIPOD);
	LedToggle(LED_RBOG);
	LedToggle(LED_BBOG);
	LedToggle(LED_LBOG);
	LedToggle(LED_DNT);
	LedToggle(LED_STATUS);
}
Exemplo n.º 10
0
/*
*********************************************************************************************************
*                                          LedInit()
*
* Description : Init the ports for leds
*
* Argument(s) : none
*
* Return(s)   : none
*
* Caller(s)   : main()
*
* Note(s)     : none.
*********************************************************************************************************
*/
void vTask1( void *pvParameters )
{
	  static u32 cnt = 50;
	  u32 fl = 0;

	  u8 er = 0;

	  timer_4_init();

	    for( ;; )
	    {
	        cnt--;
	    	if (cnt == 0) {
	    		LedToggle(LED_STATUS);

	    		cnt = gLedCnt;
	    		//USART_SendData(USART1, 'A');
	    	    if ( fl == 0 ) {
	    	    	u8 i;
	    	    	//for ( i = 1; i < 5; i++) {

	    		     //   er = eMBMasterReqWriteCoil( 1, 1, 0xFF00, (-1) );


	    			    //MB_MRE_NO_ERR,                  /*!< no error. */
	    			    //MB_MRE_NO_REG,                  /*!< illegal register address. */
	    			    //MB_MRE_ILL_ARG,                 /*!< illegal argument. */
	    			    //MB_MRE_REV_DATA,                /*!< receive data error. */
	    			    //MB_MRE_TIMEDOUT,                /*!< timeout error occurred. */
	    			    //MB_MRE_MASTER_BUSY,             /*!< master is busy now. */
	    			    //MB_MRE_EXE_FUN                  /*!< execute function error. */
	    		//	    if ( er == MB_MRE_NO_ERR )//|| er == MB_MRE_MASTER_BUSY || er == MB_MRE_REV_DATA || er == MB_MRE_EXE_FUN)
	    			//	    break;
	    		   // }

	    	    if ( i == 5 )
	    	    	gLedCnt = 2;
	    	   	}

	    	    fl = 1;
	        }

    	//ValidatorPulseProcessing(5 / portTICK_RATE_MS);
    	//ButtonSkan(5 / portTICK_RATE_MS);

        vTaskDelay(100 / portTICK_RATE_MS);
    }

    vTaskDelete (NULL);
}
Exemplo n.º 11
0
Arquivo: main.c Projeto: x893/OpenBLT
/************************************************************************************//**
** \brief     This is the entry point for the bootloader application and is called 
**            by the reset interrupt vector after the C-startup routines executed.
** \return    Program return code.
**
****************************************************************************************/
int main(void)
{
  /* initialize the microcontroller */
  Init();

  /* start the infinite program loop */
  while (1)
  {
    /* toggle LED with a fixed frequency */
    LedToggle();
  }

  /* program should never get here */
  return 0;
} /*** end of main ***/
Exemplo n.º 12
0
Arquivo: main.c Projeto: x893/OpenBLT
/************************************************************************************//**
** \brief     This is the entry point for the bootloader application and is called 
**            by the reset interrupt vector after the C-startup routines executed.
** \return    Program return code.
**
****************************************************************************************/
int main(void)
{
  /* initialize the microcontroller */
  Init();
  /* initialize the bootloader interface */
  BootComInit();

  /* start the infinite program loop */
  while (1)
  {
    /* toggle LED with a fixed frequency */
    LedToggle();
    /* check for bootloader activation request */
    BootComCheckActivationRequest();
  }

  /* program should never get here */
  return 0;
} /*** end of main ***/
Exemplo n.º 13
0
static void ManageLoop(void)
{
  static uint16_t adc_value = kAdcPending;
  // button handling
  if (ButtonSwitch(&button_small))
  {
    if (ButtonState(&button_small) == 1)
    {
      //AdcStart(0, &adc_value);
      LedToggle(&led_green);
    }
  }

  if (adc_value != kAdcPending)
  {
    UartTransmitNumber(adc_value);
    adc_value = kAdcPending;
  }
}
Exemplo n.º 14
0
Arquivo: main.c Projeto: x893/OpenBLT
/************************************************************************************//**
** \brief     This is the entry point for the bootloader application and is called 
**            by the reset interrupt vector after the C-startup routines executed.
** \return    none.
**
****************************************************************************************/
void main(void)
{
  /* initialize the microcontroller */
  Init();
  /* initialize the network application */
  NetInit();
  /* initialize the bootloader interface */
  BootComInit();

  /* start the infinite program loop */
  while (1)
  {
    /* toggle LED with a fixed frequency */
    LedToggle();
    /* run the network task */ 
    NetTask();
    /* check for bootloader activation request */
    BootComCheckActivationRequest();
  }
} /*** end of main ***/
Exemplo n.º 15
0
int main(void){  
	unsigned long i,last,now,dataLast, dataIndex;
  TExaS_Init(SW_PIN_PF40, LED_PIN_PF1);  // activate grader and set system clock to 16 MHz
  PortF_Init();   // initialize PF1 to output
  SysTick_Init(); // initialize SysTick, runs at 16 MHz
  i = 0;          // array index
  last = NVIC_ST_CURRENT_R;
	
	dataIndex=0;
  dataLast = GPIO_PORTF_DATA_R;
	EnableInterrupts();           // enable interrupts for the grader
  while(1){
		dataNow = GPIO_PORTF_DATA_R;
		if(ShouldFlashLed()){
			LedToggle();
		}else{
			LedOff();
		}
		
		
		if(dataLast != dataNow)
		{
			GPIO_PORTF_DATA_R = dataNow;
			dataLast = dataNow;
			if(dataIndex<50){
				Data[dataIndex] = dataNow;
				dataIndex++;
			}
		}
		
    if(i<50){
      now = NVIC_ST_CURRENT_R;
      Time[i] = (last-now)&0x00FFFFFF;  // 24-bit time difference
      //Data[i] = GPIO_PORTF_DATA_R&0x02; // record PF1
      last = now;
      i++;
    }
    Delay();
  }
}
Exemplo n.º 16
0
static void LedRedFlash(void)
{
  LedToggle(0);
}
Exemplo n.º 17
0
static void ToggleLed(void)
{
  LedToggle(&led);
}
Exemplo n.º 18
0
static void LedRedFlash(void)
{
  LedToggle(&led_red);
  UartTransmitNumber(256);
}
/*----------------------------------------------------------------------------------------------------------------------
Function: DebugLedTestCharacter

Description:
Checks the character and toggles associated LED if applicable.
This implementation is specific to the target hardware.

Requires:
  - u8Char_ is the character to check

Promises:
  - If u8Char_ is a valid toggling character, the corresponding LED will be toggled.
*/
static void DebugLedTestCharacter(u8 u8Char_)
{
  /* Check the char to see if an LED should be toggled */  
#ifdef MPGL1
  if(u8Char_ == 'W')
  {
    LedToggle(WHITE);
  }  

  if(u8Char_ == 'P')
  {
    LedToggle(PURPLE);
  } 

  if(u8Char_ == 'B')
  {
    LedToggle(BLUE);
  } 

  if(u8Char_ == 'C')
  {
    LedToggle(CYAN);
  } 

  if(u8Char_ == 'G')
  {
    LedToggle(GREEN);
  } 

  if(u8Char_ == 'Y')
  {
    LedToggle(YELLOW);
  } 

  if(u8Char_ == 'O')
  {
    LedToggle(ORANGE);
  } 

  if(u8Char_ == 'R')
  {
    LedToggle(RED);
  } 

#endif /* MPGL1 */
  
#ifdef MPGL2
  
#ifdef MPGL2_R01
  if(u8Char_ == 'B')
  {
    LedToggle(BLUE);
  } 

  if(u8Char_ == 'G')
  {
    LedToggle(GREEN);
  } 

  if(u8Char_ == 'Y')
  {
    LedToggle(YELLOW);
  } 

  if(u8Char_ == 'R')
  {
    LedToggle(RED);
  } 
  
#else

  if(u8Char_ == 'B')
  {
    LedToggle(BLUE0);
    LedToggle(BLUE1);
    LedToggle(BLUE2);
    LedToggle(BLUE3);
  }  

  if(u8Char_ == 'R')
  {
    LedToggle(RED0);
    LedToggle(RED1);
    LedToggle(RED2);
    LedToggle(RED3);
  }  
  
  if(u8Char_ == 'G')
  {
    LedToggle(GREEN0);
    LedToggle(GREEN1);
    LedToggle(GREEN2);
    LedToggle(GREEN3);
  }  
 
#endif /* MPGL2_R01 */
#endif /* MPGL2 */
  
} /* end DebugCommandLedTestToggle() */
Exemplo n.º 20
0
//-----------------------------------------------------------------------------
// Main Routine
//-----------------------------------------------------------------------------
void main(void)  
{
	char cmd;

   PCA0MD &= ~0x40;                    // Disable Watchdog timer

   Sysclk_Init();                      // Initialize oscillator
   Port_Init();                        // Initialize crossbar and GPIO
   P2=0xFF;  // tie high to turn off pulldowns for open drain devices connected
   Usb0_Init();                        // Initialize USB0
   Timer_Init();                       // Initialize timer2
	LedOn(); 

  	//RSTSRC =0x80;	;				   // enable USB and
                                       // missing clock detector reset sources
									   // if we enabled missing clock detector then the device doesn't work, don't know why

    // watchdog
	// load watchdog offset 
	PCA0CPL4=0xff; // maximum offset so that watchdog takes a good long time to time out
	// enable watchdog 
  PCA0MD |= 0x44;   // WDT enabled, PCA clock source is timer0 overflow
  PCA0CPH4 = 0x00;  // write value to WDT PCA to start watchdog                   

	
/*	Servo0=0;
	Servo1=0;
	Servo2=0;
	Servo3=0;
*/
   while (1)
   {
    // It is possible that the contents of the following packets can change
    // while being updated.  This doesn't cause a problem in the sample
    // application because the bytes are all independent.  If data is NOT
    // independent, packet update routines should be moved to an interrupt
    // service routine, or interrupts should be disabled during data updates.


	  PCA0CPH4 = 355;  // write value to WDT PCA to reset watchdog
	  
	             
		
		EA=0; // disable ints
	//	LedToggle();
		cmd=Out_Packet[0];
		switch(cmd){
		case CMD_SET_SERVO:
			Out_Packet[0]=0; // command is processed
			LedToggle();
			pwmNumber=Out_Packet[1];
			switch(pwmNumber)
			{
			// big endian 16 bit value to load into PWM controller
				case 0:
				{ // servo0
					pwmh1=Out_Packet[2]; // store the PCA compare value for later interrupt to load
					pwml1=Out_Packet[3];
					PCA0CPM0 |= 0x49; // enable compare function and match and interrupt for match for pca
					
				}
				break;
				case 1:
				{ // servo1
					pwmh2=Out_Packet[2];
					pwml2=Out_Packet[3];
					PCA0CPM1 |= 0x49; // enable compare function and enable match and interrupt for match for pca
				}
				break;
				case 2:
				{ // servo1
					pwmh3=Out_Packet[2];
					pwml3=Out_Packet[3];
					PCA0CPM2 |= 0x49; // enable compare function and enable match and interrupt for match for pca
				}
				break;
				case 3:
				{ // servo1
					pwmh4=Out_Packet[2];
					pwml4=Out_Packet[3];
					PCA0CPM3 |= 0x49; // enable compare function and enable match and interrupt for match for pca
				}
			}			
			EIE1 |= 0x10; // enable PCA interrupt

			break;
			case CMD_DISABLE_SERVO:
	      	//cmd: CMD, SERVO
			{
				Out_Packet[0]=0; // command is processed
				LedToggle();
				pwmNumber=Out_Packet[1];
				switch(pwmNumber)
				{
				// big endian 16 bit value to load into PWM controller
					case 0:
					{ // servo0
						PCA0CPM0 &= ~0x40; // disable compare function
					}
					break;
					case 1:
					{ // servo1
						PCA0CPM1 &= ~0x40; // disable compare function
					}
					break;
					case 2:
					{ // servo2
						PCA0CPM2 &= ~0x40; // disable compare function
					}
					break;
					case 3:
					{ // servo3
						PCA0CPM3 &= ~0x40; // disable compare function
					}
				}			
			}
			break;
			case CMD_SET_ALL_SERVOS: // cmd: CMD, PWMValue0 (2 bytes bigendian), PWMValue1 (2 bytes bigendian)
			{
				Out_Packet[0]=0; // command is processed
				LedToggle();
				
				// TODO the set all servos probably doesn't work because it doesn't save the values for the ISR to later load

				PCA0CPL0=Out_Packet[2];
				PCA0CPH0=Out_Packet[1]; // store the PCA compare value for later interrupt to load, write low value FIRST
				PCA0CPM0 |= 0x49; // enable compare function and match and interrupt for match for pca
				
				PCA0CPL1=Out_Packet[4];
				PCA0CPH1=Out_Packet[3];
				PCA0CPM1 |= 0x49; // enable compare function and enable match and interrupt for match for pca
				
				PCA0CPL2=Out_Packet[6];
				PCA0CPH2=Out_Packet[5];
				PCA0CPM2 |= 0x49; // enable compare function and enable match and interrupt for match for pca
				
				PCA0CPL3=Out_Packet[8];
				PCA0CPH3=Out_Packet[7];
				PCA0CPM3 |= 0x49; // enable compare function and enable match and interrupt for match for pca
			}	
			EIE1 |= 0x10; // enable PCA interrupt
			break;
			case CMD_DISABLE_ALL_SERVOS: 	//cmd: CMD
			{
				Out_Packet[0]=0; // command is processed
				LedToggle();
				PCA0CPM0 &= ~0x40; // disable compare function
				PCA0CPM1 &= ~0x40; // disable compare function
				PCA0CPM2 &= ~0x40; // disable compare function
				PCA0CPM3 &= ~0x40; // disable compare function
			}
			
			break;
			case CMD_SET_TIMER0_RELOAD_VALUE: 	
			{
				Out_Packet[0]=0; // command is processed
				LedToggle();
				TH0=255-Out_Packet[1]; // timer0 reload value, 2 for 60Hz, 1 for 91Hz servo pulse rate, 0 for 180 Hz
			}
			break;
			case CMD_SET_PCA0MD_CPS: // bit are ORed with 0x7, left shifted by one, and set to the PCA0MD bits 3:1
			{
				Out_Packet[0]=0; // command is processed
				LedToggle();
				// must disable watchdog before changing these bits
				PCA0MD&=~0x40;	

				PCA0MD = (PCA0MD & 0xf1) | (  (0x7&Out_Packet[1])  <<1); // this is the PCA control register, bits 3:1 are the CPS bits that control the PCA clock source
				// CPS = 0 sysclk/12
				// CPS = 1 sysclk/4
				// CPS = 2 timer0 overflow

				PCA0MD|=0x40; // re-enable watchdog
				PCA0CPH4 = 0xff;  // write value to WDT PCA to start watchdog                   

			}
			break;
			case CMD_SET_PORT2:
			{
				Out_Packet[0]=0; //ack
				LedToggle();
				P2=Out_Packet[1];
				break;
			}
			case CMD_SEND_WOWWEE_RS_CMD:
			{
				// P2.0 is high
				Out_Packet[0]=0; // cmd has been processed
				LedToggle();
				
				rsv2_cmd.cmd = (Out_Packet[1])|(Out_Packet[2]<<8);
				//rsv2_cmd.msb = (Out_Packet[2]);

				rsv2_precmd = 1; // we're sending the start 'bit'
				rsv2_cyclesleft = 517; // 8/1200
				rsv2_cmdidx = 12; // 12 bits
				rsv2_sendcmd = 1; // we're sending a cmd state
				EIE1|=0x80; // enable timer 3 interrupts, disabled at end of cmd
				break;
			}			
			case CMD_SET_PORT_DOUT:
			{
				Out_Packet[0]=0; // cmd has been processed
				LedToggle();
				
				P1MDOUT= (Out_Packet[1]); // setting bit to 1 makes port pin push-pull, 0 makes it open drain
				P2MDOUT= (Out_Packet[2]);
				break;
			}

		} // switch
		EA=1; // enable interrupts
		//LedOn();
	} // while(1)
}
Exemplo n.º 21
0
//high priority interrupt routine
void Usb2UartInterruptHandlerHigh(void) {
    if (RcIf) {
        putc_cdc(RCREG); // will handle timouts and ZLP for us.
        LedToggle(); // toggle led every sending
    }
}
Exemplo n.º 22
0
/*
** Main function. The application starts here.
*/
int main(void)
{
    unsigned char rxByte;
    unsigned int value = (unsigned int)E_FAIL;

    #ifdef __TMS470__
    /* Relocate the required section to internal RAM */
    memcpy((void *)(&relocstart), (const void *)(&iram_start),
           (unsigned int)(&iram_size));
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma section = "CodeRelocOverlay"
    #pragma section = "DataRelocOverlay"
    #pragma section = "DataOverlayBlk"
    #pragma section = "CodeOverlayBlk"
    char* srcAddr = (__section_begin("CodeRelocOverlay"));
    char* endAddr = (__section_end("DataRelocOverlay"));

    memcpy((void *)(__section_begin("CodeRelocOverlay")),
           (const void *)(__section_begin("CodeOverlayBlk")),
           endAddr - srcAddr);

    #else
    memcpy((void *)&(relocstart), (const void *)&(iram_start),
           (unsigned int)(((&(relocend)) -
            (&(relocstart))) * (sizeof(unsigned int))));
    #endif

    MMUConfigAndEnable();    

    /* Enable Instruction Cache */
    CacheEnable(CACHE_ALL);

    PeripheralsSetUp();

    /* Initialize the ARM Interrupt Controller */
    IntAINTCInit();

    /* Register the ISRs */  
    Timer2IntRegister();
    Timer4IntRegister();
    EnetIntRegister();
    RtcIntRegister();
    CM3IntRegister();
    HSMMCSDIntRegister();
    IntRegister(127, dummyIsr);

    IntMasterIRQEnable();

    pageIndex = 0;
    prevAction = 0;

    /* Enable system interrupts */
    IntSystemEnable(SYS_INT_RTCINT);
    IntPrioritySet(SYS_INT_RTCINT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_3PGSWTXINT0);
    IntPrioritySet(SYS_INT_3PGSWTXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_3PGSWRXINT0);
    IntPrioritySet(SYS_INT_3PGSWRXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_TINT2);
    IntPrioritySet(SYS_INT_TINT2, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_TINT4);
    IntPrioritySet(SYS_INT_TINT4, 0, AINTC_HOSTINT_ROUTE_IRQ);	
    IntSystemEnable(SYS_INT_MMCSD0INT);
    IntPrioritySet(SYS_INT_MMCSD0INT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_EDMACOMPINT);
    IntPrioritySet(SYS_INT_EDMACOMPINT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntPrioritySet(SYS_INT_M3_TXEV, 0, AINTC_HOSTINT_ROUTE_IRQ );
    IntSystemEnable(SYS_INT_M3_TXEV);
    IntSystemEnable(127);
    IntPrioritySet(127, 0, AINTC_HOSTINT_ROUTE_IRQ);

    IntSystemEnable(SYS_INT_UART0INT);
    IntPrioritySet(SYS_INT_UART0INT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntRegister(SYS_INT_UART0INT, uartIsr);

     /*	GPIO interrupts	*/
    IntSystemEnable(SYS_INT_GPIOINT0A);
    IntPrioritySet(SYS_INT_GPIOINT0A, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntRegister(SYS_INT_GPIOINT0A, gpioIsr);
    IntSystemEnable(SYS_INT_GPIOINT0B);
    IntPrioritySet(SYS_INT_GPIOINT0B, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntRegister(SYS_INT_GPIOINT0B, gpioIsr);

    BoardInfoInit();
    deviceVersion = DeviceVersionGet();

    CM3EventsClear();
    CM3LoadAndRun();
    waitForM3Txevent();

    /* Initialize console for communication with the Host Machine */
    ConsoleUtilsInit();

    /*
    ** Select the console type based on compile time check
    ** Note: This example is not fully complaint to semihosting. It is
    **       recommended to use Uart console interface only.
    */
    ConsoleUtilsSetType(CONSOLE_UART);

    /* Print Board and SoC information on console */
    ConsoleUtilsPrintf("\n\r Board Name          : %s", BoardNameGet());
    ConsoleUtilsPrintf("\n\r Board Version       : %s", BoardVersionGet());
    ConsoleUtilsPrintf("\n\r SoC Version         : %d", deviceVersion);

    /* On CM3 init firmware version is loaded onto the IPC Message Reg */
    ConsoleUtilsPrintf("\n CM3 Firmware Version: %d", readCM3FWVersion());

    I2CIntRegister(I2C_0);
    IntPrioritySet(SYS_INT_I2C0INT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_I2C0INT);
    I2CInit(I2C_0);

    IntSystemEnable(SYS_INT_TINT1_1MS);
    IntPrioritySet(SYS_INT_TINT1_1MS, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntRegister(SYS_INT_TINT1_1MS,clearTimerInt);

    configVddOpVoltage();
    RtcInit();
    HSMMCSDContolInit();
    DelayTimerSetup();

    initializeTimer1();
    ConsoleUtilsPrintf("\r\n After intializing timer");
    Timer2Config();
    Timer4Config();
    LedIfConfig();
    MailBoxInit();

    Timer2IntEnable();
    Timer4IntEnable();
    RtcSecIntEnable();
    	
    Timer4Start(); 
    while(FALSE == tmr4Flag);
    tmr4Flag = FALSE;
    Timer4Stop();

    ConsoleUtilsPrintf("\n\r Configuring for maximum OPP");
    mpuOpp = ConfigMaximumOPP();

    mpuFreq = FrequencyGet(mpuOpp);
    mpuVdd1 = VddVoltageGet(mpuOpp);
    PrintConfigDVFS();

    /*  Create menu page */
    pageIndex = MENU_IDX_MAIN;

    ActionEnetInit();

    /*
    ** Loop for ever. Necessary actions shall be taken
    ** after detecting the click.
    */
    while(1)
    {
        /*
        ** Check for any any activity on Uart Console and process it.
        */
        if (true == UARTCharsAvail(SOC_UART_0_REGS))
        {

            /* Receiving bytes from the host machine through serial console. */
            rxByte = UARTGetc();

            /*
            ** Checking if the entered character is a carriage return.
            ** Pressing the 'Enter' key on the keyboard executes a
            ** carriage return on the serial console.
            */
            if('\r' == rxByte)
            {
                ConsoleUtilsPrintf("\n");
                UartAction(value);
                value = (unsigned int)E_FAIL;
                rxByte = 0;
            }

            /*
            ** Checking if the character entered is one among the decimal
            ** number set 0,1,2,3,....9
            */
            if(('0' <= rxByte) && (rxByte <= '9'))
            {
                ConsoleUtilsPrintf("%c", rxByte);

                if((unsigned int)E_FAIL == value)
                {
                    value = 0;
                }

                value = value*10 + (rxByte - 0x30);
            }

        }

         /*
         ** Check if click is detected
         */
         if(clickIdx != 0)
         {
             /*
             ** Take the Action for click
             */
             ClickAction();

             clickIdx = 0;
         }
       
         /*
         ** Check if the Timer Expired
         */ 
         if(TRUE == tmrFlag)
         {
             /* Toggle the LED state */
             LedToggle();
             tmrFlag = FALSE;
         }
 
         /*
         ** Check if RTC Time is set
         */
         if(TRUE == rtcSetFlag)
         {
             if(TRUE == rtcSecUpdate)
             { 
                 rtcSecUpdate = FALSE;
                 RtcTimeCalDisplay();
                 ConsoleUtilsPrintf(" --- Selected:  ");
             }
         } 
   
         if(TRUE == tmr4Flag)
         {
            tmr4Flag = FALSE;
             /* Make sure that interrupts are disabled and no lwIP functions
                are executed while calling an lwIP exported API */
             IntMasterIRQDisable();
             etharp_tmr();
             IntMasterIRQEnable();
         }
    }
}