Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use single target to support nv14/el18/pl18/pl18ev/nb4p #5397

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d0cba7a
Initial support of NB4+
richardclli Mar 27, 2024
eb0ffa4
Current works: LCD, touch, ST, TH, some switches
richardclli Mar 29, 2024
e558076
Fixed battery charging and USB detection
richardclli Apr 2, 2024
a543463
Mapped audio mute
richardclli Apr 2, 2024
b5f3dbf
Disable voice chip
richardclli Jul 9, 2024
d2805ec
Added encoder
richardclli Jul 10, 2024
85c9681
Fixed haptic
richardclli Apr 18, 2024
27cf0d8
Unified bootloader menu for all Flysky radios
richardclli Apr 18, 2024
a4dd0f0
Can enter bootloader with S2 + S3
richardclli Apr 17, 2024
d46302f
Switch driver, key/trim driver
richardclli Apr 23, 2024
10619fc
Mapped SW1 to encoder control, SW2 and SW3 are user usable switches, …
richardclli Jul 12, 2024
5d93e72
Update Cmakelist
richardclli Jul 15, 2024
35ee976
Update battery divider for NB4+
richardclli Jul 15, 2024
ee2badc
Fixed EM in keys diagnostic screen
richardclli Jul 16, 2024
b2039dc
Map bluetooth port as int module (2 wires)
richardclli Aug 5, 2024
583cb71
USB should switch back to MCU when exiting bootloader
richardclli Aug 6, 2024
e9961ba
Cleaned up hal.h
richardclli Aug 6, 2024
f849f1e
chore(ci): build nb4p firmware
pfeerick Aug 8, 2024
c36348d
chore: define nb4p as a surface radio
pfeerick Aug 8, 2024
7ee556f
chore: consistent formatting
pfeerick Aug 8, 2024
6b1c283
Updated naming of switches and pots according to what is printed in t…
richardclli Aug 8, 2024
e9c8ee1
Fixed build problem by PR #5396
richardclli Aug 18, 2024
d5e9c22
chore: formatting
pfeerick Aug 19, 2024
ab73c60
Added touch type display
richardclli Aug 21, 2024
072708f
chore: add USE_RTC_CLOCK build time option
pfeerick Aug 21, 2024
c37c293
Fixed nv14 target build error
richardclli Aug 22, 2024
6addcb0
Fixed NB4+ int module power logic
richardclli Aug 22, 2024
8652c96
Better handling reboot
richardclli Aug 7, 2024
1c9d01a
Initial merge of nv14 target to pl18 target
richardclli Aug 6, 2024
e6a8676
LCD and touch works for EL18
richardclli Aug 6, 2024
d2a763d
Fixed audio volume, LED strip, int module pwr, battery divider
richardclli Aug 7, 2024
28472dc
Fixed gimbal, SPI flash, yaml saving, keys, trims
richardclli Aug 7, 2024
236331c
Updated build scripts
richardclli Aug 7, 2024
0fc6572
Fixed charging mechanism, EL18 and NB4P use the same chip have the sa…
richardclli Aug 7, 2024
fedf794
Fixed build errors of other targets
richardclli Aug 8, 2024
acccede
Battery divider value is wrong according to schematic
richardclli Sep 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
- xlite
- xlites
- mt12
- nb4p
container:
image: ghcr.io/edgetx/edgetx-dev:latest
volumes:
Expand Down Expand Up @@ -115,6 +116,7 @@ jobs:
- x9lite;x9lites
- xlite;xlites
- mt12
- nb4p
container:
image: ghcr.io/edgetx/edgetx-dev:latest
volumes:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- x9lite;x9lites
- xlite;xlites
- mt12
- nb4p
container:
image: ghcr.io/edgetx/edgetx-dev:latest
volumes:
Expand Down
2 changes: 1 addition & 1 deletion companion/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ elseif(PCB STREQUAL X10 AND PCBREV STREQUAL T16)
set(FLAVOUR t16)
elseif(PCB STREQUAL X10 AND PCBREV STREQUAL T18)
set(FLAVOUR t18)
elseif(PCB STREQUAL NV14 AND PCBREV STREQUAL EL18)
elseif(PCB STREQUAL PL18 AND PCBREV STREQUAL EL18)
set(FLAVOUR el18)
elseif(PCB STREQUAL PL18)
set(FLAVOUR pl18)
Expand Down
1 change: 1 addition & 0 deletions fw.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
["Flysky NV14", "nv14-"],
["Flysky PL18", "pl18-"],
["Flysky PL18EV", "pl18ev-"],
["Flysky NB4+", "nb4p-"],
["FrSky Horus X10", "x10-"],
["FrSky Horus X10 Express", "x10express-"],
["FrSky Horus X12s", "x12s-"],
Expand Down
2 changes: 1 addition & 1 deletion radio/src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ enum AudioBufferState
#define AUDIO_DATA_MIN 0
#define AUDIO_DATA_MAX 0xffff
#define AUDIO_BITS_PER_SAMPLE 16
#elif defined(PCBX12S) || defined(PCBNV14)
#elif defined(AUDIO_SPI)
typedef int16_t audio_data_t;
#define AUDIO_DATA_SILENCE 0
#define AUDIO_DATA_MIN INT16_MIN
Expand Down
18 changes: 10 additions & 8 deletions radio/src/boards/generic_stm32/switches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,34 @@

