TI中文支持网
TI专业的中文技术问题搜集分享网站

CC1310: 配置为 4Mbps 模式, 执行无线发送 (发送完成了, 产生中断)。问题: 工作一段时间以后, 发送的无线信息, 可以被接收到; 但发送端, 不能获取对应的 中断了

Part Number:CC1310

将 CC1310 配置为 4Mbps 的速率, 编写 no-RTOS 代码, 执行 下面的 周期性 操作:(1) 休眠 500ms 以后, 执行 无线发送状态的 配置( RF_tran_init )
(2) 然后读取 传感器信息(16个字节), 执行 无线发送 ( RF_tran_op )
(3) 启动 无线发送的 操作了, 也启动 定时器 工作; ( wait_WLpkg_tran )
(4) 如果 在1ms 内就执行了 tx_callback 中断, 则进入 下面的步骤(6);
(5) 如果 定时器 已经计时超过 1ms 了, 也跳出 无线发送的 等待过程, 进入 下面的步骤(6)
(6) 判断 是否 已经执行了 5次 上面的 操作; 如果少于 5次, 则跳转到(2)接着执行; 否则 进入(7)
(7) 执行 休眠 500ms

附件 rf_tran 4Mbps.c 包含上面的 具体代码; 也包含 简化以后的 main() 函数。
对于 main() 函数中, 也调用了 rf_recv 功能 (对应的代码, 参见 附件 rf_recv.c)

每隔500ms, CC1310读取 传感器信息, 无线发送; 执行 5次。
使用 侦听器 (另外一个 CC1310 单板, 配置为 无线接收状态),  获取上述 5次无线发送的 信息, 也用定时器 获取 5个无线包 之间的 间隔。

刚开始工作的时候, 无线发送过程中, tx_callback 中断处理都很正常; 对于 5个无线包的 4个间隔, 都是 2.4ms 附近;
但是, 工作一段时间以后, 发送无线包的间隔, 都是 3.1ms 附近 —- 没有得到 tx_callback 中断处理; 那个 1ms 的定时器, 将 代码 '拽出了'   持续等待 tx_callback 中断的 那种状态。
备注: 侦听器 始终可以 完整 获取到 每个周期内的 5个 无线包。即, 无论是否 tx_callback 中断处理, 无线发送的操作, 都是顺利完成了, 可以被 无线接收到。

有时候, 持续工作十几个小时, 才出现上述 3.1ms 的问题;  有时候, 半个小时以后就出现 上述问题了。
出现上述问题以后, 不能自动恢复, 这个问题 会持续存在。 只有将 单板掉电重启, 才能恢复正常。 备注:上面的操作(1), 对 CC1310 执行 全部的、配置 4Mbps、执行 无线发送的、 初始化操作

上述 rf_tran 4Mbps.c 文件中, 将 CC1310 配置为 4Mbps 速率的代码, 都是参照 TI 例程 rfPacketErrorRate, 相应 '摘取' 得到。
请帮忙指点一下, 是否上述 代码中, 漏掉了 某个关键的 处理, 然后 导致 某种状态下, 触发了某种异常情况,   于是 无线包 成功发送了,   却 没有 能够 产生 tx_callback 中断?

rf_tran 4Mbps.c

#include <stdlib.h>
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
#include "Board.h"
#include "RFQueue.h"
#include <smartrf_settings/smartrf_settings.h>
#include <smartrf_settings/smartrf_settings_predefined.h>

/***** Defines *****/
#define NUM_DATA_ENTRIES1
#define NUM_APPENDED_BYTES0// -- For the HS command (6 bytes total):  packet length (2 bytes) + Timestamp (4 bytes)// -- For other Sub-1 GHz commands (6 bytes total): packet length (1 bytes) + Timestamp (4 bytes) + status (1 byte)// -- For 200 Kbps IEEE 802.15.4g commands (5 bytes total): Timestamp (4 bytes) + status (1 byte)// -- For BLE (9 bytes total), but max payload is well under the max length supported by the sub-1 phys: Timestamp (4 bytes) + status (1 byte) + RSSI (1 byte) + CRC (3 bytes)
/***** Prototypes *****/
static void tx_callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);

/***** Variable declarations *****/
static RF_Object rfObject;
static RF_Handle rfHandle;

static volatile RF_CmdHandle cmdHandle;

static uint8_t txDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,MAX_LENGTH,NUM_APPENDED_BYTES)];

/* TX queue or RF Core to read data from */
static dataQueue_t  txDataQueue;
static rfc_dataEntryGeneral_t* tx_currentDataEntry;
static uint8_t *pPacket;

