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:
- add
stm32_pwm_setup()
inconfigs/<board_name>/src/<board_name>.h
- add
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 */
- append
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?