/*---------------------------------------------------------------------------*/ static int value(int type) { int channel; int16_t res; if(!(type & enabled_channels)) { PRINTF("ADC: channel not enabled\n"); return ZOUL_SENSORS_ERROR; } channel = get_channel_pin(type); if(channel == ZOUL_SENSORS_ERROR) { PRINTF("ADC: pin not active\n"); return ZOUL_SENSORS_ERROR; } res = adc_get(channel, ADC_SENSORS_REFERENCE, decimation_rate); /* Only allow negative values if using differential input */ if((ADC_SENSORS_REFERENCE != SOC_ADC_ADCCON_REF_EXT_DIFF) && (res < 0)) { res = 0; } return res; }
/*---------------------------------------------------------------------------*/ static int value(int type) { int channel; int16_t res; if(!(type & enabled_channels)) { return ZOUL_SENSORS_ERROR; } channel = get_channel_pin(type); if(channel == ZOUL_SENSORS_ERROR) { return ZOUL_SENSORS_ERROR; } res = adc_get(channel, SOC_ADC_ADCCON_REF_AVDD5, decimation_rate); return res; }