iNavFlight / inav

INAV: Navigation-enabled flight control software
https://inavflight.github.io
GNU General Public License v3.0
3.18k stars 1.48k forks source link

MATEK F405-TE Support more than 2 servo #8819

Closed korol-sas closed 1 year ago

korol-sas commented 1 year ago

Current Behavior

The current configuration target only has 2 servos available (TIM12, TIM13)

https://github.com/iNavFlight/inav/blob/2f2719c31363bc956ae6f0fadcd2251eff832c95/src/main/target/MATEKF405TE/target.c

Desired Behavior

I need 4 for my purposes. After reading the specification for the controller from the manufacturer, I did not find any restrictions on the use of PWM outputs timers-table timers-descr

Suggested Solution

Do I understand correctly that we can do by analogy with the older controller (MATEKF405_SERVOS6) and for example create a new configuration target - MATEKF405TE_SERVOS6

b14ckyy commented 1 year ago

Yeah I think it should be possible to define PB11, PB10, PB3 and PA15 all as servo outputs (S5-S8) in a Quadrotor configuration. But not mixed with motors. So Either Octa-Rotor + 2 Servos or Quad-Rotor + 6 Servos. Not sure if a dedicatged regular target is needed for that rare case. You could change the target file to that:

timerHardware_t timerHardware[] = {
    DEF_TIM(TIM8,  CH4,  PC9,  TIM_USE_MC_MOTOR  | TIM_USE_FW_MOTOR,   0, 0), // S1 D(2,7,7) UP217
    DEF_TIM(TIM8,  CH3,  PC8,  TIM_USE_MC_MOTOR  | TIM_USE_FW_MOTOR,   0, 0), // S2 D(2,2,0) UP217
    DEF_TIM(TIM1,  CH3N, PB15, TIM_USE_MC_MOTOR  | TIM_USE_FW_SERVO,   0, 0), // S3 D(2,6,0) UP256
    DEF_TIM(TIM1,  CH1,  PA8,  TIM_USE_MC_MOTOR  | TIM_USE_FW_SERVO,   0, 1), // S4 D(2,1,6) UP256

    DEF_TIM(TIM2,  CH4,  PB11, TIM_USE_MC_SERVO  | TIM_USE_FW_SERVO,   0, 0), // S5 D(1,7,3) UP173
    DEF_TIM(TIM2,  CH3,  PB10, TIM_USE_MC_SERVO  | TIM_USE_FW_SERVO,   0, 0), // S6 D(1,1,3) UP173
    DEF_TIM(TIM2,  CH2,  PB3,  TIM_USE_MC_SERVO  | TIM_USE_FW_SERVO,   0, 0), // S7 D(1,6,3) UP173
    DEF_TIM(TIM2,  CH1,  PA15, TIM_USE_MC_SERVO  | TIM_USE_FW_SERVO,   0, 0), // S8 D(1,5,3) UP173

    DEF_TIM(TIM12, CH1,  PB14, TIM_USE_MC_SERVO  | TIM_USE_FW_SERVO,   0, 0), // S9  DMA NONE
    DEF_TIM(TIM13, CH1,  PA6,  TIM_USE_MC_SERVO  | TIM_USE_FW_SERVO,   0, 0), // S10 DMA NONE
    DEF_TIM(TIM4,  CH1,  PB6,  TIM_USE_MC_SERVO  | TIM_USE_FW_SERVO,   0, 0), // S11 D(1,0,2)

    DEF_TIM(TIM3,  CH4,  PB1,  TIM_USE_LED,    0, 0), // 2812LED  D(1,2,5)
    DEF_TIM(TIM11, CH1,  PB9,  TIM_USE_BEEPER, 0, 0), // BEEPER PWM

    DEF_TIM(TIM9,  CH2,  PA3,  TIM_USE_PPM,    0, 0), //RX2
    DEF_TIM(TIM5,  CH3,  PA2,  TIM_USE_ANY,    0, 0), //TX2  softserial1_Tx

That should in theory do it. Can a dev please confirm?