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

📄 tx.c

📁 CC1100_CC2500_Examples_Libraries_1_31
💻 C
字号:
/*******************************************************************************************************
 *                                                                                                     *
 *        **********                                                                                   *
 *       ************                                                                                  *
 *      ***        ***                                                                                 *
 *      ***   +++   ***                                                                                *
 *      ***   + +   ***     This file contains all functions related to packet transmission in the     *
 *      ***   +             Link1 example                                                              *
 *      ***   + +   ***                                                                                *
 *      ***   +++   ***     Tx.c                                                                       *
 *      ***        ***                                                                                 *
 *       ************                                                                                  *
 *        **********                                                                                   *
 *                                                                                                     *
 *******************************************************************************************************
 * Compiler:                Keil C51 V7.50                                                             *
 * Target platform:         Chipcon CCxxx0 (Silabs F320)                                               *
 * Author:                  SNA                                                                        *
 *******************************************************************************************************
 *                                                                                                     *
 ******************************************************************************************************/
#include <Chipcon\srf04\regssrf04.h>
#include <Chipcon\srf04\halsrf04.h>
#include <Chipcon\srf04\ebsrf04.h>
#include <stdlib.h>
#include <Link1.h>




//-------------------------------------------------------------------------------------------------------
//  void createDataPacket(void) 
//
//  DESCRIPTION: 
//      This function is called before a packet is going to be transmitted.
//      Packet format:
//
//  |----------------------------------------------------------------------------------------------------
//  |              |               |             |             |            |             |             |
//  | Length field | Address Field | Random Data | Random Data |............| Random Data | Random Data |
//  |              |               |             |             |            |             |             |
//  |----------------------------------------------------------------------------------------------------
//          ^             ^               ^                                                      ^
//          |             |               |                                                      |
//     rxBuffer[0]    rxBuffer[1]    rxBuffer[2]                          rxBuffer[menuData.packetLength]
//-------------------------------------------------------------------------------------------------------
void createDataPacket(void) {
    UINT16 xdata i;

    txBuffer[0] = menuData.packetLength;
    txBuffer[1] = ADDR;
    for (i = 2; i <= menuData.packetLength; i++)
        txBuffer[i] = rand();    
} //createDataPacket




//-------------------------------------------------------------------------------------------------------
//  void pktStartTx(UINT16 timeout)
//
//  DESCRIPTION:
//      This function should be called every time the radio shall enter TX mode.
//      The data that shall be transmitted must be placed in txBuffer before this function is being
//      called. The function also updates some variables related to the TX timeout. 
//
//  ARGUMENTS:
//      UINT16 timeout
//          The timeout variable determine the delay before the radio enters TX mode.
//          TX Timeout [ms] = timeout * 200 us
//          Min TX Timeout: 0 ms
//          Max TX Timeout: 13107 ms
//-------------------------------------------------------------------------------------------------------
void pktStartTx(UINT16 timeout) {
    pktData.txPosition = 1; // Skip the length byte, which is handled separately
    pktData.txBytesLeft = pktData.pTxBuffer[0];
    pktData.txStartupTimeout = timeout;
    pktData.txStartupTimeoutActive = TRUE;
}// pktStartTx




//-------------------------------------------------------------------------------------------------------
//  BYTE pktTxHandler(void)
//
//  DESCRIPTION:
//      This function is called every time a timer1 interrupt occurs (every 200 us). The function starts
//      with timeout handling and continues by getting the status byte. A counter, 
//      pktData.txStartupTimeout, has an initial value timeout (see pktStartTx) and is decremented each
//      time this function is called until it reaches 0 => strobe TX
//      Every time the satus byte indicates that there is free space in the TX FIFO, bytes are taken from
//      txBuffer and written to the TX FIFO until the whole packet is written (pktData.txBytesLeft = 0 
//      and pktData.pktTransmitted = TRUE). When the status byte indicates that the radio has gone back 
//      to IDLE state, the pktData.txInProgress flag is cleared to notify the application that the 
//      transmission is completed. Please see the 
//      SmartRF

⌨️ 快捷键说明

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