Ejemplo n.º 1
0
Archivo: adc.c Proyecto: wzyy2/ECG-BLE
// auxIo, see MUX3 Register (Offset = 3h) [reset = X]
// auxIo, sensor controller engine IO, will map to M3's IO automatilcally
// for DIO23, auxIO7, the value should be 80h, 0x80
uint16_t OneShotADC(uint8_t auxIo)
{
  static __root uint16_t retval = 0xABBA;
  
  // Enable clock for ADC digital and analog interface (not currently enabled in driver)
  AUXWUCClockEnable(AUX_WUC_MODCLKEN0_ANAIF_M|AUX_WUC_MODCLKEN0_AUX_ADI4_M);
  // Connect AUX IO7 (DIO23) as analog input. Light sensor on SmartRF06EB
  AUXADCSelectInput(auxIo);
  
  // Set up ADC
  AUXADCEnableSync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL);
  
  // Disallow STANDBY mode while using the ADC.
  Power_setConstraint(Power_SB_DISALLOW);
  
  // Trigger ADC sampling
  AUXADCGenManualTrigger();
  
  retval = AUXADCReadFifo();
  
  // Disable ADC
  AUXADCDisable();
  // Allow STANDBY mode again
  Power_releaseConstraint(Power_SB_DISALLOW);
  
  return retval;
}
Ejemplo n.º 2
0
void adcIsr(UArg a0) {

  // Pop sample from FIFO to allow clearing ADC_IRQ event
  singleSample = AUXADCReadFifo();
  // Clear ADC_IRQ flag. Note: Missing driver for this.
  HWREGBITW(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOMCUFLAGSCLR, AUX_EVCTL_EVTOMCUFLAGSCLR_ADC_IRQ_BITN) = 1;

  // Post semaphore to wakeup task
  Semaphore_post(hSem);

}
uint16_t cc26xx_get_adc_value()
{
	uint16_t singleSample = AUXADCReadFifo();
	return singleSample;
}
Ejemplo n.º 4
0
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;
      
}