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);
+2 -1
View File
@@ -30,6 +30,7 @@
#include "hal/rotary_encoder.h"
#include "hal/usb_driver.h"
#include "hal/gpio.h"
#include "hal/rgbleds.h"
#include "board.h"
#include "boards/generic_stm32/module_ports.h"
@@ -127,7 +128,7 @@ void boardInit()
board_set_bor_level();
#endif
#if defined(FUNCTION_SWITCHES) && !defined(DEBUG)
#if defined(MANUFACTURER_JUMPER) && defined(FUNCTION_SWITCHES) && !defined(DEBUG)
// This is needed to prevent radio from starting when usb is plugged to charge
usbInit();
// prime debounce state...
+21 -4
View File
@@ -21,8 +21,9 @@
#include "hal/gpio.h"
#include "stm32_gpio.h"
#include "boards/generic_stm32/rgb_leds.h"
#include "board.h"
#include "colors.h"
void ledInit()
{
@@ -39,7 +40,7 @@ void ledInit()
gpio_init(LED_BLUE_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
#endif
#if defined(FUNCTION_SWITCHES)
#if defined(FUNCTION_SWITCHES) && !defined(FUNCTION_SWITCHES_RGB_LEDS)
gpio_init(FSLED_GPIO_1, GPIO_OUT, GPIO_PIN_SPEED_LOW);
gpio_init(FSLED_GPIO_2, GPIO_OUT, GPIO_PIN_SPEED_LOW);
gpio_init(FSLED_GPIO_3, GPIO_OUT, GPIO_PIN_SPEED_LOW);
@@ -50,7 +51,23 @@ void ledInit()
}
#if defined(FUNCTION_SWITCHES)
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
// used to map switch number to led number in the rgbled chain
uint8_t ledMapping[] = {1, 2, 3, 4, 5, 6};
void fsLedOff(uint8_t index, uint32_t color)
{
rgbSetLedColor(ledMapping[index], GET_RED(color), \
GET_GREEN(color),GET_BLUE(color));
}
void fsLedOn(uint8_t index, uint32_t color)
{
rgbSetLedColor(ledMapping[index], GET_RED(color), \
GET_GREEN(color),GET_BLUE(color));
}
#elif defined(FUNCTION_SWITCHES)
gpio_t fsLeds[] = {FSLED_GPIO_1, FSLED_GPIO_2,
FSLED_GPIO_3, FSLED_GPIO_4,
FSLED_GPIO_5, FSLED_GPIO_6};
@@ -65,7 +82,7 @@ void fsLedOn(uint8_t index)
gpio_set(fsLeds[index]);
}
bool getFSLedState(uint8_t index)
bool fsLedState(uint8_t index)
{
return (gpio_read(fsLeds[index]));
}
+29 -1
View File
@@ -20,6 +20,7 @@
*/
#include <stdint.h>
#include "hal/rgbleds.h"
bool usbChargerLed() { return true; }
void ledRed() {}
@@ -28,6 +29,33 @@ void ledBlue() {}
void ledOff() {}
void fsLedOn(uint8_t) {}
void fsLedOff(uint8_t) {}
bool getFSLedState(uint8_t) { return false;}
void fsLedRGB(uint8_t, uint32_t) {}
bool fsLedState(uint8_t) { return false;}
void rgbSetLedColor(unsigned char, unsigned char, unsigned char, unsigned char) {}
void rgbLedColorApply() {}
uint8_t getRGBColorIndex(uint32_t color)
{
for (uint8_t i = 0; i < (sizeof(colorTable) / sizeof(colorTable[0])); i++) {
if (color == colorTable[i])
return(i);
}
return 5; // Custom value set with Companion
}
// RGB
#define WS2812_BYTES_PER_LED 3
// Maximum number of supported LEDs
#if !defined(WS2812_MAX_LEDS)
# define WS2812_MAX_LEDS 48
#endif
// Pixel values
static uint8_t _led_colors[WS2812_BYTES_PER_LED * WS2812_MAX_LEDS];
uint32_t rgbGetLedColor(uint8_t led)
{
uint8_t* pixel = &_led_colors[led * WS2812_BYTES_PER_LED];
return (pixel[1] << 16) + (pixel[0] << 8) + pixel[2];
}
+45 -5
View File
@@ -7,6 +7,7 @@ option(INTERNAL_MODULE_PPM "Support for PPM internal module" OFF)
option(AUTOUPDATE "Auto update internal chips from SD" OFF)
option(BIND_KEY "Enable bind button" OFF)
option(BLUETOOTH "FrSky BT module support" OFF)
option(RGBLEDS "WS2812 addressable LED support" OFF)
set(USE_RTC_CLOCK YES)
set(HARDWARE_EXTERNAL_MODULE YES)
@@ -122,7 +123,7 @@ elseif(PCB STREQUAL X7)
set(FLAVOUR tpro)
set(ROTARY_ENCODER YES)
set(CPU_TYPE_FULL STM32F205xE)
add_definitions(-DFUNCTION_SWITCHES)
set(FUNCTION_SWITCHES ON)
add_definitions(-DRADIO_TPRO)
add_definitions(-DMANUFACTURER_JUMPER)
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
@@ -133,7 +134,7 @@ elseif(PCB STREQUAL X7)
set(FLAVOUR tprov2)
set(CPU_TYPE_FULL STM32F407xE)
set(ROTARY_ENCODER YES)
add_definitions(-DFUNCTION_SWITCHES)
set(FUNCTION_SWITCHES ON)
add_definitions(-DRADIO_TPROV2)
add_definitions(-DMANUFACTURER_JUMPER)
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
@@ -156,7 +157,7 @@ elseif(PCB STREQUAL X7)
set(NAVIGATION_TYPE x7)
set(CPU_TYPE_FULL STM32F407xG)
set(ROTARY_ENCODER YES)
add_definitions(-DFUNCTION_SWITCHES)
set(FUNCTION_SWITCHES YES)
add_definitions(-DRADIO_BUMBLEBEE)
add_definitions(-DMANUFACTURER_JUMPER)
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
@@ -192,7 +193,7 @@ elseif(PCB STREQUAL X7)
set(ROTARY_ENCODER YES)
set(CPU_TYPE_FULL STM32F407xE)
set(FLYSKY_GIMBAL ON)
add_definitions(-DFUNCTION_SWITCHES)
set(FUNCTION_SWITCHES ON)
add_definitions(-DRADIO_T20)
add_definitions(-DRADIO_FAMILY_T20)
add_definitions(-DMANUFACTURER_JUMPER)
@@ -206,7 +207,7 @@ elseif(PCB STREQUAL X7)
set(CPU_TYPE_FULL STM32F407xG)
set(FLYSKY_GIMBAL ON)
set(PXX2 ON)
add_definitions(-DFUNCTION_SWITCHES)
set(FUNCTION_SWITCHES ON)
add_definitions(-DRADIO_T20V2)
add_definitions(-DRADIO_FAMILY_T20)
add_definitions(-DMANUFACTURER_JUMPER)
@@ -285,6 +286,7 @@ elseif(PCB STREQUAL X7)
if (NOT BLUETOOTH)
set(AUX_SERIAL ON)
endif()
set(RGBLEDS YES)
elseif(PCBREV STREQUAL BOXER)
set(DEFAULT_INTERNAL_MODULE CROSSFIRE CACHE STRING "Default internal module")
set(INTERNAL_MODULE_SERIAL YES)
@@ -301,6 +303,24 @@ elseif(PCB STREQUAL X7)
if (NOT BLUETOOTH)
set(AUX_SERIAL ON)
endif()
elseif(PCBREV STREQUAL GX12)
set(DEFAULT_INTERNAL_MODULE CROSSFIRE CACHE STRING "Default internal module")
set(INTERNAL_MODULE_SERIAL YES)
set(MODULE_SIZE_SML YES)
set(FLAVOUR gx12)
set(NAVIGATION_TYPE x7)
set(CPU_TYPE_FULL STM32F407xG)
set(ROTARY_ENCODER YES)
set(USB_CHARGER YES)
add_definitions(-DRADIO_GX12)
add_definitions(-DMANUFACTURER_RADIOMASTER)
set(PXX2 ON)
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
set(FLYSKY_GIMBAL TES)
set(AUX_SERIAL ON)
set(AUX2_SERIAL OFF)
set(RGBLEDS YES)
set(FUNCTION_SWITCHES_WITH_RGB YES)
elseif(PCBREV STREQUAL ZORRO)
set(DEFAULT_INTERNAL_MODULE CROSSFIRE CACHE STRING "Default internal module")
set(INTERNAL_MODULE_SERIAL YES)
@@ -533,6 +553,15 @@ else()
message(FATAL_ERROR "Unknown CPU_TYPE_FULL" )
endif()
if(FUNCTION_SWITCHES)
add_definitions(-DFUNCTION_SWITCHES)
endif()
if(FUNCTION_SWITCHES_WITH_RGB)
set(FUNCTION_SWITCHES YES)
add_definitions(-DFUNCTION_SWITCHES)
add_definitions(-DFUNCTION_SWITCHES_RGB_LEDS)
endif()
if(ENABLE_SERIAL_PASSTHROUGH)
set(CLI ON "Enable CLI")
@@ -644,6 +673,17 @@ if(USE_RTC_CLOCK)
add_definitions(-DRTCLOCK)
endif()
if(RGBLEDS)
add_definitions(-DRGBLEDS)
endif()
if(FLAVOUR STREQUAL gx12)
target_sources(board PRIVATE
drivers/pca95xx.cpp
${TARGET_SRC_DIR}/gx12/bsp_io.cpp
)
target_include_directories(board PRIVATE ${TARGET_SRC_DIR}/gx12)
endif()
set(SRC ${SRC}
io/frsky_firmware_update.cpp
+15 -9
View File
@@ -30,6 +30,7 @@
#include "hal/abnormal_reboot.h"
#include "hal/usb_driver.h"
#include "hal/gpio.h"
#include "hal/rgbleds.h"
#include "board.h"
#include "boards/generic_stm32/module_ports.h"
@@ -198,12 +199,12 @@ void boardInit()
delay_ms(20);
#if defined(FUNCTION_SWITCHES)
// Support for FS Led to indicate battery charge level
if (getBatteryVoltage() >= 660) fsLedOn(0);
if (getBatteryVoltage() >= 700) fsLedOn(1);
if (getBatteryVoltage() >= 740) fsLedOn(2);
if (getBatteryVoltage() >= 780) fsLedOn(3);
if (getBatteryVoltage() >= 820) fsLedOn(4);
if (getBatteryVoltage() >= 842) fsLedOn(5);
if (getBatteryVoltage() >= 660) setFSLedON(0);
if (getBatteryVoltage() >= 700) setFSLedON(1);
if (getBatteryVoltage() >= 740) setFSLedON(2);
if (getBatteryVoltage() >= 780) setFSLedON(3);
if (getBatteryVoltage() >= 820) setFSLedON(4);
if (getBatteryVoltage() >= 842) setFSLedON(5);
#elif defined(STATUS_LEDS)
// Use Status LED to indicate battery charge level instead
if (getBatteryVoltage() <= 660) ledRed(); // low discharge
@@ -216,6 +217,9 @@ void boardInit()
}
#endif
delaysInit();
__enable_irq();
keysInit();
switchInit();
@@ -223,9 +227,6 @@ void boardInit()
rotaryEncoderInit();
#endif
delaysInit();
__enable_irq();
#if defined(PWM_STICKS)
sticksPwmDetect();
#endif
@@ -296,6 +297,11 @@ void boardInit()
#if defined(GUI)
lcdSetContrast(true);
#endif
#if defined(RADIO_GX12)
gpio_init(HALL_SYNC, GPIO_OUT, GPIO_PIN_SPEED_LOW);
#endif
}
#endif
+227
View File
@@ -0,0 +1,227 @@
/*
* 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 "bsp_io.h"
#include "hal/switch_driver.h"
#include "drivers/pca95xx.h"
#include "stm32_i2c_driver.h"
#include "timers_driver.h"
#include "boards/generic_stm32/rgb_leds.h"
#include <FreeRTOS/include/FreeRTOS.h>
#include <FreeRTOS/include/timers.h>
#include "myeeprom.h"
#include "bitfield.h"
struct bsp_io_expander {
pca95xx_t exp;
uint32_t mask;
uint32_t state;
};
static bsp_io_expander _io_switches;
static bsp_io_expander _io_fs_switches;
static void _init_io_expander(bsp_io_expander* io, uint32_t mask)
{
io->mask = mask;
io->state = 0;
}
static uint32_t _read_io_expander(bsp_io_expander* io)
{
uint16_t value = 0;
if (pca95xx_read(&io->exp, io->mask, &value) == 0) {
io->state = value;
}
return io->state;
}
static void _poll_switches(void *pvParameter1, uint32_t ulParameter2)
{
(void)ulParameter2;
bsp_io_expander* io = (bsp_io_expander*)pvParameter1;
_read_io_expander(io);
}
static void _io_int_handler(bsp_io_expander* io)
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) {
xTimerPendFunctionCallFromISR(_poll_switches, (void*)io, 0,
&xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
} else {
_read_io_expander(io);
}
}
static void _io_int_handler() {
_io_int_handler(&_io_switches);
_io_int_handler(&_io_fs_switches);
}
int bsp_io_init()
{
timersInit();
if (i2c_init(I2C_Bus_2) < 0) {
return -1;
}
// configure expander 1
_init_io_expander(&_io_switches, 0xFC3F);
if (pca95xx_init(&_io_switches.exp, I2C_Bus_2, 0x74) < 0) {
return -1;
}
// configure expander 2
_init_io_expander(&_io_fs_switches, 0x3F);
if (pca95xx_init(&_io_fs_switches.exp, I2C_Bus_2, 0x75) < 0) {
return -1;
}
// setup expanders pin change interrupt
gpio_init_int(IO_INT_GPIO, GPIO_IN, GPIO_FALLING, _io_int_handler);
// setup expanders reset pin
gpio_init(IO_RESET_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
gpio_set(IO_RESET_GPIO);
bsp_io_read_switches();
bsp_io_read_fs_switches();
return 0;
}
uint32_t bsp_io_read_switches()
{
return _read_io_expander(&_io_switches);
}
uint32_t bsp_io_read_fs_switches()
{
return _read_io_expander(&_io_fs_switches);
}
void boardInitSwitches()
{
bsp_io_init();
}
struct bsp_io_sw_def {
uint32_t pin_high;
uint32_t pin_low;
};
static constexpr uint32_t RGB_OFFSET = (1 << 16); // first after bspio pins
static uint16_t soft2POSLogicalState = 0xFFFF;
static const bsp_io_sw_def _switch_defs[] = {
{ SWITCH_A, RGB_OFFSET + 7 },
{ SWITCH_B_H, SWITCH_B_L },
{ SWITCH_C_H, SWITCH_C_L },
{ SWITCH_D, RGB_OFFSET + 6 },
{ SWITCH_E_H, SWITCH_E_L },
{ SWITCH_F_H, SWITCH_F_L },
{ SWITCH_G, 0 },
{ SWITCH_H, 0 },
};
static SwitchHwPos _get_switch_pos(uint8_t idx)
{
static uint32_t oldState = 0;
SwitchHwPos pos = SWITCH_HW_UP;
const bsp_io_sw_def* def = &_switch_defs[idx];
uint32_t state = _io_switches.state;
if (def->pin_low > RGB_OFFSET) {
// Potential soft 2pos
if ((SWITCH_CONFIG(idx) == SWITCH_TOGGLE)) {
if ((state & def->pin_high) == 0) {
pos = SWITCH_HW_DOWN;
}
}
else {
if (((state & def->pin_high) == 0) && ((state & def->pin_high) != (oldState & def->pin_high))) {
soft2POSLogicalState ^= def->pin_high;
}
if ((soft2POSLogicalState & def->pin_high) == 0) {
pos = SWITCH_HW_DOWN;
}
else {
pos = SWITCH_HW_UP;
}
}
if(pos == SWITCH_HW_UP) {
rgbSetLedColor(def->pin_low - RGB_OFFSET, 0x0, 0x0, 0x0);
}
else {
rgbSetLedColor(def->pin_low - RGB_OFFSET, 0xFF, 0xFF, 0xFF);
}
}
else if (!def->pin_low) {
// 2POS switch
if ((state & def->pin_high) == 0) {
pos = SWITCH_HW_DOWN;
}
} else {
bool hi = state & def->pin_high;
bool lo = state & def->pin_low;
if (hi && lo) {
pos = SWITCH_HW_MID;
} else if (!hi && lo) {
pos = SWITCH_HW_DOWN;
}
}
if (idx == switchGetMaxSwitches() - 1)
oldState = state;
return pos;
}
static SwitchHwPos _get_fs_switch_pos(uint8_t idx)
{
uint32_t state = _io_fs_switches.state;
if ((state & (1 << idx)) == 0) {
return SWITCH_HW_DOWN;
} else {
return SWITCH_HW_UP;
}
}
SwitchHwPos boardSwitchGetPosition(uint8_t cat, uint8_t idx)
{
if (cat == SWITCH_PHYSICAL) {
return _get_switch_pos(idx);
} else if (cat == SWITCH_FUNCTION){
return _get_fs_switch_pos(idx);
}
return SWITCH_HW_UP;
}
+59
View File
@@ -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.
*/
#pragma once
#include "drivers/pca95xx.h"
// Port expander 1 (0x74)
#define SWITCH_H PCA95XX_PIN_0
#define SWITCH_D PCA95XX_PIN_1
#define SWITCH_F_H PCA95XX_PIN_3
#define SWITCH_F_L PCA95XX_PIN_2
#define SWITCH_C_L PCA95XX_PIN_4
#define SWITCH_C_H PCA95XX_PIN_5
#define SWITCH_B_H PCA95XX_PIN_10
#define SWITCH_B_L PCA95XX_PIN_11
#define SWITCH_E_H PCA95XX_PIN_12
#define SWITCH_E_L PCA95XX_PIN_13
#define SWITCH_A PCA95XX_PIN_14
#define SWITCH_G PCA95XX_PIN_15
#define IO_INT_GPIO GPIO_PIN(GPIOE, 14)
#define IO_RESET_GPIO GPIO_PIN(GPIOE, 15)
// Port expander 1 (0x75)
#define FSSWITCH_1 PCA95XX_PIN_0
#define FSSWITCH_2 PCA95XX_PIN_1
#define FSSWITCH_3 PCA95XX_PIN_2
#define FSSWITCH_4 PCA95XX_PIN_3
#define FSSWITCH_5 PCA95XX_PIN_4
#define FSSWITCH_6 PCA95XX_PIN_5
int bsp_io_init();
uint32_t bsp_io_read_switches();
uint32_t bsp_io_read_fs_switches();
File diff suppressed because it is too large Load Diff
@@ -106,6 +106,14 @@ void lcdHardwareInit()
NVIC_SetPriority(LCD_DMA_Stream_IRQn, 7);
NVIC_EnableIRQ(LCD_DMA_Stream_IRQn);
#if defined(OLED_VCC_CS)
gpio_init(OLED_VCC_CS, GPIO_OUT, GPIO_PIN_SPEED_LOW);
// Coming from bootloader or EM, screen is already on
if (WAS_RESET_BY_WATCHDOG_OR_SOFTWARE())
gpio_set(OLED_VCC_CS);
#endif
}
#if defined(SSD1309_LCD)
@@ -145,6 +153,10 @@ void lcdStart()
lcdWriteCommand(0xA4); // Disable Entire Display On
lcdWriteCommand(0xA6); // Set Normal Display (not inverted)
lcdWriteCommand(0x2E); // Deactivate scroll
#if defined(OLED_VCC_CS)
delay_ms(100);
gpio_set(OLED_VCC_CS);
#endif
#else
#if defined(LCD_VERTICAL_INVERT)
// T12 and TX12 have the screen inverted.
@@ -353,7 +365,12 @@ void lcdOff()
to re-init LCD without any delay
*/
lcdWriteCommand(0xAE); // LCD sleep
#if defined(OLED_VCC_CS)
gpio_clear(OLED_VCC_CS);
delay_ms(100);
#else
delay_ms(3); // Wait for caps to drain
#endif
}
void lcdReset()
+31 -5
View File
@@ -20,11 +20,19 @@
*/
#include "hal/gpio.h"
#include "hal/rgbleds.h"
#include "stm32_gpio.h"
#include "boards/generic_stm32/rgb_leds.h"
#include "board.h"
#if defined(LED_STRIP_GPIO)
#include "boards/generic_stm32/rgb_leds.h"
#endif
#if defined(FUNCTION_SWITCHES)
#define GET_RED(color) (((color) & 0xF80000) >>16)
#define GET_GREEN(color) (((color) & 0x000F800) >> 8)
#define GET_BLUE(color) (((color) & 0xF8))
#if defined(FUNCTION_SWITCHES) && !defined(FUNCTION_SWITCHES_RGB_LEDS)
static const uint32_t fsLeds[] = {FSLED_GPIO_PIN_1, FSLED_GPIO_PIN_2,
FSLED_GPIO_PIN_3, FSLED_GPIO_PIN_4,
FSLED_GPIO_PIN_5, FSLED_GPIO_PIN_6};
@@ -44,14 +52,32 @@ void ledInit()
gpio_init(LED_BLUE_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
#endif
#if defined(FUNCTION_SWITCHES)
#if defined(FUNCTION_SWITCHES) && !defined(FUNCTION_SWITCHES_RGB_LEDS)
for (size_t i = 0; i < DIM(fsLeds); i++) {
gpio_init(fsLeds[i], GPIO_OUT, GPIO_PIN_SPEED_LOW);
}
#endif
}
#if defined(FUNCTION_SWITCHES)
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
// used to map switch number to led number in the rgbled chain
uint8_t ledMapping[] = {0, 1, 2, 3, 4, 5, 6};
void fsLedRGB(uint8_t index, uint32_t color)
{
rgbSetLedColor(ledMapping[index], GET_RED(color), \
GET_GREEN(color),GET_BLUE(color));
}
uint8_t getRGBColorIndex(uint32_t color)
{
for (uint8_t i = 0; i < (sizeof(colorTable) / sizeof(colorTable[0])); i++) {
if (color == colorTable[i])
return(i);
}
return 5; // Custom value set with Companion
}
#elif defined(FUNCTION_SWITCHES)
void fsLedOff(uint8_t index)
{
gpio_clear(fsLeds[index]);
@@ -62,7 +88,7 @@ void fsLedOn(uint8_t index)
gpio_set(fsLeds[index]);
}
bool getFSLedState(uint8_t index)
bool fsLedState(uint8_t index)
{
return gpio_read(fsLeds[index]) ? true : false;
}
@@ -37,6 +37,10 @@
#define USB_NAME "Radiomaster MT12"
#define USB_MANUFACTURER 'R', 'M', '_', 'T', 'X', ' ', ' ', ' ' /* 8 bytes */
#define USB_PRODUCT 'R', 'M', ' ', 'M', 'T', '1', '2', ' ' /* 8 Bytes */
#elif defined(RADIO_GX12)
#define USB_NAME "Radiomaster GX12"
#define USB_MANUFACTURER 'R', 'M', '_', 'T', 'X', ' ', ' ', ' ' /* 8 bytes */
#define USB_PRODUCT 'R', 'M', ' ', 'G', 'X', '1', '2', ' ' /* 8 Bytes */
#elif defined(RADIO_POCKET)
#define USB_NAME "Radiomaster Pocket"
#define USB_MANUFACTURER 'R', 'M', '_', 'T', 'X', ' ', ' ', ' ' /* 8 bytes */