From 27936900d0ee27706d7ca5a5c39d6eb5c0f07b74 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 10 Nov 2018 02:31:11 -0800 Subject: [PATCH] Add enum for PsmBatteryVoltageState --- nx/include/switch/services/psm.h | 9 ++++++++- nx/source/services/psm.c | 9 +++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/nx/include/switch/services/psm.h b/nx/include/switch/services/psm.h index 942e98c0..3062e8c2 100644 --- a/nx/include/switch/services/psm.h +++ b/nx/include/switch/services/psm.h @@ -13,12 +13,19 @@ typedef enum { ChargerType_Usb = 2 ///< Other USB-C chargers } ChargerType; +typedef enum { + PsmBatteryVoltageState_NeedsShutdown = 0, ///< Power state should transition to shutdown + PsmBatteryVoltageState_NeedsSleep = 1, ///< Power state should transition to sleep + PsmBatteryVoltageState_NoPerformanceBoost = 2, ///< Performance boost modes cannot be entered + PsmBatteryVoltageState_Normal = 3, ///< Everything is normal +} PsmBatteryVoltageState; + Result psmInitialize(void); void psmExit(void); Result psmGetBatteryChargePercentage(u32 *out); Result psmGetChargerType(ChargerType *out); -Result psmGetBatteryVoltageState(u32 *out); +Result psmGetBatteryVoltageState(PsmBatteryVoltageState *out); /** * @brief Wrapper func which handles event setup. diff --git a/nx/source/services/psm.c b/nx/source/services/psm.c index 75df717f..24f5679e 100644 --- a/nx/source/services/psm.c +++ b/nx/source/services/psm.c @@ -95,8 +95,13 @@ Result psmGetChargerType(ChargerType *out) { return _psmGetOutU32(1, out); } -Result psmGetBatteryVoltageState(u32 *out) { - return _psmGetOutU32(12, out); +Result psmGetBatteryVoltageState(PsmBatteryVoltageState *out) { + u32 state; + Result rc = _psmGetOutU32(12, &state); + if (R_SUCCEEDED(rc)) { + *out = (PsmBatteryVoltageState)state; + } + return rc; } static Result _psmOpenSession(Service* out) {