I'd like to add PWM support to my nuttx board config. I am using an STM32F765VGT6 MCU.
I started implementing it like in the STM32F4Discovery config directory:
stm32_pwm_setup()
in configs/<board_name>/src/<board_name>.h
configs/<board_name>/src/stm32_pwm.c
:#include <nuttx/config.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/drivers/pwm.h>
#include <arch/board/board.h>
#include "chip.h"
#include "up_arch.h"
#include "stm32_pwm.h"
#include "board_name.h"
#ifdef CONFIG_PWM
int stm32_pwm_setup(void) {
static bool initialized = false;
struct pwm_lowerhalf_s *pwm;
int ret;
/* Have we already initialized? */
if (!initialized) {
#if defined(CONFIG_STM32F7_TIM1_PWM)
#if defined(CONFIG_STM32F7_TIM1_CH1OUT)
pwm = stm32_pwminitialize(1);
if (!pwm) {
aerr("ERROR: Failed to get the STM32F7 PWM lower half\n");
return -ENODEV;
}
ret = pwm_register(DEV_PWM3, pwm);
if (ret < 0) {
aerr("ERROR: pwm_register failed: %d\n", ret);
return ret;
}
#endif
/* ... */
/* other timers and channels */
/* ... */
initialized = true;
}
return OK;
}
#endif /* CONFIG_PWM */
stm32_pwm.c
in the Makefile (configs/<board_name>/src/Makefile
)However, I always get the compilation error that "stm32_pwm.h" was not found.
Also, I cannot call stm32_pwm_initialize()
in my configs/<board_name>/src/stm32_boot.c
.
Did someone already implement NuttX PWM support on a STM32F7 or can give me a hint why I'm failing?
stm32_pwm.h cannot be included by applications, the include paths (intentionally) do not support. If you move the initialization code to configs/stm32f4discovery/src/stm32_bringup.c it should compile fine.
STM32F7? There is no stm32_pwm.h for STM32F7. No one has contributed the PWM driver. This time the compiler is right, the header file does not exist in arch/arm/src/stm32f7. The solution would be to port the PWM driver from a similar STM32 architecture. The choices are:
arch/arm/src/stm32 - Which includes L1, F0, F2, F3, and F4, and arch/arm/src/stm32l4 - Which is only STM32L4