From 84f8e01c17ebb2f376e0c5f281f93d9554960ba3 Mon Sep 17 00:00:00 2001 From: Juha Niskanen Date: Wed, 8 Aug 2018 06:55:25 -0600 Subject: [PATCH] arch/arm/src/stm32l4: Fix ADC and COMP breakage caused by CONFIG_STM32L4_STM32L4X2 separation in 9223123c --- arch/arm/src/stm32l4/Kconfig | 6 ++-- arch/arm/src/stm32l4/README.txt | 41 ++++++++++++++++++------ arch/arm/src/stm32l4/stm32l4.h | 1 + arch/arm/src/stm32l4/stm32l4_adc.c | 14 ++++---- arch/arm/src/stm32l4/stm32l4_comp.c | 10 +++--- arch/arm/src/stm32l4/stm32l4_comp.h | 2 +- arch/arm/src/stm32l4/stm32l4_exti_comp.c | 4 +-- 7 files changed, 50 insertions(+), 28 deletions(-) diff --git a/arch/arm/src/stm32l4/Kconfig b/arch/arm/src/stm32l4/Kconfig index 0178dc2af43..e7d93fce95c 100644 --- a/arch/arm/src/stm32l4/Kconfig +++ b/arch/arm/src/stm32l4/Kconfig @@ -403,7 +403,7 @@ config STM32L4_STM32L4X2 select ARCH_HAVE_FPU select STM32L4_HAVE_USART1 select STM32L4_HAVE_USART2 - select STM32L4_HAVE_UART3 + select STM32L4_HAVE_USART3 if !(STM32L4_L432XX || STM32L4_L442XX) select STM32L4_HAVE_LPTIM1 select STM32L4_HAVE_LPTIM2 select STM32L4_HAVE_COMP @@ -415,12 +415,12 @@ config STM32L4_STM32L4X3 select ARCH_HAVE_FPU select STM32L4_HAVE_USART1 select STM32L4_HAVE_USART2 - select STM32L4_HAVE_USART3 if !(STM32L4_L432XX || STM32L4_L442XX) + select STM32L4_HAVE_USART3 select STM32L4_HAVE_LPTIM1 select STM32L4_HAVE_LPTIM2 select STM32L4_HAVE_COMP select STM32L4_HAVE_SAI1 - select STM32L4_HAVE_LCD if !(STM32L4_STM32L4X1 || STM32L4_STM32L4X2) + select STM32L4_HAVE_LCD if !STM32L4_STM32L4X1 config STM32L4_STM32L4X5 bool diff --git a/arch/arm/src/stm32l4/README.txt b/arch/arm/src/stm32l4/README.txt index a5ca0b9bf8e..f4ff8a2a88d 100644 --- a/arch/arm/src/stm32l4/README.txt +++ b/arch/arm/src/stm32l4/README.txt @@ -1,9 +1,32 @@ This is a port of NuttX to the STM32L4 Family Used development boards are the Nucleo L476RG, Nucleo L496ZG, -Nucleo L452RE and STM32L4VGDiscovery. +Nucleo L452RE, Nucleo L432KC, STM32L4VG Discovery and +Motorola MDK. + +Most code is copied and adapted from the STM32 and STM32F7 ports. + +The various supported STM32L4 families are: + +------------------------------------------------------------- +| NuttX config | Manual | Chips +| +| Not supported | RM0392 | STM32L471xx +| +| STM32L4_STM32L4X1 | RM0394 | Subset of STM32L4_STM32L4X3 +| +| STM32L4_STM32L4X2 | RM0394 | Subset of STM32L4_STM32L4X3 +| +| STM32L4_STM32L4X3 | RM0394 | STM32L43xxx/44xxx/45xxx/46xxx +| +| STM32L4_STM32L4X5 | RM0351 | STM32L475xx (was RM0395 in past) +| +| STM32L4_STM32L4X6 | RM0351 | STM32L476xx, STM32L486xx, +| STM32L496xx, STM32L4A6xx +| +| Not supported | RM0432 | STM32L4Rxxx, STM32L4Sxxx +------------------------------------------------------------- -Most code is copied and adapted from the STM32 Port. TODO list --------- @@ -12,7 +35,7 @@ Peripherals with implementation in STM32 port: IRQs : OK GPIO : OK -EXTI : OK, to be tested. +EXTI : OK HSI : OK HSE : OK PLL : Works @ 80 MHz @@ -24,8 +47,8 @@ USART : Working in normal mode (no DMA, to be tested, code is written) DMA : works; at least tested with QSPI SRAM2 : OK; can be included in MM region or left separate for special app : purposes -SPI : OK, tested (Including DMA) -I2C : Code written, to be tested +SPI : OK, tested (including DMA) +I2C : works RTC : works QSPI : works in polling, interrupt, DMA, and also memory-mapped modes CAN : OK, tested @@ -42,12 +65,12 @@ RNG : works CRC : TODO (configurable polynomial) WWDG : TODO IWDG : works -MMCSD : TODO -ADC : Code written, to be tested -DAC : Code written, to be tested +SDMMC : works +ADC : works +DAC : works DMA2D : TODO (Chrom-Art Accelerator for image manipulation) -New peripherals with implementation to be written from scratch +New peripherals with implementation to be written from scratch. These are Low Priority TODO items, unless someone requests or contributes it. diff --git a/arch/arm/src/stm32l4/stm32l4.h b/arch/arm/src/stm32l4/stm32l4.h index 9a942ca8642..66d27ba7b25 100644 --- a/arch/arm/src/stm32l4/stm32l4.h +++ b/arch/arm/src/stm32l4/stm32l4.h @@ -59,6 +59,7 @@ #include "stm32l4_adc.h" #include "stm32l4_can.h" #include "stm32l4_comp.h" +#include "stm32l4_dac.h" #include "stm32l4_dbgmcu.h" #include "stm32l4_dma.h" #include "stm32l4_exti.h" diff --git a/arch/arm/src/stm32l4/stm32l4_adc.c b/arch/arm/src/stm32l4/stm32l4_adc.c index ada9f4d8791..6acbe84a106 100644 --- a/arch/arm/src/stm32l4/stm32l4_adc.c +++ b/arch/arm/src/stm32l4/stm32l4_adc.c @@ -76,13 +76,14 @@ #if defined(CONFIG_STM32L4_ADC1) || defined(CONFIG_STM32L4_ADC2) || \ defined(CONFIG_STM32L4_ADC3) -/* This implementation is for the STM32L4X3 and STM32L4X6 only */ +#if !(defined(CONFIG_STM32L4_STM32L4X2) || defined(CONFIG_STM32L4_STM32L4X3) || \ + defined(CONFIG_STM32L4_STM32L4X6)) +# error "Unrecognized STM32 chip" +#endif -#if defined(CONFIG_STM32L4_STM32L4X3) || defined(CONFIG_STM32L4_STM32L4X6) - -#if defined(CONFIG_STM32L4_STM32L4X3) +#if defined(CONFIG_STM32L4_STM32L4X2) || defined(CONFIG_STM32L4_STM32L4X3) # if defined(CONFIG_STM32L4_ADC2) || defined(CONFIG_STM32L4_ADC3) -# error "Using non-existent ADC on STM32L4X3" +# error "Using non-existent ADC" # endif #endif @@ -104,7 +105,7 @@ /* ADC interrupts ***********************************************************/ -#if defined(CONFIG_STM32L4_STM32L4X3) +#if defined(CONFIG_STM32L4_STM32L4X2) || defined(CONFIG_STM32L4_STM32L4X3) # define STM32L4_IRQ_ADC12 STM32L4_IRQ_ADC1 #endif @@ -2034,6 +2035,5 @@ struct adc_dev_s *stm32l4_adc_initialize(int intf, FAR const uint8_t *chanlist, return dev; } -#endif /* CONFIG_STM32L4_STM32L4X3 || CONFIG_STM32L4_STM32L4X6 */ #endif /* CONFIG_STM32L4_ADC1 || CONFIG_STM32L4_ADC2 || CONFIG_STM32L4_ADC3 */ #endif /* CONFIG_ADC */ diff --git a/arch/arm/src/stm32l4/stm32l4_comp.c b/arch/arm/src/stm32l4/stm32l4_comp.c index 2a63b031bfe..bcc8d1cd894 100644 --- a/arch/arm/src/stm32l4/stm32l4_comp.c +++ b/arch/arm/src/stm32l4/stm32l4_comp.c @@ -1,5 +1,4 @@ /**************************************************************************** - * arch/arm/src/stm32l4/stm32l4_comp.c * * Copyright (c) 2017 Gregory Nutt. All rights reserved. @@ -38,7 +37,6 @@ ****************************************************************************/ /**************************************************************************** - * Included Files ****************************************************************************/ @@ -56,8 +54,8 @@ #include -#if !(defined(CONFIG_STM32L4_STM32L4X3) || defined(CONFIG_STM32L4_STM32L4X5) || \ - defined(CONFIG_STM32L4_STM32L4X6)) +#if !(defined(CONFIG_STM32L4_STM32L4X2) || defined(CONFIG_STM32L4_STM32L4X3) || \ + defined(CONFIG_STM32L4_STM32L4X5) || defined(CONFIG_STM32L4_STM32L4X6)) # error "Unrecognized STM32 chip" #endif @@ -375,7 +373,7 @@ static int stm32l4_compconfig(FAR const struct comp_dev_s *dev) regval |= COMP_CSR_INPSEL_PIN2; break; -#if defined(CONFIG_STM32L4_STM32L4X3) +#if defined(CONFIG_STM32L4_STM32L4X2) || defined(CONFIG_STM32L4_STM32L4X3) case STM32L4_COMP_INP_PIN_3: stm32l4_configgpio(cmp == STM32L4_COMP1 ? GPIO_COMP1_INP_3 : GPIO_COMP2_INP_3); regval |= COMP_CSR_INPSEL_PIN3; @@ -439,7 +437,7 @@ static int stm32l4_compconfig(FAR const struct comp_dev_s *dev) #endif break; -#if defined(CONFIG_STM32L4_STM32L4X3) +#if defined(CONFIG_STM32L4_STM32L4X2) || defined(CONFIG_STM32L4_STM32L4X3) case STM32L4_COMP_INM_PIN_3: stm32l4_configgpio(cmp == STM32L4_COMP1 ? GPIO_COMP1_INM_3 : GPIO_COMP2_INM_3); regval |= COMP_CSR_INMSEL_INMESEL; diff --git a/arch/arm/src/stm32l4/stm32l4_comp.h b/arch/arm/src/stm32l4/stm32l4_comp.h index 6d939520b37..fe7185301e0 100644 --- a/arch/arm/src/stm32l4/stm32l4_comp.h +++ b/arch/arm/src/stm32l4/stm32l4_comp.h @@ -50,7 +50,7 @@ * Public Types ************************************************************************************/ -#if defined(CONFIG_STM32L4_STM32L4X3) +#if defined(CONFIG_STM32L4_STM32L4X2) || defined(CONFIG_STM32L4_STM32L4X3) /* Comparators */ diff --git a/arch/arm/src/stm32l4/stm32l4_exti_comp.c b/arch/arm/src/stm32l4/stm32l4_exti_comp.c index 390181c16c2..35c3796733d 100644 --- a/arch/arm/src/stm32l4/stm32l4_exti_comp.c +++ b/arch/arm/src/stm32l4/stm32l4_exti_comp.c @@ -69,8 +69,8 @@ static struct comp_callback_s g_comp_handlers[STM32L4_COMP_NUM]; static const uint32_t g_comp_lines[STM32L4_COMP_NUM] = { -#if defined(CONFIG_STM32L4_STM32L4X3) || defined (CONFIG_STM32L4_STM32L4X5) || \ - defined(CONFIG_STM32L4_STM32L4X6) +#if defined(CONFIG_STM32L4_STM32L4X2) || defined(CONFIG_STM32L4_STM32L4X3) || \ + defined(CONFIG_STM32L4_STM32L4X5) || defined(CONFIG_STM32L4_STM32L4X6) EXTI1_COMP1, EXTI1_COMP2 #else