/* Runs the transmitting part of the test application and returns a result. */
void  RF_tran_init (uint16_t  freq_MHz,  uint8_t  N_dBm)
{RF_Params rfParams;RF_Params_init(&rfParams);if( RFQueue_defineQueue(&txDataQueue,txDataEntryBuffer,sizeof(txDataEntryBuffer),NUM_DATA_ENTRIES,MAX_LENGTH + NUM_APPENDED_BYTES)  )  {//while(true);  // Failed to allocate space for all data entries}RF_cmdTxHS.pQueue = &txDataQueue;RF_cmdTxHS.startTrigger.triggerType = TRIG_NOW; //TRIG_ABSTIMERF_cmdTxHS.startTrigger.pastTrig = 1;RF_cmdTxHS.startTime = 0;//---START  //copy from ZhuYanjie
//  RF_cmdTxHS.pNextOp=(rfc_radioOp_t *)&RF_cmdRxHS;RF_cmdTxHS.pktConf.bCheckQAtEnd=0;RF_cmdTxHS.pktConf.bFsOff=0;RF_cmdTxHS.pktConf.bUseCrc=1;RF_cmdTxHS.pktConf.bVarLen=1;RF_cmdTxHS.condition.rule=COND_STOP_ON_FALSE;
	//----END//copy from ZhuYanjie//smartrf_settings_predefined.c  //-10, 0, 1, 2, 3.....11, 12, 13((12.5 dBm rounded to integer),14('14' requires CCFG_FORCE_VDDR_HH= 1)RF_cmdRadioSetup_hsm.txPower = RF_TxPowerTable_findValue((RF_TxPowerTable_Entry *)RF_PROP_txPowerTable, N_dBm).rawValue;{uint8_t i = 0;do{if ((pOverrides_fsk[i] & 0x0000FFFF) ==  0x000088A3){//RangeExtender_Dis//RangeExtender_En,  868M//RangeExtender_En,  915MpOverrides_fsk[i] = (uint32_t)0x00FB88A3; //pOverrides_fsk[i] = (uint32_t)0x000188A3;  //pOverrides_fsk[i] = (uint32_t)0x000388A3;}} while ((pOverrides_fsk[i++] != 0xFFFFFFFF));i = 0;do{if ((pOverrides_lrm[i] & 0x0000FFFF) ==  0x000088A3){//RangeExtender_Dis//RangeExtender_En,  868M//RangeExtender_En,  915MpOverrides_lrm[i] = (uint32_t)0x00FB88A3; //pOverrides_lrm[i] = (uint32_t)0x000188A3;  //pOverrides_lrm[i] = (uint32_t)0x000388A3;}} while ((pOverrides_lrm[i++] != 0xFFFFFFFF));i = 0;do{if ((pOverrides_sl_lr[i] & 0x0000FFFF) ==  0x000088A3){//RangeExtender_Dis//RangeExtender_En,  868M//RangeExtender_En,  915MpOverrides_sl_lr[i] = (uint32_t)0x00FB88A3; //pOverrides_sl_lr[i] = (uint32_t)0x000188A3;//pOverrides_sl_lr[i] = (uint32_t)0x000388A3;}} while ((pOverrides_sl_lr[i++] != 0xFFFFFFFF));i = 0;do{if ((pOverrides_ook[i] & 0x0000FFFF) ==  0x000088A3){pOverrides_ook[i] = (uint32_t)0x00FB88A3;}} while ((pOverrides_ook[i++] != 0xFFFFFFFF));}//RfSetup_Hsm//4MbpsrfHandle = RF_open(&rfObject, &RF_prop_hsm, (RF_RadioSetup*)&RF_cmdRadioSetup_hsm, &rfParams);// Set the frequencyRF_cmdFs_preDef.frequency = freq_MHz;  //0x393, 915M//0x364,  868M//915, 903, 907, 911, 919, 923, 927RF_cmdFs_preDef.fractFreq = 0; //fractFreqRF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs_preDef, RF_PriorityNormal, NULL, 0);
}

void  RF_tran_op (uint8_t sn8b,  uint16_t  pkg_Len,  uint8_t  *ptr)
{tx_currentDataEntry = (rfc_dataEntryGeneral_t*)&txDataEntryBuffer;pPacket = &tx_currentDataEntry->data;pPacket[0] = 0;pPacket[1] = sn8b;tx_currentDataEntry->length= (pkg_Len +2) ;memcpy( &pPacket[2],  ptr, pkg_Len );cmdHandle = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdTxHS, RF_PriorityNormal, &tx_callback, 0);delta_txTrig_txOK++;if(pkg_Len< 100) wait_WLpkg_tran( 1 );elsewait_WLpkg_tran( 6 ); //1022-bytes, wl_pkg tran,  3.4 Mbps
}

