BetaFlight统一硬件配置文件研读

news/2024/10/21 10:04:24/

BetaFlight统一硬件配置文件研读

  • 1. 源由
  • 2. 分析
    • 2.1 硬件SOC
    • 2.2 统一配置文件
    • 2.3 cli命令
    • 2.4 板级配置主要命令
      • 2.4.1 board_name
      • 2.4.2 manufacturer_id
      • 2.4.3 resource
      • 2.4.4 timer
      • 2.4.5 dma
      • 2.4.6 serial
      • 2.4.7 set
      • 2.4.8 feature
  • 3. 实例研读
    • 3.1 C遗留配置
    • 3.2 BoardName - AOCODARCH7DUAL
    • 3.3 ManufacturerId - SJET
    • 3.4 更多内容展开
  • 4. 参考资料

统一硬件配置文件的设计是一种非常好的设计模式,可以将硬件和软件的工作进行解耦。

1. 源由

统一硬件配置文件的软硬件解耦方式通过一系列的cli命令组成,最终通过parameter参数调整,达到硬件配置功能。

如果不过多深究内部设计,可以简单参考:BetaFlight统一硬件资源简单配置修改

希望了解更多内部实现,那不是一两句话可以简单说清楚的,我们接下来,对这部分内容进行展开,希望通过分析得到更多设计上的细节。

2. 分析

统一硬件配置文件是由一系列的cli命令组成,这些命令对不同SOC框架的MCU硬件资源进行配置。

2.1 硬件SOC

Betaflight 4.4.1 Note, 比如:4.4.1固件 STM32F405/F411/F745/F7X2/G47X/H723/H730/H743/H750
在这里插入图片描述

2.2 统一配置文件

betaflight/unified-targets, 提供了各种厂家各类板子。如果硬件设计是参考过来的,这里就有原始配置文件。基于这个进行修改将事半功倍。

厂家名录详见:manufacturer_id

在这里插入图片描述

2.3 cli命令

在BetaFlight模块设计之三十:Cli模块分析中,已经初步介绍了BetaFlight Configurator如何将cli命令解析和识别,并最终与命令挂钩的。

# help
adjrange - configure adjustment ranges<index> <unused> <range channel> <start> <end> <function> <select channel> [<center> <scale>]
aux - configure modes<index> <mode> <aux> <start> <end> <logic>
batch - start or end a batch of commandsstart | end
beacon - enable/disable Dshot beacon for a conditionlist<->[name]
beeper - enable/disable beeper for a conditionlist<->[name]
bind_rx - initiate binding for RX SPI or SRXL2
bl - reboot into bootloader[rom]
board_name - get / set the name of the board model[board name]
color - configure colors
defaults - reset to defaults and reboot{show} {nosave} {bare} {group_id <id>}
diff - list configuration changes from default[master|profile|rates|hardware|all] {defaults|bare}
dma - show/set DMA assignments<> | <device> <index> list | <device> <index> [<option>|none] | list | show
dshot_telemetry_info - display dshot telemetry info and stats
dshotprog - program DShot ESC(s)<index> <command>+
dump - dump configuration[master|profile|rates|hardware|all] {defaults|bare}
escprog - passthrough esc to serial<mode [sk/bl/ki/cc]> <index>
exit
feature - configure featureslist<->[name]
flash_erase - erase flash chip
flash_info - show flash chip info
flash_read<length> <address>
flash_scan - scan flash device for errors
flash_write<address> <message>
get - get variable value[name]
gpspassthrough - passthrough gps to serial
gyroregisters - dump gyro config registers contents
help - display command help[search string]
led - configure leds
manufacturer_id - get / set the id of the board manufacturer[manufacturer id]
map - configure rc channel order[<map>]
mcu_id - id of the microcontroller
mixer - configure mixerlist<name>
mmix - custom motor mixer
mode_color - configure mode and special colors
motor - get/set motor<index> [<value>]
msc - switch into msc mode[<timezone offset minutes>]
play_sound[<index>]
profile - change profile[<index>]
rateprofile - change rate profile[<index>]
rc_smoothing_info - show rc_smoothing operational settings
resource - show/set resources<> | <resource name> <index> [<pin>|none] | show [all]
rxfail - show/set rx failsafe settings
rxrange - configure rx channel ranges
save - save and reboot
sd_info - sdcard info
serial - configure serial ports
serialpassthrough - passthrough serial data data from port 1 to VCP / port 2<id1> [<baud1>] [<mode1>] [none|<dtr pinio>|reset] [<id2>] [<baud2>] [<mode2>]
servo - configure servos
set - change setting[<name>=<value>]
signature - get / set the board type signature[signature]
simplified_tuning - applies or disables simplified tuningapply | disable
smix - servo mixer<rule> <servo> <source> <rate> <speed> <min> <max> <box>resetload <mixer>reverse <servo> <source> r|n
status - show status
tasks - show task stats
timer - show/set timers<> | <pin> list | <pin> [af<alternate function>|none|<option(deprecated)>] | list | show
version - show version
vtx - vtx channels on switch<index> <aux_channel> <vtx_band> <vtx_channel> <vtx_power> <start_range> <end_range>
vtx_info - vtx power config dump
vtxtable - vtx frequency table<band> <bandname> <bandletter> [FACTORY|CUSTOM] <freq> ... <freq>

