Chapter 8: C Pointers and Arrays
2);
SL;
TE);
MH >> 4) + '0';
gSECOND);
) + '0';
sendFString(THE_TIME_IS);
// Count tens
++;
}
return (high << 4) | input; // Add ones and return answer
}
sendFString(ERROR_1
}
}
void showClock(void)
{
uint8_t HH, HL, MH, ML, SH,
HH = CHAR2BCD2(gHOUR);
HL = (HH & 0x0F) + '0';
HH = (HH >> 4) + '0';
MH = CHAR2BCD2(gMINU
ML = (MH & 0x0F) + '0';
MH = (
SH = CHAR2BCD2(
SL = (SH & 0x0F
SH = (SH >> 4) + '0';
sendChar(HH);
sendChar(HL);
sendChar(':');
sendChar(MH);
sendChar(ML);
sendChar(':');
sendChar(SH);
sendChar(SL);
sendChar('\r');
}
// convert a character into a binary coded decimal chracter in the range
// 0 to 99 resulting byte has tens in high nibble and ones in low nibble
char CHAR2BCD2(char input)
{
char high = 0;
while (input >= 10)
{
high
input -= 10;