在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > MEGA16游戲開發(fā)板驅(qū)動(dòng)

            MEGA16游戲開發(fā)板驅(qū)動(dòng)

            作者: 時(shí)間:2016-11-24 來(lái)源:網(wǎng)絡(luò) 收藏
            #include
            #include
            #define uchar unsigned char
            #define uint unsigned int
            #pragma interrupt_handler power_off:2
            #define EN_ PORTB&=~BIT(2)
            #define EN PORTB|=BIT(2)
            #define LE PORTB|=BIT(3) //高電平選通573
            #define LE_ PORTB&=~BIT(3) //低電平鎖存573
            #define LEDEN PORTB|=BIT(4) //高電平選通led10
            #define LEDEN_ PORTB&=~BIT(4)//低電平禁止led10
            #define RONCS PORTB|=BIT(5) //高電平選通rom
            #define ROMCS_ PORTB&=~BIT(5) //低電平禁止rom
            #define KEYEN DDRD|=BIT(7) //高電平選通導(dǎo)航鍵盤
            #define KEYEN_ DDRD&=~BIT(7) //低電平禁止導(dǎo)航鍵盤
            #define MAC_ PORTD&=~BIT(0)//開啟蜂鳴器
            #define MAC PORTD|=BIT(0) //關(guān)閉蜂鳴器
            #define CE PORTD|=BIT(1)
            #define CE_ PORTD&=~BIT(1)
            #define IO PORTD|=BIT(2)
            #define IO_ PORTD&=~BIT(2)
            #define SCLK PORTD|=BIT(3)
            #define SCLK_ PORTD&=~BIT(3)
            #define DATC PORTC
            extern dat[]={1,9,3,7};
            uchar tab1[4][4][16]={
            {{"選項(xiàng)一:涂鴉板 "},{"選項(xiàng)二:搖獎(jiǎng)機(jī) "},{"選項(xiàng)四:貪吃蛇 "},{"選項(xiàng)三:退出游戲"}},
            {{"涂鴉板使用規(guī)則—"},{"移動(dòng)使用導(dǎo)航鍵 "},{"提放筆:按ok鍵"},{"返回請(qǐng)按:B 鍵"}},
            {{"搖獎(jiǎng)機(jī)使用規(guī)則—"},{" ok鍵開始 "},{" ok鍵停止 "},{"得分為最終停止值"}},
            {{"貪吃蛇使用規(guī)則—"},{"移動(dòng)使用導(dǎo)航鍵 "},{"結(jié)束游戲按:B鍵"},{"吃閃動(dòng)的點(diǎn)會(huì)變長(zhǎng)"}},
            };

            extern png[5][8]={
            {0x00,0x40,0x42,0x7E,0x7E,0x42,0x40,0x00},
            {0x0C,0x12,0x22,0x44,0x44,0x22,0x12,0x0C},
            {0x02,0x3E,0x42,0x40,0x40,0x42,0x3E,0x02},
            {0x00,0x04,0x02,0xA2,0x12,0x0C,0x00,0x00},
            {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
            };
            const xy[]={0x80,0x90,0x88,0x98};
            const xy3[]={0x83,0x93,0x8b,0x9b};
            const tuan[]={0x05,0x00,0x0e,0x0f};
            const tab_f[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xD8,0x80,0x90};
            const wela_f[]={0x01,0X02,0X04,0X08};
            uchar dat_yj=0,dat_yj1=99,ten_f=0;
            extern dat_d[]={2,0,1,1,10,1,1,10,1,9};
            extern time[]={1,2,10,0,0,10,0,0};
            extern tem[]={0,0,0,0};
            extern lum[]={0,0,0,0,0};
            extern vol[]={0,0,0,0};
            uchar dat_f=0x00,ILU=0,ILU1=0,tyx=0x00,tyy=0x00,tyb=0,yj_f=0,yj_y=0,yj_y1=0;
            uchar flag=0x00,flag_right=0x00,dat_k=0x00,sleep=0;//flag=0,主菜單,1涂鴉,2搖獎(jiǎng)機(jī),3音樂(lè)4電子書9關(guān)機(jī)
            void delay(uint zip)
            {
            zip=zip*10;
            while(zip--);
            }
            void delayms(uint zip)
            {
            uint rar;
            for(;zip>0;zip--)
            for(rar=600;rar>0;rar--);
            }
            void reset()//任何子程序退出處理
            {
            PORTA=0X00;
            DDRC=0X00;
            LE_;
            ROMCS_;
            LEDEN_;
            KEYEN_;
            PORTD|=BIT(7);
            }
            void dat_san()
            {
            dat[0]=dat_yj0/10;
            dat[1]=dat_yj;
            dat[2]=dat_yj10/10;
            dat[3]=dat_yj1;
            }
            void dat_show()
            {
            uchar i;
            DDRB=0XFF;LE;DDRC=0Xff;DDRA=0XFF;
            dat_san();
            for(i=0;i<4;i++)
            {
            LE;
            PORTA=wela_f[i];
            LE_;
            PORTA=0X00;
            PORTC=tab_f[dat[i]];
            delay(100);
            DATC=0Xff;
            }
            reset();
            }
            void write_com(uchar com)
            {
            PORTB&=~BIT(0);
            PORTB&=~BIT(1);
            LE;
            PORTA=com;
            LE_;
            PORTA=0X00;
            PORTB|=BIT(2);
            delay(1);
            PORTB&=~BIT(2);
            delay(3);
            }

            void write_dat(uchar dat)
            {
            PORTB|=BIT(0);
            PORTB&=~BIT(1);
            LE;
            PORTA=dat;
            LE_;
            PORTA=0X00;
            PORTB|=BIT(2);
            delay(1);
            PORTB&=~BIT(2);
            delay(3);
            }
            void init()
            {
            LE;
            write_com(0X38);//設(shè)置16*2顯示,5*7點(diǎn)陣,8位數(shù)據(jù)口
            delay(5);
            write_com(0X0c);//0000 1(100),開顯示,不顯光標(biāo),不閃光標(biāo)
            delay(5);
            write_com(0X06);//0000 01(10),指針加1,整屏不移
            delay(5);
            }
            void choose_flag()
            {
            uchar i;
            for(i=0;i<4;i++)
            {
            write_com(xy3[i]);
            delay(4);
            if(flag==i)write_dat(0x12);
            else write_dat(0x20);
            delay(5);
            }
            }
            void printf(uchar ovi)
            {
            uchar ovm,ovp;
            init();
            for(ovm=0;ovm<4;ovm++)
            {
            write_com(xy[ovm]);
            delay(5);
            for(ovp=0;ovp<16;ovp++)
            {
            write_dat(tab1[ovi][ovm][ovp]);
            delay(5);
            }
            }
            if(flag_right==0)choose_flag();
            reset();
            }
            void clean()
            {
            uchar pp,qq;
            init();
            for(pp=0;pp<4;pp++)
            {
            write_com(xy[pp]);
            delay(10);
            for(qq=0;qq<17;qq++)
            {
            write_dat(0x20);
            delay(6);
            }
            }
            delay(20);
            reset();
            }
            void init_128()
            {
            write_com(0x30);//基本指令集
            write_com(0x0f);//0000,1100 后兩位為設(shè)置光標(biāo)
            }
            void write_1302(uchar add,uchar dat)
            {
            uchar i;

            }
            uchar read_1302(uchar add)
            {
            uchar i,temp;

            return temp;
            }

            void init_130()
            {
            write_1302(0x84,0x00);
            write_1302(0x80,0x00);
            write_1302(0x90,0xa0);
            }
            void brush()
            {
            time[7]=read_1302(0x81);
            time[6]=read_1302(0x81)/16;
            time[4]=read_1302(0x83);
            time[3]=read_1302(0x83)/16;
            time[1]=read_1302(0x85);
            time[0]=read_1302(0x85)/16;
            dat_d[9]=read_1302(0x87)/16;
            dat_d[8]=read_1302(0x87);
            dat_d[6]=read_1302(0x89)/16;
            dat_d[5]=read_1302(0x89);
            dat_d[3]=read_1302(0x8d)/16;
            dat_d[2]=read_1302(0x8d);
            }
            void sends(uchar addxy,uchar *str)
            {
            uchar temp;
            init();
            write_com(xy[addxy-1]);
            temp=*str;
            while(temp!=0x00)
            {
            write_dat(temp);
            temp=*(++str);
            delay(4);
            }
            reset();
            }
            void ten_led(uchar t_f)
            {
            LE;
            DDRD&=~BIT(7);
            if(t_f>0)if(ten_f>9)ten_f=0;
            if(t_f<1)if(ten_f<1)ten_f=10;
            if(t_f<1)ten_f--;
            if(ten_f<8)PORTA=BIT(ten_f);
            DDRC=0XFF;
            if(ten_f==8)PORTC|=BIT(0);
            if(ten_f==9)PORTC|=BIT(1);
            PORTB|=BIT(4);
            if(t_f>0)ten_f++;

            delay(100);
            reset();
            }
            void png_show()
            {
            uchar i;
            const tab[]={0xfe,0xfd,0xfb,0xF7,0xef,0xdf,0xbf,0x7F};
            PORTC=0XFF;
            for(i=0;i<8;i++)
            {
            PORTB|=BIT(3);
            PORTA=tab[i];
            PORTB&=~BIT(3);
            PORTA=png[ILU][i];
            delay(250);
            PORTA=0X00;
            }
            if(flag_right==0)ILU1++;
            if(ILU1==400){ILU1=0;ILU++;}
            if(ILU>4)ILU=0;
            reset();
            }
            void printf1()
            {
            uchar i;
            LE;
            init_128();
            sends(0x80,"DATA:");
            for(i=0;i<10;i++)
            {
            write_dat(dat[i]+0x30);
            }
            sends(0x90,"TIME:");
            for(i=0;i<8;i++)
            {
            write_dat(time[i]+0x30);
            }
            sends(0x88,"LUMEN:");
            for(i=0;i<5;i++)
            {
            write_dat(lum[i]+0x30);
            }
            sends(0," lm");
            sends(0x98,"");
            for(i=0;i<4;i++)
            {
            write_dat(tem[i]+0x30);
            if(i==1)sends(0,".");
            }
            sends(0," ℃");
            for(i=0;i<4;i++)
            {
            write_dat(vol[i]+0x30);
            if(i==1)sends(0,".");
            }
            sends(0," V");
            reset();

            }
            void key_init()
            {
            LE;
            PORTA=0X00;
            LE_;
            KEYEN;
            PORTD&=~BIT(7);
            DDRC=0X00;
            PORTC=0XFF;
            }
            uchar diskey()
            {
            key_init();
            if(PINC==0XFF);
            else
            {
            MAC_;
            dat_k=PINC;
            while(PINC!=0XFF){{dat_show();png_show();};MAC;DDRC=0X00;key_init();};
            }
            reset();
            return dat_k;
            }
            void power_down()
            {
            delay(100);
            clean();
            sends(2," Good_bye!");
            sends(3,"Made_from_CuAuAl");
            PORTD|=BIT(5);
            OCR1A=90000;
            OCR1B=50;
            delayms(6000);
            PORTD&=~BIT(5);
            clean();
            asm("sleep");
            }

            上一頁(yè) 1 2 下一頁(yè)

            關(guān)鍵詞: MEGA16開發(fā)板驅(qū)

            評(píng)論


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

            關(guān)閉