aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-08-25 08:45:58 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-08-25 08:45:58 +0000
commit6ccef4b00a5ab12265f57bcc70d7090aaf08163c (patch)
tree5d99df15de4715cb8ef2036ce6759dc0dacbf133 /os
parent2d9efb0eafab37e73a9be6280e677f720317d0c3 (diff)
downloadChibiOS-6ccef4b00a5ab12265f57bcc70d7090aaf08163c.tar.gz
ChibiOS-6ccef4b00a5ab12265f57bcc70d7090aaf08163c.tar.bz2
ChibiOS-6ccef4b00a5ab12265f57bcc70d7090aaf08163c.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7190 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/ports/STM32/STM32F0xx/adc_lld.c11
-rw-r--r--os/hal/ports/STM32/STM32F0xx/adc_lld.h27
2 files changed, 27 insertions, 11 deletions
diff --git a/os/hal/ports/STM32/STM32F0xx/adc_lld.c b/os/hal/ports/STM32/STM32F0xx/adc_lld.c
index 1cc1bdcd1..753f4ac43 100644
--- a/os/hal/ports/STM32/STM32F0xx/adc_lld.c
+++ b/os/hal/ports/STM32/STM32F0xx/adc_lld.c
@@ -245,13 +245,15 @@ void adc_lld_stop(ADCDriver *adcp) {
* @notapi
*/
void adc_lld_start_conversion(ADCDriver *adcp) {
- uint32_t mode;
+ uint32_t mode, cfgr1;
const ADCConversionGroup *grpp = adcp->grpp;
/* DMA setup.*/
- mode = adcp->dmamode;
+ mode = adcp->dmamode;
+ cfgr1 = grpp->cfgr1 | ADC_CFGR1_DMAEN;
if (grpp->circular) {
- mode |= STM32_DMA_CR_CIRC;
+ mode |= STM32_DMA_CR_CIRC;
+ cfgr1 |= ADC_CFGR1_DMACFG;
if (adcp->depth > 1) {
/* If circular buffer depth > 1, then the half transfer interrupt
is enabled in order to allow streaming processing.*/
@@ -273,8 +275,7 @@ void adc_lld_start_conversion(ADCDriver *adcp) {
adcp->adc->CHSELR = grpp->chselr;
/* ADC configuration and start.*/
- adcp->adc->CFGR1 = grpp->cfgr1 | ADC_CFGR1_CONT | ADC_CFGR1_DMACFG |
- ADC_CFGR1_DMAEN;
+ adcp->adc->CFGR1 = cfgr1;
adcp->adc->CR |= ADC_CR_ADSTART;
}
diff --git a/os/hal/ports/STM32/STM32F0xx/adc_lld.h b/os/hal/ports/STM32/STM32F0xx/adc_lld.h
index 4ccd50eb7..ec765df67 100644
--- a/os/hal/ports/STM32/STM32F0xx/adc_lld.h
+++ b/os/hal/ports/STM32/STM32F0xx/adc_lld.h
@@ -46,20 +46,30 @@
/** @} */
/**
- * @name Resolution
+ * @name CFGR1 register configuration helpers
* @{
*/
-#define ADC_CFGR1_RES_12BIT (0 << 3)
-#define ADC_CFGR1_RES_10BIT (1 << 3)
-#define ADC_CFGR1_RES_8BIT (2 << 3)
-#define ADC_CFGR1_RES_6BIT (3 << 3)
+#define ADC_CFGR1_RES_12BIT (0 << 3)
+#define ADC_CFGR1_RES_10BIT (1 << 3)
+#define ADC_CFGR1_RES_8BIT (2 << 3)
+#define ADC_CFGR1_RES_6BIT (3 << 3)
+
+#define ADC_CFGR1_EXTSEL_MASK (15 << 6)
+#define ADC_CFGR1_EXTSEL_SRC(n) ((n) << 6)
+
+#define ADC_CFGR1_EXTEN_MASK (3 << 10)
+#define ADC_CFGR1_EXTEN_DISABLED (0 << 10)
+#define ADC_CFGR1_EXTEN_RISING (1 << 10)
+#define ADC_CFGR1_EXTEN_FALLING (2 << 10)
+#define ADC_CFGR1_EXTEN_BOTH (3 << 10)
/** @} */
/**
* @name Threashold register initializer
* @{
*/
-#define ADC_TR(low, high) (((uint32_t)(high) << 16) | (uint32_t)(low))
+#define ADC_TR(low, high) (((uint32_t)(high) << 16) | \
+ (uint32_t)(low))
/** @} */
/*===========================================================================*/
@@ -210,6 +220,11 @@ typedef struct {
/* End of the mandatory fields.*/
/**
* @brief ADC CFGR1 register initialization data.
+ * @note The bits DMAEN and DMACFG are enforced internally
+ * to the driver, keep them to zero.
+ * @note The bits @p ADC_CFGR1_CONT or @p ADC_CFGR1_DISCEN must be
+ * specified in continuous more or if the buffer depth is
+ * greater than one.
*/
uint32_t cfgr1;
/**