diff --git a/sysmodules/rosalina/include/mcu.h b/sysmodules/rosalina/include/mcu.h
deleted file mode 100644
index d2e8a01f..00000000
--- a/sysmodules/rosalina/include/mcu.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-* This file is part of Luma3DS
-* Copyright (C) 2016-2017 Aurora Wright, TuxSH
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*
-* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
-* * Requiring preservation of specified reasonable legal notices or
-* author attributions in that material or in the Appropriate Legal
-* Notices displayed by works containing it.
-* * Prohibiting misrepresentation of the origin of that material,
-* or requiring that modified versions of such material be marked in
-* reasonable ways as different from the original version.
-*/
-
-#pragma once
-
-#include <3ds.h>
-
-Handle mcuhwcHandle;
-
-Result mcuInit(void);
-Result mcuExit(void);
-Result mcuReadRegister(u8 reg, u8* data, u32 size);
-Result mcuWriteRegister(u8 reg, u8* data, u32 size);
-Result mcuGetLEDState(u8* out);
diff --git a/sysmodules/rosalina/source/mcu.c b/sysmodules/rosalina/source/mcu.c
deleted file mode 100644
index 361bea8b..00000000
--- a/sysmodules/rosalina/source/mcu.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-* This file is part of Luma3DS
-* Copyright (C) 2016-2017 Aurora Wright, TuxSH
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*
-* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
-* * Requiring preservation of specified reasonable legal notices or
-* author attributions in that material or in the Appropriate Legal
-* Notices displayed by works containing it.
-* * Prohibiting misrepresentation of the origin of that material,
-* or requiring that modified versions of such material be marked in
-* reasonable ways as different from the original version.
-*/
-
-#include "mcu.h"
-
-Result mcuInit(void)
-{
- return srvGetServiceHandle(&mcuhwcHandle, "mcu::HWC");
-}
-
-Result mcuExit(void)
-{
- return svcCloseHandle(mcuhwcHandle);
-}
-
-Result mcuReadRegister(u8 reg, u8* data, u32 size)
-{
- u32* ipc = getThreadCommandBuffer();
- ipc[0] = 0x10082;
- ipc[1] = reg;
- ipc[2] = size;
- ipc[3] = size << 4 | 0xC;
- ipc[4] = (u32)data;
- Result ret = svcSendSyncRequest(mcuhwcHandle);
- if(ret < 0) return ret;
- return ipc[1];
-}
-
-Result mcuWriteRegister(u8 reg, u8* data, u32 size)
-{
- u32* ipc = getThreadCommandBuffer();
- ipc[0] = 0x20082;
- ipc[1] = reg;
- ipc[2] = size;
- ipc[3] = size << 4 | 0xA;
- ipc[4] = (u32)data;
- Result ret = svcSendSyncRequest(mcuhwcHandle);
- if(ret < 0) return ret;
- return ipc[1];
-}
-
-Result mcuGetLEDState(u8* out)
-{
- return mcuReadRegister(0x28, out, 1);
-}
diff --git a/sysmodules/rosalina/source/menu.c b/sysmodules/rosalina/source/menu.c
index 0e5fc213..00475f31 100644
--- a/sysmodules/rosalina/source/menu.c
+++ b/sysmodules/rosalina/source/menu.c
@@ -28,7 +28,6 @@
#include "menu.h"
#include "draw.h"
#include "fmt.h"
-#include "mcu.h"
#include "memory.h"
#include "ifile.h"
#include "menus.h"
@@ -124,26 +123,6 @@ u32 waitCombo(void)
return waitComboWithTimeout(0);
}
-static Result _MCUHWC_GetBatteryLevel(u8 *out)
-{
- #define TRY(expr) if(R_FAILED(res = (expr))) { mcuExit(); return res; }
- Result res;
-
- TRY(mcuInit());
-
- u32 *cmdbuf = getThreadCommandBuffer();
- cmdbuf[0] = 0x50000;
-
- TRY(svcSendSyncRequest(mcuhwcHandle));
-
- *out = (u8) cmdbuf[2];
-
- svcCloseHandle(mcuhwcHandle);
- return cmdbuf[1];
-
- #undef TRY
-}
-
static MyThread menuThread;
static u8 ALIGN(8) menuThreadStack[THREAD_STACK_SIZE];
static u8 batteryLevel = 255;
@@ -215,8 +194,12 @@ static void menuDraw(Menu *menu, u32 selected)
u32 version, commitHash;
bool isRelease;
- if(R_FAILED(_MCUHWC_GetBatteryLevel(&batteryLevel)))
- batteryLevel = 255;
+ if(R_SUCCEEDED(mcuHwcInit()))
+ {
+ if(R_FAILED(mcuHwcGetBatteryLevel(&batteryLevel)))
+ batteryLevel = 255;
+ mcuHwcExit();
+ }
svcGetSystemInfo(&out, 0x10000, 0);
version = (u32)out;
diff --git a/sysmodules/rosalina/source/menus/miscellaneous.c b/sysmodules/rosalina/source/menus/miscellaneous.c
index 7969431f..be0f802e 100644
--- a/sysmodules/rosalina/source/menus/miscellaneous.c
+++ b/sysmodules/rosalina/source/menus/miscellaneous.c
@@ -27,7 +27,6 @@
#include <3ds.h>
#include "menus/miscellaneous.h"
#include "input_redirection.h"
-#include "mcu.h"
#include "memory.h"
#include "draw.h"
#include "hbloader.h"
diff --git a/sysmodules/rosalina/source/menus/sysconfig.c b/sysmodules/rosalina/source/menus/sysconfig.c
index bd727241..f54b4170 100644
--- a/sysmodules/rosalina/source/menus/sysconfig.c
+++ b/sysmodules/rosalina/source/menus/sysconfig.c
@@ -26,7 +26,6 @@
#include <3ds.h>
#include "menus/sysconfig.h"
-#include "mcu.h"
#include "memory.h"
#include "draw.h"
#include "fmt.h"
@@ -65,12 +64,12 @@ void SysConfigMenu_ToggleLEDs(void)
if(pressed & BUTTON_A)
{
- mcuInit();
+ mcuHwcInit();
u8 result;
- mcuGetLEDState(&result);
- u8 value = ~result;
- mcuWriteRegister(40, &value, 1);
- mcuExit();
+ mcuHwcReadRegister(0x28, &result, 1);
+ result = ~result;
+ mcuHwcWriteRegister(40, &result, 1);
+ mcuHwcExit();
}
else if(pressed & BUTTON_B)
return;