void  RF_tran_close ()
{RF_close(rfHandle);
}

void tx_callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{cur_RF_EventMask = e ;if(e & RF_EventLastCmdDone){if(delta_txTrig_txOK>0)delta_txTrig_txOK--;}
}
/* HIGHSPEED RX FRAME (HSM)
 * +-------------------------------------------------------------+
 * |_LEN_|_____________PAYLOAD(sz)__________|_TIMESTAMP_|_STATUS_|
 * ||_SERIAL_|__________DATA___________|||
 * |2B|2B| Upto 252B| 4B| 1B|
 * +-------------------------------------------------------------+
 * Note that HSM mode can transfer up to 4KB of payload but are hard-coded for a maximum of 254B in this example
#define RX_FRAME_HSM_OFFSET_LEN0
#define RX_FRAME_HSM_OFFSET_SERIAL2
#define RX_FRAME_HSM_OFFSET_DATA4
#define RX_FRAME_HSM_OFFSET_TIMESTAMP(sz)  (RX_FRAME_HSM_OFFSET_SERIAL + sz)*/











void  wait_WLpkg_tran( uint8_t  N_ms )
{Timer_start();cnt_N_ms= 0;while( (cnt_N_ms< N_ms) && (delta_txTrig_txOK>0) ) {}Timer_stop();
}

void *mainThread(void *arg0)
{uint8_t  buf[16];uint8_t  curPat;//.............//other code//.............while(1) {usleep( GAP_500ms );//------------//------------//------------//------------//------------// WL_tran//------------//------------//------------//------------//------------RF_tran_init  ( curWL_freq,  curWL_dBm );for(curPat=0; curPat<5; curPat++) { //get_sensor_info ( &buf[0] ) ;RF_tran_op ( curPat,  16,  &buf[0] );  //2+16}RF_tran_close ( );//------------//------------//------------//------------//------------// WL_recv//------------//------------//------------//------------//------------RF_recv_init ( curWL_freq );  //1.46ms
		wait_WLpkg_recv( 5 );
		//other codeRF_recv_close ( );}//---- while(1) ----//
}


rf_recv.c

#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
#include "Board.h"
#include "RFQueue.h"
#include <smartrf_settings/smartrf_settings.h>
#include <smartrf_settings/smartrf_settings_predefined.h>

#include "cap_self.h"

/***** Defines *****/
#define NUM_DATA_ENTRIES2// NOTE: Only two data entries supported at the moment
#define NUM_APPENDED_BYTES6// -- For the HS command (6 bytes total):  packet length (2 bytes) + Timestamp (4 bytes)// -- For other Sub-1 GHz commands (6 bytes total): packet length (1 bytes) + Timestamp (4 bytes) + status (1 byte)// -- For 200 Kbps IEEE 802.15.4g commands (5 bytes total): Timestamp (4 bytes) + status (1 byte)// -- For BLE (9 bytes total), but max payload is well under the max length supported by the sub-1 phys: Timestamp (4 bytes) + status (1 byte) + RSSI (1 byte) + CRC (3 bytes)
#define ABORT_GRACEFUL1// Option for the RF cancel command
#define ABORT_ABRUPT0// Option for the RF cancel command

/***** Prototypes *****/
static void rx_callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);

/***** Variable declarations *****/
uint16_t  payload_sz = 0;

static uint16_t* crcOk;
static int8_t* rssi;

static RF_Object rfObject;
static RF_Handle rfHandle;
static RF_CmdHandle rxCmdHndl = 0; // Handle needed to abort the RX command //rockywjj-note: must use it.
static volatile RF_RatConfigCompare ratCompareConfig;
static volatile RF_RatHandle ratHandle = RF_ALLOC_ERROR;
static volatile RF_Stat ratStatus;
static volatile uint16_t nRxPkts = 0, nMissPkts = 0, nExpPkts = 0;

#pragma DATA_ALIGN (rxDataEntryBuffer, 4);
static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,MAX_LENGTH,NUM_APPENDED_BYTES)];
static dataQueue_t rxDataQueue;

rfc_dataEntryGeneral_t* currentDataEntry;
rfc_hsRxOutput_t rxStatistics_hs; // Output structure for CMD_HS_RX
rfc_propRxOutput_t rxStatistics_prop; // Output structure for CMD_PROP_RX

