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
|
||||
|
||||
@@ -14,6 +14,11 @@ set(HAPTIC YES)
|
||||
set(GUI_DIR colorlcd)
|
||||
set(NAVIGATION_TYPE horus)
|
||||
set(TARGET_DIR horus)
|
||||
set(LINKER_SCRIPT targets/horus/stm32f4_flash.ld)
|
||||
set(RTC_BACKUP_RAM YES)
|
||||
set(LUA YES)
|
||||
set(PPM_LIMITS_SYMETRICAL YES)
|
||||
set(USB_SERIAL ON CACHE BOOL "Enable USB serial (CDC)")
|
||||
|
||||
if(BOOTLOADER)
|
||||
set(LINKER_SCRIPT targets/horus/stm32f4_flash_bootloader.ld)
|
||||
@@ -21,10 +26,6 @@ else()
|
||||
set(LINKER_SCRIPT targets/horus/stm32f4_flash.ld)
|
||||
endif()
|
||||
|
||||
set(RAMBACKUP YES)
|
||||
set(PPM_LIMITS_SYMETRICAL YES)
|
||||
set(USB_SERIAL ON CACHE BOOL "Enable USB serial (CDC)")
|
||||
|
||||
option(YAML_STORAGE "Enable YAML storage" NO)
|
||||
if(YAML_STORAGE)
|
||||
set(STORAGE_FORMAT YAML)
|
||||
@@ -104,7 +105,13 @@ endif()
|
||||
add_definitions(-DPCBREV=${PCBREV})
|
||||
add_definitions(-DPCBREV_${PCBREV})
|
||||
|
||||
set(RADIO_DEPENDENCIES ${RADIO_DEPENDENCIES} ${BITMAPS_TARGET} truetype_fonts)
|
||||
set(RADIO_DEPENDENCIES
|
||||
${RADIO_DEPENDENCIES}
|
||||
${BITMAPS_TARGET}
|
||||
truetype_fonts
|
||||
)
|
||||
|
||||
set(FIRMWARE_DEPENDENCIES datacopy)
|
||||
|
||||
add_definitions(-DPCBHORUS -DSTM32F429_439xx -DSDRAM -DCOLORLCD -DHARDWARE_KEYS)
|
||||
add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK)
|
||||
@@ -198,9 +205,13 @@ set(STM32LIB_SRC
|
||||
)
|
||||
|
||||
if(PYTHONINTERP_FOUND)
|
||||
add_custom_target(datacopy
|
||||
add_custom_command(
|
||||
OUTPUT ${PROJECT_BINARY_DIR}/radio/src/datacopy.cpp
|
||||
WORKING_DIRECTORY ${RADIO_DIRECTORY}/src
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DPCBX10 -DCPUARM -DCOLORLCD -DBACKUP -Itargets/horus > storage/datacopy.cpp
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DPCBX10 -DCPUARM -DCOLORLCD -DBACKUP -Itargets/horus > ${PROJECT_BINARY_DIR}/radio/src/datacopy.cpp
|
||||
DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py
|
||||
)
|
||||
)
|
||||
add_custom_target(datacopy
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/radio/src/datacopy.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -29,10 +29,6 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t shutdownRequest; // Stores intentional shutdown to avoid reboot loop
|
||||
uint32_t shutdownReason; // Used for detecting unexpected reboots regardless of reason
|
||||
uint32_t powerupReason __NOINIT; // Stores power up reason beyond initialization for emergency mode activation
|
||||
|
||||
HardwareOptions hardwareOptions;
|
||||
|
||||
void watchdogInit(unsigned int duration)
|
||||
@@ -40,7 +36,7 @@ void watchdogInit(unsigned int duration)
|
||||
IWDG->KR = 0x5555; // Unlock registers
|
||||
IWDG->PR = 3; // Divide by 32 => 1kHz clock
|
||||
IWDG->KR = 0x5555; // Unlock registers
|
||||
IWDG->RLR = duration; // 1.5 seconds nominal
|
||||
IWDG->RLR = duration;
|
||||
IWDG->KR = 0xAAAA; // reload
|
||||
IWDG->KR = 0xCCCC; // start
|
||||
}
|
||||
@@ -173,6 +169,7 @@ void boardInit()
|
||||
#endif
|
||||
|
||||
ledInit();
|
||||
|
||||
#if defined(PCBX10) && !defined(RADIO_T16)
|
||||
sportUpdateInit();
|
||||
#endif
|
||||
@@ -189,7 +186,7 @@ void boardOff()
|
||||
backlightEnable(0);
|
||||
|
||||
while (pwrPressed()) {
|
||||
wdt_reset();
|
||||
WDG_RESET();
|
||||
}
|
||||
|
||||
SysTick->CTRL = 0; // turn off systick
|
||||
@@ -209,8 +206,12 @@ void boardOff()
|
||||
// Shutdown the Haptic
|
||||
hapticDone();
|
||||
|
||||
shutdownRequest = SHUTDOWN_REQUEST;
|
||||
shutdownReason = NORMAL_POWER_OFF;
|
||||
#if defined(RTC_BACKUP_RAM)
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_BKPSRAM, DISABLE);
|
||||
PWR_BackupRegulatorCmd(DISABLE);
|
||||
#endif
|
||||
|
||||
RTC->BKP0R = SHUTDOWN_REQUEST;
|
||||
|
||||
pwrOff();
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ DRESULT __disk_write(BYTE drv, const BYTE * buff, DWORD sector, UINT count);
|
||||
#define FLASH_PAGESIZE 256
|
||||
void unlockFlash();
|
||||
void lockFlash();
|
||||
void flashWrite(uint32_t * address, uint32_t * buffer);
|
||||
void flashWrite(uint32_t * address, const uint32_t * buffer);
|
||||
uint32_t isFirmwareStart(const uint8_t * buffer);
|
||||
uint32_t isBootloaderStart(const uint8_t * buffer);
|
||||
|
||||
@@ -305,28 +305,22 @@ void rotaryEncoderInit();
|
||||
void rotaryEncoderCheck();
|
||||
|
||||
// WDT driver
|
||||
#define WDTO_500MS 500
|
||||
extern uint32_t powerupReason;
|
||||
|
||||
#define SHUTDOWN_REQUEST 0xDEADBEEF
|
||||
#define NO_SHUTDOWN_REQUEST ~SHUTDOWN_REQUEST
|
||||
#define DIRTY_SHUTDOWN 0xCAFEDEAD
|
||||
#define NORMAL_POWER_OFF ~DIRTY_SHUTDOWN
|
||||
#define WDG_DURATION 500 /*ms*/
|
||||
|
||||
void watchdogInit(unsigned int duration);
|
||||
#if defined(SIMU)
|
||||
#define WAS_RESET_BY_WATCHDOG() (false)
|
||||
#define WAS_RESET_BY_SOFTWARE() (false)
|
||||
#define WAS_RESET_BY_WATCHDOG_OR_SOFTWARE() (false)
|
||||
#define wdt_enable(x)
|
||||
#define wdt_reset()
|
||||
#define WDG_ENABLE(x)
|
||||
#define WDG_RESET()
|
||||
#else
|
||||
#if defined(WATCHDOG)
|
||||
#define wdt_enable(x) watchdogInit(x)
|
||||
#define wdt_reset() IWDG->KR = 0xAAAA
|
||||
#define WDG_ENABLE(x) watchdogInit(x)
|
||||
#define WDG_RESET() IWDG->KR = 0xAAAA
|
||||
#else
|
||||
#define wdt_enable(x)
|
||||
#define wdt_reset()
|
||||
#define WDG_ENABLE(x)
|
||||
#define WDG_RESET()
|
||||
#endif
|
||||
#define WAS_RESET_BY_WATCHDOG() (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF))
|
||||
#define WAS_RESET_BY_SOFTWARE() (RCC->CSR & RCC_CSR_SFTRSTF)
|
||||
@@ -453,14 +447,41 @@ extern volatile uint32_t pwm_interrupt_count;
|
||||
#define BATTERY_MAX 115 // 11.5V
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
enum PowerReason {
|
||||
SHUTDOWN_REQUEST = 0xDEADBEEF,
|
||||
SOFTRESET_REQUEST = 0xCAFEDEAD,
|
||||
};
|
||||
|
||||
constexpr uint32_t POWER_REASON_SIGNATURE = 0x0178746F;
|
||||
|
||||
inline bool UNEXPECTED_SHUTDOWN()
|
||||
{
|
||||
#if defined(SIMU) || defined(NO_UNEXPECTED_SHUTDOWN)
|
||||
return false;
|
||||
#else
|
||||
if (WAS_RESET_BY_WATCHDOG())
|
||||
return true;
|
||||
else if (WAS_RESET_BY_SOFTWARE())
|
||||
return RTC->BKP0R != SOFTRESET_REQUEST;
|
||||
else
|
||||
return RTC->BKP1R == POWER_REASON_SIGNATURE && RTC->BKP0R != SHUTDOWN_REQUEST;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void SET_POWER_REASON(uint32_t value)
|
||||
{
|
||||
RTC->BKP0R = value;
|
||||
RTC->BKP1R = POWER_REASON_SIGNATURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && !defined(SIMU)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Power driver
|
||||
#define SOFT_PWR_CTRL
|
||||
extern uint32_t shutdownRequest; // Stores intentional shutdown to avoid reboot loop
|
||||
extern uint32_t shutdownReason; // Used for detecting unexpected reboots regardless of reason
|
||||
void pwrInit();
|
||||
uint32_t pwrCheck();
|
||||
void pwrOn();
|
||||
@@ -468,11 +489,6 @@ void pwrOff();
|
||||
void pwrResetHandler();
|
||||
bool pwrPressed();
|
||||
uint32_t pwrPressedDuration();
|
||||
#if defined(SIMU) || defined(NO_UNEXPECTED_SHUTDOWN)
|
||||
#define UNEXPECTED_SHUTDOWN() (false)
|
||||
#else
|
||||
#define UNEXPECTED_SHUTDOWN() ((powerupReason == DIRTY_SHUTDOWN) || WAS_RESET_BY_WATCHDOG_OR_SOFTWARE())
|
||||
#endif
|
||||
|
||||
// Led driver
|
||||
void ledInit();
|
||||
|
||||
@@ -48,7 +48,7 @@ void bootloaderInitScreen()
|
||||
|
||||
backlightEnable(BACKLIGHT_LEVEL_MAX);
|
||||
|
||||
//TODO: load/decompress bitmaps
|
||||
// TODO: load/decompress bitmaps
|
||||
extern void loadFonts();
|
||||
loadFonts();
|
||||
}
|
||||
@@ -73,7 +73,7 @@ void bootloaderDrawScreen(BootloaderState st, int opt, const char* str)
|
||||
lcd->clear(DEFAULT_BGCOLOR);
|
||||
|
||||
if (st == ST_START) {
|
||||
bootloaderDrawTitle(88, "HORUS BOOTLOADER");
|
||||
bootloaderDrawTitle(88, "OpenTX Bootloader");
|
||||
|
||||
lcd->drawBitmapPattern(90, 72, LBM_FLASH, DEFAULT_COLOR);
|
||||
lcd->drawText(124, 75, "Write Firmware");
|
||||
|
||||
@@ -199,34 +199,21 @@ uint32_t switchState(uint8_t index)
|
||||
void keysInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOB_PINS;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
INIT_KEYS_PINS(GPIOB);
|
||||
|
||||
#if defined(KEYS_GPIOC_PINS)
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOC_PINS;
|
||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
INIT_KEYS_PINS(GPIOC);
|
||||
#endif
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOD_PINS;
|
||||
GPIO_Init(GPIOD, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOE_PINS;
|
||||
GPIO_Init(GPIOE, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOG_PINS;
|
||||
GPIO_Init(GPIOG, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOH_PINS;
|
||||
GPIO_Init(GPIOH, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOI_PINS;
|
||||
GPIO_Init(GPIOI, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOJ_PINS;
|
||||
GPIO_Init(GPIOJ, &GPIO_InitStructure);
|
||||
INIT_KEYS_PINS(GPIOD);
|
||||
INIT_KEYS_PINS(GPIOE);
|
||||
INIT_KEYS_PINS(GPIOG);
|
||||
INIT_KEYS_PINS(GPIOH);
|
||||
INIT_KEYS_PINS(GPIOI);
|
||||
INIT_KEYS_PINS(GPIOJ);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "storage/rtc_backup.h"
|
||||
|
||||
void pwrInit()
|
||||
{
|
||||
@@ -81,9 +82,6 @@ void pwrOn()
|
||||
GPIO_Init(PWR_ON_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_SetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
||||
|
||||
shutdownRequest = NO_SHUTDOWN_REQUEST;
|
||||
shutdownReason = DIRTY_SHUTDOWN;
|
||||
}
|
||||
|
||||
void pwrOff()
|
||||
@@ -105,38 +103,7 @@ void pwrResetHandler()
|
||||
__ASM volatile ("nop");
|
||||
__ASM volatile ("nop");
|
||||
|
||||
// We get here whether we are powering up normally, we had an unexpected reboot or we have just powered down normally.
|
||||
// We want:
|
||||
// - In the 2nd case, to power ON as soon as possible if an unexpected reboot happened
|
||||
// (we get there running on remaining capacitor charge, soft power having been cut by the RESET).
|
||||
// - In the 3rd case, NOT power on as that would prevent from turning the system off.
|
||||
// - The 1st case does not need to be handled here, but will be as a result of the handling for the 3rd case, see below.
|
||||
//
|
||||
// shutdownRequest is used to handle the 3rd case. If we really powered down on purpose this will still be set to SHUTDOWN_REQUEST
|
||||
// as we left it in pwrOff(). If however we had an unexpected reboot, it would be set to NO_SHUTDOWN_REQUEST as we set it in pwrOn().
|
||||
// Any other value (e.g. resulting from data corruption) would also keep power on for safety, so this variable can NOT be used
|
||||
// to detect an unexpected reboot (on a normal power on the contents of the variable are random).
|
||||
//
|
||||
// shutdownReason is used to differentiate between an unexpected reboot and a normal power on. We set it to DIRTY_SHUTDOWN in pwrOn()
|
||||
// in anticipation of a potential reboot. Should there be one the value should be preserved and signal below that we rebooted unexpectedly.
|
||||
// If it is NOT set to DIRTY_SHUTDOWN we likely had a normal boot and its contents are random. Due to the need to initialize it to detect a
|
||||
// potential failure ASAP we cannot use it to determine in the firmware why we got there, it has to be buffered.
|
||||
//
|
||||
// powerupReason is there to cater for that, and is what is used in the firmware to decide whether we have to enter emergency mode.
|
||||
// This variable needs to be in a RAM section that is not initialized or zeroed, since once we exit this pwrResetHandler() function the
|
||||
// C runtime would otherwise overwrite it during program init.
|
||||
// Only for X12, X10 power circuit causes inability to shut down on some samples.
|
||||
|
||||
#if defined(PCBX12S)
|
||||
if (shutdownRequest != SHUTDOWN_REQUEST || WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||
if (shutdownReason == DIRTY_SHUTDOWN) {
|
||||
powerupReason = DIRTY_SHUTDOWN;
|
||||
}
|
||||
if (WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||
pwrOn();
|
||||
}
|
||||
#else
|
||||
if (WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||
pwrOn();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -228,8 +228,14 @@ void telemetryPortSetDirectionOutput()
|
||||
TELEMETRY_USART->CR1 &= ~USART_CR1_RE; // turn off receiver
|
||||
}
|
||||
|
||||
void sportWaitTransmissionComplete()
|
||||
{
|
||||
while (!(TELEMETRY_USART->SR & USART_SR_TC));
|
||||
}
|
||||
|
||||
void telemetryPortSetDirectionInput()
|
||||
{
|
||||
sportWaitTransmissionComplete();
|
||||
TELEMETRY_DIR_GPIO->BSRRH = TELEMETRY_DIR_GPIO_PIN; // output disable
|
||||
TELEMETRY_USART->CR1 |= USART_CR1_RE; // turn on receiver
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ DMA_TypeDef dma2;
|
||||
USART_TypeDef Usart0, Usart1, Usart2, Usart3, Usart4;
|
||||
SysTick_Type systick;
|
||||
ADC_Common_TypeDef adc;
|
||||
RTC_TypeDef rtc;
|
||||
#else
|
||||
Pio Pioa, Piob, Pioc;
|
||||
Pmc pmc;
|
||||
@@ -682,7 +683,7 @@ void lockFlash()
|
||||
{
|
||||
}
|
||||
|
||||
void flashWrite(uint32_t *address, uint32_t *buffer)
|
||||
void flashWrite(uint32_t *address, const uint32_t *buffer)
|
||||
{
|
||||
simuSleep(100);
|
||||
}
|
||||
@@ -706,7 +707,7 @@ void serialPutc(char c) { }
|
||||
|
||||
uint16_t getBatteryVoltage()
|
||||
{
|
||||
return (BATTERY_MAX + BATTERY_WARN) * 5;
|
||||
return (g_eeGeneral.vBatWarn * 10) + 50; // 0.5 volt above alerm (value is PREC1)
|
||||
}
|
||||
|
||||
void boardOff()
|
||||
|
||||
@@ -86,6 +86,7 @@ extern DMA_Stream_TypeDef dma1_stream0, dma1_stream1, dma1_stream2, dma1_stream3
|
||||
extern DMA_TypeDef dma2;
|
||||
extern SysTick_Type systick;
|
||||
extern ADC_Common_TypeDef adc;
|
||||
extern RTC_TypeDef rtc;
|
||||
#undef SysTick
|
||||
#define SysTick (&systick)
|
||||
#undef GPIOA
|
||||
@@ -166,6 +167,8 @@ extern ADC_Common_TypeDef adc;
|
||||
#define DMA2 (&dma2)
|
||||
#undef ADC
|
||||
#define ADC (&adc)
|
||||
#undef RTC
|
||||
#define RTC (&rtc)
|
||||
#elif defined(PCBSKY9X)
|
||||
extern Pmc pmc;
|
||||
#undef PMC
|
||||
|
||||
@@ -330,6 +330,7 @@ void i2cInit()
|
||||
TWI0->TWI_MMR = 0x002F0000 ; // Device 5E (>>1) and master is writing
|
||||
NVIC_EnableIRQ(TWI0_IRQn) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
void boardInit()
|
||||
{
|
||||
@@ -388,12 +389,11 @@ void boardInit()
|
||||
lcdInit();
|
||||
|
||||
init_SDcard();
|
||||
}
|
||||
#else
|
||||
void boardInit()
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(PCBAR9X)
|
||||
rtcInit();
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t temperature = 0; // Raw temp reading
|
||||
uint8_t maxTemperature = 0 ; // Raw temp reading
|
||||
|
||||
@@ -218,7 +218,7 @@ void stop_trainer_capture();
|
||||
|
||||
// Write Flash driver
|
||||
#define FLASH_PAGESIZE 256
|
||||
void flashWrite(uint32_t * address, uint32_t * buffer);
|
||||
void flashWrite(uint32_t * address, const uint32_t * buffer);
|
||||
|
||||
// Keys driver
|
||||
uint32_t switchState(uint8_t index);
|
||||
@@ -259,12 +259,12 @@ extern "C" {
|
||||
|
||||
// WDT driver
|
||||
#if !defined(WATCHDOG) || defined(SIMU)
|
||||
#define wdt_enable(x)
|
||||
#define wdt_reset()
|
||||
#define WDG_ENABLE(x)
|
||||
#define WDG_RESET()
|
||||
#define IS_RESET_REASON_WATCHDOG() false
|
||||
#else
|
||||
#define wdt_enable(x) WDT->WDT_MR = 0x3FFF207F
|
||||
#define wdt_reset() WDT->WDT_CR = 0xA5000001
|
||||
#define WDG_ENABLE(x) WDT->WDT_MR = 0x3FFF207F
|
||||
#define WDG_RESET() WDT->WDT_CR = 0xA5000001
|
||||
#define IS_RESET_REASON_WATCHDOG() ((ResetReason & RSTC_SR_RSTTYP) == (2 << 8))
|
||||
#endif
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
uint32_t (*IAP_Function)(uint32_t, uint32_t);
|
||||
|
||||
void flashWrite(uint32_t *address, uint32_t *buffer) // size is 256 bytes
|
||||
void flashWrite(uint32_t * address, const uint32_t * buffer) // size is 256 bytes
|
||||
{
|
||||
uint32_t FlashSectorNum;
|
||||
uint32_t flash_cmd = 0;
|
||||
|
||||
@@ -120,7 +120,7 @@ void lcdInit()
|
||||
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
|
||||
while ( TC0->TC_CHANNEL[0].TC_CV < 36000 ) {
|
||||
// Value depends on MCK/2 (used 18MHz) give 2mS delay
|
||||
wdt_reset(); // Wait
|
||||
WDG_RESET(); // Wait
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ elseif(PCB STREQUAL X7)
|
||||
set(NAVIGATION_TYPE 9x)
|
||||
add_definitions(-DRADIO_T12)
|
||||
add_definitions(-DEEPROM_VARIANT=0x4001)
|
||||
option(INTERNAL_MODULE_MULTI "Support for MULTI internal module" OFF)
|
||||
else()
|
||||
option(INTERNAL_MODULE_PXX1 "Support for PXX1 internal module" ON)
|
||||
option(INTERNAL_MODULE_PXX2 "Support for PXX2 internal module" OFF)
|
||||
@@ -253,7 +254,7 @@ if(PCB STREQUAL X9E OR (PCB STREQUAL X9D+ AND PCBREV STREQUAL 2019) OR (PCB STRE
|
||||
)
|
||||
endif()
|
||||
|
||||
if(PCB STREQUAL X9E OR PCB STREQUAL X7 OR PCB STREQUAL XLITE OR PCB STREQUAL XLITES OR (PCB STREQUAL X9D+ AND PCBREV STREQUAL 2019) OR PCB STREQUAL X9LITES)
|
||||
if(PCB STREQUAL X9E OR (PCB STREQUAL X7 AND NOT PCBREV STREQUAL T12) OR PCB STREQUAL XLITE OR PCB STREQUAL XLITES OR (PCB STREQUAL X9D+ AND PCBREV STREQUAL 2019) OR PCB STREQUAL X9LITES)
|
||||
add_definitions(-DBLUETOOTH)
|
||||
set(TARGET_SRC
|
||||
${TARGET_SRC}
|
||||
@@ -354,6 +355,15 @@ if(INTERNAL_MODULE_PXX2)
|
||||
add_definitions(-DINTERNAL_MODULE_PXX2)
|
||||
endif()
|
||||
|
||||
if(INTERNAL_MODULE_MULTI)
|
||||
add_definitions(-DHARDWARE_INTERNAL_MODULE)
|
||||
add_definitions(-DINTERNAL_MODULE_MULTI)
|
||||
set(TARGET_SRC
|
||||
${TARGET_SRC}
|
||||
../common/arm/stm32/intmodule_serial_driver.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(INTERNAL_MODULE_PPM)
|
||||
add_definitions(-DHARDWARE_INTERNAL_MODULE)
|
||||
add_definitions(-DINTERNAL_MODULE_PPM)
|
||||
|
||||
@@ -36,7 +36,7 @@ void watchdogInit(unsigned int duration)
|
||||
IWDG->KR = 0x5555; // Unlock registers
|
||||
IWDG->PR = 3; // Divide by 32 => 1kHz clock
|
||||
IWDG->KR = 0x5555; // Unlock registers
|
||||
IWDG->RLR = duration; // 1.5 seconds nominal
|
||||
IWDG->RLR = duration;
|
||||
IWDG->KR = 0xAAAA; // reload
|
||||
IWDG->KR = 0xCCCC; // start
|
||||
}
|
||||
@@ -222,7 +222,7 @@ void boardOff()
|
||||
|
||||
#if defined(PWR_BUTTON_PRESS)
|
||||
while (pwrPressed()) {
|
||||
wdt_reset();
|
||||
WDG_RESET();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -234,7 +234,7 @@ void boardOff()
|
||||
__disable_irq();
|
||||
|
||||
while (1) {
|
||||
wdt_reset();
|
||||
WDG_RESET();
|
||||
#if defined(PWR_BUTTON_PRESS)
|
||||
// X9E/X7 needs watchdog reset because CPU is still running while
|
||||
// the power key is held pressed by the user.
|
||||
|
||||
@@ -95,7 +95,7 @@ uint32_t sdMounted();
|
||||
#define FLASH_PAGESIZE 256
|
||||
void unlockFlash();
|
||||
void lockFlash();
|
||||
void flashWrite(uint32_t * address, uint32_t * buffer);
|
||||
void flashWrite(uint32_t * address, const uint32_t * buffer);
|
||||
uint32_t isFirmwareStart(const uint8_t * buffer);
|
||||
uint32_t isBootloaderStart(const uint8_t * buffer);
|
||||
|
||||
@@ -122,6 +122,9 @@ uint32_t isBootloaderStart(const uint8_t * buffer);
|
||||
#endif
|
||||
|
||||
void intmoduleSerialStart(uint32_t baudrate, uint8_t rxEnable, uint16_t parity, uint16_t stopBits, uint16_t wordLength);
|
||||
#if defined(INTERNAL_MODULE_MULTI)
|
||||
void intmoduleTimerStart(uint32_t periodMs);
|
||||
#endif
|
||||
void intmoduleSendByte(uint8_t byte);
|
||||
void intmoduleSendBuffer(const uint8_t * data, uint8_t size);
|
||||
void intmoduleSendNextFrame();
|
||||
@@ -438,13 +441,13 @@ uint32_t readTrims();
|
||||
#define KEYS_PRESSED() (readKeys())
|
||||
|
||||
// WDT driver
|
||||
#define WDTO_500MS 500
|
||||
#define WDG_DURATION 500 /*ms*/
|
||||
#if !defined(WATCHDOG) || defined(SIMU)
|
||||
#define wdt_enable(x)
|
||||
#define wdt_reset()
|
||||
#define WDG_ENABLE(x)
|
||||
#define WDG_RESET()
|
||||
#else
|
||||
#define wdt_enable(x) watchdogInit(x)
|
||||
#define wdt_reset() IWDG->KR = 0xAAAA
|
||||
#define WDG_ENABLE(x) watchdogInit(x)
|
||||
#define WDG_RESET() IWDG->KR = 0xAAAA
|
||||
#endif
|
||||
void watchdogInit(unsigned int duration);
|
||||
#define WAS_RESET_BY_SOFTWARE() (RCC->CSR & RCC_CSR_SFTRSTF)
|
||||
|
||||
@@ -1003,26 +1003,31 @@
|
||||
#define INTMODULE_DMA_FLAG_TC DMA_IT_TCIF5
|
||||
#define INTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
|
||||
#elif defined(RADIO_T12)
|
||||
//left here is somebody will mod the radio for internal module
|
||||
#define INTMODULE_PULSES
|
||||
#define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_DMA2)
|
||||
#define INTMODULE_RCC_APB1Periph 0
|
||||
#define INTMODULE_RCC_APB2Periph RCC_APB2Periph_TIM1
|
||||
#define INTMODULE_PWR_GPIO GPIOC
|
||||
#define INTMODULE_PWR_GPIO_PIN GPIO_Pin_6 // JUMPER INT PC.06 //X7 INT is PC.06
|
||||
#define INTMODULE_TX_GPIO GPIOA
|
||||
#define INTMODULE_TX_GPIO_PIN GPIO_Pin_7 // JUMPER INT PA.07 //X7 INT is PA.10
|
||||
#define INTMODULE_TX_GPIO_PinSource GPIO_PinSource10
|
||||
#define INTMODULE_TIMER TIM1
|
||||
#define INTMODULE_TIMER_CC_IRQn TIM1_CC_IRQn
|
||||
#define INTMODULE_TIMER_CC_IRQHandler TIM1_CC_IRQHandler
|
||||
#define INTMODULE_TX_GPIO_AF GPIO_AF_TIM1
|
||||
#define INTMODULE_DMA_CHANNEL DMA_Channel_6
|
||||
#define INTMODULE_DMA_STREAM DMA2_Stream5
|
||||
#define INTMODULE_DMA_STREAM_IRQn DMA2_Stream5_IRQn
|
||||
#define INTMODULE_DMA_STREAM_IRQHandler DMA2_Stream5_IRQHandler
|
||||
#define INTMODULE_DMA_FLAG_TC DMA_IT_TCIF5
|
||||
#define INTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
|
||||
#define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA1)
|
||||
#define INTMODULE_PWR_GPIO GPIOC
|
||||
#define INTMODULE_PWR_GPIO_PIN GPIO_Pin_6 // PC.06
|
||||
#define INTMODULE_GPIO GPIOB
|
||||
#define INTMODULE_TX_GPIO_PIN GPIO_Pin_10 // PB.10
|
||||
#define INTMODULE_RX_GPIO_PIN GPIO_Pin_11 // PB.11
|
||||
#define INTMODULE_GPIO_PinSource_TX GPIO_PinSource10
|
||||
#define INTMODULE_GPIO_PinSource_RX GPIO_PinSource11
|
||||
#define INTMODULE_USART USART3
|
||||
#define INTMODULE_GPIO_AF GPIO_AF_USART3
|
||||
#define INTMODULE_USART_IRQn USART3_IRQn
|
||||
#define INTMODULE_USART_IRQHandler USART3_IRQHandler
|
||||
#define INTMODULE_DMA_STREAM DMA1_Stream3
|
||||
#define INTMODULE_DMA_STREAM_IRQ DMA1_Stream3_IRQn
|
||||
#define INTMODULE_DMA_STREAM_IRQHandler DMA1_Stream3_IRQHandler
|
||||
#define INTMODULE_DMA_FLAG_TC DMA_IT_TCIF3
|
||||
#define INTMODULE_DMA_CHANNEL DMA_Channel_4
|
||||
#define INTMODULE_RCC_APB1Periph RCC_APB1Periph_TIM2
|
||||
#define INTMODULE_RCC_APB2Periph RCC_APB1Periph_USART3
|
||||
#define INTMODULE_TIMER TIM2
|
||||
#define INTMODULE_TIMER_IRQn TIM2_IRQn
|
||||
#define INTMODULE_TIMER_IRQHandler TIM2_IRQHandler
|
||||
#define INTMODULE_TIMER_CC_IRQn TIM2_CC_IRQn
|
||||
#define INTMODULE_TIMER_CC_IRQHandler TIM2_CC_IRQHandler
|
||||
#define INTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
|
||||
#else
|
||||
#define INTMODULE_PULSES
|
||||
#define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
|
||||
|
||||
@@ -238,43 +238,36 @@ uint32_t switchState(uint8_t index)
|
||||
void keysInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
|
||||
#if defined(KEYS_GPIOA_PINS)
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOA_PINS;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
INIT_KEYS_PINS(GPIOA);
|
||||
#endif
|
||||
|
||||
#if defined(KEYS_GPIOB_PINS)
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOB_PINS;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
INIT_KEYS_PINS(GPIOB);
|
||||
#endif
|
||||
|
||||
#if defined(KEYS_GPIOC_PINS)
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOC_PINS;
|
||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
INIT_KEYS_PINS(GPIOC);
|
||||
#endif
|
||||
|
||||
#if defined(KEYS_GPIOD_PINS)
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOD_PINS;
|
||||
GPIO_Init(GPIOD, &GPIO_InitStructure);
|
||||
INIT_KEYS_PINS(GPIOD);
|
||||
#endif
|
||||
|
||||
#if defined(KEYS_GPIOE_PINS)
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOE_PINS;
|
||||
GPIO_Init(GPIOE, &GPIO_InitStructure);
|
||||
INIT_KEYS_PINS(GPIOE);
|
||||
#endif
|
||||
|
||||
#if defined(KEYS_GPIOF_PINS)
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOF_PINS;
|
||||
GPIO_Init(GPIOF, &GPIO_InitStructure);
|
||||
INIT_KEYS_PINS(GPIOF);
|
||||
#endif
|
||||
|
||||
#if defined(KEYS_GPIOG_PINS)
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOG_PINS;
|
||||
GPIO_Init(GPIOG, &GPIO_InitStructure);
|
||||
INIT_KEYS_PINS(GPIOG);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user