资源简介

si4432驱动程序包括 发送 接收 切换

资源截图

代码片段和文件信息


#include “stm32f10x.h“
#include “spi_rf.h“
#include “spi.h“

#define  TX1_RX0 spi_write(0x0e|0x80 0x01) // 发射状态的天线开关定义
#define  TX0_RX1 spi_write(0x0e|0x80 0x02) // 接收状态的天线开关定义
#define  TX0_RX0 spi_write(0x0e|0x80 0x00)         // 非发射,接收状态的天线开关定义


static unsigned char tx_data[5] = {0x050x000x000x000x00};  
extern unsigned char   RF_Flag; 
unsigned char ReadBuffer[5] = {0x000x000x000x000x00};
unsigned char num = 0;
unsigned char tmp;
unsigned char speed=0x15;
unsigned char vol = 0x55;
void Spi_Rf_Init(void)

    TX0_RX0;
   
      spi_write(0x030x00); //清掉现有的中断标志
      spi_write(0x040x00); //清掉现有的中断标志
 
      spi_write(0x06 0x00);      //Interrupt Enable 2
      spi_write(0x07SI4432_PWRSTATE_READY);// 进入 Ready 模式
      spi_write(0x09|0x80 0x7f);  //  负载电容= 12P
      
      spi_write(0x0a|0x80 0x05); // 关闭低频输出
      spi_write(0x0b|0x80 0xea); // GPIO 0 当做普通输出口
      spi_write(0x0c|0x80 0xea); //GPIO 1 当做普通输出口
      
      spi_write(0x0d|0x80 0xf4);  // /GPIO 2 输出收到的数据
      
      
      
      spi_write(0x70|0x80 0x2c);  
      spi_write(0x1d|0x80 0x40);  // 使能 afc
      
      // 1.2K bps setting
      spi_write(0x1c|0x80 0x16); // 下面的设置根据Silabs 的Excel
      
      
      spi_write(0x20|0x80 0x83);   
      
      spi_write(0x21|0x80 0xc0); //
      spi_write(0x22|0x80 0x13);// 
      spi_write(0x23|0x80 0xa9); //
      spi_write(0x24|0x80 0x00); //
      spi_write(0x25|0x80 0x04); //
      
      spi_write(0x2a|0x80 0x14);
      spi_write(0x6e|0x80 0x09);
      spi_write(0x6f|0x80 0xd5);
      
      //1.2K bps setting end
      
      
      spi_write(0x30|0x80 0x8c);   // 使能PH+ FIFO模式,高位在前面,使能CRC校验
      
      
      spi_write(0x32|0x80 0xff);  // byte0 123 作为头码
      
      spi_write(0x33|0x80 0x42);//  byte 0123 是头码,同步字32 是同步字
      
      
      
      spi_write(0x34|0x80 16);  // 发射16个Nibble的Preamble
      spi_write(0x35|0x80 0x20);  // 需要检测4个nibble的Preamble
      spi_write(0x36|0x80 0x2d);  // 同步字为 0x2dd4
      spi_write(0x37|0x80 0xd4);
      spi_write(0x38|0x80 0x00);
      spi_write(0x39|0x80 0x00);
      spi_write(0x3a|0x80 ‘s‘);  // 发射的头码为: “swwx“
      spi_write(0x3b|0x80 ‘w‘);
      spi_write(0x3c|0x80 ‘w‘);
      spi_write(0x3d|0x80 ‘x‘);
      spi_write(0x3e|0x80 5);  // 总共发射10个字节的数据
      spi_write(0x3f|0x80 ‘s‘); // 需要校验的头码为:”swwx“
      spi_write(0x40|0x80 ‘w‘);
      spi_write(0x41|0x80 ‘w‘);
      spi_write(0x42|0x80 ‘x‘);
      spi_write(0x43|0x80 0xff);  // 头码1234 的所有位都需要校验
      spi_write(0x44|0x80 0xff);  // 
      spi_write(0x45|0x80 0xff);  // 
      spi_write(0x46|0x80 0xff);  // 
      spi_write(0x6d|0x80 0x07);  // 设置为最大功率发射
      
      spi_write(0x79|0x80 0x0);  // 不需要跳频
      spi_write(0x7a|0x80 0x0);  // 不需要跳频
      
      
      spi_write(0x71|0x80 0x22); // 发射不需要 CLK,FiFo , FSK模式
      
      spi_write(0x72|0x80 0x30);  // 频偏为 30KHz
    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5768  2012-09-18 11:37  Spi_Rf\spi_rf.c

     文件        541  2012-05-16 15:22  Spi_Rf\spi_rf.h

     目录          0  2012-05-16 15:17  Spi_Rf

----------- ---------  ---------- -----  ----

                 6309                    3


评论

共有 条评论