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

问题描述 投票:0回答:1

我想在我的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 */
  • 在Makefile中添加stm32_pwm.cconfigs/<board_name>/src/Makefile

但是,我总是得到“stm32_pwm.h”未找到的编译错误。另外,我不能在我的stm32_pwm_initialize()中调用configs/<board_name>/src/stm32_boot.c

有人已经在STM32F7上实现了NuttX PWM支持,或者可以给我一个暗示我失败的原因吗?

pwm stm32f7
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.