void  RF_recv_init ( uint16_t  freq_MHz )
{RF_Params rfParams;RF_Params_init(&rfParams);if( RFQueue_defineQueue(&rxDataQueue,rxDataEntryBuffer,sizeof(rxDataEntryBuffer),NUM_DATA_ENTRIES,MAX_LENGTH + NUM_APPENDED_BYTES))  {//while(true);  // Failed to allocate space for all data entries}RF_RatConfigCompare_init((RF_RatConfigCompare *)&ratCompareConfig);//ratCompareConfig.callback = (RF_RatCallback)&rx_timeoutCb;ratCompareConfig.channel  = RF_RatChannelAny;RF_cmdPropRx.pQueue = &rxDataQueue;RF_cmdPropRx.pOutput = (uint8_t*)&rxStatistics_prop;RF_cmdPropRx.maxPktLen = MAX_LENGTH;RF_cmdPropRx.pktConf.bRepeatOk = 1;RF_cmdPropRx.pktConf.bRepeatNok = 1;RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1;RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1;RF_cmdPropRx.rxConf.bAppendTimestamp = 1;RF_cmdPropRx.rxConf.bAppendStatus = 0x1,RF_cmdRxHS.pOutput = &rxStatistics_hs;RF_cmdRxHS.pQueue = &rxDataQueue;RF_cmdRxHS.maxPktLen = MAX_LENGTH;RF_cmdRxHS.pktConf.bRepeatOk = 1;RF_cmdRxHS.pktConf.bRepeatNok = 1;RF_cmdRxHS.rxConf.bAutoFlushCrcErr = 1;RF_cmdRxHS.rxConf.bAppendTimestamp = 1;//RangeExtender_Dis//RangeExtender_En,  868M//RangeExtender_En,  915MRF_cmdPropRadioDivSetup_fsk.txPower= 0xA73A; //RF_cmdPropRadioDivSetup_fsk.txPower= 0x00C6;  //RF_cmdPropRadioDivSetup_fsk.txPower= 0x00C9;RF_cmdPropRadioDivSetup_lrm.txPower= 0xA73A; //RF_cmdPropRadioDivSetup_lrm.txPower= 0x00C6;  //RF_cmdPropRadioDivSetup_lrm.txPower= 0x00C9;RF_cmdPropRadioDivSetup_sl_lr.txPower = 0xA73A; //RF_cmdPropRadioDivSetup_sl_lr.txPower = 0x00C6;  //RF_cmdPropRadioDivSetup_sl_lr.txPower = 0x00C9;{uint8_t i = 0;do{if ((pOverrides_fsk[i] & 0x0000FFFF) ==  0x000088A3){//RangeExtender_Dis//RangeExtender_En,  868M//RangeExtender_En,  915MpOverrides_fsk[i] = (uint32_t)0x00FB88A3; //pOverrides_fsk[i] = (uint32_t)0x000188A3;  //pOverrides_fsk[i] = (uint32_t)0x000388A3;}} while ((pOverrides_fsk[i++] != 0xFFFFFFFF));i = 0;do{if ((pOverrides_lrm[i] & 0x0000FFFF) ==  0x000088A3){//RangeExtender_Dis//RangeExtender_En,  868M//RangeExtender_En,  915MpOverrides_lrm[i] = (uint32_t)0x00FB88A3; //pOverrides_lrm[i] = (uint32_t)0x000188A3;  //pOverrides_lrm[i] = (uint32_t)0x000388A3;}} while ((pOverrides_lrm[i++] != 0xFFFFFFFF));i = 0;do{if ((pOverrides_sl_lr[i] & 0x0000FFFF) ==  0x000088A3){//RangeExtender_Dis//RangeExtender_En,  868M//RangeExtender_En,  915MpOverrides_sl_lr[i] = (uint32_t)0x00FB88A3; //pOverrides_sl_lr[i] = (uint32_t)0x000188A3;//pOverrides_sl_lr[i] = (uint32_t)0x000388A3;}} while ((pOverrides_sl_lr[i++] != 0xFFFFFFFF));}//RfSetup_Hsm//4MbpsrfHandle = RF_open(&rfObject, &RF_prop_hsm, (RF_RadioSetup*)&RF_cmdRadioSetup_hsm, &rfParams);// Set the frequencyRF_cmdFs_preDef.frequency = freq_MHz;  //0x393, 915M//0x364,  868M//915, 903, 907, 911, 919, 923, 927RF_cmdFs_preDef.fractFreq = 0; //fractFreqRF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs_preDef, RF_PriorityNormal, NULL, 0);// Enter RX mode and stay forever in RX// RfSetup_HsmrxCmdHndl = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdRxHS, RF_PriorityNormal, &rx_callback, RF_EventRxEntryDone);crcOk = &rxStatistics_hs.nRxOk;rssi = &rxStatistics_hs.lastRssi;*crcOk = 0;*rssi = 0;
}

void  RF_recv_close ( )
{
	(void)RF_ratDisableChannel(rfHandle, ratHandle); // Stop the RAT Compare
	ratHandle = RF_ALLOC_ERROR;
	(void)RF_cancelCmd(rfHandle, rxCmdHndl, ABORT_ABRUPT); // Force abort
	(void)RF_pendCmd(rfHandle, rxCmdHndl, 0);RF_close(rfHandle);
}

void rx_callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{if (e & RF_EventRxEntryDone){ /* Get current unhandled data entry, point to next entry */currentDataEntry = RFQueue_getDataEntry();RFQueue_nextEntry();{payload_sz = ( ((*(uint8_t*)(&currentDataEntry->data + 1)) << 8) | (*(uint8_t*)(&currentDataEntry->data))); //Num of [ser2B, payload]pktSeqNum16b  = ( ((*(uint8_t*)(&currentDataEntry->data + 2)) << 8) | (*(uint8_t*)(&currentDataEntry->data + 3))); //val of  ser2BCAP_pkg_rssi= (0xFF - *rssi);*rssi = 0;pkg_crcOk  =  *crcOk;*crcOk = 0;memcpy( WL_CMD_58B,  (&currentDataEntry->data+4),  (payload_sz-2) );}packetReceived = true;}
}
uint8_t  free_air_rssi(void)
{uint8_t  u_rssi;u_rssi = 0xFF - RF_getRssi(rfHandle); //(0xFF - *rssi);*rssi = 0;return  u_rssi;
}
/* HIGHSPEED RX FRAME (HSM)
 * +-------------------------------------------------------------+
 * |_LEN_|_____________PAYLOAD(sz)__________|_TIMESTAMP_|_STATUS_|
 * ||_SERIAL_|__________DATA___________|||
 * |2B|2B| Upto 252B| 4B| 1B|
 * +-------------------------------------------------------------+
 * Note that HSM mode can transfer up to 4KB of payload but are hard-coded for a maximum of 254B in this example
#define RX_FRAME_HSM_OFFSET_LEN0
#define RX_FRAME_HSM_OFFSET_SERIAL2
#define RX_FRAME_HSM_OFFSET_DATA4
#define RX_FRAME_HSM_OFFSET_TIMESTAMP(sz)  (RX_FRAME_HSM_OFFSET_SERIAL + sz)*/

// TimeStamp-4B,  UNIT-0.25us (4M)
//
// ( 256-2) byte,  0.89ms ---> 2.3 Mbps (2.283)
// ( 512-2) byte,  1.42ms ---> 2.9 Mbps (2.903)
// (1024-2) byte,  1.42ms ---> 3.4 Mbps (3.351)
Alex Zhang:

您好,已经跟进您的问题,这需要一些时间,谢谢。

,

Alex Zhang:

我不确定我是否完全理解您的 HSM 问题是什么。

我采用了 rfPacketTX 和 rfPacketRX 示例(4.20 SDK 中没有 rtos 版本),并将其修改为使用 4 mbps PHY 并每 500 毫秒发送/接收 5 个长度为 300 字节的数据包。

请看一下这个示例,看看您是否可以启动并运行它。

如果您需要更改代码以适合您的应用程序,请这样做,如果它开始失败,您可以与我分享修改,以便我可以在这里测试它并看看发生了什么。

当你的代码不是完整的示例时,我很难调试它。

附上我修改后的文件。

5265.rfPacketTx.c

/** Copyright (c) 2019, Texas Instruments Incorporated* All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions* are met:** *Redistributions of source code must retain the above copyright*notice, this list of conditions and the following disclaimer.** *Redistributions in binary form must reproduce the above copyright*notice, this list of conditions and the following disclaimer in the*documentation and/or other materials provided with the distribution.** *Neither the name of Texas Instruments Incorporated nor the names of*its contributors may be used to endorse or promote products derived*from this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*//***** Includes *****/
/* Standard C Libraries */
#include <stdlib.h>
#include <unistd.h>/* TI Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
//#include <ti/drivers/pin/PINCC26XX.h>/* Driverlib Header files */
#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)/* Board Header files */
#include "Board.h"
#include "smartrf_settings/smartrf_settings.h"#include "RFQueue.h"/***** Defines *****//* Packet TX Configuration */
#define PAYLOAD_LENGTH300
#define DATA_ENTRY_HEADER_SIZE8// Constant header size of a Generic Data Entry
#define MAX_LENGTHPAYLOAD_LENGTH// Set the length of the data entry
#define NUM_DATA_ENTRIES_TX1
#define NUM_APPENDED_BYTES_TX0
#define NUMBER_OF_PACKETS5/***** Prototypes *****//***** Variable declarations *****/
static RF_Object rfObject;
static RF_Handle rfHandle;/* Pin driver handle */
static PIN_Handle ledPinHandle;
static PIN_State ledPinState;static uint8_t *pPacket;#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_ALIGN (txDataEntryBuffer, 4);
static uint8_t
txDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES_TX,MAX_LENGTH,NUM_APPENDED_BYTES_TX)];
#elif defined(__IAR_SYSTEMS_ICC__)
#pragma data_alignment = 4
static uint8_t
txDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES_TX,MAX_LENGTH,NUM_APPENDED_BYTES_TX)];
#elif defined(__GNUC__)
static uint8_t
txDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES_TX,MAX_LENGTH,NUM_APPENDED_BYTES_TX)]__attribute__((aligned(4)));
#else
#error This compiler is not supported.
#endifstatic dataQueue_t dataQueue;
static rfc_dataEntryGeneral_t* currentDataEntry;
static uint16_t packetCounter = 0;/** Application LED pin configuration table:*- All LEDs board LEDs are off.*/
PIN_Config pinTable[] =
{Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,PIN_TERMINATE
};/***** Function definitions *****/void *mainThread(void *arg0)
{RF_Params rfParams;RF_Params_init(&rfParams);/* Open LED pins */ledPinHandle = PIN_open(&ledPinState, pinTable);if (ledPinHandle == NULL){while(1);}if( RFQueue_defineQueue(&dataQueue,txDataEntryBuffer,sizeof(txDataEntryBuffer),NUM_DATA_ENTRIES_TX,MAX_LENGTH + NUM_APPENDED_BYTES_TX)){/* Failed to allocate space for all data entries */while(true);}RF_cmdTxHS.pQueue = &dataQueue;RF_cmdTxHS.startTrigger.triggerType = TRIG_NOW;currentDataEntry = (rfc_dataEntryGeneral_t*)&txDataEntryBuffer;currentDataEntry->length = PAYLOAD_LENGTH;pPacket = &currentDataEntry->data;/* Generate the packet */uint16_t i;for (i = 1; i < PAYLOAD_LENGTH; i++){pPacket[i] = (uint8_t)(i - 1);}/* Request access to the radio */rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdRadioSetup, &rfParams);/* Set the frequency */RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);while(1){while(packetCounter++ < NUMBER_OF_PACKETS){pPacket[0] = packetCounter;PIN_setOutputValue(ledPinHandle, Board_PIN_LED1,1);RF_runCmd(rfHandle, (RF_Op*)&RF_cmdTxHS, RF_PriorityNormal, NULL, 0);PIN_setOutputValue(ledPinHandle, Board_PIN_LED1,0);}usleep(500000);packetCounter = 0;}
}