#include <stdlib.h>

void boardInitSwitches()
#define __weak __attribute__((weak))

__weak void boardInitSwitches()
{
_init_switches();
}

SwitchHwPos boardSwitchGetPosition(uint8_t cat, uint8_t idx)
__weak SwitchHwPos boardSwitchGetPosition(uint8_t cat, uint8_t idx)
{
return stm32_switch_get_position(&_switch_offsets[cat][idx]);
}

const char* boardSwitchGetName(uint8_t cat, uint8_t idx)
__weak const char* boardSwitchGetName(uint8_t cat, uint8_t idx)
{
return _switch_offsets[cat][idx].name;
}

SwitchHwType boardSwitchGetType(uint8_t cat, uint8_t idx)
__weak SwitchHwType boardSwitchGetType(uint8_t cat, uint8_t idx)
{
return _switch_offsets[cat][idx].type;
}

uint8_t boardGetMaxSwitches() { return n_switches; }
uint8_t boardGetMaxFctSwitches() { return n_fct_switches; }
__weak uint8_t boardGetMaxSwitches() { return n_switches; }
__weak uint8_t boardGetMaxFctSwitches() { return n_fct_switches; }

swconfig_t boardSwitchGetDefaultConfig() { return _switch_default_config; }
__weak swconfig_t boardSwitchGetDefaultConfig() { return _switch_default_config; }

