Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
313b196
Logging HW definitions generator
raphaelcoeffic Jul 28, 2025
713a214
Defines and JSON hardware definitions
raphaelcoeffic Jul 28, 2025
0b1a59e
Add define remover and usage checker
raphaelcoeffic Jul 12, 2025
e80acbb
Remove hardware definitions present in JSON
raphaelcoeffic Jul 28, 2025
dd490c7
chore(radio): document hardware definitions removal
raphaelcoeffic Jul 28, 2025
a12835a
chore: hal.h cleanup
raphaelcoeffic Jul 13, 2025
743b938
fix: define SURFACE_RADIO directly
raphaelcoeffic Jul 13, 2025
75cf8c3
fix: remove KEYS_GPIO_REG_PAGEDN usage
raphaelcoeffic Jul 13, 2025
5cdfa68
fix: remove KEYS_GPIO_REG_DOWN, KEYS_GPIO_REG_MINUS and KEYS_GPIO_REG…
raphaelcoeffic Jul 13, 2025
ceacdbf
fix: remove KEYS_GPIO_REG_MENU
raphaelcoeffic Jul 13, 2025
7bfbee4
fix: use new hardware defs JSON location
raphaelcoeffic Jul 13, 2025
0526905
fix: cleanup NB4P ADC usage in boot loader
raphaelcoeffic Jul 13, 2025
f9b667c
fix: paths and dependencies related to hardware definitions
raphaelcoeffic Jul 13, 2025
d665d9f
chore: hw defs cleanup and validator
raphaelcoeffic Jul 13, 2025
e984693
fix: compat Python 3.8
raphaelcoeffic Jul 14, 2025
f3a6922
fix(ci): add missing pydantic
raphaelcoeffic Jul 14, 2025
d307eb4
feat: better hardware definition type checking
raphaelcoeffic Jul 14, 2025
93d847e
Fix PGUP key logic. Cleanup color text & number edit.
Jul 14, 2025
01ec4af
Use keyIsSupported()
raphaelcoeffic Jul 16, 2025
898b080
Fix hardware data model after switch refactor
raphaelcoeffic Jul 28, 2025
382814e
Enable LTO for `board_bl` to prevent bootloader overflow
raphaelcoeffic Jul 28, 2025
c433a59
Fix NB4P bootloader
raphaelcoeffic Jul 28, 2025
29832cb
Cleanup B&W navigation definitions.
Jul 17, 2025
2e5c7e6
Define RADIO_xxx automatically. Use radio type to set B&W navigation …
Jul 17, 2025
6f621d0
Create CMake variable for radio type.
Jul 17, 2025
d3f3d25
Remove PCB/FLAVOUR refs from Companion CMakeLists.txt
raphaelcoeffic Aug 21, 2025
47bd7e5
Cleanup
raphaelcoeffic Aug 22, 2025
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: 1 addition & 1 deletion .github/workflows/macosx_cpn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
cache-key-prefix: 'install-qt-action-macOS'

- name: Install dependencies
run: python3 -m pip install --upgrade pip Pillow lz4 clang jinja2
run: python3 -m pip install --upgrade pip Pillow lz4 clang jinja2 pydantic

- name: Install libusb
run: brew install libusb
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/win_cpn-64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Install Python Dependencies
run: |
echo $PATH
$Python3_ROOT_DIR/python3.exe -m pip install clang jinja2 lz4 pillow
$Python3_ROOT_DIR/python3.exe -m pip install clang jinja2 lz4 pillow pydantic

- name: Setup dfu-util and libusb
run: |
Expand Down
16 changes: 8 additions & 8 deletions cmake/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,18 @@ function(AddHardwareDefTarget output)
endforeach()

set(GEN_HW_DEFS ${CMAKE_CXX_COMPILER} ${HW_DEF_ARGS} -x c++-header -E -dM ${HW_DEF_SRC})
set(GEN_JSON ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/hw_defs/generate_hw_def.py)
set(GEN_JSON ${GEN_JSON} -i defines -T ${FLAVOUR} -)
# set(GEN_JSON ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/hw_defs/generate_hw_def.py)
# set(GEN_JSON ${GEN_JSON} -i defines -T ${FLAVOUR} -)

