aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-01-11 10:38:11 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-01-11 10:38:11 +0000
commit72b36371b276d77da9d9654ff6338acc2c25015e (patch)
treeaf0a74d6fa1117beb9213ae7b93b14eb51c04c82 /os/hal
parentb4e1ecc760fb1dea0089428a4ba4cdd9510e1cdb (diff)
downloadChibiOS-72b36371b276d77da9d9654ff6338acc2c25015e.tar.gz
ChibiOS-72b36371b276d77da9d9654ff6338acc2c25015e.tar.bz2
ChibiOS-72b36371b276d77da9d9654ff6338acc2c25015e.zip
ADCv1 enhancement.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10031 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c92
-rw-r--r--os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.h8
2 files changed, 100 insertions, 0 deletions
diff --git a/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c b/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c
index 55d0d2d44..2f67aa80a 100644
--- a/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c
+++ b/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c
@@ -335,6 +335,98 @@ void adc_lld_serve_interrupt(ADCDriver *adcp) {
}
}
+/**
+ * @brief Enables the VREFEN bit.
+ * @details The VREFEN bit is required in order to sample the VREF channel.
+ * @note This is an STM32-only functionality.
+ * @note This function is meant to be called after @p adcStart().
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ *
+ * @notapi
+ */
+void adcSTM32EnableVREF(void) {
+
+ ADC->CCR |= ADC_CCR_VREFEN;
+}
+
+/**
+ * @brief Disables the VREFEN bit.
+ * @details The VREFEN bit is required in order to sample the VREF channel.
+ * @note This is an STM32-only functionality.
+ * @note This function is meant to be called after @p adcStart().
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ *
+ * @notapi
+ */
+void adcSTM32DisableVREF(void) {
+
+ ADC->CCR &= ~ADC_CCR_VREFEN;
+}
+
+/**
+ * @brief Enables the TSEN bit.
+ * @details The TSEN bit is required in order to sample the internal
+ * temperature sensor and internal reference voltage.
+ * @note This is an STM32-only functionality.
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ *
+ * @notapi
+ */
+void adcSTM32EnableTS(void) {
+
+ ADC->CCR |= ADC_CCR_TSEN;
+}
+
+/**
+ * @brief Disables the TSEN bit.
+ * @details The TSEN bit is required in order to sample the internal
+ * temperature sensor and internal reference voltage.
+ * @note This is an STM32-only functionality.
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ *
+ * @notapi
+ */
+void adcSTM32DisableTS(void) {
+
+ ADC->CCR &= ~ADC_CCR_TSEN;
+}
+
+#ifdef STM32F0XX
+/**
+ * @brief Enables the VBATEN bit.
+ * @details The VBATEN bit is required in order to sample the VBAT channel.
+ * @note This is an STM32-only functionality.
+ * @note This function is meant to be called after @p adcStart().
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ *
+ * @notapi
+ */
+void adcSTM32EnableVBAT(void) {
+
+ ADC->CCR |= ADC_CCR_VBATEN;
+}
+
+/**
+ * @brief Disables the VBATEN bit.
+ * @details The VBATEN bit is required in order to sample the VBAT channel.
+ * @note This is an STM32-only functionality.
+ * @note This function is meant to be called after @p adcStart().
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ *
+ * @notapi
+ */
+void adcSTM32DisableVBAT(void) {
+
+ ADC->CCR &= ~ADC_CCR_VBATEN;
+}
+#endif /* STM32F0XX */
+
#endif /* HAL_USE_ADC */
/** @} */
diff --git a/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.h b/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.h
index 6cb2e0a9a..93bba6cb9 100644
--- a/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.h
+++ b/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.h
@@ -430,6 +430,14 @@ extern "C" {
void adc_lld_start_conversion(ADCDriver *adcp);
void adc_lld_stop_conversion(ADCDriver *adcp);
void adc_lld_serve_interrupt(ADCDriver *adcp);
+ void adcSTM32EnableVREF(void);
+ void adcSTM32DisableVREF(void);
+ void adcSTM32EnableTS(void);
+ void adcSTM32DisableTS(void);
+#ifdef STM32F0XX
+ void adcSTM32EnableVBAT(void);
+ void adcSTM32DisableVBAT(void);
+#endif /* STM32F0XX */
#ifdef __cplusplus
}
#endif