4251.rfPacketRx.c

/** Copyright (c) 2019, Texas Instruments Incorporated* All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions* are met:** *Redistributions of source code must retain the above copyright*notice, this list of conditions and the following disclaimer.** *Redistributions in binary form must reproduce the above copyright*notice, this list of conditions and the following disclaimer in the*documentation and/or other materials provided with the distribution.** *Neither the name of Texas Instruments Incorporated nor the names of*its contributors may be used to endorse or promote products derived*from this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*//***** Includes *****/
/* Standard C Libraries */
#include <stdlib.h>/* TI Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>/* Driverlib Header files */
#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)/* Board Header files */
#include "Board.h"/* Application Header files */
#include "RFQueue.h"
#include "smartrf_settings/smartrf_settings.h"/***** Defines *****//* Packet RX Configuration */
#define DATA_ENTRY_HEADER_SIZE8/* Constant header size of a Generic Data Entry */
#define MAX_LENGTH300 /* Max length byte the radio will accept */
#define NUM_DATA_ENTRIES2/* NOTE: Only two data entries supported at the moment */
#define NUM_APPENDED_BYTES2/* RF_cmdRxHS.rxConf.bIncludeLen = 1 */
#define LENGTH_BYTE_SIZE2/***** Prototypes *****/
static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);/***** Variable declarations *****/
static RF_Object rfObject;
static RF_Handle rfHandle;/* Pin driver handle */
static PIN_Handle ledPinHandle;
static PIN_State ledPinState;/* Buffer which contains all Data Entries for receiving data.* Pragmas are needed to make sure this buffer is 4 byte aligned (requirement from the RF Core) */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_ALIGN (rxDataEntryBuffer, 4);
static uint8_t
rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,MAX_LENGTH,NUM_APPENDED_BYTES)];
#elif defined(__IAR_SYSTEMS_ICC__)
#pragma data_alignment = 4
static uint8_t
rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,MAX_LENGTH,NUM_APPENDED_BYTES)];
#elif defined(__GNUC__)
static uint8_t
rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,MAX_LENGTH,NUM_APPENDED_BYTES)]__attribute__((aligned(4)));
#else
#error This compiler is not supported.
#endif/* Receive dataQueue for RF Core to fill in data */
static dataQueue_t dataQueue;
static rfc_dataEntryGeneral_t* currentDataEntry;
static uint8_t packetLength;
static uint8_t* packetDataPointer;
static rfc_hsRxOutput_t rxStatistics;static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - LENGTH_BYTE_SIZE]; /* The length info (2 bytes) is stored in a separate variable *//** Application LED pin configuration table:*- All LEDs board LEDs are off.*/
PIN_Config pinTable[] =
{Board_PIN_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,PIN_TERMINATE
};/***** Function definitions *****/void *mainThread(void *arg0)
{RF_Params rfParams;RF_Params_init(&rfParams);/* Open LED pins */ledPinHandle = PIN_open(&ledPinState, pinTable);if (ledPinHandle == NULL){while(1);}if( RFQueue_defineQueue(&dataQueue,rxDataEntryBuffer,sizeof(rxDataEntryBuffer),NUM_DATA_ENTRIES,MAX_LENGTH + NUM_APPENDED_BYTES)){/* Failed to allocate space for all data entries */while(1);}RF_cmdRxHS.pOutput = &rxStatistics;RF_cmdRxHS.pQueue = &dataQueue;RF_cmdRxHS.rxConf.bAutoFlushCrcErr = 1;RF_cmdRxHS.maxPktLen = MAX_LENGTH;RF_cmdRxHS.pktConf.bRepeatOk = 1;RF_cmdRxHS.pktConf.bRepeatNok = 1;// Appended bytesRF_cmdRxHS.rxConf.bIncludeLen = 1;RF_cmdRxHS.rxConf.bIncludeCrc = 0;RF_cmdRxHS.rxConf.bAppendStatus = 0;RF_cmdRxHS.rxConf.bAppendTimestamp = 0;/* Request access to the radio */rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdRadioSetup, &rfParams);/* Set the frequency */RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);RF_runCmd(rfHandle, (RF_Op*)&RF_cmdRxHS, RF_PriorityNormal, &callback, RF_EventRxEntryDone);while(1);
}void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{if (e & RF_EventRxEntryDone){/* Toggle pin to indicate RX */PIN_setOutputValue(ledPinHandle, Board_PIN_LED2, !PIN_getOutputValue(Board_PIN_LED2));/* Get current unhandled data entry */currentDataEntry = RFQueue_getDataEntry();/* Handle the packet data, located at &currentDataEntry->data */packetLength= ((*(uint8_t*)(&currentDataEntry->data + 1)) << 8) |(*(uint8_t*)(&currentDataEntry->data));packetDataPointer = (uint8_t*)(&currentDataEntry->data + 2);/* Copy the payload + optional status byte to the packet variable */memcpy(packet, packetDataPointer, (packetLength + NUM_APPENDED_BYTES - LENGTH_BYTE_SIZE));RFQueue_nextEntry();}
}

