首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NuttX:如何增加对STM32F7板的脉宽调制支持?(stm32_pwm.h未找到)

NuttX:如何增加对STM32F7板的脉宽调制支持?(stm32_pwm.h未找到)
EN

Stack Overflow用户
提问于 2019-03-23 22:06:50
回答 1查看 357关注 0票数 0

我想添加PWM支持到我的nuttx板配置。我使用的是STM32F765VGT6单片机。

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

  • stm32_pwm_setup()中添加configs/<board_name>/src/<board_name>.h
  • 添加configs/<board_name>/src/stm32_pwm.c
代码语言:javascript
复制
#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.c (configs/<board_name>/src/Makefile)

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

是否有人已经在NuttX上实现了STM32F7的脉宽调制支持,或者能给我一个提示为什么我失败了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55318829

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档