switch_display_pos_t switchGetDisplayPosition(uint8_t idx)
__weak switch_display_pos_t switchGetDisplayPosition(uint8_t idx)
{
// TODO: find a solution for FLEX switches so they can be displayed on main view
if (idx >= DIM(_switch_display)) return {0, 0};
Expand Down
12 changes: 8 additions & 4 deletions radio/src/datastructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static inline void check_struct()
CHKSIZE(TimerData, 17);
CHKSIZE(ModelHeader, 131);
CHKSIZE(CustomScreenData, 1892);
#if defined(PCBNV14)
#if defined(PCBNV14) || defined(RADIO_NB4P) || defined(RADIO_NV14_FAMILY)
CHKTYPE(TopBarPersistentData, 704);
#else
CHKTYPE(TopBarPersistentData, 1048);
Expand Down Expand Up @@ -102,10 +102,14 @@ static inline void check_struct()
CHKSIZE(ModelData, 6770);
#elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBX9LITE)
CHKSIZE(ModelData, 6329);
#elif defined(PCBNV14)
CHKSIZE(ModelData, 26463);
#elif defined(PCBPL18)
CHKSIZE(ModelData, 26845);
#if defined(RADIO_NB4P) || defined(RADIO_NV14_FAMILY)
CHKSIZE(ModelData, 26499);
#else
CHKSIZE(ModelData, 26845);
#endif
#elif defined(PCBNV14)
CHKSIZE(ModelData, 21899);
#elif defined(RADIO_T15)
CHKSIZE(ModelData, 26834);
#elif defined(PCBHORUS)
Expand Down
5 changes: 4 additions & 1 deletion radio/src/gui/colorlcd/radio/radio_diagkeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
#include "libopenui.h"
#include "edgetx.h"

#if defined(PCBPL18)
#if defined(RADIO_NB4P)
static const uint8_t _trimMap[MAX_TRIMS * 2] = {0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15};
#elif defined(PCBPL18)
static const uint8_t _trimMap[MAX_TRIMS * 2] = {8, 9, 10, 11, 12, 13, 14, 15,
2, 3, 4, 5, 0, 1, 6, 7};
#else
Expand Down
4 changes: 4 additions & 0 deletions radio/src/gui/colorlcd/radio/radio_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ RadioVersionPage::RadioVersionPage() :

#if defined(PCBNV14) || defined(PCBPL18)
extern const char* boardLcdType;
extern const char* boardTouchType;
#endif

void RadioVersionPage::build(Window* window)
Expand Down Expand Up @@ -370,6 +371,9 @@ void RadioVersionPage::build(Window* window)
version += nl;
version += "LCD: ";
version += boardLcdType;
version += nl;
version += "Touch: ";
version += boardTouchType;
#endif

auto txt = new StaticText(window, rect_t{}, version);
Expand Down
4 changes: 2 additions & 2 deletions radio/src/storage/yaml/yaml_datastructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
#else
#include "yaml_datastructs_x10.cpp"
#endif
#elif defined(PCBNV14)
#include "yaml_datastructs_nv14.cpp"
#elif defined(PCBPL18)
#include "yaml_datastructs_pl18.cpp"
#elif defined(PCBNV14)
#include "yaml_datastructs_nv14.cpp"
#elif defined(PCBX7)
#if defined(RADIO_TPRO) || defined(RADIO_TPROV2) || defined(RADIO_BUMBLEBEE)
#include "yaml_datastructs_tpro.cpp"
Expand Down
3 changes: 3 additions & 0 deletions radio/src/targets/nv14/touch_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ volatile static bool touchEventOccured;
enum TouchControllers {TC_NONE, TC_FT6236, TC_CST836U};
TouchControllers touchController = TC_NONE;

const char* boardTouchType = "";
static tc_handle_TypeDef tc_handle = {0, 0};

tmr10ms_t downTime = 0;
Expand Down Expand Up @@ -388,9 +389,11 @@ void detectTouchController()
{
touchController = TC_CST836U;
tc = &CST836U;
boardTouchType = "CST836U";
} else {
touchController = TC_FT6236;
tc = &FT6236;
boardTouchType = "FT6236";
}
}

Expand Down
111 changes: 92 additions & 19 deletions radio/src/targets/pl18/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
option(DISK_CACHE "Enable SD card disk cache" ON)
option(UNEXPECTED_SHUTDOWN "Enable the Unexpected Shutdown screen" ON)
option(PXX1 "PXX1 protocol support" ON)
option(PXX2 "PXX2 protocol support" OFF)
Expand All @@ -18,34 +19,77 @@ set(RTC_BACKUP_RAM YES)
set(PPM_LIMITS_SYMETRICAL YES)
set(USB_SERIAL ON CACHE BOOL "Enable USB serial (CDC)")
set(HARDWARE_EXTERNAL_MODULE YES)
set(WIRELESS_CHARGER YES)

#option(STICKS_DEAD_ZONE "Enable sticks dead zone" YES)
#option(AFHDS2 "Support for AFHDS2" OFF)

option(USE_RTC_CLOCK "RTC Clock" ON)

# for size report script
set(CPU_TYPE_FULL STM32F429xI)
set(TARGET_LINKER_DIR stm32f429_sdram)
set(TARGET_SDRAM_START 0xC0000000)

set(SIZE_TARGET_MEM_DEFINE "MEM_SIZE_SDRAM1=8192")

#set(RF_BAUD_RATE 921600 230400 115200 57600 38400 19200 9600 4800 2400 1200)
#set(PCB_RF_BAUD 921600 CACHE STRING "INTERNAL_MODULE_BAUDRATE: ${RF_BAUD_RATE}")
#set_property(CACHE PCB_RF_BAUD PROPERTY STRINGS ${RF_BAUD_RATE})
set(RF_BAUD_RATE 921600 230400 115200 57600 38400 19200 9600 4800 2400 1200)
set(PCB_RF_BAUD 921600 CACHE STRING "INTERNAL_MODULE_BAUDRATE: ${RF_BAUD_RATE}")
set_property(CACHE PCB_RF_BAUD PROPERTY STRINGS ${RF_BAUD_RATE})

