Skip to content

Commit

Permalink
Moved powering device from pwrResetHandler to bard init - checking po…
Browse files Browse the repository at this point in the history
…wer switch is also there - more convenient solution.
  • Loading branch information
qba667 committed Mar 18, 2019
1 parent a8e7e6a commit 5e49bc4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
3 changes: 0 additions & 3 deletions radio/src/targets/nv14/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ add_definitions(-DGPS_USART_BAUDRATE=${INTERNAL_GPS_BAUDRATE})
add_definitions(-DPWR_BUTTON_${PWR_BUTTON})
add_definitions(-DCROSSFIRE_NATIVE)
add_definitions(-DWIDGETS_MISSING)
#add_definitions(-DNO_UNEXPECTED_SHUTDOWN)

add_definitions(-DFLYSKY_HALL_STICKS_REVERSE)
#add_definitions(-DFLYSKY_AUTO_POWER_DOWN)
add_definitions(-DFLYSKY_STARTUP_DELAY)
option(MENU_SIMPLE "Used simplified menu" ON)
if(MENU_SIMPLE)
add_definitions(-DSUPER_SIMPLE_MENU)
Expand Down
2 changes: 2 additions & 0 deletions radio/src/targets/nv14/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ void boardInit()
init1msTimer();

uint32_t pwr_press_time = 0;
if(UNEXPECTED_SHUTDOWN()) pwrOn();

while (boardState == BOARD_POWER_OFF)
{
if (pwrPressed())
Expand Down
12 changes: 2 additions & 10 deletions radio/src/targets/nv14/pwr_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,13 @@ void pwrInit()
// Init TRAINER DETECT PIN
// GPIO_InitStructure.GPIO_Pin = TRAINER_DETECT_GPIO_PIN;
// GPIO_Init(TRAINER_DETECT_GPIO, &GPIO_InitStructure);

boardState = BOARD_POWER_OFF;
}

void pwrOn()
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = PWR_ON_GPIO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(PWR_GPIO, &GPIO_InitStructure);

GPIO_SetBits(PWR_GPIO, PWR_ON_GPIO_PIN);

boardState = BOARD_POWER_ON;
}

Expand Down Expand Up @@ -110,7 +103,6 @@ void pwrResetHandler()
if (boardState != BOARD_POWER_OFF) {
powerupReason = boardState != BOARD_REBOOT && WAS_RESET_BY_WATCHDOG_OR_SOFTWARE() ? DIRTY_SHUTDOWN : ~DIRTY_SHUTDOWN;
RCC->CSR |= RCC_CSR_RMVF; //clear all flags
pwrOn();
}
else {
powerupReason = ~DIRTY_SHUTDOWN;
Expand Down

0 comments on commit 5e49bc4

Please sign in to comment.