AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/xplained/ASF/xmega/drivers/adc/adc.h
static inline void adcch_enable_correction (struct adc_channel_config
					      *ch_conf, uint16_t offset_corr,
					      uint16_t expected_value,
					      uint16_t captured_value)
  {
    uint32_t gain_corr;

    gain_corr = (2048L * expected_value) / captured_value;
    ch_conf->offsetcorr0 = LSB (offset_corr);
    ch_conf->offsetcorr1 = MSB (offset_corr);
    ch_conf->gaincorr0 = LSB (gain_corr);
    ch_conf->gaincorr1 = MSB (gain_corr);
    ch_conf->corrctrl = ADC_CH_CORREN_bm;
  }
/**
 * \brief Enable gain & offset corrections on ADC channel
 *
 * \param ch_conf         Pointer to ADC channel configuration.
 * \param offset_corr     Offset correction value to set.
 * \param expected_value  Expected value for a specific input voltage
 * \param captured_value  Captured value for a specific input voltage
 *
 * \Note
 * Gived "expected_value = captured_value = 1" to ignore the gain correction
 * Gain correction is equal to "expected_value / captured_value"
 */
\brief Enable gain & offset corrections on ADC channel
\param ch_conf         Pointer to ADC channel configuration.
\param offset_corr     Offset correction value to set.
\param expected_value  Expected value for a specific input voltage
\param captured_value  Captured value for a specific input voltage

\Note
Gived "expected_value = captured_value = 1" to ignore the gain correction
Gain correction is equal to "expected_value / captured_value"
\ brief Enable gain & offset corrections on ADC channel \ param ch_conf Pointer to ADC channel configuration . \ param offset_corr Offset correction value to set . \ param expected_value Expected value for a specific input voltage \ param captured_value Captured value for a specific input voltage \ Note Gived " expected_value = captured_value = 1 " to ignore the gain correction Gain correction is equal to " expected_value / captured_value "
static inline void adcch_enable_correction (struct adc_channel_config
					      *ch_conf, uint16_t offset_corr,
					      uint16_t expected_value,
					      uint16_t captured_value)
  {
    uint32_t gain_corr;
    gain_corr = (2048L * expected_value) / captured_value;
    ch_conf->offsetcorr0 = LSB (offset_corr);
    ch_conf->offsetcorr1 = MSB (offset_corr);
    ch_conf->gaincorr0 = LSB (gain_corr);
    ch_conf->gaincorr1 = MSB (gain_corr);
    ch_conf->corrctrl = ADC_CH_CORREN_bm;
  }
static inline void adcch_enable_correction ( struct adc_channel_config * ch_conf , uint16_t offset_corr , uint16_t expected_value , uint16_t captured_value ) { uint32_t gain_corr ; gain_corr = ( 2048L * expected_value ) / captured_value ; ch_conf -> offsetcorr0 = LSB ( offset_corr ) ; ch_conf -> offsetcorr1 = MSB ( offset_corr ) ; ch_conf -> gaincorr0 = LSB ( gain_corr ) ; ch_conf -> gaincorr1 = MSB ( gain_corr ) ; ch_conf -> corrctrl = ADC_CH_CORREN_bm ; }
\brief Enable gain & offset corrections on ADC channel
 \param ch_conf         Pointer to ADC channel configuration.
\ brief Enable gain & offset corrections on ADC channel \ param ch_conf Pointer to ADC channel configuration .