


void enterStandby()
{

    DL_I2C_disableController(I2C_0_INST);
    DL_I2C_disablePower(I2C_0_INST); //
    
    DL_Timer_disablePower(TIMER_1_INST); 
    

    DL_ADC12_disableConversions(ADC12_0_INST);
    DL_ADC12_disablePower(ADC12_0_INST);  
    DL_VREF_disableInternalRef(VREF);
    DL_VREF_disablePower(VREF);
    DL_UART_disable(UART_0_INST);
    DL_UART_Main_disablePower(UART_0_INST); 
}


void exitStandby()
{
    
    DL_I2C_reset(I2C_0_INST);
    DL_UART_Main_reset(UART_0_INST);
    DL_ADC12_reset(ADC12_0_INST);
    DL_VREF_reset(VREF);
    DL_I2C_enablePower(I2C_0_INST); // 
    DL_ADC12_enableConversions(ADC12_0_INST);
    DL_ADC12_enablePower(ADC12_0_INST); 
    DL_VREF_enablePower(VREF);
    DL_UART_Main_enablePower(UART_0_INST);

    DL_Timer_enablePower(TIMER_1_INST);
    DL_TimerG_reset(TIMER_1_INST);
    

    DL_I2C_enableController(I2C_0_INST); 
    DL_UART_enable(UART_0_INST);
    DL_VREF_enableInternalRef(VREF);

    SYSCFG_DL_I2C_0_init();
    SYSCFG_DL_TIMER_1_init();
    SYSCFG_DL_UART_0_init();
    SYSCFG_DL_ADC12_0_init();
    SYSCFG_DL_VREF_init();

}

void AdcMeasurement()
{
	DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);
    
#if 1           
      ADC Measurement for 7 sample

int main(void)
{

#if 1
    uint8_t reg_val;
    uint8_t test_value[3];
    int8_t ret;
    uint16_t adc_accum_result;
   
    SYSCFG_DL_init();
    NVIC_EnableIRQ(TIMER_0_INST_INT_IRQN);      // For Stand by
    NVIC_EnableIRQ(TIMER_1_INST_INT_IRQN);      
	
    NVIC_EnableIRQ(ADC12_0_INST_INT_IRQN);

#if 0   // ******** Very importent Change , Previously it is acts as one of pre-request 
        // for standby entering 
    DL_SYSCTL_enableSleepOnExit(); 
#endif

//DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_RI_LED_PIN);
#if 1 // For MCU bootup and sync with I2C    
    for(uint8_t dlycnt = 0; dlycnt<5;dlycnt++){
        delay_cycles(6400000); // 200ms (Approx)
        delay_cycles(6400000); // 200ms (Approx)
        delay_cycles(6400000); // 200ms (Approx)
        delay_cycles(6400000); // 200ms (Approx)
        delay_cycles(6400000); // 200ms (Approx)
    }
#endif   
    
	{
		Application code Statement here
	
	}

#if 1  
    
    // Pre-request for Standby mode 
    enterStandby();
    DL_TimerG_startCounter(TIMER_0_INST);
    
    
#endif // Pre-request for Standby mode ****




void TIMER_0_INST_IRQHandler(void)
{
    int8_t ret;
    
    switch (DL_TimerG_getPendingInterrupt(TIMER_0_INST)) {
        case DL_TIMER_IIDX_ZERO:
            /*
             * Counter stopped to avoid a conflict with the timer reading
             * the LOAD value while it's being set
             */
            DL_TimerG_stopCounter(TIMER_0_INST);
            
            exitStandby();
            
            LED ON to indicate coming out from standby
#if 1 // Delay  
            for(uint8_t dlycnt = 0; dlycnt<3;dlycnt++){
                delay_cycles(6400000); // 200ms (Approx)
                delay_cycles(6400000); // 200ms (Approx)
                delay_cycles(6400000); // 200ms (Approx)
                delay_cycles(6400000); // 200ms (Approx)
                delay_cycles(6400000); // 200ms (Approx)
            }
#endif

#if 1   
            Set Pin before ADC Measurment
			Adc Measurement with 7 sample
			Clear Pin before ADC Measurment
			Other Application Statement
#endif 
            LED OFF to indicate going to standby 

            
#if 1 // Pre-request for Standby mode 
            enterStandby();
            DL_TimerG_startCounter(TIMER_0_INST);
    
#endif // Pre-request for Standby mode ****



            break;
        default:
            break;
    }
}
