NuttX:如何为STM32F7板增加PWM支持? (找不到stm32_pwm.h)

时间:2019-03-23 22:06:51

标签: stm32 pwm stm32f7 nuttx pulsewidthmodulation

我想在我的nuttx板配置中添加PWM支持。 我正在使用STM32F765VGT6 MCU。

我开始像在STM32F4Discovery配置目录中那样实现它:

  • stm32_pwm_setup()中添加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)中附加configs/<board_name>/src/Makefile

但是,我总是收到找不到“ stm32_pwm.h”的编译错误。 另外,我无法在自己的stm32_pwm_initialize()中呼叫configs/<board_name>/src/stm32_boot.c

有人已经在STM32F7上实现了NuttX PWM支持吗?或者可以给我提示我为什么失败的原因?

1 个答案:

答案 0 :(得分:1)

应用程序无法包含

stm32_pwm.h,(有意地)不包含路径。如果将初始化代码移到configs / stm32f4discovery / src / stm32_bringup.c,则应该可以正常编译。

STM32F7? STM32F7没有stm32_pwm.h。没有人提供PWM驱动器。这次编译器是正确的,头文件在arch / arm / src / stm32f7中不存在。解决方案是从类似的STM32架构移植PWM驱动器。选择是:

arch / arm / src / stm32-其中包括L1,F0,F2,F3和F4,以及 arch / arm / src / stm32l4-仅STM32L4