新聞中心

S3C2440-RTC

作者: 時(shí)間:2016-12-02 來源:網(wǎng)絡(luò) 收藏
void GetTime(){
rRTCCON |= 0x1;
data_buffer[0] = rBCDSEC;
data_buffer[1] = rBCDMIN;
data_buffer[2] = rBCDHOUR;
data_buffer[3] = rBCDDATE;
data_buffer[4] = rBCDDAY;
data_buffer[5] = rBCDMON;
data_buffer[6] = rBCDYEAR;
rRTCCON &= 0xfe;
if(data_buffer[0] == 0){
rRTCCON |= 0x1;
data_buffer[0] = rBCDSEC;
data_buffer[1] = rBCDMIN;
data_buffer[2] = rBCDHOUR;
data_buffer[3] = rBCDDATE;
data_buffer[4] = rBCDDAY;
data_buffer[5] = rBCDMON;
data_buffer[6] = rBCDYEAR;
rRTCCON &= 0xfe;
}
}
void Paint_text(U32 x, U32 y, U32 color, unsigned char ch[]){
int i, j, test,t = 0;
for(i = 0; i < 16; i++){
test = 0x80;
for(j = 0; j < 16; j++){
if(j == 8){
test = 0x80;
t++;
}
if(ch[t] & test)
LCD_BUFFER[x+i][y+j] = color;
test >>= 1;
}
t++;
}
}
void Paint_Ascii(U32 x, U32 y, U32 color, unsigned char ch[]){
int i, j, test;
for(i = 0; i < 16; i++){
test = 0x80;
for(j = 0; j < 8; j++){
if(test & ch[ i])
LCD_BUFFER[x+i][y+j] = color;
test >>= 1;
}
}
}
//2010年12月26日星期日19:17:51
void ShowTime(){
U32 qh, wh;
unsigned char s0,s1;
int i, t, k;
char h, l;
GetTime();
//當(dāng)前時(shí)間為
for(i = 0,t = 0, k = 0; i < 5; i++){
s0 = str0[t];
s1 = str0[t+1];
qh = s0-0xa0;
wh = s1-0xa0;
temp = & __HZK[((qh-1)*94+wh-1)*32];
Paint_text(100,k,0x0,temp);
t = t + 2;
k += 16;
}
//:
temp = &__ASCII[:*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
//20
temp = &__ASCII[2*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
temp = &__ASCII[0*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
//10
h = (data_buffer[6]>>4)+48;
temp = &__ASCII[h*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
l = (data_buffer[6]&0x0f)+48;
temp = &__ASCII[l*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
//年
qh = str1[0]-0xa0;
wh = str1[1]-0xa0;
temp = & __HZK[((qh-1)*94+wh-1)*32];
Paint_text(100,k,0x0,temp);
k+=16;
//12
h = (data_buffer[5]>>4)+48;
temp = &__ASCII[h*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
l = (data_buffer[5]&0xf)+48;
temp = &__ASCII[l*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
//月
qh = str2[0]-0xa0;
wh = str2[1]-0xa0;
temp = & __HZK[((qh-1)*94+wh-1)*32];
Paint_text(100,k,0x0,temp);
k+=16;
//26
h = (data_buffer[3]>>4)+48;
temp = &__ASCII[h*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
l = (data_buffer[3]&0xf)+48;
temp = &__ASCII[l*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
//日
qh = str3[0]-0xa0;
wh = str3[1]-0xa0;
temp = & __HZK[((qh-1)*94+wh-1)*32];
Paint_text(100,k,0x0,temp);
k+=16;
//星期日
for(i = 0,t = 0; i < 3; i++){
s0 = str[0][t];
s1 = str[0][t+1];
qh = s0-0xa0;
wh = s1-0xa0;
temp = & __HZK[((qh-1)*94+wh-1)*32];
Paint_text(100,k,0x0,temp);
t = t + 2;
k += 16;
}
//19:17:51
//19
h = (data_buffer[2]>>4)+48;
temp = &__ASCII[h*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
l = (data_buffer[2]&0xf)+48;
temp = &__ASCII[l*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
//:
temp = &__ASCII[:*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
//17
h = (data_buffer[1]>>4)+48;
temp = &__ASCII[h*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
l = (data_buffer[1]&0xf)+48;
temp = &__ASCII[l*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
//:
temp = &__ASCII[:*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
//51
h = (data_buffer[0]>>4)+48;
temp = &__ASCII[h*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;
l = (data_buffer[0]&0xf)+48;
temp = &__ASCII[l*16];
Paint_Ascii(100,k,0x0,temp);
k+=8;

評論


技術(shù)專區(qū)

關(guān)閉