feat: support for RadioMaster GX12 (#5703)

Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
3djc
2024-12-13 12:41:38 +10:00
committed by GitHub
co-authored by raphaelcoeffic philmoz Peter Feerick
parent 0f86cd9a95
commit 36cdd93a1a
95 changed files with 2287 additions and 605 deletions
@@ -35,10 +35,10 @@
static const stm32_usart_t fsUSART = {
.USARTx = FLYSKY_HALL_SERIAL_USART,
.txGPIO = GPIO_UNDEF,
.txGPIO = FLYSKY_HALL_SERIAL_TX_GPIO,
.rxGPIO = FLYSKY_HALL_SERIAL_RX_GPIO,
.IRQn = FLYSKY_HALL_SERIAL_USART_IRQn,
.IRQ_Prio = 6,
.IRQ_Prio = 4,
.txDMA = nullptr,
.txDMA_Stream = 0,
.txDMA_Channel = 0,
@@ -49,6 +49,13 @@ static const stm32_usart_t fsUSART = {
DEFINE_STM32_SERIAL_PORT(FSGimbal, fsUSART, HALLSTICK_BUFF_SIZE, 0);
static const etx_serial_port_t _fs_gimbal_serial_port = {
.name = "gimbals",
.uart = &STM32SerialDriver,
.hw_def = REF_STM32_SERIAL_PORT(FSGimbal),
.set_pwr = nullptr,
};
static STRUCT_HALL HallProtocol = { 0 };
static void* _fs_usart_ctx = nullptr;
@@ -150,7 +157,7 @@ static void flysky_gimbal_loop(void*)
}
}
static void flysky_gimbal_deinit()
void flysky_gimbal_deinit()
{
STM32SerialDriver.deinit(_fs_usart_ctx);
}
@@ -181,3 +188,8 @@ bool flysky_gimbal_init()
flysky_gimbal_deinit();
return false;
}
const etx_serial_port_t* flysky_gimbal_get_port()
{
return &_fs_gimbal_serial_port;
}
@@ -18,6 +18,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include "hal/serial_port.h"
#define HALLSTICK_BUFF_SIZE ( 512 )
#define FLYSKY_HALL_BAUDRATE ( 921600 )
@@ -124,3 +128,5 @@ extern unsigned short hall_adc_values[FLYSKY_HALL_CHANNEL_COUNT];
// returns true if the gimbals were detected properly
bool flysky_gimbal_init();
void flysky_gimbal_deinit();
const etx_serial_port_t* flysky_gimbal_get_port();
@@ -27,7 +27,7 @@
#define GPIO_UNDEF (0xffffffff)
// #define GPIO_PIN(x, y) ((GPIOA_BASE + (x << 10)) | y)
#define GPIO_PIN(x, y) ((intptr_t)x | y)
#define GPIO_PIN(x, y) ((uintptr_t)x | y)
// Generate GPIO mode bitfields
//
@@ -231,6 +231,22 @@ void ws2812_set_color(uint8_t led, uint8_t r, uint8_t g, uint8_t b)
pixel[_b_offset] = b;
}
uint32_t ws2812_get_color(uint8_t led)
{
if (led >= _led_strip_len) return 0;
uint8_t* pixel = &_led_colors[led * WS2812_BYTES_PER_LED];
return (pixel[1] << 16) + (pixel[0] << 8) + pixel[2];
}
bool ws2812_get_state(uint8_t led)
{
if (led >= _led_strip_len) return false;
uint8_t* pixel = &_led_colors[led * WS2812_BYTES_PER_LED];
return pixel[0] || pixel[1] || pixel[2];
}
void ws2812_update(const stm32_pulse_timer_t* tim)
{
WS2812_DBG_HIGH;
@@ -42,6 +42,8 @@
void ws2812_init(const stm32_pulse_timer_t* timer, uint8_t strip_len, uint8_t type);
void ws2812_update(const stm32_pulse_timer_t* timer);
bool ws2812_get_state(uint8_t led);
void ws2812_dma_isr(const stm32_pulse_timer_t* timer);
void ws2812_set_color(uint8_t led, uint8_t r, uint8_t g, uint8_t b);
uint32_t ws2812_get_color(uint8_t led);