Daniel Pereira de Carvalho
Em qui., 9 de jan. de 2020 às 16:59, Gregory Nutt <spudan...@gmail.com> escreveu: > > > The following patch add support to LPTIM2 PWM output on nucleo-l432kc. > > I don't see anything attached. Currently dev@nuttx.apache.org is > removing attachments with the extension. I know that is a bad behavior > and needs to be fixed someday. > > If you change the patch extension to .txt, it will not be removed. > > Sorry about the inconvenience. > > Greg > > >
From 83780095060c27fe955794ffed4882bd9cfed714 Mon Sep 17 00:00:00 2001 From: "Daniel P. Carvalho" <daniel...@gmail.com> Date: Thu, 9 Jan 2020 16:48:28 -0300 Subject: [PATCH] Remove LPTIM1/2 duplicated entrys on Timer Configuration Menu. Timers TIM3, TIM4, TIM5, TIM8 and TIM17 are not available on STM32L432KC. Added support for timers LPTIM1/2. --- arch/arm/src/stm32l4/Kconfig | 26 ------- .../arm/stm32l4/nucleo-l432kc/include/board.h | 16 +++++ .../nucleo-l432kc/include/nucleo-l432kc.h | 2 + .../arm/stm32l4/nucleo-l432kc/src/stm32_pwm.c | 69 +++---------------- 4 files changed, 26 insertions(+), 87 deletions(-) diff --git a/arch/arm/src/stm32l4/Kconfig b/arch/arm/src/stm32l4/Kconfig index d79508364d..3d372197c6 100644 --- a/arch/arm/src/stm32l4/Kconfig +++ b/arch/arm/src/stm32l4/Kconfig @@ -2993,19 +2993,6 @@ endif # !STM32L4_PWM_MULTICHAN endif # STM32L4_TIM17_PWM -config STM32L4_LPTIM1_PWM - bool "LPTIM1 PWM" - default n - depends on STM32L4_LPTIM1 - select PWM - ---help--- - Reserve Low-power timer 1 for use by PWM - - Timer devices may be used for different purposes. One special purpose is - to generate modulated outputs for such things as motor control. If STM32L4_LPTIM1 - is defined then THIS following may also be defined to indicate that - the timer is intended to be used for pulsed output modulation. - if STM32L4_LPTIM1_PWM if STM32L4_PWM_MULTICHAN @@ -3049,19 +3036,6 @@ endif # !STM32L4_PWM_MULTICHAN endif # STM32L4_LPTIM1_PWM -config STM32L4_LPTIM2_PWM - bool "LPTIM2 PWM" - default n - depends on STM32L4_LPTIM2 - select PWM - ---help--- - Reserve Low-power timer 2 for use by PWM - - Timer devices may be used for different purposes. One special purpose is - to generate modulated outputs for such things as motor control. If STM32L4_LPTIM2 - is defined then THIS following may also be defined to indicate that - the timer is intended to be used for pulsed output modulation. - if STM32L4_LPTIM2_PWM if STM32L4_PWM_MULTICHAN diff --git a/boards/arm/stm32l4/nucleo-l432kc/include/board.h b/boards/arm/stm32l4/nucleo-l432kc/include/board.h index d934b6a548..ae9ceb9ea7 100644 --- a/boards/arm/stm32l4/nucleo-l432kc/include/board.h +++ b/boards/arm/stm32l4/nucleo-l432kc/include/board.h @@ -246,6 +246,22 @@ #define GPIO_TIM1_CH2OUT GPIO_TIM1_CH2OUT_1 #define GPIO_TIM1_CH2NOUT GPIO_TIM1_CH2N_1 +/* LPTIM2 PWM output + * REVISIT : Add support for the other clock sources, LSE, LSI and HSI + * + * CH1 | 1(A4) 2(A8) + */ + +#if defined(CONFIG_STM32L4_LPTIM2_CLK_APB1) +# define STM32L4_LPTIM2_FREQUENCY STM32L4_APB1_LPTIM2_CLKIN +#endif + +#if 1 +# define GPIO_LPTIM2_CH1OUT GPIO_LPTIM2_OUT_1 +#else +# define GPIO_LPTIM2_CH1OUT GPIO_LPTIM2_OUT_2 +#endif + /******************************************************************************* * Public Data ******************************************************************************/ diff --git a/boards/arm/stm32l4/nucleo-l432kc/include/nucleo-l432kc.h b/boards/arm/stm32l4/nucleo-l432kc/include/nucleo-l432kc.h index c1036d25fa..480a47e314 100644 --- a/boards/arm/stm32l4/nucleo-l432kc/include/nucleo-l432kc.h +++ b/boards/arm/stm32l4/nucleo-l432kc/include/nucleo-l432kc.h @@ -286,6 +286,8 @@ #define STM32L4_APB1_TIM2_CLKIN (STM32L4_PCLK1_FREQUENCY) #define STM32L4_APB1_TIM6_CLKIN (STM32L4_PCLK1_FREQUENCY) #define STM32L4_APB1_TIM7_CLKIN (STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_LPTIM1_CLKIN (STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_LPTIM2_CLKIN (STM32L4_PCLK1_FREQUENCY) /* APB2 clock (PCLK2) is HCLK (80MHz) */ diff --git a/boards/arm/stm32l4/nucleo-l432kc/src/stm32_pwm.c b/boards/arm/stm32l4/nucleo-l432kc/src/stm32_pwm.c index 06cea8ccb6..e479223f74 100644 --- a/boards/arm/stm32l4/nucleo-l432kc/src/stm32_pwm.c +++ b/boards/arm/stm32l4/nucleo-l432kc/src/stm32_pwm.c @@ -137,8 +137,8 @@ int stm32l4_pwm_setup(void) } #endif -#if defined(CONFIG_STM32L4_TIM3_PWM) - pwm = stm32l4_pwminitialize(3); +#if defined(CONFIG_STM32L4_TIM15_PWM) + pwm = stm32l4_pwminitialize(15); if (!pwm) { aerr("ERROR: Failed to get the STM32L4 PWM lower half\n"); @@ -155,8 +155,8 @@ int stm32l4_pwm_setup(void) } #endif -#if defined(CONFIG_STM32L4_TIM4_PWM) - pwm = stm32l4_pwminitialize(4); +#if defined(CONFIG_STM32L4_TIM16_PWM) + pwm = stm32l4_pwminitialize(16); if (!pwm) { aerr("ERROR: Failed to get the STM32L4 PWM lower half\n"); @@ -173,8 +173,8 @@ int stm32l4_pwm_setup(void) } #endif -#if defined(CONFIG_STM32L4_TIM5_PWM) - pwm = stm32l4_pwminitialize(5); +#if defined(CONFIG_STM32L4_LPTIM1_PWM) + pwm = stm32l4_lp_pwminitialize(1); if (!pwm) { aerr("ERROR: Failed to get the STM32L4 PWM lower half\n"); @@ -191,8 +191,8 @@ int stm32l4_pwm_setup(void) } #endif -#if defined(CONFIG_STM32L4_TIM8_PWM) - pwm = stm32l4_pwminitialize(8); +#if defined(CONFIG_STM32L4_LPTIM2_PWM) + pwm = stm32l4_lp_pwminitialize(2); if (!pwm) { aerr("ERROR: Failed to get the STM32L4 PWM lower half\n"); @@ -209,59 +209,6 @@ int stm32l4_pwm_setup(void) } #endif -#if defined(CONFIG_STM32L4_TIM15_PWM) - pwm = stm32l4_pwminitialize(15); - if (!pwm) - { - aerr("ERROR: Failed to get the STM32L4 PWM lower half\n"); - return -ENODEV; - } - - /* Register the PWM driver at "/dev/pwm6" */ - - ret = pwm_register("/dev/pwm6", pwm); - if (ret < 0) - { - aerr("ERROR: pwm_register failed: %d\n", ret); - return ret; - } -#endif - -#if defined(CONFIG_STM32L4_TIM16_PWM) - pwm = stm32l4_pwminitialize(16); - if (!pwm) - { - aerr("ERROR: Failed to get the STM32L4 PWM lower half\n"); - return -ENODEV; - } - - /* Register the PWM driver at "/dev/pwm7" */ - - ret = pwm_register("/dev/pwm7", pwm); - if (ret < 0) - { - aerr("ERROR: pwm_register failed: %d\n", ret); - return ret; - } -#endif - -#if defined(CONFIG_STM32L4_TIM17_PWM) - pwm = stm32l4_pwminitialize(17); - if (!pwm) - { - aerr("ERROR: Failed to get the STM32L4 PWM lower half\n"); - return -ENODEV; - } - - /* Register the PWM driver at "/dev/pwm8" */ - - ret = pwm_register("/dev/pwm8", pwm); - if (ret < 0) - { - aerr("ERROR: pwm_register failed: %d\n", ret); - return ret; - } -#endif /* Now we are initialized */ initialized = true; -- 2.23.0