MCPcopy Create free account
hub / github.com/BruceDevices/firmware / GetTime

Method GetTime

lib/RTC/cplus_RTC.cpp:90–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90void cplus_RTC::GetTime(RTC_TimeTypeDef *RTC_TimeStruct) {
91 // if()
92 uint8_t buf[3] = {0};
93
94 wr->beginTransmission(0x51);
95 wr->write(0x02);
96 wr->endTransmission();
97 wr->requestFrom(0x51, 3);
98
99 while (wr->available()) {
100 buf[0] = wr->read();
101 buf[1] = wr->read();
102 buf[2] = wr->read();
103 }
104
105 RTC_TimeStruct->Seconds = Bcd2ToByte(buf[0] & 0x7f); // 秒
106 RTC_TimeStruct->Minutes = Bcd2ToByte(buf[1] & 0x7f); // 分
107 RTC_TimeStruct->Hours = Bcd2ToByte(buf[2] & 0x3f); // 时
108}
109
110void cplus_RTC::SetTime(RTC_TimeTypeDef *RTC_TimeStruct) {
111 if (RTC_TimeStruct == NULL) return;

Callers 4

init_clockFunction · 0.45
setClockFunction · 0.45
runClockLoopFunction · 0.45
dateCallbackFunction · 0.45

Calls 3

writeMethod · 0.45
availableMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected