mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 11:00:02 +03:00
Merge remote-tracking branch 'betaflight/master' into RP2350
This commit is contained in:
commit
635b3c2de4
13 changed files with 71 additions and 42 deletions
|
@ -104,7 +104,6 @@ COMMON_SRC = \
|
|||
drivers/io.c \
|
||||
drivers/io_preinit.c \
|
||||
drivers/light_led.c \
|
||||
drivers/mco.c \
|
||||
drivers/motor.c \
|
||||
drivers/pinio.c \
|
||||
drivers/pin_pull_up_down.c \
|
||||
|
|
|
@ -4680,7 +4680,7 @@ static void cliStatus(const char *cmdName, char *cmdline)
|
|||
|
||||
cliPrintf("MCU %s Clock=%dMHz", getMcuTypeName(), (SystemCoreClock / 1000000));
|
||||
|
||||
#if defined(STM32F4) || defined(STM32G4) || defined(APM32F4)
|
||||
#if PLATFORM_TRAIT_CONFIG_HSE
|
||||
// Only F4 and G4 is capable of switching between HSE/HSI (for now)
|
||||
int sysclkSource = SystemSYSCLKSource();
|
||||
|
||||
|
@ -5402,15 +5402,11 @@ dmaoptEntry_t dmaoptEntryTable[] = {
|
|||
#define DMA_OPT_UI_INDEX(i) ((i) + 1)
|
||||
#define DMA_OPT_STRING_BUFSIZE 5
|
||||
|
||||
#if defined(STM32H7) || defined(STM32G4) || defined(AT32F435)
|
||||
#define DMA_CHANREQ_STRING "Request"
|
||||
#else
|
||||
#if !defined(DMA_CHANREQ_STRING)
|
||||
#define DMA_CHANREQ_STRING "Channel"
|
||||
#endif
|
||||
|
||||
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(APM32F4)
|
||||
#define DMA_STCH_STRING "Stream"
|
||||
#else
|
||||
#if !defined(DMA_STCH_STRING)
|
||||
#define DMA_STCH_STRING "Channel"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1685,7 +1685,7 @@ const clivalue_t valueTable[] = {
|
|||
#endif // end of #ifdef USE_OSD
|
||||
|
||||
// PG_SYSTEM_CONFIG
|
||||
#if defined(STM32F4) || defined(STM32G4) || defined(APM32F4)
|
||||
#if PLATFORM_TRAIT_CONFIG_HSE
|
||||
{ "system_hse_mhz", VAR_UINT8 | HARDWARE_VALUE, .config.minmaxUnsigned = { 0, 30 }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, hseMhz) },
|
||||
#endif
|
||||
{ "task_statistics", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, task_statistics) },
|
||||
|
@ -1867,11 +1867,12 @@ const clivalue_t valueTable[] = {
|
|||
#endif
|
||||
#endif
|
||||
#ifdef USE_MCO
|
||||
#ifdef STM32G4
|
||||
#if defined(USE_MCO_DEVICE1)
|
||||
// TODO: remove pin specific names
|
||||
{ "mco_on_pa8", VAR_UINT8 | HARDWARE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MCO_CONFIG, PG_ARRAY_ELEMENT_OFFSET(mcoConfig_t, 0, enabled) },
|
||||
{ "mco_source", VAR_UINT8 | HARDWARE_VALUE, .config.minmaxUnsigned = { 0, MCO_SOURCE_COUNT - 1 }, PG_MCO_CONFIG, PG_ARRAY_ELEMENT_OFFSET(mcoConfig_t, 0, source) },
|
||||
{ "mco_divider", VAR_UINT8 | HARDWARE_VALUE, .config.minmaxUnsigned = { 0, MCO_DIVIDER_COUNT - 1 }, PG_MCO_CONFIG, PG_ARRAY_ELEMENT_OFFSET(mcoConfig_t, 0, divider) },
|
||||
#else
|
||||
#elif defined(USE_MCO_DEVICE2)
|
||||
{ "mco2_on_pc9", VAR_UINT8 | HARDWARE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MCO_CONFIG, PG_ARRAY_ELEMENT_OFFSET(mcoConfig_t, 1, enabled) },
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -27,9 +27,4 @@ typedef enum {
|
|||
MCODEV_2,
|
||||
} MCODevice_e;
|
||||
|
||||
#ifdef STM32G4
|
||||
#define MCO_SOURCE_COUNT 8
|
||||
#define MCO_DIVIDER_COUNT 5
|
||||
#endif
|
||||
|
||||
void mcoConfigure(MCODevice_e device, const mcoConfig_t *config);
|
||||
void mcoInit(void);
|
||||
|
|
|
@ -483,9 +483,7 @@ void init(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(STM32F4) || defined(STM32G4) || defined(APM32F4)
|
||||
// F4 has non-8MHz boards
|
||||
// G4 for Betaflight allow 8, 16, 24, 26 or 27MHz oscillator
|
||||
#if PLATFORM_TRAIT_CONFIG_HSE
|
||||
systemClockSetHSEValue(systemConfig()->hseMhz * 1000000U);
|
||||
#endif
|
||||
|
||||
|
@ -495,18 +493,7 @@ void init(void)
|
|||
|
||||
// Configure MCO output after config is stable
|
||||
#ifdef USE_MCO
|
||||
// Note that mcoConfigure must be augmented with an additional argument to
|
||||
// indicate which device instance to configure when MCO and MCO2 are both supported
|
||||
|
||||
#if defined(STM32F4) || defined(STM32F7) || defined(APM32F4)
|
||||
// F4 and F7 support MCO on PA8 and MCO2 on PC9, but only MCO2 is supported for now
|
||||
mcoConfigure(MCODEV_2, mcoConfig(MCODEV_2));
|
||||
#elif defined(STM32G4)
|
||||
// G4 only supports one MCO on PA8
|
||||
mcoConfigure(MCODEV_1, mcoConfig(MCODEV_1));
|
||||
#else
|
||||
#error Unsupported MCU
|
||||
#endif
|
||||
mcoInit();
|
||||
#endif // USE_MCO
|
||||
|
||||
#ifdef USE_TIMER
|
||||
|
@ -574,7 +561,7 @@ void init(void)
|
|||
initFlags |= QUAD_OCTO_SPI_BUSSES_INIT_ATTEMPTED;
|
||||
}
|
||||
|
||||
#if defined(USE_SDCARD_SDIO) && !defined(CONFIG_IN_SDCARD) && defined(STM32H7)
|
||||
#if defined(USE_SDCARD_SDIO) && !defined(CONFIG_IN_SDCARD) && PLATFORM_TRAIT_SDIO_INIT
|
||||
sdioPinConfigure();
|
||||
SDIO_GPIO_Init();
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "drivers/time.h"
|
||||
|
||||
#include "displayport_crsf.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
#define CRSF_DISPLAY_PORT_OPEN_DELAY_MS 400
|
||||
#define CRSF_DISPLAY_PORT_CLEAR_DELAY_MS 45
|
||||
|
@ -155,6 +156,11 @@ crsfDisplayPortScreen_t *crsfDisplayPortScreen(void)
|
|||
|
||||
void crsfDisplayPortMenuOpen(void)
|
||||
{
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
// when armed, make it impossible to open the menu (it wouldn't be possible to disarm)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmsInMenu) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -117,6 +117,7 @@
|
|||
#define USE_USB_MSC
|
||||
#define USE_PERSISTENT_MSC_RTC
|
||||
#define USE_MCO
|
||||
#define USE_MCO_DEVICE2
|
||||
#define USE_DMA_SPEC
|
||||
#define USE_PERSISTENT_OBJECTS
|
||||
#define USE_LATE_TASK_STATISTICS
|
||||
|
@ -127,6 +128,7 @@
|
|||
#define SCHEDULER_DELAY_LIMIT 10
|
||||
|
||||
#define DEFAULT_CPU_OVERCLOCK 0
|
||||
#define PLATFORM_TRAIT_CONFIG_HSE 1
|
||||
|
||||
#define FAST_IRQ_HANDLER
|
||||
|
||||
|
@ -207,4 +209,6 @@
|
|||
#define USB_DP_PIN PA12
|
||||
|
||||
#define FLASH_CONFIG_BUFFER_TYPE uint32_t
|
||||
|
||||
#define DMA_STCH_STRING "Stream"
|
||||
#endif
|
||||
|
|
|
@ -150,6 +150,7 @@ MCU_COMMON_SRC = \
|
|||
common/stm32/system.c \
|
||||
common/stm32/io_impl.c \
|
||||
common/stm32/config_flash.c \
|
||||
common/stm32/mco.c \
|
||||
APM32/startup/system_apm32f4xx.c \
|
||||
drivers/inverter.c \
|
||||
drivers/dshot_bitbang_decode.c \
|
||||
|
|
|
@ -162,3 +162,7 @@ typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
|
|||
#define FLASH_CONFIG_BUFFER_TYPE uint32_t
|
||||
|
||||
#define USB_DP_PIN PA12
|
||||
|
||||
#if defined(AT32F435)
|
||||
#define DMA_CHANREQ_STRING "Request"
|
||||
#endif
|
||||
|
|
|
@ -85,6 +85,7 @@ MCU_COMMON_SRC = \
|
|||
common/stm32/system.c \
|
||||
common/stm32/io_impl.c \
|
||||
common/stm32/config_flash.c \
|
||||
common/stm32/mco.c \
|
||||
AT32/startup/at32f435_437_clock.c \
|
||||
AT32/startup/system_at32f435_437.c \
|
||||
AT32/adc_at32f43x.c \
|
||||
|
|
|
@ -130,6 +130,7 @@
|
|||
#define USE_USB_MSC
|
||||
#define USE_PERSISTENT_MSC_RTC
|
||||
#define USE_MCO
|
||||
#define USE_MCO_DEVICE2
|
||||
#define USE_DMA_SPEC
|
||||
#define USE_PERSISTENT_OBJECTS
|
||||
#define USE_LATE_TASK_STATISTICS
|
||||
|
@ -152,6 +153,7 @@
|
|||
#define USE_USB_MSC
|
||||
#define USE_PERSISTENT_MSC_RTC
|
||||
#define USE_MCO
|
||||
#define USE_MCO_DEVICE2
|
||||
#define USE_DMA_SPEC
|
||||
#define USE_PERSISTENT_OBJECTS
|
||||
#define USE_LATE_TASK_STATISTICS
|
||||
|
@ -188,6 +190,7 @@
|
|||
#define USE_USB_MSC
|
||||
#define USE_USB_CDC_HID
|
||||
#define USE_MCO
|
||||
#define USE_MCO_DEVICE1
|
||||
#define USE_DMA_SPEC
|
||||
#define USE_LATE_TASK_STATISTICS
|
||||
#endif
|
||||
|
@ -447,4 +450,24 @@ extern uint8_t _dmaram_end__;
|
|||
#define QUADSPI_TRAIT_AF_PIN 1
|
||||
#define QUADSPI_TRAIT_HANDLE 1
|
||||
#define MAX_QUADSPI_PIN_SEL 3
|
||||
#define PLATFORM_TRAIT_SDIO_INIT 1
|
||||
#endif
|
||||
|
||||
// F4 has non-8MHz boards
|
||||
// G4 for Betaflight allow 8, 16, 24, 26 or 27MHz oscillator
|
||||
#if defined(STM32F4) || defined(STM32G4)
|
||||
#define PLATFORM_TRAIT_CONFIG_HSE 1
|
||||
#endif
|
||||
|
||||
#if defined(STM32G4)
|
||||
#define MCO_SOURCE_COUNT 8
|
||||
#define MCO_DIVIDER_COUNT 5
|
||||
#endif
|
||||
|
||||
#if defined(STM32H7) || defined(STM32G4)
|
||||
#define DMA_CHANREQ_STRING "Request"
|
||||
#endif
|
||||
|
||||
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7)
|
||||
#define DMA_STCH_STRING "Stream"
|
||||
#endif
|
||||
|
|
|
@ -5,6 +5,7 @@ MCU_COMMON_SRC += \
|
|||
common/stm32/system.c \
|
||||
common/stm32/config_flash.c \
|
||||
common/stm32/bus_spi_pinconfig.c \
|
||||
common/stm32/mco.c \
|
||||
drivers/bus_spi_config.c \
|
||||
drivers/serial_pinconfig.c \
|
||||
common/stm32/bus_i2c_pinconfig.c \
|
||||
|
|
|
@ -61,7 +61,7 @@ const uint32_t mcoDividers[MCO_DIVIDER_COUNT] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
void mcoConfigure(MCODevice_e device, const mcoConfig_t *config)
|
||||
static void mcoConfigure(MCODevice_e device, const mcoConfig_t *config)
|
||||
{
|
||||
if (!config->enabled) {
|
||||
return;
|
||||
|
@ -69,15 +69,19 @@ void mcoConfigure(MCODevice_e device, const mcoConfig_t *config)
|
|||
|
||||
IO_t io;
|
||||
|
||||
#if defined(STM32F4) || defined(STM32F7) || defined(APM32F4)
|
||||
// Only configure MCO2 with PLLI2SCLK as source for now.
|
||||
// Other MCO1 and other sources can easily be added.
|
||||
|
||||
switch(device) {
|
||||
case MCODEV_1: // MCO1 on PA8
|
||||
return; // Not supported (yet)
|
||||
|
||||
#if defined(STM32G4)
|
||||
io = IOGetByTag(DEFIO_TAG_E(PA8));
|
||||
IOInit(io, OWNER_MCO, 1);
|
||||
HAL_RCC_MCOConfig(RCC_MCO, mcoSources[config->source], mcoDividers[config->divider]);
|
||||
#endif
|
||||
break;
|
||||
case MCODEV_2: // MCO2 on PC9
|
||||
#if defined(STM32F4) || defined(STM32F7) || defined(APM32F4)
|
||||
io = IOGetByTag(DEFIO_TAG_E(PC9));
|
||||
IOInit(io, OWNER_MCO, 2);
|
||||
#if defined(STM32F7)
|
||||
|
@ -90,16 +94,23 @@ void mcoConfigure(MCODevice_e device, const mcoConfig_t *config)
|
|||
// All F4s
|
||||
RCC_MCO2Config(RCC_MCO2Source_PLLI2SCLK, RCC_MCO2Div_4);
|
||||
IOConfigGPIOAF(io, IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, GPIO_PuPd_NOPULL), GPIO_AF_MCO);
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
// No MCO configured
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void mcoInit(void)
|
||||
{
|
||||
#if defined(STM32F4) || defined(STM32F7) || defined(APM32F4)
|
||||
// F4 and F7 support MCO on PA8 and MCO2 on PC9, but only MCO2 is supported for now
|
||||
mcoConfigure(MCODEV_2, mcoConfig(MCODEV_2));
|
||||
#elif defined(STM32G4)
|
||||
// G4 only supports one MCO on PA8
|
||||
UNUSED(device);
|
||||
|
||||
io = IOGetByTag(DEFIO_TAG_E(PA8));
|
||||
IOInit(io, OWNER_MCO, 1);
|
||||
HAL_RCC_MCOConfig(RCC_MCO, mcoSources[config->source], mcoDividers[config->divider]);
|
||||
mcoConfigure(MCODEV_1, mcoConfig(MCODEV_1));
|
||||
#else
|
||||
#error Unsupported MCU
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue