Other Parts Discussed in Thread: CC1190,
Tool/software: TI-RTOS
Hi,
I have a board which is with CC1310, CC1190. I want to use range extender.
I use SimpleLink CC13x0 SDK v1.30.00.06-> CC1310Launchpad -> rfpacket error rate test-> TI-RTOS in CCS 7.01 as a reference.
Board_HGM | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_LNA_EN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_PA_EN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
and other settings...
I was try to implement it to rfpacketTx and Rx. Code is below.
In SmartRF Studio :
If I select the LAUNCHXL_CC1310-CC1190-EU as target and set the LNA, PA and HGM pin. Board was work perfect.
But I select the LAUNCHXL_CC1310 and modify my code to set LNA, PA and HGM which is not working.
Please tell me how to do it.
/*
example rftxpaket cc1190 ayarlar� yapmaya �al���yorum.
E�er bu tutarsa t�m hepsine uygulayaca��m.
*/
/***** Includes *****/
#include <stdlib.h>
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/* Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
/* Board Header files */
#include "Board.h"
#include <ti/drivers/pin/PINCC26XX.h>
#include "smartrf_settings/smartrf_settings.h"
#include "smartrf_settings/smartrf_settings_predefined.h"
/* Pin driver handle */
static PIN_Handle ledPinHandle;
static PIN_State ledPinState;
/*
* Application LED pin configuration table:
* - All LEDs board LEDs are off.
*/
PIN_Config pinTable[] =
{
Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_HGM | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_LNA_EN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_PA_EN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
PIN_TERMINATE
};
/***** Defines *****/
#define TX_TASK_STACK_SIZE 1024
#define TX_TASK_PRIORITY 2
/* Packet TX Configuration */
#define PAYLOAD_LENGTH 30
#define PACKET_INTERVAL (uint32_t)(4000000*0.5f) /* Set packet interval to 500ms */
/***** Prototypes *****/
static void txTaskFunction(UArg arg0, UArg arg1);
/***** Variable declarations *****/
static Task_Params txTaskParams;
Task_Struct txTask; /* not static so you can see in ROV */
static uint8_t txTaskStack[TX_TASK_STACK_SIZE];
static RF_Object rfObject;
static RF_Handle rfHandle;
uint32_t time;
//static uint8_t RangeExtender = 1;
static uint8_t packet[PAYLOAD_LENGTH];
static uint16_t seqNumber;
static PIN_Handle pinHandle;
/***** Function definitions *****/
void TxTask_init(PIN_Handle inPinHandle)
{
pinHandle = inPinHandle;
Task_Params_init(&txTaskParams);
txTaskParams.stackSize = TX_TASK_STACK_SIZE;
txTaskParams.priority = TX_TASK_PRIORITY;
txTaskParams.stack = &txTaskStack;
txTaskParams.arg0 = (UInt)1000000;
Task_construct(&txTask, txTaskFunction, &txTaskParams, NULL);
}
static void txTaskFunction(UArg arg0, UArg arg1)
{
// if (RangeExtender==0)
// {
/* Revers the pins to GPIO mapping */
// PINCC26XX_setMux(pinHandle, Board_LNA_EN, -1);
// PINCC26XX_setMux(pinHandle, Board_PA_EN, -1);
// }
// else
// {
/* Configure the pins tp control the range extender */
PIN_setOutputValue(pinHandle, Board_HGM, 1);
PINCC26XX_setMux(pinHandle, Board_LNA_EN, PINCC26XX_MUX_RFC_GPO0);
PINCC26XX_setMux(pinHandle, Board_PA_EN, PINCC26XX_MUX_RFC_GPO1);
// }
// uint8_t i = 0;
// do
// {
// if ((pOverrides_fsk[i] & 0x0000FFFF) == 0x000088A3)
// {
// pOverrides_fsk[i] = (uint32_t)0x000188A3;
// }
// } while ((pOverrides_fsk[i++] != 0xFFFFFFFF));
uint32_t time;
RF_Params rfParams;
RF_Params_init(&rfParams);
RF_cmdPropTx.pktLen = PAYLOAD_LENGTH;
RF_cmdPropTx.pPkt = packet;
RF_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME;
RF_cmdPropTx.startTrigger.pastTrig = 1;
RF_cmdPropTx.startTime = 0;
/* Request access to the radio */
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
/* Set the frequency */
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
/* Get current time */
time = RF_getCurrentTime();
while(1)
{
/* Create packet with incrementing sequence number and random payload */
packet[0] = (uint8_t)(seqNumber >> 8);
packet[1] = (uint8_t)(seqNumber++);
uint8_t i;
for (i = 2; i < PAYLOAD_LENGTH; i++)
{
packet[i] = 'C';
}
/* Set absolute TX time to utilize automatic power management */
time += PACKET_INTERVAL;
RF_cmdPropTx.startTime = time;
/* Send packet */
RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
if (!(result & RF_EventLastCmdDone))
{
/* Error */
while(1);
}
PIN_setOutputValue(pinHandle, Board_LED1,!PIN_getOutputValue(Board_LED1));
// seqNumber = 0;
}
}
/*
* ======== main ========
*/
int main(void)
{
/* Call board init functions. */
Board_initGeneral();
/* Open LED pins */
ledPinHandle = PIN_open(&ledPinState, pinTable);
if(!ledPinHandle)
{
System_abort("Error initializing board LED pins\n");
}
/* Initialize task */
TxTask_init(ledPinHandle);
/* Start BIOS */
BIOS_start();
return (0);
}
/*
example rftxpaket cc1190 ayarlar� yapmaya �al���yorum.
E�er bu tutarsa t�m hepsine uygulayaca��m.
*/
/***** Includes *****/
#include <stdlib.h>
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/* Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
#include <driverlib/rf_prop_mailbox.h>
/* Board Header files */
#include "Board.h"
#include "RFQueue.h"
#include <ti/drivers/pin/PINCC26XX.h>
#include "smartrf_settings/smartrf_settings.h"
#include "smartrf_settings/smartrf_settings_predefined.h"
#include <stdlib.h>
/* Pin driver handle */
static PIN_Handle ledPinHandle;
static PIN_State ledPinState;
/*
* Application LED pin configuration table:
* - All LEDs board LEDs are off.
*/
PIN_Config pinTable[] =
{
Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_HGM | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_LNA_EN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_PA_EN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
PIN_TERMINATE
};
/***** Defines *****/
#define RX_TASK_STACK_SIZE 1024
#define RX_TASK_PRIORITY 2
/* Packet RX Configuration */
#define DATA_ENTRY_HEADER_SIZE 8 /* Constant header size of a Generic Data Entry */
#define MAX_LENGTH 30 /* Max length byte the radio will accept */
#define NUM_DATA_ENTRIES 2 /* NOTE: Only two data entries supported at the moment */
#define NUM_APPENDED_BYTES 2 /* The Data Entries data field will contain:
* 1 Header byte (RF_cmdPropRx.rxConf.bIncludeHdr = 0x1)
* Max 30 payload bytes
* 1 status byte (RF_cmdPropRx.rxConf.bAppendStatus = 0x1) */
/***** Prototypes *****/
static void rxTaskFunction(UArg arg0, UArg arg1);
static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
/***** Variable declarations *****/
static Task_Params rxTaskParams;
Task_Struct rxTask; /* not static so you can see in ROV */
static uint8_t rxTaskStack[RX_TASK_STACK_SIZE];
static RF_Object rfObject;
static RF_Handle rfHandle;
//static uint8_t RangeExtender = 1;
/* 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 PIN_Handle pinHandle;
static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */
/***** Function definitions *****/
void RxTask_init(PIN_Handle ledPinHandle) {
pinHandle = ledPinHandle;
Task_Params_init(&rxTaskParams);
rxTaskParams.stackSize = RX_TASK_STACK_SIZE;
rxTaskParams.priority = RX_TASK_PRIORITY;
rxTaskParams.stack = &rxTaskStack;
rxTaskParams.arg0 = (UInt)1000000;
Task_construct(&rxTask, rxTaskFunction, &rxTaskParams, NULL);
}
static void rxTaskFunction(UArg arg0, UArg arg1)
{
// if (RangeExtender==0)
// {
/* Revers the pins to GPIO mapping */
// PINCC26XX_setMux(pinHandle, Board_LNA_EN, -1);
// PINCC26XX_setMux(pinHandle, Board_PA_EN, -1);
// }
// else
// {
/* Configure the pins tp control the range extender */
PIN_setOutputValue(pinHandle, Board_HGM, 1);
PINCC26XX_setMux(pinHandle, Board_LNA_EN, PINCC26XX_MUX_RFC_GPO0); //data out 0
PINCC26XX_setMux(pinHandle, Board_PA_EN, PINCC26XX_MUX_RFC_GPO1); // data out 1
// }
RF_Params rfParams;
RF_Params_init(&rfParams);
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);
}
/* Modify CMD_PROP_RX command for application needs */
RF_cmdPropRx.pQueue = &dataQueue; /* Set the Data Entity queue for received data */
RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1; /* Discard ignored packets from Rx queue */
RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1; /* Discard packets with CRC error from Rx queue */
RF_cmdPropRx.maxPktLen = MAX_LENGTH; /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
RF_cmdPropRx.pktConf.bRepeatOk = 1;
RF_cmdPropRx.pktConf.bRepeatNok = 1;
/*
uint8_t i = 0;
do
{
if ((pOverrides_fsk[i] & 0x0000FFFF) == 0x000088A3)
{
pOverrides_fsk[i] = (uint32_t)0x000188A3;
}
} while ((pOverrides_fsk[i++] != 0xFFFFFFFF));
*/
/* Request access to the radio */
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
/* Set the frequency */
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
/* Enter RX mode and stay forever in RX */
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, IRQ_RX_ENTRY_DONE);
while(1);
}
void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
if (e & RF_EventRxEntryDone)
{
/* Get current unhandled data entry */
currentDataEntry = RFQueue_getDataEntry();
/* Handle the packet data, located at ¤tDataEntry->data:
* - Length is the first byte with the current configuration
* - Data starts from the second byte */
packetLength = *(uint8_t*)(¤tDataEntry->data);
packetDataPointer = (uint8_t*)(¤tDataEntry->data + 1);
/* Copy the payload + the status byte to the packet variable */
memcpy(packet, packetDataPointer, (packetLength + 1));
uint8_t i;
for (i = 2; i < MAX_LENGTH; i++)
{
packet[i] = 'C';
}
if (packet[2] == 'C')
PIN_setOutputValue(pinHandle, Board_LED2,!PIN_getOutputValue(Board_LED2));
RFQueue_nextEntry();
}
}
/*
* ======== main ========
*/
int main(void)
{
/* Call board init functions. */
Board_initGeneral();
/* Open LED pins */
ledPinHandle = PIN_open(&ledPinState, pinTable);
if(!ledPinHandle)
{
System_abort("Error initializing board LED pins\n");
}
/* Initialize task */
RxTask_init(ledPinHandle);
/* Start BIOS */
BIOS_start();
return (0);
}