mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-08-07 01:13:18 +00:00
Fix incorrect time updating logic
This commit is contained in:
+11
-13
@@ -275,26 +275,24 @@ void AVCLAN_init() {
|
|||||||
|
|
||||||
/* Increment packed 2-digit BCD number.
|
/* Increment packed 2-digit BCD number.
|
||||||
WARNING: Overflow behavior is incorrect (e.g. `incBCD(0x99) != 0x00`) */
|
WARNING: Overflow behavior is incorrect (e.g. `incBCD(0x99) != 0x00`) */
|
||||||
uint8_t incBCD(uint8_t data) {
|
void incBCD(uint8_t *data) {
|
||||||
if ((data & 0x9) == 0x9)
|
if ((*data & 0x9) == 0x9)
|
||||||
return (data + 7);
|
*data += 7;
|
||||||
|
else
|
||||||
return (data + 1);
|
*data += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Periodic interrupt with a 1 sec period
|
// Periodic interrupt with a 1 sec period
|
||||||
ISR(RTC_PIT_vect) {
|
ISR(RTC_PIT_vect) {
|
||||||
if (CD_Mode == stPlay) {
|
if (CD_Mode == stPlay) {
|
||||||
uint8_t sec = *cd_Time_Sec;
|
if (*cd_Time_Sec == 0x59) {
|
||||||
uint8_t min = *cd_Time_Min;
|
|
||||||
sec = incBCD(sec);
|
|
||||||
if (sec == 0x60) {
|
|
||||||
*cd_Time_Sec = 0;
|
*cd_Time_Sec = 0;
|
||||||
min = incBCD(min);
|
if (*cd_Time_Min == 0x99) {
|
||||||
if (min == 0xA0) {
|
|
||||||
*cd_Time_Min = 0;
|
*cd_Time_Min = 0;
|
||||||
}
|
} else
|
||||||
}
|
incBCD(cd_Time_Min);
|
||||||
|
} else
|
||||||
|
incBCD(cd_Time_Sec);
|
||||||
answerReq = cm_CDStatus;
|
answerReq = cm_CDStatus;
|
||||||
}
|
}
|
||||||
RTC.PITINTFLAGS |= RTC_PI_bm;
|
RTC.PITINTFLAGS |= RTC_PI_bm;
|
||||||
|
|||||||
Reference in New Issue
Block a user