⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fasong.lst

📁 NRF905无线收发模块详细资料
💻 LST
字号:
C51 COMPILER V7.06   FASONG                                                                04/11/2008 22:27:37 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE FASONG
OBJECT MODULE PLACED IN Fasong.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Fasong.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include <reg52.h>
   2          #include <ABSACC.h>
   3          #include <intrins.h>
   4          #include <stdio.h>
   5          //--------------------------------------------------------------------------------------------------------
             ---------
   6          #define uint unsigned int
   7          #define uchar unsigned char
   8          //--------------------------------------------------------------------------------------------------------
             ---------
   9          #define BYTE_BIT0       0x01
  10          #define BYTE_BIT1       0x02
  11          #define BYTE_BIT2       0x04
  12          #define BYTE_BIT3       0x08
  13          #define BYTE_BIT4       0x10
  14          #define BYTE_BIT5       0x20
  15          #define BYTE_BIT6       0x40
  16          #define BYTE_BIT7       0x80
  17          bdata unsigned  char DATA_BUF;
  18          #define DATA7   ((DATA_BUF&BYTE_BIT7) != 0)
  19          #define DATA0   ((DATA_BUF&BYTE_BIT0) != 0)
  20          sbit    flag    =DATA_BUF^7;
  21          sbit    flag1   =DATA_BUF^0;
  22          //--------------------------------------------------------------------------------------------------------
             ---------
  23          #define TxRxBuf_Len 4
  24          unsigned char TxRxBuf[TxRxBuf_Len]=
  25          {
  26          0x29,0x30,0x31,0x32,
  27          };
  28          //--------------------------------------------------NRF905端口配置----------------------------------------
             ---------
  29          sbit    TXEN=P1^0;
  30          sbit    TRX_CE=P3^4;
  31          sbit    PWR=P1^1;
  32          sbit    MISO=P1^6;
  33          sbit    MOSI=P1^5;
  34          sbit    SCK=P1^7;
  35          sbit    CSN=P1^3;
  36          sbit    AM=P1^4;
  37          sbit    DR=P3^2;
  38          sbit    CD=P1^2;
  39          //---------------------------------------------------NRF905寄存器配置-------------------------------------
             ---------------
  40          unsigned char idata RFConf[11]=
  41          {
  42            0x00,                             //配置命令//
  43            0x4c,                             //CH_NO,配置频段在423MHZ
  44            0x0C,                             //输出功率为10db,不重发,节电为正常模式
  45            0x44,                             //地址宽度设置,为4字节
  46            0x04,0x04,                        //接收发送有效数据长度为32字节
  47            0xCC,0xCC,0xCC,0xCC,              //接收地址
  48            0x58,                              //CRC充许,8位CRC校验,外部时钟信号不使能,16M晶振
  49          };
  50          code TxAddress[4]={0xcc,0xcc,0xcc,0xcc};
C51 COMPILER V7.06   FASONG                                                                04/11/2008 22:27:37 PAGE 2   

  51          //----------------------------------------------------NRF905控制指令--------------------------------------
             ---------
  52          #define WC              0x00
  53          #define RC              0x10
  54          #define WTP             0x20
  55          #define RTP             0x21
  56          #define WTA             0x22
  57          #define RTA             0x23
  58          #define RRP             0x24
  59          //----------------------------------------------------延时------------------------------------------------
             -------
  60          static void Delay(uchar n)
  61          {
  62   1              uint i;
  63   1              while(n--)
  64   1              for(i=0;i<80;i++);
  65   1      }
  66          //---------------------------------------------------SPI写函数--------------------------------------------
             ---------
  67          void SpiWrite(unsigned char send)
  68          {
  69   1              unsigned char i;
  70   1              DATA_BUF=send;
  71   1              for (i=0;i<8;i++)
  72   1              {
  73   2                      if (DATA7)      //总是发送最高位
  74   2                      {
  75   3                              MOSI=1;
  76   3                      }
  77   2                      else
  78   2                      {
  79   3                              MOSI=0;
  80   3                      }
  81   2                      SCK=1;
  82   2                      DATA_BUF=DATA_BUF<<1;
  83   2                      SCK=0;
  84   2              }
  85   1      }
  86          //---------------------------------------------------初始化nRF905状态-------------------------------------
             -------------
  87          void nRF905Init(void)
  88          {
  89   1          CSN=1;                                              // Spi  disable
  90   1              SCK=0;                                          // Spi clock line init low
  91   1              DR=0;                                           // Init DR for input
  92   1              AM=0;                                           // Init AM for input
  93   1              CD=0;                                           // Init CD for input
  94   1              PWR=1;                                  // nRF905 power on
  95   1              TRX_CE=0;                                       // Set nRF905 in standby mode
  96   1              TXEN=0;                                 // set radio in Rx mode
  97   1      }
  98          //---------------------------------------------------初始化NRF905寄存器-----------------------------------
             ----------
  99          void Config905(void)
 100          {
 101   1              uchar i;
 102   1              CSN=0;                                          // Spi enable for write a spi command
 103   1              //SpiWrite(WC);                         // Write config command写放配置命令
 104   1              for (i=0;i<11;i++)      // Write configration words  写放配置字
 105   1              {
 106   2                 SpiWrite(RFConf[i]);
 107   2              }
C51 COMPILER V7.06   FASONG                                                                04/11/2008 22:27:37 PAGE 3   

 108   1              CSN=1;                                  // Disable Spi
 109   1      }
 110          //----------------------------------------------------数据打包--------------------------------------------
             ---------------------
 111          void TxPacket(void)
 112          {
 113   1              uchar i;
 114   1              //Config905();
 115   1              CSN=0;
 116   1              SpiWrite(WTP);                          // Write payload command
 117   1              for (i=0;i<4;i++)
 118   1              {
 119   2                      SpiWrite(TxRxBuf[i]);           // Write 32 bytes Tx data
 120   2              }// Spi enable for write a spi command
 121   1              CSN=1;
 122   1              Delay(1);                                               // Spi disable
 123   1              CSN=0;                                          // Spi enable for write a spi command
 124   1              SpiWrite(WTA);                          // Write address command
 125   1              for (i=0;i<4;i++)                       // Write 4 bytes address
 126   1              {
 127   2                      SpiWrite(TxAddress[i]);
 128   2              }
 129   1              CSN=1;                                          // Spi disable
 130   1              TRX_CE=1;                                       // Set TRX_CE high,start Tx data transmission
 131   1              Delay(1);                                       // while (DR!=1);
 132   1              TRX_CE=0;                                       // Set TRX_CE low
 133   1      }
 134          //----------------------------------------------------设置发送状态----------------------------------------
             ----------
 135          void SetTxMode(void)
 136          {
 137   1              TRX_CE=0;
 138   1              TXEN=1;
 139   1              Delay(1);                                       // delay for mode change(>=650us)
 140   1      }
 141          //-----------------------------------------------------数据发送-------------------------------------------
             ---------
 142          void TX(void)
 143          {
 144   1          SetTxMode();// Set nRF905 in Tx mode
 145   1              TxPacket();// Send data by nRF905
 146   1              // SetRF_PA_PWR(unsigned char i);       //设置发射功率
 147   1      }
 148          void main(void)
 149          {
 150   1              nRF905Init();
 151   1              Config905();
 152   1              while(1)
 153   1                      {
 154   2               TX();
 155   2                      }
 156   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    192    ----
   CONSTANT SIZE    =      8    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      5    ----
   IDATA SIZE       =     11    ----
   BIT SIZE         =   ----    ----
C51 COMPILER V7.06   FASONG                                                                04/11/2008 22:27:37 PAGE 4   

END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -