Fixes #2681: the PWR pin was not turned on correctly in _bootStart(). Watchdog reset now works on 9XE, the Bootloader exit also works.
Trim switch pull up not enabled for 9XE in _bootStart(). Added watchdog test option in DEBUG screen (long press MENU key), use WATCHDOG_TEST=YES compile option to enable it.
This commit is contained in:
@@ -361,6 +361,10 @@ SIMU_DISKIO = NO
|
||||
# Values = NO, YES
|
||||
SIMU_AUDIO = NO
|
||||
|
||||
# Enable Watchdog test (DANGEROUS)
|
||||
# Values = NO, YES
|
||||
WATCHDOG_TEST = NO
|
||||
|
||||
#------- END BUILD OPTIONS ---------------------------
|
||||
|
||||
# Define programs and commands.
|
||||
@@ -1023,6 +1027,9 @@ ifeq ($(PCB), TARANIS)
|
||||
ifeq ($(MIXERS_MONITOR), YES)
|
||||
CPPDEFS += -DMIXERS_MONITOR
|
||||
endif
|
||||
ifeq ($(WATCHDOG_TEST), YES)
|
||||
CPPDEFS += -DWATCHDOG_TEST
|
||||
endif
|
||||
endif
|
||||
|
||||
CC = $(TRGT)gcc
|
||||
|
||||
@@ -105,6 +105,15 @@ void menuStatisticsDebug(uint8_t event)
|
||||
{
|
||||
TITLE(STR_MENUDEBUG);
|
||||
|
||||
#if defined(WATCHDOG_TEST)
|
||||
if (s_warning_result) {
|
||||
s_warning_result = 0;
|
||||
// do a user requested watchdog test
|
||||
TRACE("Performing watchdog test");
|
||||
pausePulses();
|
||||
}
|
||||
#endif
|
||||
|
||||
switch(event)
|
||||
{
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
@@ -136,6 +145,15 @@ void menuStatisticsDebug(uint8_t event)
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
#if defined(WATCHDOG_TEST)
|
||||
case EVT_KEY_LONG(KEY_MENU):
|
||||
{
|
||||
POPUP_CONFIRMATION("Test the watchdog?");
|
||||
const char * w = "The radio will reset!";
|
||||
SET_WARNING_INFO(w, strlen(w), 0);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
lcd_putsLeft(MENU_DEBUG_Y_FREE_RAM, "Free Mem");
|
||||
|
||||
+20
-11
@@ -89,24 +89,33 @@ const uint8_t BootCode[] = {
|
||||
__attribute__ ((section(".bootrodata"), used))
|
||||
void _bootStart()
|
||||
{
|
||||
// turn soft power ON now
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; // Enable portD clock
|
||||
GPIOD->BSRRL = 1;
|
||||
GPIOD->MODER = (GPIOD->MODER & 0xFFFFFFFC) | 1;
|
||||
|
||||
#if defined(REV9E)
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN; // Enable portC clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOGEN; // Enable portG clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN | RCC_AHB1ENR_GPIOGEN | RCC_AHB1ENR_GPIODEN;
|
||||
#else
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN; // Enable portC clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOEEN; // Enable portE clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN | RCC_AHB1ENR_GPIOEEN | RCC_AHB1ENR_GPIODEN;
|
||||
#endif
|
||||
|
||||
// these two NOPs are needed (see STM32F errata sheet) before the peripheral
|
||||
// register can be written after the peripheral clock was enabled
|
||||
__ASM volatile ("nop");
|
||||
__ASM volatile ("nop");
|
||||
|
||||
// Turn soft power ON now
|
||||
GPIOD->BSRRL = 1; // set PWR_GPIO_PIN_ON pin to 1
|
||||
GPIOD->MODER = (GPIOD->MODER & 0xFFFFFFFC) | 1; // General purpose output mode
|
||||
|
||||
// TRIMS_GPIO_PIN_LHR is on PG0 on 9XE and on PE3 on Taranis
|
||||
// TRIMS_GPIO_PIN_RHL is on PC1 on all versions
|
||||
|
||||
// turn on pull-ups on trim keys
|
||||
GPIOC->PUPDR = 0x00000004;
|
||||
#if defined(REV9E)
|
||||
GPIOG->PUPDR = 0x00000001;
|
||||
#else
|
||||
GPIOE->PUPDR = 0x00000040;
|
||||
#endif
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < 50000; i += 1) {
|
||||
for (uint32_t i = 0; i < 50000; i += 1) {
|
||||
bwdt_reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ void boardInit()
|
||||
#endif
|
||||
|
||||
#if defined(REV9E)
|
||||
if (!(RCC->CSR & (RCC_CSR_SFTRSTF | RCC_CSR_WDGRSTF))) {
|
||||
if (!WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||
lcd_clear();
|
||||
lcd_bmp(76, 2, bmp_lock, 0, 60);
|
||||
lcdRefresh();
|
||||
|
||||
@@ -236,8 +236,9 @@ void checkRotaryEncoder(void);
|
||||
void watchdogInit(unsigned int duration);
|
||||
#define wdt_enable(x) watchdogInit(1500)
|
||||
#define wdt_reset() IWDG->KR = 0xAAAA
|
||||
#define WAS_RESET_BY_WATCHDOG() (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF))
|
||||
#define WAS_RESET_BY_SOFTWARE() (RCC->CSR & RCC_CSR_SFTRSTF)
|
||||
#define WAS_RESET_BY_SOFTWARE() (RCC->CSR & RCC_CSR_SFTRSTF)
|
||||
#define WAS_RESET_BY_WATCHDOG() (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF))
|
||||
#define WAS_RESET_BY_WATCHDOG_OR_SOFTWARE() (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF | RCC_CSR_SFTRSTF))
|
||||
#endif
|
||||
|
||||
// ADC driver
|
||||
|
||||
@@ -363,7 +363,7 @@ void lcdInit()
|
||||
{
|
||||
LCD_Hardware_Init();
|
||||
|
||||
if (WAS_RESET_BY_WATCHDOG()|WAS_RESET_BY_SOFTWARE()) return; //no need to reset LCD module
|
||||
if (WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) return; //no need to reset LCD module
|
||||
|
||||
//reset LCD module
|
||||
LCD_RST_LOW();
|
||||
@@ -400,7 +400,7 @@ void lcdInitFinish()
|
||||
initialization (without reset) is also recommended by the data sheet.
|
||||
*/
|
||||
|
||||
if (!WAS_RESET_BY_WATCHDOG() && !WAS_RESET_BY_SOFTWARE()) {
|
||||
if (!WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||
#if !defined(BOOT)
|
||||
while(g_tmr10ms < (RESET_WAIT_DELAY_MS/10)) {}; //wait measured from the power-on
|
||||
#else
|
||||
|
||||
@@ -42,6 +42,9 @@ extern volatile uint32_t g_tmr10ms;
|
||||
|
||||
void pwrInit()
|
||||
{
|
||||
// if any changes are done to the PWR PIN or pwrOn() function
|
||||
// then the same changes must be done in _bootStart()
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = PWR_GPIO_PIN_ON;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
|
||||
Reference in New Issue
Block a user