S3C2440-RTC中斷
void Paint_background(U32 c, U32 startx, U32 starty, U32 endx, U32 endy){
U32 i,j;
for(j = starty; j < endy; j++)
for(i = startx; i < endx; i++)
LCD_BUFFER[j][ i] = c;
}
void SetTime(){
rRTCCON |= 0x1;
rBCDSEC = data_buffer[0];
rBCDMIN = data_buffer[1];
rBCDHOUR = data_buffer[2];
rBCDDATE = data_buffer[3];
rBCDDAY = data_buffer[4];
rBCDMON = data_buffer[5];
rBCDYEAR = data_buffer[6];
rRTCCON &= 0xfe;
}
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;
if(data_buffer[0] == 0){
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;
}
}
}
void __irq Uart_ISR(void){
char buf;
rSUBSRCPND |= 0x3;
rSRCPND |= 0x1<<28;
rINTPND |= 0x1<<28;
if(rUTRSTAT0&0x1){
buf = rURXH0;
if((buf == 0xaa) && (t == 0)){
t = 1;
i = 0;
rUTXH0 = 0xaa;
}
else{
if(t){
data_buffer[ i] = buf;
i++;
rUTXH0 = 0xdd;
if(i == 7){
rUTXH0 = 0xbb;
SetTime();
i = 0;
t = 0;
flag = 1;
}
}
else{
rUTXH0 = 0xcc;
}
}
}
}
//2010年12月26日星期日19:17:51
void ShowTime(){
U32 qh, wh;
unsigned char s0,s1;
int i, t, k;
char h, l;
GetTime();
//當前時間為
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;
}
評論