diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-07-27 08:18:34 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-07-27 08:18:34 +0000 |
commit | 4a3264b5bfe5adaab913e2d987193dc91d3ea3b3 (patch) | |
tree | 40d7bbba4310789b5c7afc294dd288f01b4220df | |
parent | 6425481eb9383061a876f73b41d4a3bfda939e94 (diff) | |
download | ChibiOS-4a3264b5bfe5adaab913e2d987193dc91d3ea3b3.tar.gz ChibiOS-4a3264b5bfe5adaab913e2d987193dc91d3ea3b3.tar.bz2 ChibiOS-4a3264b5bfe5adaab913e2d987193dc91d3ea3b3.zip |
STM32L0xx ADC now working.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8111 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | os/hal/ports/STM32/LLD/ADCv1/adc_lld.c | 10 | ||||
-rw-r--r-- | testhal/STM32/STM32L0xx/ADC/main.c | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/os/hal/ports/STM32/LLD/ADCv1/adc_lld.c b/os/hal/ports/STM32/LLD/ADCv1/adc_lld.c index 4f947f085..d8e70201a 100644 --- a/os/hal/ports/STM32/LLD/ADCv1/adc_lld.c +++ b/os/hal/ports/STM32/LLD/ADCv1/adc_lld.c @@ -30,6 +30,9 @@ /* Driver local definitions. */
/*===========================================================================*/
+#define ADC1_DMA_CHANNEL \
+ STM32_DMA_GETCHANNEL(STM32_ADC_ADC1_DMA_STREAM, STM32_ADC1_DMA_CHN)
+
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
@@ -130,8 +133,9 @@ void adc_lld_init(void) { /* Driver initialization.*/
adcObjectInit(&ADCD1);
ADCD1.adc = ADC1;
- ADCD1.dmastp = STM32_DMA1_STREAM1;
- ADCD1.dmamode = STM32_DMA_CR_PL(STM32_ADC_ADC1_DMA_PRIORITY) |
+ ADCD1.dmastp = STM32_DMA_STREAM(STM32_ADC_ADC1_DMA_STREAM);
+ ADCD1.dmamode = STM32_DMA_CR_CHSEL(ADC1_DMA_CHANNEL) |
+ STM32_DMA_CR_PL(STM32_ADC_ADC1_DMA_PRIORITY) |
STM32_DMA_CR_DIR_P2M |
STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_PSIZE_HWORD |
STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE |
@@ -258,7 +262,7 @@ void adc_lld_start_conversion(ADCDriver *adcp) { #if STM32_ADC_SUPPORTS_OVERSAMPLING == TRUE
{
uint32_t cfgr2 = adcp->adc->CFGR2 & STM32_ADC_CKMODE_MASK;
- adcp->adc->CFGR1 = cfgr2 | grpp->cfgr2;
+ adcp->adc->CFGR2 = cfgr2 | grpp->cfgr2;
}
#endif
diff --git a/testhal/STM32/STM32L0xx/ADC/main.c b/testhal/STM32/STM32L0xx/ADC/main.c index 6c2020646..4cb541966 100644 --- a/testhal/STM32/STM32L0xx/ADC/main.c +++ b/testhal/STM32/STM32L0xx/ADC/main.c @@ -145,7 +145,7 @@ int main(void) { * Normal main() thread activity, in this demo it does nothing.
*/
while (true) {
- if (palReadPad(GPIOC, GPIOC_BUTTON)) {
+ if (!palReadPad(GPIOC, GPIOC_BUTTON)) {
adcStopConversion(&ADCD1);
adcSTM32SetCCR(0);
}
|