summaryrefslogtreecommitdiff
path: root/tests/adc-power/adc-power.c
diff options
context:
space:
mode:
authorKarl Palsson <karlp@tweak.net.au>2015-11-03 23:21:44 +0000
committerKarl Palsson <karlp@tweak.net.au>2015-11-03 23:21:44 +0000
commit73e12bd0fdfc0f58212dbd248f7582f923240b62 (patch)
treea5aaa3143f63bbe88a42961943c824a2ad11f3e4 /tests/adc-power/adc-power.c
parent4a1f9d06d27fc5e76bfdd6d533f7c7fa9103473f (diff)
downloadolsndot-73e12bd0fdfc0f58212dbd248f7582f923240b62.tar.gz
olsndot-73e12bd0fdfc0f58212dbd248f7582f923240b62.tar.bz2
olsndot-73e12bd0fdfc0f58212dbd248f7582f923240b62.zip
f3 temp sensor working
Diffstat (limited to 'tests/adc-power/adc-power.c')
-rw-r--r--tests/adc-power/adc-power.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/adc-power/adc-power.c b/tests/adc-power/adc-power.c
index 4b591a6..db72a8e 100644
--- a/tests/adc-power/adc-power.c
+++ b/tests/adc-power/adc-power.c
@@ -21,10 +21,12 @@
// Still have some bad shit to deal with...
#if defined(STM32F3)
-#define SAMPLE_TIME_BASIC ADC_SMPR1_SMP_19DOT5CYC
+#define SAMPLE_TIME_BASIC ADC_SMPR1_SMP_181DOT5CYC
+#define SAMPLE_TIME_TEMP ADC_SMPR1_SMP_601DOT5CYC // 2.2usecs or more
+#define SAMPLE_TIME_VREF SAMPLE_TIME_TEMP
#elif defined(STM32F4)
#define SAMPLE_TIME_BASIC ADC_SMPR_SMP_28CYC
-#define SAMPLE_TIME_TEMP ADC_SMPR_SMP_144CYC
+#define SAMPLE_TIME_TEMP ADC_SMPR_SMP_144CYC // 10 usecs or more, in theory needs 840cycles!
#define SAMPLE_TIME_VREF SAMPLE_TIME_TEMP
#define ADC_CHANNEL_TEMP ADC_CHANNEL_TEMP_F40
#define SEPARATE_VREF 0
@@ -50,13 +52,8 @@ void adc_power_init(void)
rcc_periph_clock_enable(RCC_ADC12);
rcc_adc_prescale(RCC_CFGR2_ADCxPRES_PLL_CLK_DIV_1, RCC_CFGR2_ADCxPRES_PLL_CLK_DIV_1);
adc_enable_regulator(ADC1);
- adc_set_sample_time_on_all_channels(ADC1, ADC_SMPR1_SMP_19DOT5CYC);
#else
rcc_periph_clock_enable(RCC_ADC1);
- adc_set_sample_time_on_all_channels(ADC1, SAMPLE_TIME_BASIC);
- adc_set_sample_time(ADC1, ADC_CHANNEL_TEMP, SAMPLE_TIME_TEMP);
- adc_set_sample_time(ADC1, ADC_CHANNEL_TEMP, SAMPLE_TIME_VREF);
-
#if 0
// DANGER DANGER! doing this without DMA is dum.
// but... we're busy polling, we should be right... right?
@@ -68,6 +65,9 @@ void adc_power_init(void)
#endif
#endif
+ adc_set_sample_time_on_all_channels(ADC1, SAMPLE_TIME_BASIC);
+ adc_set_sample_time(ADC1, ADC_CHANNEL_TEMP, SAMPLE_TIME_TEMP);
+ adc_set_sample_time(ADC1, ADC_CHANNEL_TEMP, SAMPLE_TIME_VREF);
adc_enable_temperature_sensor();
#if (SEPARATE_VREF == 1)
adc_enable_vrefint();