cc1101初始化c语言程序,cc1101无线模块的程序及使用介绍

cc1101作为cc1100的升级版完全兼容也cc1100。

虽然有着超高的性价比但却不为大多数初学者所用究其主要原因是程序比较烦杂。

cc1101看似恐怖其实只是个纸老虎罢了,如果你真的了解了他其实他还是蛮可爱的。下面就为初学者做简单的介绍(如果你是大神就飞过)

全面的代码是对cc1101寄存器进行配置(可以不用管,开发是直接粘贴复制即可,如果你喜欢寻根究底的话可以查看1101的手册,不过有点多100多页对自己的耐心是个挑战希望你可以坚持),读者可以直接把本文拖到最下面我给大家介绍(有点长往下到最下面就ok)。

/***************************************************************************************************************************/

#include

#include

#define  INT8U  unsigned char

#define  INT16U  unsigned int

#define  WRITE_BURST      0x40      //连续写入

#define  READ_SINGLE      0x80      //读

#define  READ_BURST       0xC0      //连续读

#define  BYTES_IN_RXFIFO     0x7F        //接收缓冲区的有效字节数

#define  CRC_OK              0x80       //CRC校验通过位标志

//*****************************************************************************************

sbit  GDO0 =P1^3;

sbit  GDO2 =P3^2;

sbit MISO =P1^6;

sbit MOSI =P1^5;

sbit SCK  =P1^7;

sbit CSN  =P1^4;

//*****************************************************************************************

INT8U num=0;

//*****************************************************************************************

//*****************************************************************************************

INT8U PaTabel[8] = {0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60};

//*****************************************************************************************

INT8U seg[10]={0xC0,0xCF,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};         //0~~9段码

//*****************************************************************************************

void SpiInit(void);

void CpuInit(void);

void RESET_CC1100(void);

void POWER_UP_RESET_CC1100(void);

void halSpiWriteReg(INT8U addr, INT8U value);

void halSpiWriteBurstReg(INT8U addr, INT8U *buffer, INT8U count);

void halSpiStrobe(INT8U strobe);

INT8U halSpiReadReg(INT8U addr);

void halSpiReadBurstReg(INT8U addr, INT8U *buffer, INT8U count);

INT8U halSpiReadStatus(INT8U addr);

void halRfWriteRfSettings(void);

void halRfSendPacket(INT8U *txBuffer, INT8U size);

INT8U halRfReceivePacket(INT8U *rxBuffer, INT8U *length);

void UART_init();

//*****************************************************************************************

// CC1100 STROBE, CONTROL AND STATUS REGSITER

#define CCxxx0_IOCFG2       0x00        // GDO2 output pin configuration

#define CCxxx0_IOCFG1       0x01        // GDO1 output pin configuration

#define CCxxx0_IOCFG0       0x02        // GDO0 output pin configuration

#define CCxxx0_FIFOTHR      0x03        // RX FIFO and TX FIFO thresholds

#define CCxxx0_SYNC1        0x04        // Sync word, high INT8U

#define CCxxx0_SYNC0        0x05        // Sync word, low INT8U

#define CCxxx0_PKTLEN       0x06        // Packet length

#define CCxxx0_PKTCTRL1     0x07        // Packet automation control

#define CCxxx0_PKTCTRL0     0x08        // Packet automation control

#define CCxxx0_ADDR         0x09        // Device address

#define CCxxx0_CHANNR       0x0A        // Channel number

#define CCxxx0_FSCTRL1      0x0B        // Frequency synthesizer control

#define CCxxx0_FSCTRL0      0x0C        // Frequency synthesizer control

#define CCxxx0_FREQ2        0x0D        // Frequency control word, high INT8U

#define CCxxx0_FREQ1        0x0E        // Frequency control word, middle INT8U

#define CCxxx0_FREQ0        0x0F        // Frequency control word, low INT8U

#define CCxxx0_MDMCFG4      0x10        // Modem configuration

#define CCxxx0_MDMCFG3      0x11        // Modem configuration

#define CCxxx0_MDMCFG2      0x12        // Modem configuration

#define CCxxx0_MDMCFG1      0x13        // Modem configuration

#define CCxxx0_MDMCFG0      0x14        // Modem configuration

#define CCxxx0_DEVIATN      0x15        // Modem deviation setting

#define CCxxx0_MCSM2        0x16        // Main Radio Control State Machine configuration

#define CCxxx0_MCSM1        0x17        // Main Radio Control State Machine configuration

#define CCxxx0_MCSM0        0x18        // Main Radio Control State Machine configuration

#define CCxxx0_FOCCFG       0x19        // Frequency Offset Compensation configuration

#define CCxxx0_BSCFG        0x1A        // Bit Synchronization configuration

#define CCxxx0_AGCCTRL2     0x1B        // AGC control

#define CCxxx0_AGCCTRL1     0x1C        // AGC control

#define CCxxx0_AGCCTRL0     0x1D        // AGC control

#define CCxxx0_WOREVT1      0x1E        // High INT8U Event 0 timeout

#define CCxxx0_WOREVT0      0x1F        // Low INT8U Event 0 timeout

#define CCxxx0_WORCTRL      0x20        // Wake On Radio control

#define CCxxx0_FREND1       0x21        // Front end RX configuration

#define CCxxx0_FREND0       0x22        // Front end TX configuration

#define CCxxx0_FSCAL3       0x23        // Frequency synthesizer calibration

#define CCxxx0_FSCAL2       0x24        // Frequency synth

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值