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

📄 main.c

📁 基于cc1010的设计实例
💻 C
字号:
/*****************************************************************************
 *                                                                           *
 *        **********                                                         *
 *       ************                                                        *
 *      ***        ***                                                       *
 *      ***   +++   ***                                                      *
 *      ***   + +   ***                                                      *
 *      ***   +                    CHIPCON CC1010 EXAMPLE PROGRAM            *
 *      ***   + +   ***               SIMPLE RX/TX SWITCHING                 *
 *      ***   +++   ***                                                      *
 *      ***       ***                                                        *
 *       ***********                                                         *
 *        *********                                                          *
 *                                                                           *
 *****************************************************************************
 * This program puts the CC1010 into RX mode, and configures the test MUX so *
 * that the raw output from the demodulator is available at pin 0.1 (DIO     *
 * connector on the evaluation board). This can be useful for diagnostics,   *
 * and is similar to the functionality implemented by SmartRF Studio.        *
 * When the 0_2 pin (testpin TP6 on the CC1010EM module) is shorted to       *
 * ground, the device goes into TX mode. Since the program functions on the  *
 * Evaluation Module indepentently of it being plugged into the Evaluation   *
 * Board, it is useful for doing testing using the module in a stand-alone   *
 * fashion.                                                                  *
 *****************************************************************************
 * Author:              KHT                                                  *
 *****************************************************************************
 * Revision history:                                                         *
 * 1.0  2002/08/29      First Public Release                                 *
 *                                                                           *
 * $Log: main.c,v $
 * Revision 1.2  2002/11/19 15:12:31  kht
 * Added startup macros
 *
 * Revision 1.1  2002/10/14 10:59:00  tos
 * Initial version in CVS.
 *
 *                                                                           *
 ****************************************************************************/

#include <chipcon/reg1010.h>
#include <chipcon/cc1010eb.h>
#include <chipcon/hal.h>



void main() {


// Note: Separation is set to zero for all RF settings, this is done so that the
// user can measure on an unmodulated carrier in TX mode

#ifdef FREQ868

// X-tal frequency: 14.745600 MHz
// RF frequency A: 868.277200 MHz	Rx
// RF frequency B: 868.277200 MHz	Tx
// RX Mode: Low side LO
// Frequency separation:  0 kHz
// Data rate: 2.4 kBaud
// Data Format: Manchester
// RF output power: 4 dBm
// IF/RSSI: RSSI Enabled

RF_RXTXPAIR_SETTINGS code RF_SETTINGS = {
    0x4B, 0x2F, 0x0F,    // Modem 0, 1 and 2
    0x75, 0xA0, 0x00,    // Freq A
    0x58, 0x33, 0x63,    // Freq B
    0x00, 0x00,          // FSEP 1 and 0
    0x40,                // PLL_RX
    0x30,                // PLL_TX
    0x6C,                // CURRENT_RX
    0xF3,                // CURRENT_TX
    0x32,                // FREND
    0xFF,                // PA_POW
    0x00,                // MATCH
    0x00,                // PRESCALER
    };

#endif

#ifdef FREQ915

// X-tal frequency: 14.745600 MHz
// RF frequency A: 915.027455 MHz	Rx
// RF frequency B: 915.027455 MHz	Tx
// RX Mode: Low side LO
// Frequency separation:  0 kHz
// Data rate: 2.4 kBaud
// Data Format: Manchester
// RF output power: 4 dBm
// IF/RSSI: RSSI Enabled

RF_RXTXPAIR_SETTINGS code RF_SETTINGS = {
    0x4B, 0x2F, 0x0F,    // Modem 0, 1 and 2
    0xAA, 0x80, 0x00,    // Freq A
    0x5C, 0xF4, 0xD7,    // Freq B
    0x00, 0x00,          // FSEP 1 and 0
    0x58,                // PLL_RX
    0x30,                // PLL_TX
    0x6C,                // CURRENT_RX
    0xF3,                // CURRENT_TX
    0x32,                // FREND
    0xFF,                // PA_POW
    0x00,                // MATCH
    0x00,                // PRESCALER
    };

#endif

#ifdef FREQ433

// X-tal frequency: 14.745600 MHz
// RF frequency A: 433.302000 MHz	Rx
// RF frequency B: 433.302000 MHz	Tx
// RX Mode: Low side LO
// Frequency separation:  0 kHz
// Data rate: 2.4 kBaud
// Data Format: Manchester
// RF output power: 10 dBm
// IF/RSSI: RSSI Enabled

RF_RXTXPAIR_SETTINGS code RF_SETTINGS = {
    0x4B, 0x2F, 0x0A,    // Modem 0, 1 and 2
    0x58, 0x00, 0x00,    // Freq A
    0x41, 0xFD, 0xDC,    // Freq B
    0x00, 0x00,          // FSEP 1 and 0
    0x60,                // PLL_RX
    0x48,                // PLL_TX
    0x44,                // CURRENT_RX
    0x81,                // CURRENT_TX
    0x0A,                // FREND
    0xFF,                // PA_POW
    0xC0,                // MATCH
    0x00,                // PRESCALER
    };

#endif

    
    // Used to keep track of which mode we're in
    char state;

    // Calibration data
    RF_RXTXPAIR_CALDATA xdata RF_CALDATA;

    
    

    // Disable watchdog timer
    WDT_ENABLE(FALSE);

    // Set optimum settings for speed and low power consumption
    MEM_NO_WAIT_STATES();
    FLASH_SET_POWER_MODE(FLASH_STANDBY_BETWEEN_READS);

    // Calibrate
    halRFCalib(&RF_SETTINGS, &RF_CALDATA);

    // Turn on RF for RX
    halRFSetRxTxOff(RF_RX, &RF_SETTINGS, &RF_CALDATA);

    // Set port 0 direction
    halSetPortDir(0, POUT);

    PORTDIRBIT(0,2,PIN);
    
    // Set up so that demodulator data is present on pin 0.1
    TESTMUX = 0x06;

    // Enable bitmode, start RX
    RF_SET_BITMODE();
    RF_START_RX();

    state=1;

    while (1) {
        if ((PORTBIT(0,2)==0)&&(state==1)) {
            // Switch from RX to TX
            halRFSetRxTxOff(RF_TX, &RF_SETTINGS, &RF_CALDATA);
            RF_START_TX();
            state=0;
        }

        if ((PORTBIT(0,2)==1)&&(state==0)) {
            // Switch from TX to RX
            halRFSetRxTxOff(RF_RX, &RF_SETTINGS, &RF_CALDATA);
            RF_START_RX();
            state=1;
        }
    }
}

⌨️ 快捷键说明

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