add_definitions(-DPCBPL18 -DPCBFLYSKY)
add_definitions(-DBATTERY_CHARGE)
add_definitions(-DSOFTWARE_VOLUME)
add_definitions(-DSPI_FLASH)
add_definitions(-DSTM32_SUPPORT_32BIT_TIMERS)

if(PCBREV STREQUAL PL18EV)
if (PCBREV STREQUAL EL18)
set(FLAVOUR el18)
add_definitions(-DRADIO_EL18 -DRADIO_NV14_FAMILY -DPCBNV14 -DUSE_HATS_AS_KEYS)
set(DISK_CACHE ON)
set(FLYSKY_GIMBAL ON)
set(USE_VS1053B ON)
set(AFHDS3 ON)

# defines existing internal modules
set(INTERNAL_MODULES AFHDS3;CRSF CACHE STRING "Internal modules")
set(DEFAULT_INTERNAL_MODULE FLYSKY_AFHDS3 CACHE STRING "Default internal module")
elseif(PCBREV STREQUAL NV14)
set(FLAVOUR nv14)
add_definitions(-DRADIO_NV14 -DRADIO_NV14_FAMILY -DPCBNV14)
add_definitions(-DUSE_HATS_AS_KEYS -DAFHDS2_BAUDRATE=${PCB_RF_BAUD})
set(DISK_CACHE ON)
set(FLYSKY_GIMBAL ON)
set(USE_VS1053B ON)
set(AFHDS2 ON)

# defines existing internal modules
set(INTERNAL_MODULES AFHDS2A CACHE STRING "Internal modules")
set(DEFAULT_INTERNAL_MODULE FLYSKY_AFHDS2A CACHE STRING "Default internal module")
elseif(PCBREV STREQUAL NB4P)
set(FLAVOUR nb4p)
add_definitions(-DRADIO_NB4P -DSPI_FLASH)
set(ROTARY_ENCODER YES)
set(LED_STRIP ON)
set(AFHDS3 ON)
set(KEY_DRIVER nb4p_key_driver.cpp)

# Defines internal modules for PL18 via UART7
set(INTERNAL_MODULES MULTI;AFHDS3;CRSF CACHE STRING "Internal modules")
set(DEFAULT_INTERNAL_MODULE MULTIMODULE CACHE STRING "Default internal module")
elseif(PCBREV STREQUAL PL18EV)
set(FLAVOUR pl18ev)
add_definitions(-DRADIO_PL18EV)
add_definitions(-DRADIO_PL18EV -DSPI_FLASH -DUSE_HATS_AS_KEYS)
set(WIRELESS_CHARGER YES)
set(FLYSKY_GIMBAL ON)
set(LED_STRIP ON)
set(AFHDS3 ON)
set(KEY_DRIVER key_driver.cpp)
else()
set(FLAVOUR pl18)
add_definitions(-DRADIO_PL18)
add_definitions(-DRADIO_PL18 -DSPI_FLASH -DUSE_HATS_AS_KEYS)
set(WIRELESS_CHARGER YES)
set(FLYSKY_GIMBAL ON)
set(LED_STRIP ON)
set(AFHDS3 ON)
set(KEY_DRIVER key_driver.cpp)

# Defines internal modules for PL18 via UART7
set(INTERNAL_MODULES MULTI CACHE STRING "Internal modules")
Expand All @@ -62,22 +106,26 @@ set(FIRMWARE_DEPENDENCIES datacopy)

set(HARDWARE_TOUCH ON)
set(SOFTWARE_KEYBOARD ON)
set(FLYSKY_GIMBAL ON)

add_definitions(
-DSTM32F429_439xx -DSTM32F429xx
-DSDRAM -DCCMRAM -DCOLORLCD -DLIBOPENUI
-DHARDWARE_TOUCH -DHARDWARE_KEYS
-DSOFTWARE_KEYBOARD -DUSE_HATS_AS_KEYS)
-DSOFTWARE_KEYBOARD)

set(SDRAM ON)

