www.pudn.com > M8_cc1100_receive.rar > cc1100.c


/*C************************************************************************** 
* NAME:         cc1100.c 
*---------------------------------------------------------------------------- 
* Copyright (c) 2007 endylu 
*---------------------------------------------------------------------------- 
* RELEASE:      M8-cc1100 
* REVISION:     1.0      
*---------------------------------------------------------------------------- 
* PURPOSE: 
* This file include cc1100 receive and send function 
*****************************************************************************/ 
 
/*_____ I N C L U D E S ____________________________________________________*/ 
 
#include  
#include  
#include "main.h" 
/*_____ M A C R O S ________________________________________________________*/ 
 
 
/*_____ D E F I N I T I O N ________________________________________________*/ 
 
 
//------------------------------------------------------------------------------------------------------ 
// Chipcon 
// Product = CC1100 
// Chip version = E 
// Crystal accuracy = 40 ppm 
// X-tal frequency = 26 MHz 
// RF output power = 0 dBm 
// RX filterbandwidth = 540.000000 kHz 
// Deviation = 0.000000  
// Datarate = 250.000000 kbps 
// Modulation = (7) MSK 
// Manchester enable = (0) Manchester disabled 
// RF Frequency = 433.000000 MHz 
// Channel spacing = 199.951172 kHz 
// Channel number = 0 
// Optimization = Sensitivity 
// Sync mode = (3) 30/32 sync word bits detected 
// Format of RX/TX data = (0) Normal mode, use FIFOs for RX and TX 
// CRC operation = (1) CRC calculation in TX and CRC check in RX enabled 
// Forward Error Correction = (0) FEC disabled 
// Length configuration = (1) Variable length packets, packet length configured by the first received byte after sync word. 
// Packetlength = 255 
// Preamble count = (2)  4 bytes 
// Append status = 1 
// Address check = (0) No address check 
// FIFO autoflush = 0 
// Device address = 0 
// GDO0 signal selection = ( 6) Asserts when sync word has been sent / received, and de-asserts at the end of the packet 
// GDO2 signal selection = (11) Serial Clock 
const RF_SETTINGS rfSettings = { 
    0x00, 
    0x02,   // FSCTRL1   Frequency synthesizer control. 
    0x00,   // FSCTRL0   Frequency synthesizer control. 
    0x10,   // FREQ2     Frequency control word, high byte. 
    0x33,   // FREQ1     Frequency control word, middle byte. 
    0x62,   // FREQ0     Frequency control word, low byte. 
    0x2D,   // MDMCFG4   Modem configuration. 
    0x3B,   // MDMCFG3   Modem configuration. 
    0x73,   // MDMCFG2   Modem configuration. 
    0xa2,   // MDMCFG1   Modem configuration. 
    0xF8,   // MDMCFG0   Modem configuration. 
 
    0x00,   // CHANNR    Channel number. 
    0x00,   // DEVIATN   Modem deviation setting (when FSK modulation is enabled). 
    0xB6,   // FREND1    Front end RX configuration. 
    0x10,   // FREND0    Front end RX configuration. 
    0x18,   // MCSM0     Main Radio Control State Machine configuration. 
    0x1D,   // FOCCFG    Frequency Offset Compensation Configuration. 
    0x1C,   // BSCFG     Bit synchronization Configuration. 
    0xC7,   // AGCCTRL2  AGC control. 
    0x00,   // AGCCTRL1  AGC control. 
    0xB2,   // AGCCTRL0  AGC control. 
 
    0xEA,   // FSCAL3    Frequency synthesizer calibration. 
    0x0A,   // FSCAL2    Frequency synthesizer calibration. 
    0x00,   // FSCAL1    Frequency synthesizer calibration. 
    0x11,   // FSCAL0    Frequency synthesizer calibration. 
    0x59,   // FSTEST    Frequency synthesizer calibration. 
    0x88,   // TEST2     Various test settings. 
    0x31,   // TEST1     Various test settings. 
    0x0B,   // TEST0     Various test settings. 
    0x03,    //IOCFG2    GDO2 output pin configuration. 
    0x07,   // IOCFG0    GDO0 output pin configuration. Refer to SmartRF?Studio User Manual for detailed pseudo register explanation. 
 
    0x05,   // PKTCTRL1  Packet automation control. 
    0x45,   // PKTCTRL0  Packet automation control. 
    ID_Oneself,   // ADDR      Device address. 
    0xf0,    // PKTLEN    Packet length. 
}; 
 
/*_____ D E C L A R A T I O N ______________________________________________*/ 
 
 
 
//***************************************************************************************** 
//函数名:delay(unsigned int s) 
//输入:时间 
//输出:无 
//功能描述:普通廷时 
//*****************************************************************************************		 
void delay(unsigned int s) 
{ 
	unsigned int i; 
	for(i=0; i sync transmitted 
    while (!GDO0); 
     
    // Wait for GDO0 to be set - > sync transmitted  
    while (GDO0); 
     
	halSpiStrobe(CCxxx0_SFTX);        //清洗发送缓冲区 
	 
}