Skip to content

Commit

Permalink
Fixed build problem post #3846
Browse files Browse the repository at this point in the history
  • Loading branch information
richardclli committed Dec 4, 2023
1 parent f46e188 commit 010d98a
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 1,223 deletions.
4 changes: 3 additions & 1 deletion radio/src/storage/yaml/yaml_datastructs_pl18.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_SET_SCREEN, "SET_SCREEN" },
{ FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" },
{ FUNC_RGB_LED, "RGB_LED" },
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
Expand Down Expand Up @@ -286,7 +287,8 @@ static const struct YamlNode struct_CustomFunctionData[] = {
YAML_ENUM("func", 6, enum_Functions),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 48 ),
YAML_PADDING( 8 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
Expand Down
13 changes: 4 additions & 9 deletions radio/src/targets/pl18/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,14 @@ set(USB_SERIAL ON CACHE BOOL "Enable USB serial (CDC)")
set(HARDWARE_EXTERNAL_MODULE YES)
set(WIRELESS_CHARGER YES)

if(BOOTLOADER)
set(LINKER_SCRIPT targets/pl18/stm32f4_flash_bootloader.ld)
else()
set(LINKER_SCRIPT targets/pl18/stm32f4_flash.ld)
endif()

#option(STICKS_DEAD_ZONE "Enable sticks dead zone" YES)
#option(AFHDS2 "Support for AFHDS2" OFF)


# for size report script
set(CPU_TYPE_FULL STM32F429xI)
set(SIZE_TARGET_MEM_DEFINE "MEM_SIZE_SDRAM2=8192")
set(TARGET_LINKER_DIR stm32f429_sdram)
set(TARGET_LINKER_PARAMS "-Wl,--defsym=__SDRAM_START__=0xC0000000")
set(SIZE_TARGET_MEM_DEFINE "MEM_SIZE_SDRAM1=8192")

#set(RF_BAUD_RATE 921600 230400 115200 57600 38400 19200 9600 4800 2400 1200)
#set(PCB_RF_BAUD 921600 CACHE STRING "INTERNAL_MODULE_BAUDRATE: ${RF_BAUD_RATE}")
Expand Down Expand Up @@ -73,7 +68,7 @@ set(FLYSKY_GIMBAL ON)

add_definitions(
-DSTM32F429_439xx -DSTM32F429xx
-DSDRAM -DCOLORLCD -DLIBOPENUI
-DSDRAM -DCCMRAM -DCOLORLCD -DLIBOPENUI
-DHARDWARE_TOUCH -DHARDWARE_KEYS
-DSOFTWARE_KEYBOARD -DUSE_HATS_AS_KEYS)

Expand Down
1 change: 0 additions & 1 deletion radio/src/targets/pl18/backlight_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,5 @@ bool boardBacklightOn;

bool isBacklightEnabled()
{
if (globalData.unexpectedShutdown) return true;
return boardBacklightOn;
}
44 changes: 4 additions & 40 deletions radio/src/targets/pl18/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include "hal/adc_driver.h"
#include "hal/trainer_driver.h"
#include "hal/switch_driver.h"
#include "hal/abnormal_reboot.h"
#include "hal/watchdog_driver.h"

#include "globals.h"
#include "sdcard.h"
Expand All @@ -41,7 +43,6 @@

#include "battery_driver.h"
#include "touch_driver.h"
#include "watchdog_driver.h"

#include "bitmapbuffer.h"
#include "colors.h"
Expand All @@ -60,43 +61,6 @@ extern "C" {
// common ADC driver
extern const etx_hal_adc_driver_t _adc_driver;

enum PowerReason {
SHUTDOWN_REQUEST = 0xDEADBEEF,
SOFTRESET_REQUEST = 0xCAFEDEAD,
};

constexpr uint32_t POWER_REASON_SIGNATURE = 0x0178746F;

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
}

void SET_POWER_REASON(uint32_t value)
{
RTC->BKP0R = value;
RTC->BKP1R = POWER_REASON_SIGNATURE;
}

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->KR = 0xAAAA; // reload
// IWDG->KR = 0xCCCC; // start
}

#if defined(SEMIHOSTING)
extern "C" void initialise_monitor_handles();
#endif
Expand Down Expand Up @@ -250,13 +214,13 @@ void boardOff()
if (isChargerActive())
{
delay_ms(100); // Add a delay to wait for lcdOff
RTC->BKP0R = SOFTRESET_REQUEST;
// RTC->BKP0R = SOFTRESET_REQUEST;
NVIC_SystemReset();
}
else
#endif
{
RTC->BKP0R = SHUTDOWN_REQUEST;
// RTC->BKP0R = SHUTDOWN_REQUEST;
pwrOff();
}

Expand Down
39 changes: 12 additions & 27 deletions radio/src/targets/pl18/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
#include "board_common.h"
#include "hal.h"
#include "hal/serial_port.h"

#include "watchdog_driver.h"
#include "hal/watchdog_driver.h"

#define FLASHSIZE 0x200000
#define BOOTLOADER_SIZE 0x20000
Expand Down Expand Up @@ -100,17 +99,6 @@ void SDRAM_Init();
#define BATTERY_MAX 43 // 4.3V
#define BATTERY_DIVIDER 962

enum EnumPowerupState
{
BOARD_POWER_OFF = 0xCAFEDEAD,
BOARD_POWER_ON = 0xDEADBEEF,
BOARD_STARTED = 0xBAADF00D,
BOARD_REBOOT = 0xC00010FF,
};

bool UNEXPECTED_SHUTDOWN();
void SET_POWER_REASON(uint32_t value);

#if defined(__cplusplus) && !defined(SIMU)
extern "C" {
#endif
Expand Down Expand Up @@ -169,22 +157,19 @@ void backlightEnable(uint8_t dutyCycle);
void backlightFullOn();
bool isBacklightEnabled();

#define BACKLIGHT_ENABLE() \
{ \
boardBacklightOn = true; \
backlightEnable(globalData.unexpectedShutdown \
? BACKLIGHT_LEVEL_MAX \
: BACKLIGHT_LEVEL_MAX - currentBacklightBright); \
#define BACKLIGHT_ENABLE() \
{ \
boardBacklightOn = true; \
backlightEnable(BACKLIGHT_LEVEL_MAX - currentBacklightBright); \
}

#define BACKLIGHT_DISABLE() \
{ \
boardBacklightOn = false; \
backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX \
: ((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && \
(g_eeGeneral.backlightMode != e_backlight_mode_off)) \
? 0 \
: g_eeGeneral.blOffBright); \
#define BACKLIGHT_DISABLE() \
{ \
boardBacklightOn = false; \
backlightEnable(((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && \
(g_eeGeneral.backlightMode != e_backlight_mode_off)) \
? 0 \
: g_eeGeneral.blOffBright); \
}

#if !defined(SIMU)
Expand Down
Loading

0 comments on commit 010d98a

Please sign in to comment.