add_custom_command(OUTPUT ${output}
COMMAND ${GEN_HW_DEFS} | ${GEN_JSON} > ${output}
DEPENDS ${HW_DEF_SRC} ${RADIO_DIRECTORY}/util/hw_defs/generate_hw_def.py
)
# add_custom_command(OUTPUT ${output}
# COMMAND ${GEN_HW_DEFS} | ${GEN_JSON} > ${output}
# DEPENDS ${HW_DEF_SRC} ${RADIO_DIRECTORY}/util/hw_defs/generate_hw_def.py
# )

add_custom_command(OUTPUT ${output}.h
COMMAND ${GEN_HW_DEFS} > ${output}.h
DEPENDS ${HW_DEF_SRC} ${RADIO_DIRECTORY}/util/hw_defs/generate_hw_def.py
)
)
endfunction()

function(AddHWGenTarget input template output)
Expand All @@ -116,7 +116,7 @@ function(AddHWGenTarget input template output)
set(GEN_JSON ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/hw_defs/generate_hw_def.py)

# Inputs
set(INPUT_JSON ${CMAKE_CURRENT_BINARY_DIR}/${input})
set(INPUT_JSON ${RADIO_SRC_DIR}/boards/hw_defs/${input})
set(TEMPLATE ${RADIO_DIRECTORY}/util/hw_defs/${template}.jinja)
set(GEN_PY_DEPS
${RADIO_DIRECTORY}/util/hw_defs/generator.py
Expand Down
20 changes: 2 additions & 18 deletions companion/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ else()
endif()

############# Import radio hardware definitions ###############
set(HWDEFS_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../radio/src")

set(HWDEFS_DIR "${CMAKE_SOURCE_DIR}/radio/src/boards/hw_defs")
set(HWDEFS_TMPL "${COMPANION_SRC_DIRECTORY}/hwdefs.qrc.in")
set(HWDEFS_PHDR "HWDEF_JSON_LIST")
set(HWDEFS_QRC "${CMAKE_CURRENT_BINARY_DIR}/hwdefs.qrc")
Expand Down Expand Up @@ -300,22 +301,6 @@ add_subdirectory(tests)

############# Install ####################

# the current flavour is not automatically added if build in the current cmake iteration, so always
# add its library name to be sure
string(TOLOWER ${PCB} FLAVOUR)

if(PCBREV)
if(PCB STREQUAL X7 AND PCBREV STREQUAL ACCESS)
set(FLAVOUR x7access)
elseif(PCB STREQUAL X9D+ AND PCBREV STREQUAL 2019)
set(FLAVOUR x9d+2019)
elseif(PCB STREQUAL X10 AND PCBREV STREQUAL EXPRESS)
set(FLAVOUR x10express)
else()
string(TOLOWER ${PCBREV} FLAVOUR)
endif()
endif(PCBREV)

set(COMPANION_TARGETS_DIR_ROOT "${COMPANION_SRC_DIRECTORY}/../targets")

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
Expand Down Expand Up @@ -680,4 +665,3 @@ else()
endif()

include(CPack)

11 changes: 8 additions & 3 deletions radio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,18 @@ else()
message(FATAL_ERROR "Unknown PCB '${PCB}'")
endif()

# Add RADIO_xxx definition
string(TOUPPER ${FLAVOUR} RADIO_NAME)
string(REPLACE "+" "P" RADIO_NAME ${RADIO_NAME})
string(CONCAT RADIO_NAME "RADIO_" ${RADIO_NAME})
add_definitions(-D${RADIO_NAME})
set(${RADIO_NAME} YES)

set(HW_DESC_JSON ${FLAVOUR}.json)
AddHardwareDefTarget(${HW_DESC_JSON})

# enable generating JSON definition separately for debugging
add_custom_target(hardware_defs DEPENDS ${HW_DESC_JSON} ${HW_DESC_JSON}.h)
add_custom_target(hardware_defs DEPENDS ${HW_DESC_JSON}.h)

include(hal/CMakeLists.txt)

Expand Down Expand Up @@ -719,5 +726,3 @@ if(CPU_FAMILY STREQUAL STM32)
endif()

PrintTargetReport("firmware")

AddHardwareDefTarget(hardware_defs ${RADIO_DIRECTORY}/src/targets/hw_defs/${FLAVOUR}.json)
2 changes: 1 addition & 1 deletion radio/src/boards/generic_stm32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ AddHWGenTarget(${HW_DESC_JSON} hal_adc_inputs hal_adc_inputs.inc)

# Dependencies common to bootloader and firmware
set(MINIMAL_BOARD_LIB_SRC
${CMAKE_CURRENT_BINARY_DIR}/${HW_DESC_JSON}
${RADIO_SRC_DIR}/boards/hw_defs/${HW_DESC_JSON}
${CMAKE_CURRENT_BINARY_DIR}/stm32_keys.inc

boards/generic_stm32/inputs.cpp
Expand Down
22 changes: 17 additions & 5 deletions radio/src/boards/generic_stm32/analog_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "hal.h"

#if defined(ADC_SPI)
#if defined(USE_ADS79XX)
#include "ads79xx.h"
#endif

Expand All @@ -40,8 +40,9 @@

// generated files
#include "stm32_adc_inputs.inc"
#include "stm32_pwm_inputs.inc"
#if !defined(BOOT)
#include "hal_adc_inputs.inc"
#endif

constexpr uint8_t n_ADC = DIM(_ADC_adc);
constexpr uint8_t n_ADC_spi = DIM(_ADC_spi);
Expand All @@ -54,16 +55,21 @@ static_assert(n_inputs <= MAX_ANALOG_INPUTS, "Too many analog inputs");
static bool adc_init()
{
bool success = stm32_hal_adc_init(_ADC_adc, n_ADC, _ADC_inputs, _ADC_GPIOs, n_GPIO);
#if defined(ADC_SPI)
#if defined(USE_ADS79XX)
if (n_ADC_spi > 0) ads79xx_init(&_ADC_spi[0]);
#endif
return success;
}

static void adc_deinit()
{
stm32_hal_adc_deinit(_ADC_adc, n_ADC);
}

static bool adc_start_read()
{
bool success = stm32_hal_adc_start_read(_ADC_adc, n_ADC, _ADC_inputs, n_inputs);
#if defined(ADC_SPI)
#if defined(USE_ADS79XX)
if (n_ADC_spi > 0) {
success = success && ads79xx_adc_start_read(&_ADC_spi[0], _ADC_inputs);
}
Expand All @@ -73,7 +79,7 @@ static bool adc_start_read()

static void adc_wait_completion()
{
#if defined(ADC_SPI)
#if defined(USE_ADS79XX)
// ADS79xx does all the work in the completion function
// so it's probably better to poll it first
if (n_ADC_spi > 0) ads79xx_adc_wait_completion(&_ADC_spi[0], _ADC_inputs);
Expand All @@ -82,17 +88,22 @@ static void adc_wait_completion()
}

const etx_hal_adc_driver_t _adc_driver = {
#if !defined(BOOT)
.inputs = _hal_inputs,
.default_pots_cfg = _pot_default_config,
#endif
.init = adc_init,
.deinit = adc_deinit,
.start_conversion = adc_start_read,
.wait_completion = adc_wait_completion,
.set_input_mask = stm32_hal_set_inputs_mask,
.get_input_mask = stm32_hal_get_inputs_mask,
};

#if !defined(BOOT)
#if defined(PWM_STICKS)
#include "stm32_gpio.h"
#include "stm32_pwm_inputs.inc"

static const stick_pwm_timer_t _sticks_timer = {
.GPIOx = PWM_GPIO,
Expand Down Expand Up @@ -141,3 +152,4 @@ void gimbalsDetect()
detected = gimbal_drivers[idx++]();
}
}
#endif // !BOOT
Loading
Loading