void cc26xx_adc_init(uint32_t ADCInput)
{

	//intialisation of ADC
	ti_lib_aon_wuc_aux_wakeup_event(AONWUC_AUX_WAKEUP);
	while(!(ti_lib_aon_wuc_power_status_get() & AONWUC_AUX_POWER_ON))
	{ }

	// Enable clock for ADC digital and analog interface (not currently enabled in driver)
	// Enable clocks
	ti_lib_aux_wuc_clock_enable(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK);
	while(ti_lib_aux_wuc_clock_status(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK) != AUX_WUC_CLOCK_READY)
	{ }

	printf("clock selected\r\n");

	// Connect AUX IO7 (DIO23, but also DP2 on XDS110) as analog input.
	AUXADCSelectInput(ADCInput);
	printf("input selected\r\n");

	// Set up ADC range
	// AUXADC_REF_FIXED = nominally 4.3 V
	AUXADCEnableSync(AUXADC_REF_FIXED,  AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL);
	printf("init adc --- OK\r\n");
}
static uint16_t Get_ADC_reading(void)
{
      uint16_t  result_data = 0;
      uint16_t ADC_array[ADC_Average] = {0};
      int32_t adc_temp=0;      
      double result=0;
      sensor_power_set_on();
      adc_ct_select_set_on();
      // Enable AUX 
      ti_lib_aon_wuc_aux_wakeup_event(AONWUC_AUX_WAKEUP);
      while(!(ti_lib_aon_wuc_power_status_get() & AONWUC_AUX_POWER_ON))
      { }

      

      // Enable clocks
      ti_lib_aux_wuc_clock_enable(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK);
      while(ti_lib_aux_wuc_clock_status(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK) != AUX_WUC_CLOCK_READY)
      { }

      
      // Select input
      AUXADCSelectInput(ADC_COMPB_IN_AUXIO5);
      

      // Configure and enable
    //  AUXADCEnableSync(AUXADC_REF_VDDS_REL,  AUXADC_SAMPLE_TIME_10P6_US, AUXADC_TRIGGER_MANUAL);
      AUXADCEnableSync(AUXADC_REF_VDDS_REL,  AUXADC_SAMPLE_TIME_170_US, AUXADC_TRIGGER_MANUAL);    
     // AUXADCEnableSync(AUXADC_REF_FIXED,  AUXADC_SAMPLE_TIME_10P6_US, AUXADC_TRIGGER_MANUAL);

  
     
          
      // Read
      for(int i=0;i<ADC_Average;i++)
      {
        AUXADCGenManualTrigger();
        
        adc_temp = AUXADCReadFifo();
        if(adc_temp<2048)
        {
           result = adc_temp - 2048;        
          
        }else{
          
           result = adc_temp;
          
        }
        
        ADC_array[i] = (uint16_t)(abs(result));
       //  AUXADCReadFifo();
        
      }
      
      result_data = Adc_Average(ADC_array);
      
     // result_data = upcount++;
    //  AUXADCGenManualTrigger();
    //  result_data = AUXADCReadFifo();
      
      
      


      // Disable ADC
      AUXADCDisable();
      adc_ct_select_set_off();
     // relay_all_clear();
     // sensor_power_set_off();
      
      return result_data;
      
}