基于MSP430單片機驅動NRF24L01無線模塊接收C語言程序 作者: 時間:2016-11-30 來源:網絡 加入技術交流群 掃碼加入和技術大咖面對面交流海量資料庫查詢 收藏 ////////////////////////////////////////////// for(i=0;i<4;i++) //發(fā)送低4位{if((b&0x08)?1:0) //1LCD_D_1; //data=1;elseLCD_D_0; //data=0;LCD_CLK_0; //clk=0LCD_CLK_1; ; //clk=1b=b<<1;}LCD_D_0; //data=0;for(i=0;i<4;i++) //RS,RW,0 發(fā)送4個0;{LCD_CLK_0; //clk=0LCD_CLK_1; ; //clk=1} LCD_CS_1; //cs=1;Delayus(15);}void CLEAR(){Write_command(0x30);Write_command(0x01);Write_command(0x34);Write_command(0x30);}void drclear(void){//以下是清繪畫RAMuchar i,j;Write_command(0x34);for(j=0;j<32;j++){for(i=0;i<32;i++){tu[i][j]=0x00;}} for(j=0;j<32;j++){for(i=0;i<16;i++){tu[i][j]=0x00;Write_command(0x80+j); //設定垂直坐標Write_command(0x80+i); //設定水平坐標Write_data(0x00); //放入數據高字節(jié)Write_data(0x00); //放入數據低字節(jié)}} }void LCD_Init(){LCD_RST_0; //rst=0Delayus(100);LCD_RST_1; //rst=1Delayus(100);Write_command(0x30);Delayus(20);Write_command(0x30);Delayus(20);Write_command(0x30);Write_command(0x30);//--------------Write_command(0x0c);//Write_command(0x0C);Delayus(10);Write_command(0x01);Delayus(20);Write_command(0x06);/*//以下是清繪畫RAMuchar i,j;Write_command(0x34);for(j=0;j<32;j++){for(i=0;i<16;i++){Write_command(0x80+j); //設定垂直坐標Write_command(0x80+i); //設定水平坐標Write_data(0x00); //放入數據高字節(jié)Write_data(0x00); //放入數據低字節(jié)}} */}void writechar(uchar x, uint chinese){Write_command(0x30);Write_command(x);Write_data(chinese);}void writechinese(uchar x,const char *p){uint i;i=strlen(p);Write_command(x);for(;i;i--)Write_data(*(p++)); }void hexdisp(uchar f1){Write_data(0+f1+7*(f1/10));}void hex4(uint f2){uchar f1;f1=(f2&0xf000)>>12;hexdisp(f1);f1=(f2&0x0f00)>>8;hexdisp(f1);f1=(f2&0xf0)>>4;hexdisp(f1);f1=f2&0x0f;hexdisp(f1);}void liney(uchar x,uchar y,uchar l) //在(x,y)向下開始顯示長度為l(<=16)的豎線{uchar l1,i;uint x1=0x00,x2=0x00,ix=x/16;l1=x-ix*16;if (l1<8){x1=0x80>>l1;}else{x2=0x80>>(l1-8);}for (i=0;i>(l1+l2);x1=x1<>l1;x2=0xff<>(l2+l1-8);x2=x2<>l1;x2=0xff;}else{l2=l1-8;x1=0x00;x2=0xff>>l2;}if(l+l1<=24){l2=24-l-l1;x3=0xff<0;k--){c^=a&0x0001; //奇偶校驗a=a>>1;}buffer=buffer|c;return buffer;}/******************************************************************///收發(fā)void send_bit1(){send_1;Delayus(500);send_0;Delayus(500);}void send_bit0(){send_0;Delayus(1000);}void send_data(){int k;ulong buffer2;buffer2=convert();for(k=16;k>0;k--)//發(fā)送數據位{if(buffer2&0x01==0x01)send_bit1();elsesend_bit0();buffer2=buffer2>>1;}}void send_adrs(uint z){ int k;uint buffer1=z;for(k=16;k>0;k--)//發(fā)送地址位{if(buffer1&0x01==0x01)send_bit1();elsesend_bit0();buffer1=buffer1>>1;}} 上一頁 1 2 3 下一頁
評論