mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
RTCファイルがある時のみインポートするように
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@69 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
2af6c2dd86
commit
9c28be8cb5
@ -418,44 +418,46 @@ void ImportMcuRtc()
|
|||||||
|
|
||||||
if(handle.IsValid())
|
if(handle.IsValid())
|
||||||
{
|
{
|
||||||
|
if (common::CheckFileExists(common::MCU_RTC_PATHNAME))
|
||||||
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
|
|
||||||
NN_LOG("AllocatableSize = %d\n", bufSize);
|
|
||||||
|
|
||||||
void* buf = common::HeapManager::GetHeap()->Allocate(bufSize);
|
|
||||||
if (buf != NULL)
|
|
||||||
{
|
{
|
||||||
common::SdReaderWriter sdReader;
|
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
|
||||||
|
NN_LOG("AllocatableSize = %d\n", bufSize);
|
||||||
|
|
||||||
size_t readSize;
|
void* buf = common::HeapManager::GetHeap()->Allocate(bufSize);
|
||||||
result = sdReader.ReadBuf(common::MCU_RTC_PATHNAME, buf, bufSize, &readSize);
|
if (buf != NULL)
|
||||||
if (result.IsSuccess())
|
|
||||||
{
|
{
|
||||||
// mcuを使ってセットする
|
common::SdReaderWriter sdReader;
|
||||||
nn::mcu::CTR::HwCheck mcu(handle);
|
|
||||||
nn::mcu::CTR::RtcData* rtc = reinterpret_cast<nn::mcu::CTR::RtcData*>(buf);
|
|
||||||
NN_LOG("RTC = 20%02d/%02d/%02d %02d:%02d:%02d\n", rtc->m_Year, rtc->m_Month, rtc->m_Day, rtc->m_Hour, rtc->m_Minute, rtc->m_Second);
|
|
||||||
|
|
||||||
// BCD変換が必要
|
size_t readSize;
|
||||||
|
result = sdReader.ReadBuf(common::MCU_RTC_PATHNAME, buf, bufSize, &readSize);
|
||||||
size_t RTC_PARAM_SIZE = sizeof(nn::mcu::CTR::RtcData);
|
if (result.IsSuccess())
|
||||||
u8 bcd[RTC_PARAM_SIZE];
|
|
||||||
for (int i = 0; i < RTC_PARAM_SIZE; i++)
|
|
||||||
{
|
{
|
||||||
bcd[i] = DecimalToBcd(reinterpret_cast<u8*>(rtc)[i]);
|
// mcuを使ってセットする
|
||||||
|
nn::mcu::CTR::HwCheck mcu(handle);
|
||||||
|
nn::mcu::CTR::RtcData* rtc = reinterpret_cast<nn::mcu::CTR::RtcData*> (buf);
|
||||||
|
NN_LOG("RTC = 20%02d/%02d/%02d %02d:%02d:%02d\n", rtc->m_Year, rtc->m_Month, rtc->m_Day, rtc->m_Hour, rtc->m_Minute, rtc->m_Second);
|
||||||
|
|
||||||
|
// BCD変換が必要
|
||||||
|
|
||||||
|
size_t RTC_PARAM_SIZE = sizeof(nn::mcu::CTR::RtcData);
|
||||||
|
u8 bcd[RTC_PARAM_SIZE];
|
||||||
|
for (int i = 0; i < RTC_PARAM_SIZE; i++)
|
||||||
|
{
|
||||||
|
bcd[i] = DecimalToBcd(reinterpret_cast<u8*> (rtc)[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = mcu.WriteBySend(nn::drivers::mcu::CTR::MCU_RTC_SEC_ADDR, bcd, RTC_PARAM_SIZE);
|
||||||
|
|
||||||
|
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = mcu.WriteBySend(nn::drivers::mcu::CTR::MCU_RTC_SEC_ADDR, bcd, RTC_PARAM_SIZE);
|
|
||||||
|
|
||||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||||
}
|
|
||||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
|
||||||
|
|
||||||
common::HeapManager::GetHeap()->Free(buf);
|
common::HeapManager::GetHeap()->Free(buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
COMMON_LOGGER("Failed Allocate Heap!!\n");
|
COMMON_LOGGER("Failed Allocate Heap!!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user