BetaFlight模块设计之十七:pinioBox任务分析
Posted lida2003
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了BetaFlight模块设计之十七:pinioBox任务分析相关的知识,希望对你有一定的参考价值。
BetaFlight模块设计之十七:pinioBox任务分析
基于BetaFlight开源代码框架简介的框架设计,逐步分析内部模块功能设计。
pinioBox任务
描述:主要根据状态做IO高低电平控制(比如:点灯等)。
├──> 初始化
│ ├──> [v]硬件初始化pinioInit
│ └──> [v]业务初始化pinioBoxInit
├──> 任务
│ ├──> [x]实时任务
│ ├──> [x]事件任务
│ └──> [v]时间任务[TASK_PINIOBOX] = DEFINE_TASK("PINIOBOX", NULL, NULL, pinioBoxUpdate, TASK_PERIOD_HZ(20), TASK_PRIORITY_LOWEST),
├──> 驱动
│ ├──> [x]查询
│ └──> [x]中断
└──> 接口
├──> void pinioset(int index, bool on)
└──> void pinioBoxTaskControl(void)
业务配置
该任务主要可以配置4个pinioBox。
\\src\\main\\drivers\\pinio.h
#define PINIO_COUNT 4
从boxes默认配置看都不用。
\\src\\main\\pg\\piniobox.c
PG_RESET_TEMPLATE(pinioBoxConfig_t, pinioBoxConfig,
.permanentId =
PERMANENT_ID_NONE,
PERMANENT_ID_NONE,
PERMANENT_ID_NONE,
PERMANENT_ID_NONE
,
);
如果需要可以通过命令行配置需要关注的box。
\\src\\main\\msp\\msp_box.c
// permanent IDs must uniquely identify BOX meaning, DO NOT REUSE THEM!
static const box_t boxes[CHECKBOX_ITEM_COUNT] =
BOXARM, "ARM", 0 ,
BOXANGLE, "ANGLE", 1 ,
BOXHORIZON, "HORIZON", 2 ,
// BOXBARO, "BARO", 3 ,
BOXANTIGRAVITY, "ANTI GRAVITY", 4 ,
BOXMAG, "MAG", 5 ,
BOXHEADFREE, "HEADFREE", 6 ,
BOXHEADADJ, "HEADADJ", 7 ,
BOXCAMSTAB, "CAMSTAB", 8 ,
// BOXCAMTRIG, "CAMTRIG", 9 ,
// BOXGPSHOME, "GPS HOME", 10 ,
// BOXGPSHOLD, "GPS HOLD", 11 ,
BOXPASSTHRU, "PASSTHRU", 12 ,
BOXBEEPERON, "BEEPER", 13 ,
// BOXLEDMAX, "LEDMAX", 14 , (removed)
BOXLEDLOW, "LEDLOW", 15 ,
// BOXLLIGHTS, "LLIGHTS", 16 , (removed)
BOXCALIB, "CALIB", 17 ,
// BOXGOV, "GOVERNOR", 18 , (removed)
BOXOSD, "OSD DISABLE", 19 ,
BOXTELEMETRY, "TELEMETRY", 20 ,
// BOXGTUNE, "GTUNE", 21 , (removed)
// BOXRANGEFINDER, "RANGEFINDER", 22 , (removed)
BOXSERVO1, "SERVO1", 23 ,
BOXSERVO2, "SERVO2", 24 ,
BOXSERVO3, "SERVO3", 25 ,
BOXBLACKBOX, "BLACKBOX", 26 ,
BOXFAILSAFE, "FAILSAFE", 27 ,
BOXAIRMODE, "AIR MODE", 28 ,
BOX3D, "3D DISABLE / SWITCH", 29,
BOXFPVANGLEMIX, "FPV ANGLE MIX", 30,
BOXBLACKBOXERASE, "BLACKBOX ERASE (>30s)", 31 ,
BOXCAMERA1, "CAMERA CONTROL 1", 32,
BOXCAMERA2, "CAMERA CONTROL 2", 33,
BOXCAMERA3, "CAMERA CONTROL 3", 34 ,
BOXFLIPOVERAFTERCRASH, "FLIP OVER AFTER CRASH", 35 ,
BOXPREARM, "PREARM", 36 ,
BOXBEEPGPSCOUNT, "GPS BEEP SATELLITE COUNT", 37 ,
// BOX3DONASWITCH, "3D ON A SWITCH", 38 , (removed)
BOXVTXPITMODE, "VTX PIT MODE", 39 ,
BOXUSER1, "USER1", 40 ,
BOXUSER2, "USER2", 41 ,
BOXUSER3, "USER3", 42 ,
BOXUSER4, "USER4", 43 ,
BOXPIDAUDIO, "PID AUDIO", 44 ,
BOXPARALYZE, "PARALYZE", 45 ,
BOXGPSRESCUE, "GPS RESCUE", 46 ,
BOXACROTRAINER, "ACRO TRAINER", 47 ,
BOXVTXCONTROLDISABLE, "VTX CONTROL DISABLE", 48,
BOXLAUNCHCONTROL, "LAUNCH CONTROL", 49 ,
BOXMSPOVERRIDE, "MSP OVERRIDE", 50,
BOXSTICKCOMMANDDISABLE, "STICK COMMANDS DISABLE", 51,
BOXBEEPERMUTE, "BEEPER MUTE", 52,
;
硬件配置
板子Kakute F7 AIO是没有这个管脚定义,因此找了一个pinioBox使用比较全的模型来分析。搜索下来,使用piniobox 3只有EXF722DUAL模型,也是比较全用到的pinioBox现有功能的一个模型。
# grep -rn --exclude-dir=obj "PINIO3_PIN" .
./src/main/target/EXF722DUAL/target.h:151:#define PINIO3_PIN PB8 // VTX power switcher
./src/main/pg/pinio.c:35:#ifndef PINIO3_PIN
./src/main/pg/pinio.c:36:#define PINIO3_PIN NONE
./src/main/pg/pinio.c:48: IO_TAG(PINIO3_PIN),
板级配置定义:
/src/main/target/EXF722DUAL/target.h:
#define USE_PINIO
#define PINIO1_PIN PC13 // activate/deactivate Bluetooth When disarmed/armed using PINIO_BOX
#define PINIO2_PIN PC14 // 2xCamera switcher
#define PINIO3_PIN PB8 // VTX power switcher
#define USE_PINIOBOX
pinioBoxUpdate任务分析
pinioBoxUpdate
└──> <for (int i = 0; i < PINIO_COUNT; i++)> //遍历所有pinioBox
└──> <if (pinioBoxRuntimeConfig.boxId[i] != BOXID_NONE)> //有效pinioBox
└──> pinioSet(i, getBoxIdState(pinioBoxRuntimeConfig.boxId[i])); //根据当前flight mode或者功能使能情况,对应IO输出(点灯)
以上是关于BetaFlight模块设计之十七:pinioBox任务分析的主要内容,如果未能解决你的问题,请参考以下文章