2.4 板级配置主要命令

通常来说,与板子配置相关的主要命令如下:

2.4.1 board_name

board_name - get / set the name of the board model[board name]

2.4.2 manufacturer_id

manufacturer_id - get / set the id of the board manufacturer[manufacturer id]

2.4.3 resource

resource - show/set resources<> | <resource name> <index> [<pin>|none] | show [all]

2.4.4 timer

timer - show/set timers<> | <pin> list | <pin> [af<alternate function>|none|

2.4.5 dma

dma - show/set DMA assignments<> | <device> <index> list | <device> <index> [<option>|none] | list | show

2.4.6 serial

serial - configure serial ports

2.4.7 set

set - change setting[<name>=<value>]

2.4.8 feature

feature - configure featureslist<->[name]

3. 实例研读

手边正好有一块AOCODARC H7DUAL的板子,后续将就这块板子进行一个配置研读。

在这里插入图片描述
在这里插入图片描述

3.1 C遗留配置

以下配置内容,主要是说明该板子使用了一下硬件芯片:

  • 陀螺仪:BMI270
  • 气压计:DPS310
  • SPI Flash:W25N01G
  • 模拟OSD芯片:MAX7456
#define USE_ACCGYRO_BMI270
#define USE_BARO_DPS310
#define USE_FLASH_W25N01G
#define USE_MAX7456

3.2 BoardName - AOCODARCH7DUAL

board_name AOCODARCH7DUAL
static void cliBoardName(const char *cmdName, char *cmdline)
{const unsigned int len = strlen(cmdline);const char *boardName = getBoardName();if (len > 0 && strlen(boardName) != 0 && boardInformationIsSet() && (len != strlen(boardName) || strncmp(boardName, cmdline, len))) {  //合法性检查cliPrintErrorLinef(cmdName, ERROR_MESSAGE, "BOARD_NAME", boardName);} else {if (len > 0 && !configIsInCopy && setBoardName(cmdline)) {  //设置板子名称boardInformationUpdated = true;cliPrintHashLine("Set board_name.");}printBoardName(DUMP_ALL);}
}

3.3 ManufacturerId - SJET

manufacturer_id SJET
static void cliManufacturerId(const char *cmdName, char *cmdline)
{const unsigned int len = strlen(cmdline);const char *manufacturerId = getManufacturerId();if (len > 0 && boardInformationIsSet() && strlen(manufacturerId) != 0 && (len != strlen(manufacturerId) || strncmp(manufacturerId, cmdline, len))) {  //合法性验证cliPrintErrorLinef(cmdName, ERROR_MESSAGE, "MANUFACTURER_ID", manufacturerId);} else {if (len > 0 && !configIsInCopy && setManufacturerId(cmdline)) {  //设置生产商名称boardInformationUpdated = true;cliPrintHashLine("Set manufacturer_id.");}printManufacturerId(DUMP_ALL);}
}

3.4 更多内容展开

鉴于内容比较多,所以后续我们分章节进行(围绕配置命令展开):

  • 【1】BetaFlight统一硬件配置文件研读之resource命令
  • 【2】BetaFlight统一硬件配置文件研读之timer命令
  • 【3】BetaFlight统一硬件配置文件研读之serial命令
  • 【4】BetaFlight统一硬件配置文件研读之set命令
  • 【5】BetaFlight统一硬件配置文件研读之feature命令
  • 【6】BetaFlight统一硬件配置文件研读之dma命令
  • 【7】BetaFlight统一硬件AOCODARC H7DUAL配置文件讨论

关于驱动方面设计,后续我们找时间展开研讨!

4. 参考资料

【1】BetaFlight开源代码框架简介
【2】BetaFlight统一硬件资源简单配置修改
【3】BetaFlight模块设计之三十:Cli模块分析


http://www.ppmy.cn/news/61336.html

相关文章

普通2本,去过字节外包,到现在年薪25W+的测试开发,我的2年转行心酸经历...

个人简介 我是一个普通二本大学机械专业毕业&#xff0c;17年毕业&#xff0c;19年转行&#xff0c;目前做IT行业的软件测试已经有3年多&#xff0c;职位是高级测试工程师&#xff0c;坐标上海… 我想现在我也有一点资格谈论关于转行这个话题&#xff1b;希望你在决定转行之前…

浅谈Spring中的BeanFactory与FactoryBean

前言 理解FactoryBean是非常非常有必要的&#xff0c;因为在Spring中FactoryBean最为典型的一个应用就是用来创建AOP的代理对象&#xff0c;不仅如此&#xff0c;而且对理解Mybatis核心源码也非常有帮助&#xff01;如果甘愿crud&#xff0c;做个快乐的码农&#xff0c;那我就哦…

jdk中juc多线程编程工具

jdk线程池实现原理分析 目录 CompletionService CompletableFuture 基本原理 CompletableFuture的接口 静态方法 handle() vs whenComplete() xxxEither() 异常处理exceptionally() 获取任务结果 结束任务 Semaphore CyclicBarrier CountDownLatch jdk线程池实…

RabbitMQ简介

MQ引言 1.1 什么是MQ ​ MQ(Message Quene) : 翻译为消息队列,通过典型的生产者和消费者模型,生产者不断向消息队列中生产消息&#xff0c;消费者不断的从队列中获取消息。因为消息的生产和消费都是异步的&#xff0c;而且只关心消息的发送和接收&#xff0c;没有业务逻辑的侵…

【Java EE】-使用Fiddler抓包以及HTTP的报文格式

作者&#xff1a;学Java的冬瓜 博客主页&#xff1a;☀冬瓜的主页&#x1f319; 专栏&#xff1a;【JavaEE】 分享: 在满园弥漫的沉静的光芒之前&#xff0c;一个人更容易看到时间&#xff0c;并看到自己的身影。——史铁生《我与地坛》 主要内容&#xff1a;使用FIddler抓包的…

网络安全之信息收集

​​​第一部分&#xff1a;被动信息收集 1、简介 ​ 在信息收集这块区域&#xff0c;我将其分为两部分&#xff1a;第一部分即被动信息收集&#xff0c;第二部分即主动信息收集。 ​ 对于标准的渗透测试人员来说&#xff0c;当明确目标做好规划之后首先应当进行的便是信息收…

qsort详细用法

qsort是C语言标准库中的一个函数&#xff0c;用于对数组进行快速排序。它的原型如下&#xff1a; void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); 其中&#xff0c;参数解释如下&#xff1a; - base&#xff1a;指向要排序的…

​力扣解法汇总1033. 移动石子直到连续

目录链接&#xff1a; 力扣编程题-解法汇总_分享记录-CSDN博客 GitHub同步刷题项目&#xff1a; https://github.com/September26/java-algorithms 原题链接&#xff1a;力扣 描述&#xff1a; 三枚石子放置在数轴上&#xff0c;位置分别为 a&#xff0c;b&#xff0c;c。 …