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

Method SetDate

lib/RTC/cplus_RTC.cpp:147–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147void cplus_RTC::SetDate(RTC_DateTypeDef *RTC_DateStruct) {
148 if (RTC_DateStruct == NULL) return;
149 wr->beginTransmission(0x51);
150 wr->write(0x05);
151 wr->write(ByteToBcd2(RTC_DateStruct->Date));
152 wr->write(ByteToBcd2(RTC_DateStruct->WeekDay));
153
154 if (RTC_DateStruct->Year < 2000) {
155 wr->write(ByteToBcd2(RTC_DateStruct->Month) | 0x80);
156 wr->write(ByteToBcd2((uint8_t)(RTC_DateStruct->Year % 100)));
157
158 } else {
159 /* code */
160 wr->write(ByteToBcd2(RTC_DateStruct->Month) | 0x00);
161 wr->write(ByteToBcd2((uint8_t)(RTC_DateStruct->Year % 100)));
162 }
163
164 wr->endTransmission();
165}
166
167void cplus_RTC::WriteReg(uint8_t reg, uint8_t data) {
168 wr->beginTransmission(0x51);

Callers

nothing calls this directly

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected