我想添加PWM支持到我的nuttx板配置。我使用的是STM32F765VGT6单片机。
我开始在STM32F4Discovery配置目录中实现它:
stm32_pwm_setup()中添加configs/<board_name>/src/<board_name>.hconfigs/<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 (configs/<board_name>/src/Makefile)但是,我总是收到"stm32_pwm.h“未找到的编译错误。而且,我不能在我的stm32_pwm_initialize()中调用configs/<board_name>/src/stm32_boot.c。
是否有人已经在NuttX上实现了STM32F7的脉宽调制支持,或者能给我一个提示为什么我失败了?
发布于 2019-03-24 11:58:00
应用程序不能包含stm32_pwm.h,包含路径(有意)不支持。如果您将初始化代码移到to /stm32f4finiation/src/stm32 32_bringup.c,那么它应该可以很好地编译。
STM32F7?没有用于stm32_pwm.h的STM32F7。没有人为PWM驱动做出贡献。这一次编译器是正确的,头文件不存在于arch/arm/src/stm32f7中。解决方案是将PWM驱动程序从类似的STM32体系结构中移植。这些选择是:
arch/arm/src/stm32 32--包括L1、F0、F2、F3和F4,以及arch/arm/src/stm32l4 --仅为STM32L4
https://stackoverflow.com/questions/55318829
复制相似问题