feat(mt12): make use of "servo test" port (#6528)

Co-authored-by: 3djc <3djc@gh.com>
Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
Co-authored-by: Peter Feerick <5500713+pfeerick@users.noreply.github.com>
This commit is contained in:
Raphael Coeffic
2026-08-19 09:18:17 +10:00
committed by GitHub
co-authored by 3djc raphaelcoeffic Peter Feerick
parent 559b9a9991
commit 423876b10b
27 changed files with 212 additions and 1 deletions
+15
View File
@@ -568,6 +568,12 @@ if(ROTARY_ENCODER)
)
endif()
if(PCBREV STREQUAL MT12)
list(APPEND BOARD_COMMON_SRC
${TARGET_SRC_DIR}/pwm_ch_driver.cpp
)
endif()
# Bootloader board library
add_library(board_bl OBJECT EXCLUDE_FROM_ALL
${BOARD_COMMON_SRC}
@@ -641,6 +647,15 @@ if(FLAVOUR STREQUAL xlites)
)
endif()
if(FLAVOUR STREQUAL mt12)
target_sources(board PRIVATE
${TARGET_SRC_DIR}/pwm_ch_driver.cpp
)
set(SRC ${SRC}
gui/common/stdlcd/radio_servo_pwm.cpp
)
endif()
set(SRC ${SRC}
io/frsky_firmware_update.cpp
io/multi_firmware_update.cpp
+11
View File
@@ -975,6 +975,17 @@
#endif
#endif
#if defined(RADIO_MT12)
#define SERVO_PWM
#define PWM_GPIO GPIO_PIN(GPIOB, 0) // PB.00
#define PWM_GPIO_AF GPIO_AF2
#define PWM_GPIO_TIMER TIM3 // Timer 3 Channel3
#define PWM_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
#define PWM_COUNTER_REGISTER PWM_TIMER->CCR3
#define PWM_CCMR2 TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_2
#define PWM_CCER TIM_CCER_CC3E
#endif
#if defined(RADIO_BOXER) || defined(RADIO_FAMILY_T20) || defined(RADIO_X9DP2019) || defined (RADIO_V14) || defined(RADIO_V14LCD) || defined(RADIO_GX12)
// Flysky Hall Stick
#define FLYSKY_HALL_SERIAL_USART UART4
@@ -0,0 +1,59 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "stm32_pulse_driver.h"
#include "stm32_gpio.h"
#include "edgetx_types.h"
#include "board.h"
static const stm32_pulse_timer_t _pwm_timer = {
.GPIO = (gpio_t)PWM_GPIO,
.GPIO_Alternate = PWM_GPIO_AF,
.TIMx = PWM_GPIO_TIMER,
.TIM_Freq = PWM_TIMER_FREQ,
.TIM_Channel = LL_TIM_CHANNEL_CH3,
.TIM_IRQn = (IRQn_Type)-1,
.DMAx = nullptr,
.DMA_Stream = 0,
.DMA_Channel = 0,
.DMA_IRQn = (IRQn_Type)-1,
.DMA_TC_CallbackPtr = nullptr,
};
void pwmOutputDisable()
{
stm32_pulse_stop(&_pwm_timer);
}
void pwmOutputInit()
{
stm32_pulse_init(&_pwm_timer, 2000000);
stm32_pulse_config_output(&_pwm_timer, true, LL_TIM_OCMODE_PWM1, 0);
LL_TIM_SetAutoReload(_pwm_timer.TIMx, 15000); // 15ms between PWM pulses
LL_TIM_EnableCounter(_pwm_timer.TIMx);
}
void pwmOutputEnable(uint16_t pulse_width_us)
{
stm32_pulse_set_cmp_val(&_pwm_timer, pulse_width_us);
stm32_pulse_start(&_pwm_timer);
}