<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > A7105(2.4G)與STC89C52單片機(jī)無線收發(fā)程序(發(fā)射程序)

          A7105(2.4G)與STC89C52單片機(jī)無線收發(fā)程序(發(fā)射程序)

          作者: 時(shí)間:2016-11-27 來源:網(wǎng)絡(luò) 收藏

          void Init_A7105(void)
          {
          SCK=0;
          SDIO=1;
          SCS=1;
          GPIO1=1;
          A7105_Reset_Chip();
          //delay_us(50000);
          A7105_Write_ID();
          A7105_Config_Chip();
          A7105_Calibration();
          }

          void A7105_Entry_Stdy(void)
          {
          A7105_Write_Command(CMD_STBY);
          }

          void A7105_Setup_Wpll(void)
          {
          A7105_Write_Command(CMD_PLL);
          }

          void A7105_Setup_Channel(uchar ch)
          {
          A7105_Write_Register(PLL1_REG,ch);
          }

          void A7105_Entry_RX(void)
          {
          A7105_Write_Command(CMD_RX);
          }

          void A7105_Entry_TX(void)
          {
          A7105_Write_Command(CMD_TX);
          }

          void A7105_Reset_Chip(void)
          {
          A7105_Write_Register(MODE_REG,0x00);
          }

          void A7105_Reset_RX_FIFO(void)
          {
          A7105_Write_Command(CMD_RX_FIFO_RESET);
          }

          void A7105_Reset_TX_FIFO(void)
          {
          A7105_Write_Command(CMD_TX_FIFO_RESET);
          }
          void Write_Register(uchar bits,uchar value)
          {
          uchar i;
          for(i=0;i{
          if(value&0x80)
          SDIO=1;
          else
          SDIO=0;
          SCK=1;
          value<<=0x01;
          SCK=0;

          }
          }
          uchar Read_Register(void)
          {
          uchar i,temp=0;
          SDIO=1;
          for(i=0;i<8;i++)
          {
          if(SDIO)
          temp=(temp<<1)|0x01;
          else
          temp<<=0x01;
          SCK=1;
          SCK=0;
          }
          return temp;
          }

          void A7105_Write_Command(uchar cmd)
          {
          SCS=0;
          Write_Register(0x04,cmd);
          SCS=1;
          }

          void A7105_Write_Register(uchar addr,uchar value)
          {
          SCS=0;
          addr|=0x00;
          Write_Register(0x08,addr);
          Write_Register(0x08,value);
          SCS=1;
          }

          uchar A7105_Read_Register(uchar addr)
          {
          uchar temp=0;
          SCS=0;
          addr|=0x40;
          Write_Register(0x08,addr);
          temp=Read_Register();
          SCS=1;
          return temp;
          }
          void A7105_Write_ID(void)
          {
          SCS=0;
          Write_Register(0x08,ID_DATA_REG);

          Write_Register(0x08,ID_CODE0);
          Write_Register(0x08,ID_CODE1);
          Write_Register(0x08,ID_CODE2);
          Write_Register(0x08,ID_CODE3);
          SCS=1;

          A7105_Read_ID(Read_ID);
          }

          void A7105_Read_ID(uchar *read_prt)
          {
          SCS=0;
          Write_Register(0x08,(ID_DATA_REG|0x40));
          SDIO=1;
          *read_prt++=Read_Register();
          *read_prt++=Read_Register();
          *read_prt++=Read_Register();
          *read_prt++=Read_Register();
          SCS=1;
          }


          void A7105_Write_DATA_To_FIFO(void)
          {
          uchar i=0;
          SCS=0;
          Write_Register(0x08,FIFO_DATA_REG);
          for(i=0;i{
          LED=~LED;
          Write_Register(0x08,LED_BIT[i]);
          }
          SCS=1;
          }

          void A7105_Calibration(void)
          {
          uchar temp;
          uchar fb,fbcf;
          A7105_Entry_Stdy();//校準(zhǔn)必須在待機(jī)模式下進(jìn)行
          A7105_Write_Register(CALIBRATION_REG,0x01);
          do
          {
          temp=A7105_Read_Register(CALIBRATION_REG);
          temp&=0x01;
          }while(temp);
          temp=A7105_Read_Register(IF_CALIBRATION1_REG);
          fb=temp&0x0f;
          fbcf=(temp>>4)&0x01;
          if(fbcf==1)
          {
          ;
          }
          A7105_Write_Register(VCO_CURRENT_CAL_REG,0x13);
          A7105_Write_Register(VCO_SINGLE_BAND_CAL1_REG,0x09);

          }

          void A7105_Config_Chip(void)
          {
          uchar i;

          //0x00 mode register, for reset
          //0x05 fifo data register
          //0x06 id code register
          //0x23 IF calibration II, only read
          //0x32 filter test register

          for(i=0x01;i<=0x04;i++)
          A7105_Write_Register(i,A7105_Default_Par[i]);
          for(i=0x07;i<=0x22;i++)
          A7105_Write_Register(i,A7105_Default_Par[i]);
          for(i=0x24;i<=0x31;i++)
          A7105_Write_Register(i,A7105_Default_Par[i]);
          }

          void main(void)
          {
          P0=0xff;
          P1=0xff;
          P2=0xff;
          P3=0xff;
          Init_A7105();
          delay_ms(50);
          A7105_Entry_Stdy();
          A7105_Write_DATA_To_FIFO();

          while(1)
          {

          A7105_Setup_Channel(100);
          A7105_Setup_Wpll();
          A7105_Entry_TX();
          delay_us(150);
          while(GPIO1);
          }
          }


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

          評(píng)論


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

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();