Merge from 2.3
This commit is contained in:
@@ -147,7 +147,7 @@ endif()
|
||||
|
||||
if(MULTIMODULE)
|
||||
add_definitions(-DMULTIMODULE)
|
||||
set(SRC ${SRC} pulses/multi.cpp telemetry/spektrum.cpp telemetry/flysky_ibus.cpp telemetry/hitec.cpp telemetry/multi.cpp io/multi_firmware_update.cpp)
|
||||
set(SRC ${SRC} pulses/multi.cpp telemetry/spektrum.cpp telemetry/flysky_ibus.cpp telemetry/hitec.cpp telemetry/hott.cpp telemetry/multi.cpp io/multi_firmware_update.cpp)
|
||||
endif()
|
||||
|
||||
if(CROSSFIRE)
|
||||
|
||||
@@ -138,4 +138,13 @@ void delay_ms(uint32_t ms);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define INIT_KEYS_PINS(GPIO) \
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_ ## GPIO ## _PINS; \
|
||||
GPIO_Init(GPIO, &GPIO_InitStructure)
|
||||
|
||||
#define SET_KEYS_PINS_HIGH(GPIO) \
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_ ## GPIO ## _PINS; \
|
||||
GPIO_Init(GPIO, &GPIO_InitStructure); \
|
||||
GPIO_SetBits(GPIO, KEYS_ ## GPIO ## _PINS)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,8 @@ if(CPU_TYPE_FULL STREQUAL STM32F429xI)
|
||||
../f4/system_stm32f4xx.c
|
||||
../../../../../targets/${TARGET_DIR}/startup_stm32f42_43xxx.s
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rtc.c
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c
|
||||
@@ -25,6 +27,8 @@ elseif(CPU_TYPE_FULL STREQUAL STM32F407xE)
|
||||
../f4/system_stm32f4xx.c
|
||||
../../../../../targets/${TARGET_DIR}/startup_stm32f40_41xxx.s
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rtc.c
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c
|
||||
@@ -114,6 +118,7 @@ if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
|
||||
../../../../../thirdparty/libopenui/src/libopenui_globals.cpp
|
||||
../../../../../targets/${TARGET_DIR}/sdram_driver.c
|
||||
../../../../../targets/common/arm/stm32/sdio_sd.c
|
||||
../../../../../targets/common/arm/stm32/rtc_driver.cpp
|
||||
../../../../../targets/${TARGET_DIR}/haptic_driver.cpp
|
||||
../../../../../syscalls.c
|
||||
)
|
||||
@@ -125,6 +130,12 @@ if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
|
||||
../../../../../serial.cpp
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
set(BOOTLOADER_SRC
|
||||
${BOOTLOADER_SRC}
|
||||
../../../../../targets/${TARGET_DIR}/i2c_driver.cpp
|
||||
)
|
||||
remove_definitions(-DDEBUG)
|
||||
endif()
|
||||
|
||||
remove_definitions(-DDEBUG)
|
||||
@@ -132,6 +143,8 @@ remove_definitions(-DDISK_CACHE)
|
||||
remove_definitions(-DLUA)
|
||||
remove_definitions(-DCLI)
|
||||
remove_definitions(-DUSB_SERIAL)
|
||||
remove_definitions(-DWATCHDOG)
|
||||
|
||||
add_definitions(-DBOOT)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${MCU} -mthumb -nostartfiles -lm -T${RADIO_SRC_DIR}/targets/${TARGET_DIR}/stm32_ramboot.ld -Wl,-Map=bootloader.map,--cref,--no-warn-mismatch,--gc-sections")
|
||||
|
||||
@@ -69,13 +69,13 @@ FlashCheckRes valid;
|
||||
MemoryType memoryType;
|
||||
uint32_t unlocked = 0;
|
||||
|
||||
void interrupt10ms(void)
|
||||
void interrupt10ms()
|
||||
{
|
||||
tenms |= 1; // 10 mS has passed
|
||||
tenms |= 1u; // 10 mS has passed
|
||||
|
||||
uint8_t index = 0;
|
||||
uint8_t in = readKeys();
|
||||
for (uint8_t i = 1; i != uint8_t(1 << TRM_BASE); i <<= 1) {
|
||||
for (uint8_t i = 1; i != uint8_t(1u << TRM_BASE); i <<= 1) {
|
||||
uint8_t value = (in & i);
|
||||
keys[index].input(value);
|
||||
++index;
|
||||
@@ -195,8 +195,6 @@ int main()
|
||||
FRESULT fr;
|
||||
uint32_t nameCount = 0;
|
||||
|
||||
wdt_reset();
|
||||
|
||||
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | KEYS_RCC_AHB1Periph |
|
||||
LCD_RCC_AHB1Periph | BACKLIGHT_RCC_AHB1Periph |
|
||||
AUX_SERIAL_RCC_AHB1Periph | I2C_RCC_AHB1Periph |
|
||||
@@ -212,12 +210,12 @@ int main()
|
||||
pwrInit();
|
||||
keysInit();
|
||||
|
||||
#if defined(PCBHORUS)
|
||||
// wait a bit for the inputs to stabilize...
|
||||
for (uint32_t i = 0; i < 50000; i++) {
|
||||
wdt_reset();
|
||||
if (!WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||
for (uint32_t i = 0; i < 150000; i++) {
|
||||
__ASM volatile ("nop");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// LHR & RHL trims not pressed simultanously
|
||||
if (readTrims() != BOOTLOADER_KEYS) {
|
||||
@@ -265,12 +263,12 @@ int main()
|
||||
#if defined(PWR_BUTTON_PRESS)
|
||||
// wait until power button is released
|
||||
while (pwrPressed()) {
|
||||
wdt_reset();
|
||||
WDG_RESET();
|
||||
}
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
wdt_reset();
|
||||
WDG_RESET();
|
||||
|
||||
if (tenms) {
|
||||
tenms = 0;
|
||||
@@ -506,16 +504,12 @@ int main()
|
||||
lcdRefresh();
|
||||
lcdRefreshWait();
|
||||
|
||||
#if !defined(EEPROM)
|
||||
// Use jump on radios with emergency mode
|
||||
// to avoid triggering it with a soft reset
|
||||
|
||||
// Jump to proper application address
|
||||
jumpTo(APP_START_ADDRESS);
|
||||
#else
|
||||
// Use software reset everywhere else
|
||||
NVIC_SystemReset();
|
||||
#if defined(RTC_BACKUP_RAM)
|
||||
rtcInit();
|
||||
RTC->BKP0R = SOFTRESET_REQUEST;
|
||||
#endif
|
||||
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,5 +517,5 @@ int main()
|
||||
}
|
||||
|
||||
#if defined(PCBHORUS)
|
||||
void *__dso_handle = 0;
|
||||
void *__dso_handle = nullptr;
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,13 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
void waitFlashIdle()
|
||||
{
|
||||
do {
|
||||
WDG_RESET();
|
||||
} while (FLASH->SR & FLASH_FLAG_BSY);
|
||||
}
|
||||
|
||||
//After reset, write is not allowed in the Flash control register (FLASH_CR) to protect the
|
||||
//Flash memory against possible unwanted operations due, for example, to electric
|
||||
//disturbances. The following sequence is used to unlock this register:
|
||||
@@ -37,21 +44,16 @@ void unlockFlash()
|
||||
|
||||
void lockFlash()
|
||||
{
|
||||
while (FLASH->SR & FLASH_SR_BSY);
|
||||
waitFlashIdle();
|
||||
FLASH->CR |= FLASH_CR_LOCK;
|
||||
}
|
||||
|
||||
void waitFlashIdle()
|
||||
{
|
||||
while (FLASH->SR & FLASH_FLAG_BSY) {
|
||||
wdt_reset();
|
||||
}
|
||||
}
|
||||
|
||||
#define SECTOR_MASK ((uint32_t)0xFFFFFF07)
|
||||
|
||||
void eraseSector(uint32_t sector)
|
||||
{
|
||||
WDG_ENABLE(3000); // some sectors may take > 1s to erase
|
||||
|
||||
waitFlashIdle();
|
||||
|
||||
FLASH->CR &= CR_PSIZE_MASK;
|
||||
@@ -66,9 +68,11 @@ void eraseSector(uint32_t sector)
|
||||
/* if the erase operation is completed, disable the SER Bit */
|
||||
FLASH->CR &= (~FLASH_CR_SER);
|
||||
FLASH->CR &= SECTOR_MASK;
|
||||
|
||||
WDG_ENABLE(WDG_DURATION);
|
||||
}
|
||||
|
||||
void flashWrite(uint32_t * address, uint32_t * buffer) // page size is 256 bytes
|
||||
void flashWrite(uint32_t * address, const uint32_t * buffer) // page size is 256 bytes
|
||||
{
|
||||
#define SECTOR_ADDRESS (((uint32_t)address) & 0xFFFFF)
|
||||
|
||||
@@ -110,7 +114,6 @@ void flashWrite(uint32_t * address, uint32_t * buffer) // page size is 256 bytes
|
||||
eraseSector(4 + FLASH_BANK);
|
||||
}
|
||||
else if ((((uint32_t)address) & 0x3FFF) == 0) {
|
||||
|
||||
// test other 16KB sectors
|
||||
if (SECTOR_ADDRESS == 0x04000) {
|
||||
eraseSector(1 + FLASH_BANK);
|
||||
@@ -141,7 +144,7 @@ void flashWrite(uint32_t * address, uint32_t * buffer) // page size is 256 bytes
|
||||
|
||||
/* Wait for operation to be completed */
|
||||
waitFlashIdle();
|
||||
FLASH->CR &= (~FLASH_CR_PG);
|
||||
FLASH->CR &= ~FLASH_CR_PG;
|
||||
|
||||
/* Check the written value */
|
||||
if (*address != *buffer) {
|
||||
@@ -192,7 +195,7 @@ uint32_t isBootloaderStart(const uint8_t * buffer)
|
||||
{
|
||||
const uint32_t * block = (const uint32_t *)buffer;
|
||||
|
||||
for (int i=0; i<256; i++) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
if (block[i] == 0x544F4F42/*BOOT*/) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -59,17 +59,14 @@ void rtcGetTime(struct gtm * t)
|
||||
|
||||
void rtcInit()
|
||||
{
|
||||
RTC_InitTypeDef RTC_InitStruct;
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
|
||||
PWR_BackupAccessCmd(ENABLE);
|
||||
RCC_LSEConfig(RCC_LSE_ON);
|
||||
|
||||
// Prevent lockup in case of 32kHz oscillator failure
|
||||
uint32_t i = 0;
|
||||
while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
|
||||
{
|
||||
if ( ++i > 1000000 )
|
||||
while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) {
|
||||
if (++i > 1000000)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,17 +74,21 @@ void rtcInit()
|
||||
RCC_RTCCLKCmd(ENABLE);
|
||||
RTC_WaitForSynchro();
|
||||
|
||||
#if !defined(BOOT)
|
||||
RTC_InitTypeDef RTC_InitStruct;
|
||||
|
||||
// RTC time base = LSE / ((AsynchPrediv+1) * (SynchPrediv+1)) = 1 Hz*/
|
||||
RTC_InitStruct.RTC_HourFormat = RTC_HourFormat_24;
|
||||
RTC_InitStruct.RTC_AsynchPrediv = 127;
|
||||
RTC_InitStruct.RTC_SynchPrediv = 255;
|
||||
RTC_Init(&RTC_InitStruct);
|
||||
|
||||
|
||||
struct gtm utm;
|
||||
rtcGetTime(&utm);
|
||||
g_rtcTime = gmktime(&utm);
|
||||
#endif
|
||||
|
||||
#if defined(RAMBACKUP)
|
||||
#if defined(RTC_BACKUP_RAM) && !defined(BOOT)
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_BKPSRAM, ENABLE);
|
||||
PWR_BackupRegulatorCmd(ENABLE);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user