add_definitions(-DAUDIO -DVOICE -DRTCLOCK)
add_definitions(-DAUDIO -DVOICE)
add_definitions(-DGPS_USART_BAUDRATE=${INTERNAL_GPS_BAUDRATE})
add_definitions(-DPWR_BUTTON_${PWR_BUTTON})
add_definitions(-DCROSSFIRE_NATIVE)
add_definitions(-DHARDWARE_EXTERNAL_MODULE)

if(USE_RTC_CLOCK)
message("-- RTC Clock enabled")
add_definitions(-DRTCLOCK)
endif()

if(WIRELESS_CHARGER)
add_definitions(-DWIRELESS_CHARGER)
endif()
Expand All @@ -90,8 +138,6 @@ if(NOT UNEXPECTED_SHUTDOWN)
add_definitions(-DNO_UNEXPECTED_SHUTDOWN)
endif()

set(AFHDS3 ON)

# VCP CLI
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
set(CLI ON CACHE BOOL "Enable CLI")
Expand All @@ -100,8 +146,7 @@ set(TARGET_SRC_DIR targets/${TARGET_DIR})

set(BOARD_COMMON_SRC
${TARGET_SRC_DIR}/board.cpp
${TARGET_SRC_DIR}/led_driver.cpp
${TARGET_SRC_DIR}/key_driver.cpp
${TARGET_SRC_DIR}/${KEY_DRIVER}
${TARGET_SRC_DIR}/haptic_driver.cpp
${TARGET_SRC_DIR}/backlight_driver.cpp
${TARGET_SRC_DIR}/${LCD_DRIVER}
Expand All @@ -118,6 +163,19 @@ set(BOARD_COMMON_SRC
drivers/frftl.cpp
)

if(ROTARY_ENCODER)
set(BOARD_COMMON_SRC ${BOARD_COMMON_SRC}
targets/common/arm/stm32/rotary_encoder_driver.cpp
)
endif()

if(DISK_CACHE)
set(BOARD_COMMON_SRC ${BOARD_COMMON_SRC}
disk_cache.cpp
)
add_definitions(-DDISK_CACHE)
endif()

# Bootloader board library
add_library(board_bl OBJECT EXCLUDE_FROM_ALL
${BOARD_COMMON_SRC}
Expand All @@ -131,22 +189,37 @@ add_library(board OBJECT EXCLUDE_FROM_ALL
${BOARD_COMMON_SRC}
${TARGET_SRC_DIR}/${TOUCH_DRIVER}
${TARGET_SRC_DIR}/battery_driver.cpp
targets/common/arm/stm32/audio_dac_driver.cpp
targets/common/arm/stm32/delays_driver.cpp
targets/common/arm/stm32/heartbeat_driver.cpp
targets/common/arm/stm32/mixer_scheduler_driver.cpp
targets/common/arm/stm32/module_timer_driver.cpp
targets/common/arm/stm32/stm32_pulse_driver.cpp
targets/common/arm/stm32/stm32_softserial_driver.cpp
targets/common/arm/stm32/stm32_switch_driver.cpp
targets/common/arm/stm32/stm32_ws2812.cpp
targets/common/arm/stm32/trainer_driver.cpp
targets/common/arm/stm32/spi_flash.cpp
targets/common/arm/stm32/diskio_spi_flash.cpp
drivers/frftl.cpp
drivers/frftl.cpp
)
set(FIRMWARE_SRC ${FIRMWARE_SRC} $<TARGET_OBJECTS:board>)

if(PCBREV STREQUAL NB4P)
target_sources(board PRIVATE ${TARGET_SRC_DIR}/switch_driver.cpp)
endif()

if(USE_VS1053B)
target_sources(board PRIVATE targets/common/arm/stm32/vs1053b.cpp)
else()
target_sources(board PRIVATE targets/common/arm/stm32/audio_dac_driver.cpp)
add_definitions(-DSOFTWARE_VOLUME)
endif()

if(LED_STRIP)
target_sources(board PRIVATE ${TARGET_SRC_DIR}/led_driver.cpp)
target_sources(board PRIVATE targets/common/arm/stm32/stm32_ws2812.cpp)
endif()


set(FIRMWARE_SRC
${FIRMWARE_SRC}
targets/common/arm/loadboot.cpp
Expand Down
Loading
Loading