新聞中心

        S3C2440-RTC

        作者: 時間:2016-12-02 來源:網絡 收藏
        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();
        //當前時間為
        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;

        關鍵詞: S3C2440RTC實時時

        評論


        技術專區

        關閉
        主站蜘蛛池模板: 河间市| 卓尼县| 芮城县| 海安县| 鄯善县| 广东省| 桑日县| 长宁区| 长汀县| 汕尾市| 米易县| 轮台县| 怀仁县| 上虞市| 镇赉县| 泗阳县| 盱眙县| 吕梁市| 乐亭县| 北宁市| 玉树县| 甘孜县| 鹤壁市| 黄山市| 海城市| 中卫市| 郑州市| 磴口县| 白银市| 德保县| 天气| 冷水江市| 南丰县| 仁怀市| 堆龙德庆县| 平南县| 临城县| 汶上县| 巴南区| 兴业县| 沙坪坝区|