| 145 | } |
| 146 | |
| 147 | void 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 | |
| 167 | void cplus_RTC::WriteReg(uint8_t reg, uint8_t data) { |
| 168 | wr->beginTransmission(0x51); |