betaflight / betaflight

Open Source Flight Controller Firmware
GNU General Public License v3.0
8k stars 2.86k forks source link

PINIO Behavior in 4.5 #13613

Open ot0tot opened 2 weeks ago

ot0tot commented 2 weeks ago

Describe the bug

Has the PINIO behavior changed in 4.5? It seems some targets with PINIO switched VTX power are not working now without additional configuration, where they were working in 4.4 with the same config. Example: https://github.com/betaflight/config/pull/412

Is the PINIO not active if a box is not defined in the config?

In the above example, PINIO2 is used to toggle the VTX power. In 4.4, without additional configuration, the PINIO settings have PINIO2 config set to 1 (Output-Push-Pull), and PINIO2 box set to 255 (BOXID_NONE). Thus you would expect the default value to be PINIO2 high, which should mean the VTX power is always on. This seems to work in 4.4, but not in 4.5.

To Reproduce

Flash BF 4.5.0 to a FC that uses PINIO, eg for VTX power control.

Expected behavior

Without specific PINIO configuration set, the PINIO_CONFIG and PINIO_BOX parameters should apply. e.g all PINIO pins should be set to high in the default case:

set pinio_config = 1,1,1,1
set pinio_box = 255,255,255,255

Support ID

defaults nosave

# version
# Betaflight / STM32H743 (SH74) 4.5.0 Apr 30 2024 / 10:25:06 (c155f5830) MSP API: 1.46
# config rev: 2ceeadc

# start the command batch
batch start

# reset configuration to default settings
defaults nosave

board_name MAMBAH743_2022B
manufacturer_id DIAT
mcu_id 002f00493133510234393330
signature 

# feature
feature TELEMETRY
feature OSD

# serial
serial 0 64 115200 57600 0 115200
serial 2 131073 115200 57600 0 115200
serial 3 1 115200 57600 0 115200

# beacon
beacon RX_LOST
beacon RX_SET

# aux
aux 0 0 0 1800 2100 0 0
aux 1 1 1 1300 1700 0 0
aux 2 13 2 1800 2100 0 0
aux 3 35 1 1800 2100 0 0
aux 4 40 0 900 2100 0 0

# master
set gyro_lpf1_static_hz = 0
set gyro_lpf2_static_hz = 1000
set dyn_notch_count = 1
set dyn_notch_q = 500
set gyro_lpf1_dyn_min_hz = 0
set gyro_lpf1_dyn_max_hz = 1000
set acc_calibration = -6,-5,43,1
set min_check = 1010
set max_check = 1990
set rc_smoothing_auto_factor = 120
set dshot_bidir = ON
set motor_output_reordering = 3,2,1,0,4,5,6,7
set align_board_yaw = 180
set yaw_motors_reversed = ON
set small_angle = 180
set simplified_gyro_filter_multiplier = 200
set report_cell_voltage = ON
set osd_vbat_pos = 2573
set osd_rssi_pos = 3618
set osd_altitude_pos = 2655
set osd_warnings_pos = 14931
set osd_avg_cell_voltage_pos = 2605
set osd_core_temp_pos = 2637
set pinio_box = 0,40,255,255
set rpm_filter_q = 750

profile 0

# profile 0
set dterm_lpf1_dyn_min_hz = 82
set dterm_lpf1_dyn_max_hz = 165
set dterm_lpf1_static_hz = 165
set dterm_lpf2_static_hz = 165
set feedforward_averaging = 2_POINT
set feedforward_smooth_factor = 65
set dyn_idle_min_rpm = 30
set simplified_dterm_filter_multiplier = 110

profile 1

profile 2

profile 3

# restore original profile selection
profile 0

rateprofile 0

# rateprofile 0
set rates_type = BETAFLIGHT
set roll_rc_rate = 127
set pitch_rc_rate = 127
set yaw_rc_rate = 100
set roll_expo = 40
set pitch_expo = 40
set roll_srate = 72
set pitch_srate = 72
set yaw_srate = 75

rateprofile 1

rateprofile 2

rateprofile 3

# restore original rateprofile selection
rateprofile 0

# save configuration

Flight controller

MAMBAH743_2022B

Other components

No response

How are the different components wired up (including port information)

No response

Add any other context about the problem that you think might be relevant here

Discord troubleshooting thread: https://discord.com/channels/868013470023548938/1234851582181638296

haslinghuis commented 2 weeks ago

Think this is handled in

https://github.com/betaflight/betaflight/blob/4640a5da9658c7f3ffc5922b56f5fac7c0c3654c/src/main/pg/piniobox.c#L33-L47

https://github.com/betaflight/betaflight/blob/4640a5da9658c7f3ffc5922b56f5fac7c0c3654c/src/main/msp/msp_box.h#L31