2019-05-03 02:33:12 +00:00
|
|
|
/*
|
2021-10-04 19:59:10 +00:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2019-05-03 02:33:12 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-05-11 22:02:10 +00:00
|
|
|
#include <stratosphere.hpp>
|
2019-05-03 02:33:12 +00:00
|
|
|
#include "boot_rtc_driver.hpp"
|
|
|
|
|
2019-10-24 09:30:10 +00:00
|
|
|
namespace ams::boot {
|
2019-05-03 02:33:12 +00:00
|
|
|
|
2019-06-22 07:10:21 +00:00
|
|
|
Result RtcDriver::ReadRtcRegister(u8 *out, u8 address) {
|
|
|
|
const u8 update_addr = 0x04;
|
|
|
|
const u8 update_val = 0x10;
|
2021-10-10 07:14:06 +00:00
|
|
|
R_TRY(WriteI2cRegister(m_i2c_session, &update_val, sizeof(update_val), &update_addr, sizeof(update_addr)));
|
2020-11-09 10:01:29 +00:00
|
|
|
os::SleepThread(TimeSpan::FromMilliSeconds(16));
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(ReadI2cRegister(m_i2c_session, out, sizeof(*out), &address, sizeof(address)));
|
2019-06-22 07:10:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result RtcDriver::GetRtcIntr(u8 *out) {
|
|
|
|
const u8 addr = 0x00;
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(ReadI2cRegister(m_i2c_session, out, sizeof(*out), &addr, sizeof(addr)));
|
2019-06-22 07:10:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result RtcDriver::GetRtcIntrM(u8 *out) {
|
|
|
|
const u8 addr = 0x01;
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(this->ReadRtcRegister(out, addr));
|
2019-06-22 07:10:21 +00:00
|
|
|
}
|
2019-05-03 02:33:12 +00:00
|
|
|
|
|
|
|
}
|