1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

kinetis: Allow per-board config of ADC ref

ADC reference can be external pin or internal VREF module on most
Kinetis CPUs.
This commit is contained in:
Joakim Nohlgård 2018-02-14 15:14:50 +01:00
parent 2b7dc32035
commit b61eeb9fe0
5 changed files with 28 additions and 1 deletions

View File

@ -132,6 +132,13 @@ static const adc_conf_t adc_config[] = {
};
#define ADC_NUMOF (sizeof(adc_config) / sizeof(adc_config[0]))
/*
* K22F ADC reference settings:
* 0: VREFH/VREFL external pin pair
* 1: VREF_OUT internal 1.2 V reference (VREF module must be enabled)
* 2-3: reserved
*/
#define ADC_REF_SETTING 0
/** @} */
/**

View File

@ -126,6 +126,13 @@ static const adc_conf_t adc_config[] = {
};
#define ADC_NUMOF (sizeof(adc_config) / sizeof(adc_config[0]))
/*
* K64F ADC reference settings:
* 0: VREFH/VREFL external pin pair
* 1: VREF_OUT internal 1.2 V reference (VREF module must be enabled)
* 2-3: reserved
*/
#define ADC_REF_SETTING 0
/** @} */
/**

View File

@ -183,6 +183,13 @@ static const adc_conf_t adc_config[] = {
};
#define ADC_NUMOF (sizeof(adc_config) / sizeof(adc_config[0]))
/*
* K60D ADC reference settings:
* 0: VREFH/VREFL external pin pair
* 1: VREF_OUT internal 1.2 V reference (VREF module must be enabled)
* 2-3: reserved
*/
#define ADC_REF_SETTING 0
/** @} */
/**

View File

@ -141,6 +141,12 @@ static const adc_conf_t adc_config[] = {
};
#define ADC_NUMOF (sizeof(adc_config) / sizeof(adc_config[0]))
/*
* KW2xD ADC reference settings:
* 0: VREFH/VREFL external pin pair
* 1-3: reserved
*/
#define ADC_REF_SETTING 0
/** @} */
/**

View File

@ -196,7 +196,7 @@ int adc_init(adc_t line)
/* select ADxxb channels, longest sample time (20 extra ADC cycles) */
dev(line)->CFG2 = ADC_CFG2_MUXSEL_MASK | ADC_CFG2_ADLSTS(0);
/* select software trigger, external ref pins */
dev(line)->SC2 = ADC_SC2_REFSEL(0);
dev(line)->SC2 = ADC_SC2_REFSEL(ADC_REF_SETTING);
/* select hardware average over 32 samples */
dev(line)->SC3 = ADC_SC3_AVGE_MASK | ADC_SC3_AVGS(3);
/* set an (arbitrary) input channel, single-ended mode */