4251.smartrf_settings.c

#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
#include DeviceFamily_constructPath(driverlib/rf_hs_mailbox.h)
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
#include DeviceFamily_constructPath(driverlib/rf_hs_cmd.h)
#include <ti/drivers/rf/RF.h>
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_hsp_4mbps.h)
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_hsp_4mbps.h)
#include "smartrf_settings.h"RF_Mode RF_prop =
{.rfMode = RF_MODE_PROPRIETARY_SUB_1,.cpePatchFxn =0,.mcePatchFxn =&rf_patch_mce_hsp_4mbps,.rfePatchFxn =&rf_patch_rfe_hsp_4mbps,
};// Overrides for CMD_RADIO_SETUP
uint32_t shapeovr[] = {0x00000000, 0x00000000, 0x00000000, 0x12010000, 0x72685C43, 0x8986817A};uint32_t pOverrides[] =
{MCE_RFE_OVERRIDE(1,0,0,1,0,0),ADI_HALFREG_OVERRIDE(0,61,0xF,0x0),ADI_REG_OVERRIDE(1,4,0x9F),ADI_HALFREG_OVERRIDE(1,7,0x4,0x4),HW_REG_OVERRIDE(0x4038,0x003A),HW_REG_OVERRIDE(0x4020,0x7F00),HW_REG_OVERRIDE(0x4064,0x0040),0x000604A3,0xB1070503,0x05330523,0x0A480583,0x7AB80603,0x00108463,0x02010403,0x04B00243,0x00038883,0xC0040031,(uint32_t) &shapeovr[0],0xC0040021,(uint32_t) (0x00000035),0x000388A3,HW_REG_OVERRIDE(0x50B4,0x6666),HW_REG_OVERRIDE(0x50B8,0x000C),(uint32_t)0xFFFFFFFF,
};// CMD_RADIO_SETUP
rfc_CMD_RADIO_SETUP_t RF_cmdRadioSetup =
{.commandNo = CMD_RADIO_SETUP,.status = 0x0000,.pNextOp = 0x00000000,.startTime = 0x00000000,.startTrigger.triggerType = 0x0,.startTrigger.bEnaCmd = 0x0,.startTrigger.triggerNo = 0x0,.startTrigger.pastTrig = 0x0,.condition.rule = 0x1,.condition.nSkip = 0x0,.mode = 0x05,.loDivider = 5,.config.frontEndMode = 0x0,.config.biasMode = 0x1,.config.bNoFsPowerUp = 0,.txPower = 0xA63F,.pRegOverride = pOverrides,
};// CMD_FS
rfc_CMD_FS_t RF_cmdFs =
{.commandNo = 0x0803,.status = 0x0000,.pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx.startTime = 0x00000000,.startTrigger.triggerType = 0x0,.startTrigger.bEnaCmd = 0x0,.startTrigger.triggerNo = 0x0,.startTrigger.pastTrig = 0x0,.condition.rule = 0x1,.condition.nSkip = 0x0,.frequency = 0x0364,.fractFreq = 0x0000,.synthConf.bTxMode = 0x0,.synthConf.refFreq = 0x0,.__dummy0 = 0x00,.__dummy1 = 0x00,.__dummy2 = 0x00,.__dummy3 = 0x0000,
};// CMD_TX_HS
rfc_CMD_HS_TX_t RF_cmdTxHS =
{.commandNo = 0x3841,.status = 0x0000,.pNextOp = 0x00000000,.startTime = 0x00000000,.startTrigger.triggerType = 0x0,.startTrigger.bEnaCmd = 0x0,.startTrigger.triggerNo = 0x0,.startTrigger.pastTrig = 0x0,.condition.rule = 0x1,.condition.nSkip = 0x0,.pktConf.bFsOff = 0x0,.pktConf.bUseCrc = 0x1,.pktConf.bVarLen = 0x1,.pQueue = 0,
};// CMD_RX_HS
rfc_CMD_HS_RX_t RF_cmdRxHS =
{.commandNo = CMD_HS_RX,.status = 0x0000,.pNextOp = 0x00000000,.startTime = 0x00000000,.startTrigger.triggerType = 0x0,.startTrigger.bEnaCmd = 0x0,.startTrigger.triggerNo = 0x0,.startTrigger.pastTrig = 0x0,.condition.rule = 0x1,.condition.nSkip = 0x0,.pktConf.bFsOff = 0,.pktConf.bUseCrc = 1,.pktConf.bVarLen = 1,.pktConf.bRepeatOk = 0,.pktConf.bRepeatNok = 0,.pktConf.addressMode = 0,.rxConf.bAutoFlushCrcErr = 0,.rxConf.bIncludeLen = 1,.rxConf.bIncludeCrc = 0,.rxConf.bAppendStatus = 0,.rxConf.bAppendTimestamp = 0,.maxPktLen = 0,.address0 = 0,.address1 = 0,.__dummy0 = 0,.endTrigger.triggerType = 1,.endTrigger.bEnaCmd = 0,.endTrigger.triggerNo = 0,.endTrigger.pastTrig = 0,.endTime = 0,.pQueue = 0,.pOutput = 0,
};

赞(0)
未经允许不得转载:TI中文支持网 » CC1310: 配置为 4Mbps 模式, 执行无线发送 (发送完成了, 产生中断)。问题: 工作一段时间以后, 发送的无线信息, 可以被接收到; 但发送端, 不能获取对应的 中断了
分享到: 更多 (0)