mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 18:47:21 +08:00
platforms/common/shutdown.cpp: Enable boardctl functions for shutdown and poweroff
Shutdown and poweroff must go through boardctl in NuttX protected build Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
committed by
Daniel Agar
parent
7185bb3243
commit
d0d7f29422
@@ -56,6 +56,7 @@
|
|||||||
|
|
||||||
#ifdef __PX4_NUTTX
|
#ifdef __PX4_NUTTX
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
|
#include <sys/boardctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace time_literals;
|
using namespace time_literals;
|
||||||
@@ -99,7 +100,7 @@ int px4_shutdown_unlock()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_SCHED_WORKQUEUE)
|
#if defined(CONFIG_SCHED_WORKQUEUE) || (!defined(CONFIG_BUILD_FLAT) && defined(CONFIG_LIB_USRWORK))
|
||||||
|
|
||||||
static struct work_s shutdown_work = {};
|
static struct work_s shutdown_work = {};
|
||||||
static uint16_t shutdown_counter = 0; ///< count how many times the shutdown worker was executed
|
static uint16_t shutdown_counter = 0; ///< count how many times the shutdown worker was executed
|
||||||
@@ -174,7 +175,7 @@ static void shutdown_worker(void *arg)
|
|||||||
if (shutdown_args & SHUTDOWN_ARG_REBOOT) {
|
if (shutdown_args & SHUTDOWN_ARG_REBOOT) {
|
||||||
#if defined(CONFIG_BOARDCTL_RESET)
|
#if defined(CONFIG_BOARDCTL_RESET)
|
||||||
PX4_INFO_RAW("Reboot NOW.");
|
PX4_INFO_RAW("Reboot NOW.");
|
||||||
board_reset((shutdown_args & SHUTDOWN_ARG_TO_BOOTLOADER) ? 1 : 0);
|
boardctl(BOARDIOC_RESET, (shutdown_args & SHUTDOWN_ARG_TO_BOOTLOADER) ? 1 : 0);
|
||||||
#else
|
#else
|
||||||
PX4_PANIC("board reset not available");
|
PX4_PANIC("board reset not available");
|
||||||
#endif
|
#endif
|
||||||
@@ -182,7 +183,11 @@ static void shutdown_worker(void *arg)
|
|||||||
} else {
|
} else {
|
||||||
#if defined(BOARD_HAS_POWER_CONTROL)
|
#if defined(BOARD_HAS_POWER_CONTROL)
|
||||||
PX4_INFO_RAW("Powering off NOW.");
|
PX4_INFO_RAW("Powering off NOW.");
|
||||||
|
#if defined(CONFIG_BOARDCTL_POWEROFF)
|
||||||
|
boardctl(BOARDIOC_POWEROFF, 0);
|
||||||
|
#else
|
||||||
board_power_off(0);
|
board_power_off(0);
|
||||||
|
#endif
|
||||||
#elif defined(__PX4_POSIX)
|
#elif defined(__PX4_POSIX)
|
||||||
// simply exit on posix if real shutdown (poweroff) not available
|
// simply exit on posix if real shutdown (poweroff) not available
|
||||||
PX4_INFO_RAW("Exiting NOW.");
|
PX4_INFO_RAW("Exiting NOW.");
|
||||||
|
|||||||
Reference in New Issue
Block a user