aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/STM32F0xx
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-05-26 11:24:52 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-05-26 11:24:52 +0000
commit6e2f377dd5b17c3ab2836a5ae5406676275f9bb5 (patch)
treed8012df76077d3733ae01b164818f946acddb52a /os/hal/platforms/STM32F0xx
parent512b78de728dfa1fe6bacadc525c8edc1dfdb041 (diff)
downloadChibiOS-6e2f377dd5b17c3ab2836a5ae5406676275f9bb5.tar.gz
ChibiOS-6e2f377dd5b17c3ab2836a5ae5406676275f9bb5.tar.bz2
ChibiOS-6e2f377dd5b17c3ab2836a5ae5406676275f9bb5.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4235 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms/STM32F0xx')
-rw-r--r--os/hal/platforms/STM32F0xx/adc_lld.c32
-rw-r--r--os/hal/platforms/STM32F0xx/adc_lld.h10
2 files changed, 18 insertions, 24 deletions
diff --git a/os/hal/platforms/STM32F0xx/adc_lld.c b/os/hal/platforms/STM32F0xx/adc_lld.c
index 751f15afd..95e0ddf77 100644
--- a/os/hal/platforms/STM32F0xx/adc_lld.c
+++ b/os/hal/platforms/STM32F0xx/adc_lld.c
@@ -174,6 +174,16 @@ void adc_lld_start(ADCDriver *adcp) {
chDbgAssert(!b, "adc_lld_start(), #1", "stream already allocated");
dmaStreamSetPeripheral(adcp->dmastp, &ADC1->DR);
rccEnableADC1(FALSE);
+#if STM32_ADCSW == STM32_ADCSW_HSI14
+ /* Clock from HSI14, no need for jitter removal.*/
+ ADC1->CFGR2 = 0x00001000;
+#else
+#if STM32_ADCPRE == STM32_ADCPRE_DIV2
+ ADC1->CFGR2 = 0x00001000 | ADC_CFGR2_JITOFFDIV2;
+#else
+ ADC1->CFGR2 = 0x00001000 | ADC_CFGR2_JITOFFDIV4;
+#endif
+#endif
}
#endif /* STM32_ADC_USE_ADC1 */
@@ -265,28 +275,6 @@ void adc_lld_stop_conversion(ADCDriver *adcp) {
adc_lld_stop_adc(adcp->adc);
}
-/**
- * @brief Enables the TSVREFE bit.
- * @details The TSVREFE bit is required in order to sample the internal
- * temperature sensor and internal reference voltage.
- * @note This is an STM32-only functionality.
- */
-void adcSTM32EnableTSVREFE(void) {
-
- ADC->CCR |= ADC_CCR_VREFEN;
-}
-
-/**
- * @brief Disables the TSVREFE bit.
- * @details The TSVREFE bit is required in order to sample the internal
- * temperature sensor and internal reference voltage.
- * @note This is an STM32-only functionality.
- */
-void adcSTM32DisableTSVREFE(void) {
-
- ADC->CCR &= ~ADC_CCR_VREFEN;
-}
-
#endif /* HAL_USE_ADC */
/** @} */
diff --git a/os/hal/platforms/STM32F0xx/adc_lld.h b/os/hal/platforms/STM32F0xx/adc_lld.h
index 3be5a053c..31029f31c 100644
--- a/os/hal/platforms/STM32F0xx/adc_lld.h
+++ b/os/hal/platforms/STM32F0xx/adc_lld.h
@@ -264,6 +264,14 @@ struct ADCDriver {
/* Driver macros. */
/*===========================================================================*/
+/**
+ * @brief Changes the value of the ADC CCR register.
+ * @details Use this function in order to enable or disable the internal
+ * analog sources. See the documentation in the STM32F0xx Reference
+ * Manual.
+ */
+#define adcSTM32SetCCR(ccr) (ADC->CCR = (ccr))
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
@@ -280,8 +288,6 @@ extern "C" {
void adc_lld_stop(ADCDriver *adcp);
void adc_lld_start_conversion(ADCDriver *adcp);
void adc_lld_stop_conversion(ADCDriver *adcp);
- void adcSTM32EnableTSVREFE(void);
- void adcSTM32DisableTSVREFE(void);
#ifdef __cplusplus
}
#endif