如同用CC1101的朋友好少,在此也贴上CC1101收发程序吧!这样会削减我们很多时刻去调试。不多说了直接上程序了:
#include
#include
#define IOCFG2
#define IOCFG1
#define IOCFG0
#define FIFOTHR
#define SYNC1
#define SYNC0
#define PKTLEN
#define PKTCTRL1
#define PKTCTRL0
#define ADDR
#define CHANNR
#define FSCTRL1
#define FSCTRL0
#define FREQ2
#define FREQ1
#define FREQ0
#define MDMCFG4
#define MDMCFG3
#define MDMCFG2
#define MDMCFG1
#define MDMCFG0
#define DEVIATN
#define MCSM2
#define MCSM1
#define MCSM0
#define FOCCFG
#define BSCFG
#define AGCCTRL2
#define AGCCTRL1
#define AGCCTRL0
#define WOREVT1
#define WOREVT0
#define WORCTRL
#define FREND1
#define FREND0
#define FSCAL3
#define FSCAL2
#define FSCAL1
#define FSCAL0
#define RCCTRL1
#define RCCTRL0
#define FSTEST
#define PTEST
#define AGCTEST
#define TEST2
#define TEST1
#define TEST0
#define SRES
#define
#define SXOFF
#define SCAL
#define SRX
#define STX
#define SIDLE
#define SAFC
#define SWOR
#define SPWD
#define SFRX
#define SFTX
#define SWORRST
#define SNOP
#define PARTNUM
#define VERSION
#define FREQEST
#define LQI
#define RSSI
#define MARCSTATE
#define WORTIME1
#define WORTIME0
#define PKTSTATUS
#define VCO_VC_DAC
#define TXBYTES
#define RXBYTES
#define PATABLE
#define TX_FIFO
#define RX_FIFO
#define data_len
typedef
typedef
uchar rx_buffer[data_len]={0,0,0,0,0,0,0,0};//rx data
//uchar RX_data[data_len];
uchar code tx_buffer[data_len]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//tx data
uchar data_length=0;
uchar code P_Config[]={0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0};//功率装备
sbit CSN=P2^1;
sbit SCLK=P2^7;
sbit SI=P2^2;
sbit SO=P2^0;
sbit GDO0=P2^6;
sbit key=P2^5;
sbit LED=P0^0;
//sbit LED1=P0^6;
void CC1101_Init(void);
void CC1101_RESET(void);
void POWER_UP_RESET(void);
uchar SPI_WR_Byte(uchar value);
void SPI_Write_Byte(uchar addr,uchar value);
uchar SPI_Read_Byte(uchar addr);
void SPI_Write_Strobe(uchar strobe);
void SPI_Write_Burst(uchar addr,uchar *buffer,uchar count);
void SPI_Read_Burst(uchar addr,uchar *buffer,uchar count);
void SPI_Write_Packet(uchar *TX_Buffer,uchar size);
uchar SPI_Read_Packet(uchar *RX_Buffer,uchar length);
void CC1101_Set_TX(void);
void CC1101_Set_RX(void);
void Write_Config(void);
void delay_ms(uint x)
{
}
void delay_us(uint x)
{
}
//————————————————/
//函数功用:经过SPI写读一字节
//输入参数:value
//输出参数:B_value
//———————————————–/
uchar SPI_WR_Byte(uchar value)
{
}
//————————————————-/
//函数功用:重置CC1101
//输入参数:无
//输出参数:无
//———————————————-/
void CC1101_RESET(void)
{
}
//———————————————–/
//函数功用:CC1101上电重置
//输入参数:无
//输出参数:无
//——————————————–/
void POWER_UP_RESET(void)
{
}