Skip to content

Instantly share code, notes, and snippets.

@KrissN
Last active December 22, 2021 12:42
Show Gist options
  • Save KrissN/ad86b1731f2dce8123daae8aa3733ef5 to your computer and use it in GitHub Desktop.
Save KrissN/ad86b1731f2dce8123daae8aa3733ef5 to your computer and use it in GitHub Desktop.
Radio front-end configuration for EByte E72-2G4M20S1E (TI CC2652P based)
/*
* Copyright (c) 2018-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.
*/
/*
* =================== CC26X2R1_LAUNCHXL_fxns.c ============================
* This file contains the board-specific initialization functions.
*/
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <ti/devices/cc13x2_cc26x2/driverlib/ioc.h>
#include <ti/devices/cc13x2_cc26x2/driverlib/cpu.h>
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/pin/PINCC26XX.h>
#include "ti_drivers_config.h"
/*
* ======== Antenna switching ========
*/
static PIN_Handle antennaPins;
static PIN_State antennaState;
void initAntennaSwitch()
{
const PIN_Config antennaConfig[] = {
/* Parent Signal: /ti/drivers/RF RF Antenna Pin 0, (DIO5) */
CONFIG_RF_ANTENNA_PIN_PA | PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_DIS,
/* Parent Signal: /ti/drivers/RF RF Antenna Pin 1, (DIO6) */
CONFIG_RF_ANTENNA_PIN_LNA | PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_DIS,
PIN_TERMINATE
};
antennaPins = PIN_open(&antennaState, antennaConfig);
}
/*
* ======== rfDriverCallback ========
* Sets up the antenna switch depending on the current PHY configuration.
* Truth table:
*
* Path DIO5 DIO6
* =========== ===== =====
* Off 0 0
* 2.4 GHz 0 1
* 20 dBm TX 1 0
*/
void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void* arg)
{
/* Switch off all paths first. Needs to be done anyway in every sub-case below. */
PINCC26XX_setOutputValue(CONFIG_RF_ANTENNA_PIN_PA, 0);
PINCC26XX_setOutputValue(CONFIG_RF_ANTENNA_PIN_LNA, 0);
if (events & RF_GlobalEventRadioSetup) {
/* Decode the current PA configuration. */
RF_TxPowerTable_PAType paType = (RF_TxPowerTable_PAType)RF_getTxPower(client).paType;
/* 2.4 GHz */
if (paType == RF_TxPowerTable_HighPA) {
/* PA enable --> HIGH PA
* LNA enable --> 2.4 GHz
*/
PINCC26XX_setMux(antennaPins, CONFIG_RF_ANTENNA_PIN_LNA, PINCC26XX_MUX_RFC_GPO0);
/* Note: RFC_GPO3 is a work-around because the RFC_GPO1 (PA enable signal) is sometimes not
de-asserted on CC1352 Rev A. */
PINCC26XX_setMux(antennaPins, CONFIG_RF_ANTENNA_PIN_PA, PINCC26XX_MUX_RFC_GPO3);
} else {
/* RF core active --> 2.4 GHz */
PINCC26XX_setMux(antennaPins, CONFIG_RF_ANTENNA_PIN_LNA, PINCC26XX_MUX_GPIO);
PINCC26XX_setMux(antennaPins, CONFIG_RF_ANTENNA_PIN_PA, PINCC26XX_MUX_GPIO);
PINCC26XX_setOutputValue(CONFIG_RF_ANTENNA_PIN_LNA, 1);
}
} else {
/* Reset the IO multiplexer to GPIO functionality */
PINCC26XX_setMux(antennaPins, CONFIG_RF_ANTENNA_PIN_LNA, PINCC26XX_MUX_GPIO);
PINCC26XX_setMux(antennaPins, CONFIG_RF_ANTENNA_PIN_PA, PINCC26XX_MUX_GPIO);
}
}
void rfDriverCallbackAntennaSwitching(RF_Handle client, RF_GlobalEvent events, void* arg)
{
/* Nothing here as all the work happens in rfDriverCallback. */
}
/*
* ======== Board_initHook ========
* Called by Board_init() to perform board-specific initialization.
*/
void Board_initHook()
{
initAntennaSwitch();
}
/**
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
* @cliArgs --device "CC1352P1F3RGZ" --package "RGZ" --part "Default" --product "simplelink_cc13x2_26x2_sdk@4.40.04.04"
* @versions {"tool":"1.9.0+2015","templates":null}
*/
/**
* Import the modules used in this configuration.
*/
const CCFG = scripting.addModule("/ti/devices/CCFG");
const rfdesign = scripting.addModule("/ti/devices/radioconfig/rfdesign");
const AESCBC = scripting.addModule("/ti/drivers/AESCBC");
const AESCBC1 = AESCBC.addInstance();
const AESCCM = scripting.addModule("/ti/drivers/AESCCM");
const AESCCM1 = AESCCM.addInstance();
const AESECB = scripting.addModule("/ti/drivers/AESECB");
const AESECB1 = AESECB.addInstance();
const Board = scripting.addModule("/ti/drivers/Board");
const DMA = scripting.addModule("/ti/drivers/DMA");
const ECDH = scripting.addModule("/ti/drivers/ECDH");
const ECDH1 = ECDH.addInstance();
const ECDSA = scripting.addModule("/ti/drivers/ECDSA");
const ECDSA1 = ECDSA.addInstance();
const ECJPAKE = scripting.addModule("/ti/drivers/ECJPAKE");
const ECJPAKE1 = ECJPAKE.addInstance();
const NVS = scripting.addModule("/ti/drivers/NVS");
const NVS1 = NVS.addInstance();
const Power = scripting.addModule("/ti/drivers/Power");
const RF = scripting.addModule("/ti/drivers/RF");
const SHA2 = scripting.addModule("/ti/drivers/SHA2");
const SHA21 = SHA2.addInstance();
const TRNG = scripting.addModule("/ti/drivers/TRNG");
const TRNG1 = TRNG.addInstance();
const zstack = scripting.addModule("/ti/zstack/zstack");
/**
* Write custom configuration values to the imported modules.
*/
CCFG.enableBootloader = true;
CCFG.enableBootloaderBackdoor = true;
CCFG.dioBootloaderBackdoor = 13;
CCFG.levelBootloaderBackdoor = "Active low";
CCFG.ccfgTemplate.$name = "ti_devices_CCFGTemplate0";
rfdesign.rfDesign = "LAUNCHXL-CC1352P-2";
AESCBC1.$name = "CONFIG_AESCBC_0";
AESCCM1.$name = "CONFIG_AESCCM_0";
AESCCM1.interruptPriority = "2";
AESECB1.$name = "CONFIG_AESECB_0";
AESECB1.interruptPriority = "1";
ECDH1.$name = "CONFIG_ECDH_0";
ECDSA1.$name = "CONFIG_ECDSA_0";
ECJPAKE1.$name = "CONFIG_ECJPAKE_0";
NVS1.$name = "CONFIG_NVSINTERNAL";
NVS1.internalFlash.$name = "ti_drivers_nvs_NVSCC26XX0";
NVS1.internalFlash.regionBase = 0x52000;
NVS1.internalFlash.regionSize = 0x4000;
RF.globalCallbackFunction = "rfDriverCallback";
RF.pinSelectionAntenna = 2;
RF.rfAntennaPinSymbol0 = "CONFIG_RF_ANTENNA_PIN_PA";
RF.rfAntennaPinSymbol1 = "CONFIG_RF_ANTENNA_PIN_LNA";
RF.rfAntennaPin0.$assign = "DIO_5";
RF.rfAntennaPin1.$assign = "DIO_6";
SHA21.$name = "CONFIG_SHA2_0";
TRNG1.$name = "CONFIG_TRNG_0";
zstack.deviceType = "zr";
zstack.deviceTypeReadOnly = true;
zstack.touchlink.$name = "ti_zstack_touchlink_zstack_touchlink0";
zstack.pm.$name = "ti_zstack_pm_zstack_pm0";
zstack.rf.$name = "ti_zstack_rf_zstack_rf0";
zstack.rf.txPower = "2";
zstack.rf.primaryChannels = [11,15,19,23,26];
zstack.rf.radioConfig.$name = "ti_devices_radioconfig_settings_ieee_15_40";
zstack.rf.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param0";
zstack.network.$name = "ti_zstack_network_zstack_network0";
zstack.advanced.$name = "ti_zstack_advanced_zstack_advanced0";
zstack.advanced.routing.$name = "ti_zstack_advanced_zstack_routing0";
zstack.advanced.packetSending.$name = "ti_zstack_advanced_zstack_packet_sending0";
zstack.advanced.tableSize.$name = "ti_zstack_advanced_zstack_table_size0";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment