feat: H7 support (#5738)

Co-authored-by: Richard Li <richard.li@ces.hk>
Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
This commit is contained in:
Malte Langermann
2025-01-18 10:08:13 +01:00
committed by GitHub
co-authored by Richard Li philmoz raphaelcoeffic
parent 5a15ffb017
commit 3d25c2a0f8
458 changed files with 441554 additions and 2410 deletions
+9
View File
@@ -30,16 +30,25 @@ set(BOOTLOADER_SRC ${BOOTLOADER_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/hal/key_driver.cpp
)
if(FUNCTION_SWITCHES_WITH_RGB)
set(SRC ${SRC}
hal/rgbleds.cpp
)
endif()
if (NOT NATIVE_BUILD)
set(SRC ${SRC}
hal/storage.cpp
hal/fatfs_diskio.cpp
hal/flash_driver.cpp
${FATFS_DIR}/ff.c
${FATFS_DIR}/ffunicode.c
)
set(BOOTLOADER_SRC ${BOOTLOADER_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/hal/storage.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hal/fatfs_diskio.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hal/flash_driver.cpp
${CMAKE_CURRENT_SOURCE_DIR}/${FATFS_DIR}/ff.c
${CMAKE_CURRENT_SOURCE_DIR}/${FATFS_DIR}/ffunicode.c
)
+6
View File
@@ -41,6 +41,12 @@ void abnormalRebootDisableDetection();
// (see AbnormalRebootCause)
uint32_t abnormalRebootGetCause();
// Retrieve last reboot command
uint32_t abnormalRebootGetCmd();
// Reset reboot command
void abnormalRebootResetCmd();
#define UNEXPECTED_SHUTDOWN() \
(abnormalRebootGetCause() == ARC_Watchdog)
+1 -1
View File
@@ -27,7 +27,7 @@
const etx_hal_adc_driver_t* _hal_adc_driver = nullptr;
const etx_hal_adc_inputs_t* _hal_adc_inputs = nullptr;
static uint16_t adcValues[MAX_ANALOG_INPUTS] __DMA;
static uint16_t adcValues[MAX_ANALOG_INPUTS] __DMA_NO_CACHE;
#if defined(CSD203_SENSOR)
extern uint16_t getCSD203BatteryVoltage(void);
+48
View File
@@ -0,0 +1,48 @@
#include "hal/flash_driver.h"
typedef struct {
const etx_flash_driver_t* drv;
uint32_t start_addr;
uint32_t end_addr;
} flash_media_t;
static flash_media_t _flash_media[2] = {{nullptr, 0, 0}};
void flashRegisterDriver(uint32_t start_addr, uint32_t length,
const etx_flash_driver_t* drv)
{
for (int i = 0; i < 2; i++) {
flash_media_t& fm = _flash_media[i];
if (fm.drv) continue;
fm = {
.drv = drv,
.start_addr = start_addr,
.end_addr = start_addr + length - 1,
};
return;
}
}
const etx_flash_driver_t* flashFindDriver(uint32_t addr)
{
for (int i = 0; i < 2; i++) {
const flash_media_t& fm = _flash_media[i];
if (!fm.drv) continue;
if (fm.start_addr <= addr && fm.end_addr >= addr)
return fm.drv;
}
return nullptr;
}
uint32_t flashGetSize(uint32_t addr)
{
for (int i = 0; i < 2; i++) {
const flash_media_t& fm = _flash_media[i];
if (!fm.drv) continue;
if (fm.start_addr <= addr && fm.end_addr >= addr)
return fm.end_addr - fm.start_addr + 1;
}
return 0;
}
+40
View File
@@ -0,0 +1,40 @@
/*
* 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 <stdint.h>
typedef struct {
uint32_t (*get_size_kb)();
uint32_t (*get_sector)(uint32_t address);
uint32_t (*get_sector_size)(uint32_t sector);
int (*erase_sector)(uint32_t address);
int (*program)(uint32_t address, void* data, uint32_t len);
int (*read)(uint32_t address, void* data, uint32_t len);
} etx_flash_driver_t;
void flashRegisterDriver(uint32_t start_addr, uint32_t length,
const etx_flash_driver_t* drv);
const etx_flash_driver_t* flashFindDriver(uint32_t addr);
uint32_t flashGetSize(uint32_t addr);
+1 -2
View File
@@ -1,5 +1,4 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
@@ -49,4 +48,4 @@ void setFSLedON(uint8_t index) {
bool getFSLedState(uint8_t index) {
return fsLedState(index);
}
#endif
#endif
+1 -2
View File
@@ -1,5 +1,4 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
@@ -30,4 +29,4 @@ constexpr uint32_t colorTabl2[] = {0x000000, 0xF8F8F8, 0xF80000, 0x00F800, 0xF8F
void setFSLedOFF(uint8_t index);
void setFSLedON(uint8_t index);
bool getFSLedState(uint8_t index);
bool getFSLedState(uint8_t index);
+3 -3
View File
@@ -31,10 +31,10 @@
// Board API
void boardInitSwitches();
SwitchHwPos boardSwitchGetPosition(uint8_t cat, uint8_t idx);
SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx);
const char* boardSwitchGetName(uint8_t cat, uint8_t idx);
SwitchHwType boardSwitchGetType(uint8_t cat, uint8_t idx);
const char* boardSwitchGetName(SwitchCategory cat, uint8_t idx);
SwitchHwType boardSwitchGetType(SwitchCategory cat, uint8_t idx);
uint8_t boardGetMaxSwitches();
uint8_t boardGetMaxFctSwitches();
+8 -3
View File
@@ -33,10 +33,11 @@ enum usbMode {
USB_JOYSTICK_MODE,
USB_MASS_STORAGE_MODE,
USB_SERIAL_MODE,
USB_DFU_MODE,
#if defined(USB_SERIAL)
USB_MAX_MODE=USB_SERIAL_MODE
USB_MAX_MODE=USB_SERIAL_MODE,
#else
USB_MAX_MODE=USB_MASS_STORAGE_MODE
USB_MAX_MODE=USB_MASS_STORAGE_MODE,
#endif
};
@@ -53,11 +54,15 @@ bool usbStarted();
EXTERN_C(int getSelectedUsbMode());
void setSelectedUsbMode(int mode);
// USB CDC
uint32_t usbSerialFreeSpace();
extern const etx_serial_port_t UsbSerialPort;
// USB HID
#if defined(USBJ_EX)
void usbJoystickRestart();
#endif
void usbJoystickUpdate();
extern const etx_serial_port_t UsbSerialPort;
// USB DFU
int usbRegisterDFUMedia(const void* dfu_media);