diff --git a/.ccsproject b/.ccsproject new file mode 100644 index 0000000..ed5c90f --- /dev/null +++ b/.ccsproject @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/.cproject b/.cproject new file mode 100644 index 0000000..8f00122 --- /dev/null +++ b/.cproject @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launches/empty_min_CC2650STK_TI.launch b/.launches/empty_min_CC2650STK_TI.launch new file mode 100644 index 0000000..6021a6b --- /dev/null +++ b/.launches/empty_min_CC2650STK_TI.launch @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/.launches/sniffer_CC2650STK.launch b/.launches/sniffer_CC2650STK.launch new file mode 100644 index 0000000..1610807 --- /dev/null +++ b/.launches/sniffer_CC2650STK.launch @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..9edb910 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + sniffer_CC2650STK + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.rtsc.xdctools.buildDefinitions.XDC.xdcNature + com.ti.ccstudio.core.ccsNature + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/.settings/org.eclipse.cdt.codan.core.prefs b/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 0000000..98b6350 --- /dev/null +++ b/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +inEditor=false +onBuild=false diff --git a/.settings/org.eclipse.cdt.debug.core.prefs b/.settings/org.eclipse.cdt.debug.core.prefs new file mode 100644 index 0000000..58d4fb2 --- /dev/null +++ b/.settings/org.eclipse.cdt.debug.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.cdt.debug.core.toggleBreakpointModel=com.ti.ccstudio.debug.CCSBreakpointMarker diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..9f85c7a --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,27 @@ +eclipse.preferences.version=1 +encoding//Debug/makefile=UTF-8 +encoding//Debug/objects.mk=UTF-8 +encoding//Debug/source/phy/devices/cc26x0lp/subdir_rules.mk=UTF-8 +encoding//Debug/source/phy/devices/cc26x0lp/subdir_vars.mk=UTF-8 +encoding//Debug/source/phy/subdir_rules.mk=UTF-8 +encoding//Debug/source/phy/subdir_vars.mk=UTF-8 +encoding//Debug/source/smartrf_settings/cc26x0lp/15.4/subdir_rules.mk=UTF-8 +encoding//Debug/source/smartrf_settings/cc26x0lp/15.4/subdir_vars.mk=UTF-8 +encoding//Debug/source/subdir_rules.mk=UTF-8 +encoding//Debug/source/subdir_vars.mk=UTF-8 +encoding//Debug/sources.mk=UTF-8 +encoding//Debug/subdir_rules.mk=UTF-8 +encoding//Debug/subdir_vars.mk=UTF-8 +encoding//Release/makefile=UTF-8 +encoding//Release/objects.mk=UTF-8 +encoding//Release/source/phy/devices/cc26x0lp/subdir_rules.mk=UTF-8 +encoding//Release/source/phy/devices/cc26x0lp/subdir_vars.mk=UTF-8 +encoding//Release/source/phy/subdir_rules.mk=UTF-8 +encoding//Release/source/phy/subdir_vars.mk=UTF-8 +encoding//Release/source/smartrf_settings/cc26x0lp/15.4/subdir_rules.mk=UTF-8 +encoding//Release/source/smartrf_settings/cc26x0lp/15.4/subdir_vars.mk=UTF-8 +encoding//Release/source/subdir_rules.mk=UTF-8 +encoding//Release/source/subdir_vars.mk=UTF-8 +encoding//Release/sources.mk=UTF-8 +encoding//Release/subdir_rules.mk=UTF-8 +encoding//Release/subdir_vars.mk=UTF-8 diff --git a/.xdchelp b/.xdchelp new file mode 100644 index 0000000..e69de29 diff --git a/Board.h b/Board.h new file mode 100644 index 0000000..764c94d --- /dev/null +++ b/Board.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2015-2016, 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. + */ + +#ifndef __BOARD_H +#define __BOARD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "CC2650STK.h" + + +#define Board_PIN_LED1 Board_STK_LED1 + +/* These #defines allow us to reuse TI-RTOS across other device families */ +#define Board_LED1 Board_STK_LED1 +#define Board_LED2 Board_STK_LED2 +#define Board_LED0 Board_LED2 + +#define Board_BUTTON0 Board_KEY_LEFT +#define Board_BUTTON1 Board_KEY_RIGHT + +#define Board_I2C0 Board_I2C +#define Board_I2C_TMP Board_I2C0 +#define Board_UART0 Board_UART +#define Board_AES0 Board_AES +#define Board_WATCHDOG0 CC2650STK_WATCHDOG0 + +#define Board_initGeneral() { \ + Power_init(); \ + if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) \ + {System_abort("Error with PIN_init\n"); \ + } \ +} + +#define Board_initGPIO() +#define Board_initPWM() PWM_init() +#define Board_initI2C() I2C_init() +#define Board_initSPI() SPI_init() +#define Board_initUART() UART_init() +#define Board_initWatchdog() Watchdog_init() +#define GPIO_toggle(n) +#define GPIO_write(n,m) + +/* Board specific I2C addresses */ + +/* Interface #0 */ +#define Board_HDC1000_ADDR (0x43) +#define Board_TMP007_ADDR (0x44) +#define Board_OPT3001_ADDR (0x45) +#define Board_BMP280_ADDR (0x77) + +/* Interface #1 */ +#define Board_MPU9250_ADDR (0x68) +#define Board_MPU9250_MAG_ADDR (0x0C) + +#ifdef __cplusplus +} +#endif + +#endif /* __BOARD_H */ diff --git a/CC2650STK.c b/CC2650STK.c new file mode 100644 index 0000000..5e3da59 --- /dev/null +++ b/CC2650STK.c @@ -0,0 +1,647 @@ +/* + * Copyright (c) 2015-2016, 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. + */ + +/* + * ====================== CC2650STK.c ========================================= + * This file is responsible for setting up the board specific items for the + * CC2650 SensorTag. + */ + + +/* + * ====================== Includes ============================================ + */ +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +/* + * ========================= IO driver initialization ========================= + * From main, PIN_init(BoardGpioInitTable) should be called to setup safe + * settings for this board. + * When a pin is allocated and then de-allocated, it will revert to the state + * configured in this table. + */ +/* Place into subsections to allow the TI linker to remove items properly */ +#if defined(__TI_COMPILER_VERSION__) +#pragma DATA_SECTION(BoardGpioInitTable, ".const:BoardGpioInitTable") +#pragma DATA_SECTION(PINCC26XX_hwAttrs, ".const:PINCC26XX_hwAttrs") +#endif + +const PIN_Config BoardGpioInitTable[] = { + + Board_STK_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */ + Board_STK_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */ + Board_KEY_LEFT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ + Board_KEY_RIGHT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ + Board_RELAY | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Relay is active high */ + Board_MPU_INT | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_NEGEDGE | PIN_HYSTERESIS, /* MPU_INT is active low */ + Board_TMP_RDY | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* TMP_RDY is active high */ + Board_BUZZER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* Buzzer initially off */ + Board_MPU_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* MPU initially on */ + Board_MIC_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* MIC initially off */ + Board_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ + Board_SPI_DEVPK_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* DevPack chip select */ + Board_AUDIO_DI | PIN_INPUT_EN | PIN_PULLDOWN, /* Audio DI */ + Board_AUDIODO | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* Audio data out */ + Board_AUDIO_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ + Board_DP2 | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ + Board_DP1 | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ + Board_DP0 | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ + Board_DP3 | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ + Board_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ + Board_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* DevPack */ + Board_DEVPK_ID | PIN_INPUT_EN | PIN_NOPULL, /* Device pack ID - external PU */ + Board_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */ + Board_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */ + Board_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */ + + PIN_TERMINATE +}; + +const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { + .intPriority = ~0, + .swiPriority = 0 +}; +/*============================================================================*/ + +/* + * ============================= Power begin ================================== + */ +/* Place into subsections to allow the TI linker to remove items properly */ +#if defined(__TI_COMPILER_VERSION__) +#pragma DATA_SECTION(PowerCC26XX_config, ".const:PowerCC26XX_config") +#endif +const PowerCC26XX_Config PowerCC26XX_config = { + .policyInitFxn = NULL, + .policyFxn = &PowerCC26XX_standbyPolicy, + .calibrateFxn = &PowerCC26XX_calibrate, + .enablePolicy = TRUE, + .calibrateRCOSC_LF = TRUE, + .calibrateRCOSC_HF = TRUE, +}; +/* + * ============================= Power end =================================== + */ + +/* + * ============================= UART begin =================================== + */ +/* Place into subsections to allow the TI linker to remove items properly */ +#if defined(__TI_COMPILER_VERSION__) +#pragma DATA_SECTION(UART_config, ".const:UART_config") +#pragma DATA_SECTION(uartCC26XXHWAttrs, ".const:uartCC26XXHWAttrs") +#endif + +/* Include drivers */ +#include +#include + +/* UART objects */ +UARTCC26XX_Object uartCC26XXObjects[CC2650STK_UARTCOUNT]; +unsigned char uartCC26XXRingBuffer[CC2650STK_UARTCOUNT][32]; + +/* UART hardware parameter structure, also used to assign UART pins */ +const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC2650STK_UARTCOUNT] = { + { + .baseAddr = UART0_BASE, + .powerMngrId = PowerCC26XX_PERIPH_UART0, + .intNum = INT_UART0_COMB, + .intPriority = ~0, + .swiPriority = 0, + .txPin = Board_UART_TX, + .rxPin = Board_UART_RX, + .ctsPin = PIN_UNASSIGNED, + .rtsPin = PIN_UNASSIGNED, + .ringBufPtr = uartCC26XXRingBuffer[0], + .ringBufSize = sizeof(uartCC26XXRingBuffer[0]) + } +}; + +/* UART configuration structure */ +const UART_Config UART_config[] = { + { + .fxnTablePtr = &UARTCC26XX_fxnTable, + .object = &uartCC26XXObjects[0], + .hwAttrs = &uartCC26XXHWAttrs[0] + }, + {NULL, NULL, NULL} +}; +/* + * ============================= UART end ===================================== + */ + +/* + * ============================= UDMA begin =================================== + */ +/* Place into subsections to allow the TI linker to remove items properly */ +#if defined(__TI_COMPILER_VERSION__) +#pragma DATA_SECTION(UDMACC26XX_config, ".const:UDMACC26XX_config") +#pragma DATA_SECTION(udmaHWAttrs, ".const:udmaHWAttrs") +#endif + +/* Include drivers */ +#include + +/* UDMA objects */ +UDMACC26XX_Object udmaObjects[CC2650STK_UDMACOUNT]; + +/* UDMA configuration structure */ +const UDMACC26XX_HWAttrs udmaHWAttrs[CC2650STK_UDMACOUNT] = { + { + .baseAddr = UDMA0_BASE, + .powerMngrId = PowerCC26XX_PERIPH_UDMA, + .intNum = INT_DMA_ERR, + .intPriority = ~0 + } +}; + +/* UDMA configuration structure */ +const UDMACC26XX_Config UDMACC26XX_config[] = { + { + .object = &udmaObjects[0], + .hwAttrs = &udmaHWAttrs[0] + }, + {NULL, NULL} +}; +/* + * ============================= UDMA end ===================================== + */ + +/* + * ========================== SPI DMA begin =================================== + */ +/* Place into subsections to allow the TI linker to remove items properly */ +#if defined(__TI_COMPILER_VERSION__) +#pragma DATA_SECTION(SPI_config, ".const:SPI_config") +#pragma DATA_SECTION(spiCC26XXDMAHWAttrs, ".const:spiCC26XXDMAHWAttrs") +#endif + +/* Include drivers */ +#include + +/* SPI objects */ +SPICC26XXDMA_Object spiCC26XXDMAObjects[CC2650STK_SPICOUNT]; + +/* SPI configuration structure, describing which pins are to be used */ +const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC2650STK_SPICOUNT] = { + { + .baseAddr = SSI0_BASE, + .intNum = INT_SSI0_COMB, + .intPriority = ~0, + .swiPriority = 0, + .powerMngrId = PowerCC26XX_PERIPH_SSI0, + .defaultTxBufValue = 0, + .rxChannelBitMask = 1< + +/* I2C objects */ +I2CCC26XX_Object i2cCC26xxObjects[CC2650STK_I2CCOUNT]; + +/* I2C configuration structure, describing which pins are to be used */ +const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC2650STK_I2CCOUNT] = { + { + .baseAddr = I2C0_BASE, + .powerMngrId = PowerCC26XX_PERIPH_I2C0, + .intNum = INT_I2C_IRQ, + .intPriority = ~0, + .swiPriority = 0, + .sdaPin = Board_I2C0_SDA0, + .sclPin = Board_I2C0_SCL0, + } +}; + +const I2C_Config I2C_config[] = { + { + .fxnTablePtr = &I2CCC26XX_fxnTable, + .object = &i2cCC26xxObjects[0], + .hwAttrs = &i2cCC26xxHWAttrs[0] + }, + {NULL, NULL, NULL} +}; +/* + * ========================== I2C end ========================================= + */ + +/* + * ========================== Crypto begin ==================================== + * NOTE: The Crypto implementation should be considered experimental + * and not validated! + */ +/* Place into subsections to allow the TI linker to remove items properly */ +#if defined(__TI_COMPILER_VERSION__) +#pragma DATA_SECTION(CryptoCC26XX_config, ".const:CryptoCC26XX_config") +#pragma DATA_SECTION(cryptoCC26XXHWAttrs, ".const:cryptoCC26XXHWAttrs") +#endif + +/* Include drivers */ +#include + +/* Crypto objects */ +CryptoCC26XX_Object cryptoCC26XXObjects[CC2650STK_CRYPTOCOUNT]; + +/* Crypto configuration structure, describing which pins are to be used */ +const CryptoCC26XX_HWAttrs cryptoCC26XXHWAttrs[CC2650STK_CRYPTOCOUNT] = { + { + .baseAddr = CRYPTO_BASE, + .powerMngrId = PowerCC26XX_PERIPH_CRYPTO, + .intNum = INT_CRYPTO_RESULT_AVAIL_IRQ, + .intPriority = ~0, + } +}; + +/* Crypto configuration structure */ +const CryptoCC26XX_Config CryptoCC26XX_config[] = { + { + .object = &cryptoCC26XXObjects[0], + .hwAttrs = &cryptoCC26XXHWAttrs[0] + }, + {NULL, NULL} +}; +/* + * ========================== Crypto end ====================================== + */ + +/* + * ============================= PDM begin ==================================== + */ +/* Place into subsections to allow the TI linker to remove items properly */ +#if defined(__TI_COMPILER_VERSION__) +#pragma DATA_SECTION(PDMCC26XX_config, ".const:PDMCC26XX_config") +#pragma DATA_SECTION(pdmCC26XXHWAttrs, ".const:pdmCC26XXHWAttrs") +#pragma DATA_SECTION(pdmC26XXI2SHWAttrs, ".const:pdmC26XXI2SHWAttrs") +#pragma DATA_SECTION(PDMCC26XX_I2S_config, ".const:PDMCC26XX_I2S_config") +#endif + +/* Include drivers */ +#include +#include + +/* PDM objects, one for PDM driver, one for PDM/I2S helper file */ +PDMCC26XX_Object pdmCC26XXObjects[CC2650STK_PDMCOUNT]; +PDMCC26XX_I2S_Object pdmCC26XXI2SObjects[CC2650STK_PDMCOUNT]; + +/* PDM driver hardware attributes */ +const PDMCC26XX_HWAttrs pdmCC26XXHWAttrs[CC2650STK_PDMCOUNT] = { + { + .micPower = Board_MIC_POWER, + .taskPriority = 2 + } +}; + +/* PDM configuration structure */ +const PDMCC26XX_Config PDMCC26XX_config[] = { + { + .object = &pdmCC26XXObjects[0], + .hwAttrs = &pdmCC26XXHWAttrs[0] + } +}; + +/* PDM_I2S hardware attributes */ +const PDMCC26XX_I2S_HWAttrs pdmC26XXI2SHWAttrs[CC2650STK_PDMCOUNT] = { + { + .baseAddr = I2S0_BASE, + .intNum = INT_I2S_IRQ, + .powerMngrId = PowerCC26XX_PERIPH_I2S, + .intPriority = ~0, + .mclkPin = PIN_UNASSIGNED, + .bclkPin = Board_AUDIO_CLK, + .wclkPin = PIN_UNASSIGNED, + .ad0Pin = Board_AUDIO_DI, + } +}; + +/* PDM_I2S configuration structure */ +const PDMCC26XX_I2S_Config PDMCC26XX_I2S_config[] = { + { + .object = &pdmCC26XXI2SObjects[0], + .hwAttrs = &pdmC26XXI2SHWAttrs[0] + }, + { NULL, NULL } +}; + +/* + * ============================= PDM end ====================================== + */ + +/* + * ========================= RF driver begin ================================== + */ +/* Place into subsections to allow the TI linker to remove items properly */ +#if defined(__TI_COMPILER_VERSION__) +#pragma DATA_SECTION(RFCC26XX_hwAttrs, ".const:RFCC26XX_hwAttrs") +#endif + +/* Include drivers */ +#include + +/* RF hwi and swi priority */ +const RFCC26XX_HWAttrs RFCC26XX_hwAttrs = { + .hwiCpe0Priority = ~0, + .hwiHwPriority = ~0, + .swiCpe0Priority = 0, + .swiHwPriority = 0, +}; + +/* + * ========================== RF driver end =================================== + */ + +/* + * ========================= Display begin ==================================== + */ +/* Place into subsections to allow the TI linker to remove items properly */ +#if defined(__TI_COMPILER_VERSION__) +#pragma DATA_SECTION(Display_config, ".const:Display_config") +#pragma DATA_SECTION(displaySharpHWattrs, ".const:displaySharpHWattrs") +#pragma DATA_SECTION(displayUartHWAttrs, ".const:displayUartHWAttrs") +#endif + +#include +#include +#include + +/* Structures for UartPlain Blocking */ +DisplayUart_Object displayUartObject; + +#ifndef BOARD_DISPLAY_UART_STRBUF_SIZE +#define BOARD_DISPLAY_UART_STRBUF_SIZE 128 +#endif +static char uartStringBuf[BOARD_DISPLAY_UART_STRBUF_SIZE]; + +const DisplayUart_HWAttrs displayUartHWAttrs = { + .uartIdx = Board_UART, + .baudRate = 115200, + .mutexTimeout = BIOS_WAIT_FOREVER, + .strBuf = uartStringBuf, + .strBufLen = BOARD_DISPLAY_UART_STRBUF_SIZE, +}; + +/* Structures for SHARP */ +DisplaySharp_Object displaySharpObject; + +#ifndef BOARD_DISPLAY_SHARP_SIZE +#define BOARD_DISPLAY_SHARP_SIZE 96 // 96->96x96 is the most common board, alternative is 128->128x128. +#endif +static uint8_t sharpDisplayBuf[BOARD_DISPLAY_SHARP_SIZE * BOARD_DISPLAY_SHARP_SIZE / 8]; + +const DisplaySharp_HWAttrs displaySharpHWattrs = { + .spiIndex = Board_SPI0, + .csPin = Board_LCD_CS, + .extcominPin = Board_LCD_EXTCOMIN, + .powerPin = Board_LCD_POWER, + .enablePin = Board_LCD_ENABLE, + .pixelWidth = BOARD_DISPLAY_SHARP_SIZE, + .pixelHeight = BOARD_DISPLAY_SHARP_SIZE, + .displayBuf = sharpDisplayBuf, +}; + +/* As the pins for UART and Watch Devpack conflict, prefer UART by default */ +#if !defined(BOARD_DISPLAY_EXCLUDE_UART) && !defined(BOARD_DISPLAY_EXCLUDE_LCD) +# define BOARD_DISPLAY_EXCLUDE_LCD +#endif + +/* Array of displays */ +const Display_Config Display_config[] = { +#if !defined(BOARD_DISPLAY_EXCLUDE_UART) + { + .fxnTablePtr = &DisplayUart_fxnTable, + .object = &displayUartObject, + .hwAttrs = &displayUartHWAttrs, + }, +#endif +#if !defined(BOARD_DISPLAY_EXCLUDE_LCD) + { + .fxnTablePtr = &DisplaySharp_fxnTable, + .object = &displaySharpObject, + .hwAttrs = &displaySharpHWattrs + }, +#endif + { NULL, NULL, NULL } // Terminator +}; + +/* + * ========================= Display end ====================================== + */ + +/* + * ============================ GPTimer begin ================================= + * Remove unused entries to reduce flash usage both in Board.c and Board.h + */ +/* Place into subsections to allow the TI linker to remove items properly */ +#if defined(__TI_COMPILER_VERSION__) +#pragma DATA_SECTION(GPTimerCC26XX_config, ".const:GPTimerCC26XX_config") +#pragma DATA_SECTION(gptimerCC26xxHWAttrs, ".const:gptimerCC26xxHWAttrs") +#endif + +/* GPTimer hardware attributes, one per timer part (Timer 0A, 0B, 1A, 1B..) */ +const GPTimerCC26XX_HWAttrs gptimerCC26xxHWAttrs[CC2650STK_GPTIMERPARTSCOUNT] = { + { .baseAddr = GPT0_BASE, .intNum = INT_GPT0A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0A, }, + { .baseAddr = GPT0_BASE, .intNum = INT_GPT0B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0B, }, + { .baseAddr = GPT1_BASE, .intNum = INT_GPT1A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT1, .pinMux = GPT_PIN_1A, }, + { .baseAddr = GPT1_BASE, .intNum = INT_GPT1B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT1, .pinMux = GPT_PIN_1B, }, + { .baseAddr = GPT2_BASE, .intNum = INT_GPT2A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT2, .pinMux = GPT_PIN_2A, }, + { .baseAddr = GPT2_BASE, .intNum = INT_GPT2B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT2, .pinMux = GPT_PIN_2B, }, + { .baseAddr = GPT3_BASE, .intNum = INT_GPT3A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT3, .pinMux = GPT_PIN_3A, }, + { .baseAddr = GPT3_BASE, .intNum = INT_GPT3B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT3, .pinMux = GPT_PIN_3B, }, +}; + +/* GPTimer objects, one per full-width timer (A+B) (Timer 0, Timer 1..) */ +GPTimerCC26XX_Object gptimerCC26XXObjects[CC2650STK_GPTIMERCOUNT]; + +/* GPTimer configuration (used as GPTimer_Handle by driver and application) */ +const GPTimerCC26XX_Config GPTimerCC26XX_config[CC2650STK_GPTIMERPARTSCOUNT] = { + { &gptimerCC26XXObjects[0], &gptimerCC26xxHWAttrs[0], GPT_A }, + { &gptimerCC26XXObjects[0], &gptimerCC26xxHWAttrs[1], GPT_B }, + { &gptimerCC26XXObjects[1], &gptimerCC26xxHWAttrs[2], GPT_A }, + { &gptimerCC26XXObjects[1], &gptimerCC26xxHWAttrs[3], GPT_B }, + { &gptimerCC26XXObjects[2], &gptimerCC26xxHWAttrs[4], GPT_A }, + { &gptimerCC26XXObjects[2], &gptimerCC26xxHWAttrs[5], GPT_B }, + { &gptimerCC26XXObjects[3], &gptimerCC26xxHWAttrs[6], GPT_A }, + { &gptimerCC26XXObjects[3], &gptimerCC26xxHWAttrs[7], GPT_B }, +}; + +/* + * ============================ GPTimer end =================================== + */ + + + +/* + * ============================= PWM begin ==================================== + * Remove unused entries to reduce flash usage both in Board.c and Board.h + */ +/* Place into subsections to allow the TI linker to remove items properly */ +#if defined(__TI_COMPILER_VERSION__) +#pragma DATA_SECTION(PWM_config, ".const:PWM_config") +#pragma DATA_SECTION(pwmtimerCC26xxHWAttrs, ".const:pwmtimerCC26xxHWAttrs") +#endif + +/* PWM configuration, one per PWM output. */ +PWMTimerCC26XX_HwAttrs pwmtimerCC26xxHWAttrs[CC2650STK_PWMCOUNT] = { + { .pwmPin = Board_PWMPIN0, .gpTimerUnit = Board_GPTIMER0A }, + { .pwmPin = Board_PWMPIN1, .gpTimerUnit = Board_GPTIMER0B }, + { .pwmPin = Board_PWMPIN2, .gpTimerUnit = Board_GPTIMER1A }, + { .pwmPin = Board_PWMPIN3, .gpTimerUnit = Board_GPTIMER1B }, + { .pwmPin = Board_PWMPIN4, .gpTimerUnit = Board_GPTIMER2A }, + { .pwmPin = Board_PWMPIN5, .gpTimerUnit = Board_GPTIMER2B }, + { .pwmPin = Board_PWMPIN6, .gpTimerUnit = Board_GPTIMER3A }, + { .pwmPin = Board_PWMPIN7, .gpTimerUnit = Board_GPTIMER3B }, +}; + +/* PWM object, one per PWM output */ +PWMTimerCC26XX_Object pwmtimerCC26xxObjects[CC2650STK_PWMCOUNT]; + +extern const PWM_FxnTable PWMTimerCC26XX_fxnTable; + +/* PWM configuration (used as PWM_Handle by driver and application) */ +const PWM_Config PWM_config[CC2650STK_PWMCOUNT + 1] = { + { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[0], &pwmtimerCC26xxHWAttrs[0] }, + { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[1], &pwmtimerCC26xxHWAttrs[1] }, + { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[2], &pwmtimerCC26xxHWAttrs[2] }, + { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[3], &pwmtimerCC26xxHWAttrs[3] }, + { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[4], &pwmtimerCC26xxHWAttrs[4] }, + { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[5], &pwmtimerCC26xxHWAttrs[5] }, + { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[6], &pwmtimerCC26xxHWAttrs[6] }, + { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[7], &pwmtimerCC26xxHWAttrs[7] }, + { NULL, NULL, NULL } +}; + + +/* + * ============================= PWM end ====================================== + */ + +/* + * =============================== Watchdog =============================== + */ +/* Place into subsections to allow the TI linker to remove items properly */ +#if defined(__TI_COMPILER_VERSION__) +#pragma DATA_SECTION(Watchdog_config, ".const:Watchdog_config") +#pragma DATA_SECTION(watchdogCC26XXHWAttrs, ".const:watchdogCC26XXHWAttrs") +#endif + +#include +#include + +WatchdogCC26XX_Object watchdogCC26XXObjects[CC2650STK_WATCHDOGCOUNT]; + +const WatchdogCC26XX_HWAttrs watchdogCC26XXHWAttrs[CC2650STK_WATCHDOGCOUNT] = { + { + .baseAddr = WDT_BASE, + .intNum = INT_WDT_IRQ, + .reloadValue = 1000 /* Reload value in milliseconds */ + }, +}; + +const Watchdog_Config Watchdog_config[] = { + { + .fxnTablePtr = &WatchdogCC26XX_fxnTable, + .object = &watchdogCC26XXObjects[0], + .hwAttrs = &watchdogCC26XXHWAttrs[0] + }, + {NULL, NULL, NULL}, +}; + +/* + * ======== CC26XX_LAUNCHXL_initWatchdog ======== + */ +void CC26XX_LAUNCHXL_initWatchdog(void) +{ + Watchdog_init(); +} diff --git a/CC2650STK.cmd b/CC2650STK.cmd new file mode 100644 index 0000000..ccb9738 --- /dev/null +++ b/CC2650STK.cmd @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2015-2016, 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. + */ +/* + * ======== CC2650STK.cmd ======== + * CC26x0F128 PG2 linker configuration file for Code Composer Studio + */ + +--stack_size=1024 /* C stack is also used for ISR stack */ + +HEAPSIZE = 0xC00; /* Size of heap buffer used by HeapMem */ + +/* Override default entry point. */ +--entry_point ResetISR +/* Allow main() to take args */ +--args 0x8 +/* Suppress warnings and errors: */ +/* - 10063: Warning about entry point not being _c_int00 */ +/* - 16011, 16012: 8-byte alignment errors. Observed when linking in object */ +/* files compiled using Keil (ARM compiler) */ +--diag_suppress=10063,16011,16012 + +/* The starting address of the application. Normally the interrupt vectors */ +/* must be located at the beginning of the application. */ +#define FLASH_BASE 0x0 +#define FLASH_SIZE 0x20000 +#define RAM_BASE 0x20000000 +#define RAM_SIZE 0x5000 +#define GPRAM_BASE 0x11000000 +#define GPRAM_SIZE 0x2000 + +/* System memory map */ + +MEMORY +{ + /* Application stored in and executes from internal flash */ + FLASH (RX) : origin = FLASH_BASE, length = FLASH_SIZE + /* Application uses internal RAM for data */ + SRAM (RWX) : origin = RAM_BASE, length = RAM_SIZE + GPRAM (RWX): origin = GPRAM_BASE, length = GPRAM_SIZE +} + +/* Section allocation in memory */ + +SECTIONS +{ + .text : > FLASH + .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT) + .const : > FLASH + .constdata : > FLASH + .rodata : > FLASH + .cinit : > FLASH + .pinit : > FLASH + .init_array : > FLASH + .emb_text : > FLASH + .ccfg : > FLASH (HIGH) + + .data : > SRAM + .bss : > SRAM + .sysmem : > SRAM + .nonretenvar : > SRAM + .gpram_data : > GPRAM + + /* Heap buffer used by HeapMem */ + .priheap : { + __primary_heap_start__ = .; + . += HEAPSIZE; + __primary_heap_end__ = .; + } > SRAM align 8 + + .stack : > SRAM (HIGH) +} diff --git a/CC2650STK.h b/CC2650STK.h new file mode 100644 index 0000000..6cfd69f --- /dev/null +++ b/CC2650STK.h @@ -0,0 +1,326 @@ +/* + * Copyright (c) 2015-2016, 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. + */ +/** ============================================================================ + * @file CC2650STK.h + * + * @brief CC2650SENSORTAG Board Specific header file. + * + * NB! This is the board file for PCB versions 1.2 and 1.3 + * + * ============================================================================ + */ +#ifndef __CC2650STK_SENSORTAG_BOARD_H__ +#define __CC2650STK_SENSORTAG_BOARD_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** ============================================================================ + * Includes + * ==========================================================================*/ +#include +#include + +/** ============================================================================ + * Externs + * ==========================================================================*/ +extern const PIN_Config BoardGpioInitTable[]; + +/** ============================================================================ + * Defines + * ==========================================================================*/ + +/* Same RF Configuration as 7x7 EM */ +#define CC2650EM_7ID +#define CC2650STK + +/* Mapping of pins to board signals using general board aliases + * + */ + +/* Discrete outputs */ +#define Board_STK_LED1 IOID_10 +#define Board_STK_LED2 IOID_15 +#define Board_BUZZER IOID_21 +#define Board_LED_ON 1 +#define Board_LED_OFF 0 +#define Board_BUZZER_ON 1 +#define Board_BUZZER_OFF 0 + +/* Discrete inputs */ +#define Board_KEY_LEFT IOID_0 +#define Board_KEY_RIGHT IOID_4 +#define Board_RELAY IOID_3 + +/* Sensor outputs */ +#define Board_MPU_INT IOID_7 +#define Board_TMP_RDY IOID_1 + +/* I2C */ +#define Board_I2C0_SDA0 IOID_5 +#define Board_I2C0_SCL0 IOID_6 +#define Board_I2C0_SDA1 IOID_8 +#define Board_I2C0_SCL1 IOID_9 + +/* SPI */ +#define Board_SPI_FLASH_CS IOID_14 +#define Board_SPI_DEVPK_CS IOID_20 +#define Board_FLASH_CS_ON 0 +#define Board_FLASH_CS_OFF 1 +#define Board_DEVPK_CS_ON 1 +#define Board_DEVPK_CS_OFF 0 + +#define Board_SPI0_MISO IOID_18 +#define Board_SPI0_MOSI IOID_19 +#define Board_SPI0_CLK IOID_17 +#define Board_SPI0_CSN PIN_UNASSIGNED +#define Board_SPI1_MISO PIN_UNASSIGNED +#define Board_SPI1_MOSI PIN_UNASSIGNED +#define Board_SPI1_CLK PIN_UNASSIGNED +#define Board_SPI1_CSN PIN_UNASSIGNED + +/* UART when connected to SRF06EB */ +#define Board_EB_UART_TX IOID_16 +#define Board_EB_UART_RX IOID_17 + +/* Power control */ +#define Board_MPU_POWER IOID_12 +#define Board_MPU_POWER_ON 1 +#define Board_MPU_POWER_OFF 0 + +/* Audio */ +#define Board_MIC_POWER IOID_13 +#define Board_MIC_POWER_ON 1 +#define Board_MIC_POWER_OFF 0 +#define Board_AUDIO_DI IOID_2 +#define Board_AUDIO_CLK IOID_11 + +/* UART pins used by driver */ +#define Board_UART_TX Board_DP5_UARTTX +#define Board_UART_RX Board_DP4_UARTRX + +/* DevPack common */ +#define Board_AUDIOFS_TDO IOID_16 +#define Board_AUDIODO IOID_22 +#define Board_DP2 IOID_23 +#define Board_DP1 IOID_24 +#define Board_DP0 IOID_25 +#define Board_DP3 IOID_27 +#define Board_DP4_UARTRX IOID_28 +#define Board_DP5_UARTTX IOID_29 +#define Board_DEVPK_ID IOID_30 +#define Board_SPI_DEVPK_CS IOID_20 + +/* LCD DevPack */ +#define Board_LCD_EXTCOMIN IOID_22 +#define Board_LCD_EXTMODE IOID_28 +#define Board_LCD_ENABLE IOID_29 +#define Board_LCD_POWER PIN_UNASSIGNED +#define Board_LCD_CS Board_SPI_DEVPK_CS +#define Board_LCD_CS_ON 1 +#define Board_LCD_CS_OFF 0 + +/* LED-Audio DevPack */ +#define Board_DEVPK_LIGHT_BLUE IOID_23 +#define Board_DEVPK_LIGHT_GREEN IOID_24 +#define Board_DEVPK_LIGHT_WHITE IOID_25 +#define Board_DEVPK_LIGHT_RED IOID_27 + +/* PWM outputs */ +#define Board_PWMPIN0 Board_STK_LED1 +#define Board_PWMPIN1 Board_STK_LED2 +#define Board_PWMPIN2 PIN_UNASSIGNED +#define Board_PWMPIN3 PIN_UNASSIGNED +#define Board_PWMPIN4 PIN_UNASSIGNED +#define Board_PWMPIN5 PIN_UNASSIGNED +#define Board_PWMPIN6 PIN_UNASSIGNED +#define Board_PWMPIN7 PIN_UNASSIGNED + +/** ============================================================================ + * Instance identifiers + * ==========================================================================*/ +/* Generic I2C instance identifiers */ +#define Board_I2C CC2650STK_I2C0 +/* Generic PDM instance identifiers */ +#define Board_PDM CC2650STK_PDM0 +/* Generic SPI instance identifiers */ +#define Board_SPI0 CC2650STK_SPI0 +#define Board_SPI1 CC2650STK_SPI1 +/* Generic UART instance identifiers */ +#define Board_UART CC2650STK_UART0 +/* Generic Crypto instance identifiers */ +#define Board_CRYPTO CC2650STK_CRYPTO0 +/* Generic GPTimer instance identifiers */ +#define Board_GPTIMER0A CC2650STK_GPTIMER0A +#define Board_GPTIMER0B CC2650STK_GPTIMER0B +#define Board_GPTIMER1A CC2650STK_GPTIMER1A +#define Board_GPTIMER1B CC2650STK_GPTIMER1B +#define Board_GPTIMER2A CC2650STK_GPTIMER2A +#define Board_GPTIMER2B CC2650STK_GPTIMER2B +#define Board_GPTIMER3A CC2650STK_GPTIMER3A +#define Board_GPTIMER3B CC2650STK_GPTIMER3B +/* Generic PWM instance identifiers */ +#define Board_PWM0 CC2650STK_PWM0 +#define Board_PWM1 CC2650STK_PWM1 +#define Board_PWM2 CC2650STK_PWM2 +#define Board_PWM3 CC2650STK_PWM3 +#define Board_PWM4 CC2650STK_PWM4 +#define Board_PWM5 CC2650STK_PWM5 +#define Board_PWM6 CC2650STK_PWM6 +#define Board_PWM7 CC2650STK_PWM7 + +/** ============================================================================ + * Number of peripherals and their names + * ==========================================================================*/ + +/*! + * @def CC2650STK_I2CName + * @brief Enum of I2C names on the CC2650 dev board + */ +typedef enum CC2650STK_I2CName { + CC2650STK_I2C0 = 0, + + CC2650STK_I2CCOUNT +} CC2650STK_I2CName; + +/*! + * @def CC2650STK_CryptoName + * @brief Enum of Crypto names on the CC2650 dev board + */ +typedef enum CC2650STK_CryptoName { + CC2650STK_CRYPTO0 = 0, + + CC2650STK_CRYPTOCOUNT +} CC2650STK_CryptoName; + +/*! + * @def CC2650STK_PdmName + * @brief Enum of PDM names on the CC2650 dev board + */ +typedef enum CC2650STK_PDMName { + CC2650STK_PDM0 = 0, + CC2650STK_PDMCOUNT +} CC2650STK_PDMName; + +/*! + * @def CC2650STK_SPIName + * @brief Enum of SPI names on the CC2650 dev board + */ +typedef enum CC2650STK_SPIName { + CC2650STK_SPI0 = 0, + CC2650STK_SPI1, + + CC2650STK_SPICOUNT +} CC2650STK_SPIName; + +/*! + * @def CC2650STK_UARTName + * @brief Enum of UARTs on the CC2650 dev board + */ +typedef enum CC2650STK_UARTName { + CC2650STK_UART0 = 0, + + CC2650STK_UARTCOUNT +} CC2650STK_UARTName; + +/*! + * @def CC2650STK_UdmaName + * @brief Enum of DMA buffers + */ +typedef enum CC2650STK_UdmaName { + CC2650STK_UDMA0 = 0, + + CC2650STK_UDMACOUNT +} CC2650STK_UdmaName; +/*! + * @def CC2650STK_GPTimerName + * @brief Enum of GPTimer parts + */ +typedef enum CC2650STK_GPTimerName +{ + CC2650STK_GPTIMER0A = 0, + CC2650STK_GPTIMER0B, + CC2650STK_GPTIMER1A, + CC2650STK_GPTIMER1B, + CC2650STK_GPTIMER2A, + CC2650STK_GPTIMER2B, + CC2650STK_GPTIMER3A, + CC2650STK_GPTIMER3B, + CC2650STK_GPTIMERPARTSCOUNT +} CC2650STK_GPTimerName; + +/*! + * @def CC2650STK_GPTimers + * @brief Enum of GPTimers + */ +typedef enum CC2650STK_GPTimers +{ + CC2650STK_GPTIMER0 = 0, + CC2650STK_GPTIMER1, + CC2650STK_GPTIMER2, + CC2650STK_GPTIMER3, + CC2650STK_GPTIMERCOUNT +} CC2650STK_GPTimers; + +/*! + * @def CC2650STK_PWM + * @brief Enum of PWM outputs on the board + */ +typedef enum CC2650STK_PWM +{ + CC2650STK_PWM0 = 0, + CC2650STK_PWM1, + CC2650STK_PWM2, + CC2650STK_PWM3, + CC2650STK_PWM4, + CC2650STK_PWM5, + CC2650STK_PWM6, + CC2650STK_PWM7, + CC2650STK_PWMCOUNT +} CC2650STK_PWM; + +/*! + * @def CC2650STK_WatchdogName + * @brief Enum of Watchdogs on the CC2650STK dev board + */ +typedef enum CC2650STK_WatchdogName { + CC2650STK_WATCHDOG0 = 0, + + CC2650STK_WATCHDOGCOUNT +} CC2650STK_WatchdogName; + +#ifdef __cplusplus +} +#endif + +#endif /* __CC2650STK_SENSORTAG_BOARD_H__ */ diff --git a/Debug/.gitignore b/Debug/.gitignore new file mode 100644 index 0000000..885a51a --- /dev/null +++ b/Debug/.gitignore @@ -0,0 +1,6 @@ +/makefile +/objects.mk +/source/ +/sources.mk +/subdir_rules.mk +/subdir_vars.mk diff --git a/DeviceFamily.h b/DeviceFamily.h new file mode 100644 index 0000000..50a2d4e --- /dev/null +++ b/DeviceFamily.h @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2017, 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. + */ +/** ============================================================================ + * @file DeviceFamily.h + * + * @brief Infrastructure to select correct driverlib path and identify devices + * + * This module enables the selection of the correct driverlib path for the current + * device. It also facilitates the use of per-device conditional compilation + * to enable minor variations in drivers between devices. + * + * In order to use this functionality, DeviceFamily_XYZ must be defined as one of + * the supported values. The DeviceFamily_ID and DeviceFamily_DIRECTORY defines + * are set based on DeviceFamily_XYZ. + */ + +#ifndef ti_devices_DeviceFamily__include +#define ti_devices_DeviceFamily__include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * DeviceFamily_ID_XYZ values. + * + * DeviceFamily_ID may be used in the preprocessor for conditional compilation. + * DeviceFamily_ID is set to one of these values based on the top level + * DeviceFamily_XYZ define. + */ +#define DeviceFamily_ID_CC13X0 1 +#define DeviceFamily_ID_CC26X0 2 +#define DeviceFamily_ID_CC26X0R2 3 +#define DeviceFamily_ID_CC13X2_V1 4 +#define DeviceFamily_ID_CC13X2_V2 5 +#define DeviceFamily_ID_CC13X2 DeviceFamily_ID_CC13X2_V1 +#define DeviceFamily_ID_CC26X2_V1 6 +#define DeviceFamily_ID_CC26X2_V2 7 +#define DeviceFamily_ID_CC26X2 DeviceFamily_ID_CC26X2_V1 +#define DeviceFamily_ID_CC3200 8 +#define DeviceFamily_ID_CC3220 9 +#define DeviceFamily_ID_MSP432P401x 10 +#define DeviceFamily_ID_MSP432P4x1xI 11 +#define DeviceFamily_ID_MSP432P4x1xT 12 +#define DeviceFamily_ID_MSP432E401Y 13 +#define DeviceFamily_ID_MSP432E411Y 14 + +/* + * DeviceFamily_PARENT_XYZ values. + * + * DeviceFamily_PARENT may be used in the preprocessor for conditional + * compilation. DeviceFamily_PARENT is set to one of these values based + * on the top-level DeviceFamily_XYZ define. + */ +#define DeviceFamily_PARENT_CC13X0_CC26X0 1 +#define DeviceFamily_PARENT_CC13X2_CC26X2 2 +#define DeviceFamily_PARENT_MSP432P401R 3 +#define DeviceFamily_PARENT_MSP432P4111 4 + +/* + * Lookup table that sets DeviceFamily_ID, DeviceFamily_DIRECTORY, and + * DeviceFamily_PARENT based on the DeviceFamily_XYZ define. + * If DeviceFamily_XYZ is undefined, a compiler error is thrown. If + * multiple DeviceFamily_XYZ are defined, the first one encountered is used. + */ +#if defined(DeviceFamily_CC13X0) + #define DeviceFamily_ID DeviceFamily_ID_CC13X0 + #define DeviceFamily_DIRECTORY cc13x0 + #define DeviceFamily_PARENT DeviceFamily_PARENT_CC13X0_CC26X0 + +#elif defined(DeviceFamily_CC13X2) + #define DeviceFamily_ID DeviceFamily_ID_CC13X2 + #define DeviceFamily_DIRECTORY cc13x2_cc26x2_v1 + #define DeviceFamily_PARENT DeviceFamily_PARENT_CC13X2_CC26X2 + +#elif defined(DeviceFamily_CC13X2_V1) + #define DeviceFamily_ID DeviceFamily_ID_CC13X2_V1 + #define DeviceFamily_DIRECTORY cc13x2_cc26x2_v1 + #define DeviceFamily_PARENT DeviceFamily_PARENT_CC13X2_CC26X2 + +#elif defined(DeviceFamily_CC13X2_V2) + #define DeviceFamily_ID DeviceFamily_ID_CC13X2_V2 + #define DeviceFamily_DIRECTORY cc13x2_cc26x2_v2 + #define DeviceFamily_PARENT DeviceFamily_PARENT_CC13X2_CC26X2 + +#elif defined(DeviceFamily_CC26X0) + #define DeviceFamily_ID DeviceFamily_ID_CC26X0 + #define DeviceFamily_DIRECTORY cc26x0 + #define DeviceFamily_PARENT DeviceFamily_PARENT_CC13X0_CC26X0 + +#elif defined(DeviceFamily_CC26X0R2) + #define DeviceFamily_ID DeviceFamily_ID_CC26X0R2 + #define DeviceFamily_DIRECTORY cc26x0r2 + #define DeviceFamily_PARENT DeviceFamily_PARENT_CC13X0_CC26X0 + +#elif defined(DeviceFamily_CC26X2) + #define DeviceFamily_ID DeviceFamily_ID_CC26X2 + #define DeviceFamily_DIRECTORY cc13x2_cc26x2_v1 + #define DeviceFamily_PARENT DeviceFamily_PARENT_CC13X2_CC26X2 + +#elif defined(DeviceFamily_CC26X2_V1) + #define DeviceFamily_ID DeviceFamily_ID_CC26X2_V1 + #define DeviceFamily_DIRECTORY cc13x2_cc26x2_v1 + #define DeviceFamily_PARENT DeviceFamily_PARENT_CC13X2_CC26X2 + +#elif defined(DeviceFamily_CC26X2_V2) + #define DeviceFamily_ID DeviceFamily_ID_CC26X2_V2 + #define DeviceFamily_DIRECTORY cc13x2_cc26x2_v2 + #define DeviceFamily_PARENT DeviceFamily_PARENT_CC13X2_CC26X2 + +#elif defined(DeviceFamily_CC3200) + #define DeviceFamily_ID DeviceFamily_ID_CC3200 + #define DeviceFamily_DIRECTORY cc32xx + +#elif defined(DeviceFamily_CC3220) + #define DeviceFamily_ID DeviceFamily_ID_CC3220 + #define DeviceFamily_DIRECTORY cc32xx + +#elif defined(DeviceFamily_MSP432P401x) || defined(__MSP432P401R__) + #define DeviceFamily_ID DeviceFamily_ID_MSP432P401x + #define DeviceFamily_DIRECTORY msp432p4xx + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSP432P401R + #if !defined(__MSP432P401R__) + #define __MSP432P401R__ + #endif + +#elif defined(DeviceFamily_MSP432P4x1xI) + #define DeviceFamily_ID DeviceFamily_ID_MSP432P4x1xI + #define DeviceFamily_DIRECTORY msp432p4xx + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSP432P4111 + #if !defined(__MSP432P4111__) + #define __MSP432P4111__ + #endif + +#elif defined(DeviceFamily_MSP432P4x1xT) + #define DeviceFamily_ID DeviceFamily_ID_MSP432P4x1xT + #define DeviceFamily_DIRECTORY msp432p4xx + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSP432P4111 + #if !defined(__MSP432P4111__) + #define __MSP432P4111__ + #endif + +#elif defined(DeviceFamily_MSP432E401Y) + #define DeviceFamily_ID DeviceFamily_ID_MSP432E401Y + #define DeviceFamily_DIRECTORY msp432e4 + #if !defined(__MSP432E401Y__) + #define __MSP432E401Y__ + #endif + +#elif defined(DeviceFamily_MSP432E411Y) + #define DeviceFamily_ID DeviceFamily_ID_MSP432E411Y + #define DeviceFamily_DIRECTORY msp432e4 + #if !defined(__MSP432E411Y__) + #define __MSP432E411Y__ + #endif +#else + #error "DeviceFamily_XYZ undefined. You must defined DeviceFamily_XYZ!" +#endif + +/*! + * @brief Macro to include correct driverlib path. + * + * @pre DeviceFamily_XYZ which sets DeviceFamily_DIRECTORY must be defined + * first. + * + * @param x A token containing the path of the file to include based on + * the root device folder. The preceding forward slash must be + * omitted. For example: + * - #include DeviceFamily_constructPath(inc/hw_memmap.h) + * - #include DeviceFamily_constructPath(driverlib/ssi.h) + * + * @return Returns an include path. + * + */ +//#define DeviceFamily_constructPath(x) +#define DeviceFamily_constructPath(x) #x + +#ifdef __cplusplus +} +#endif + +#endif /* ti_devices_DeviceFamily__include */ diff --git a/README.html b/README.html new file mode 100644 index 0000000..43bfa78 --- /dev/null +++ b/README.html @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + +
+ + Texas Instruments + + + +
+

+

Table of Contents

+ +

Example Summary

+

This example is intended to be a starting point for new development where a minimal footprint is needed.

+

Peripherals Exercised

+
    +
  • Board_LED0 - Indicates that the board was initialized within main()
  • +
+

Example Usage

+
    +
  • The example lights Board_LED0 as part of the initialization in main(). Then a heartBeat task toggles the LED at a rate determined by the arg0 parameter for the constructed Task instance in the .c file.
  • +
+

Application Design Details

+

This examples is the same as the Empty example except many development and debug features are disabled. For example:

+
    +
  • No Kernel Idle task
  • +
  • No stack overflow checking
  • +
  • No Logs or Asserts are enabled
  • +
+
+

The ROM is being used in this example. This is controlled by the following lines in the .cfg file:

+
+
+
var ROM = xdc.useModule('ti.sysbios.rom.ROM');
+    ROM.romName = ROM.CC2650;
+

Since the kernel in the ROM is being used, there is no logging or assert checking done by the kernel.

+
+
+

For IAR users using any SensorTag(STK) Board, the XDS110 debugger must be selected with the 4-wire JTAG connection within your projects’ debugger configuration.

+
+

References

+
    +
  • For GNU and IAR users, please read the following website for details about enabling semi-hosting in order to view console output.

  • +
  • Please refer to the Memory Footprint Reduction section in the TI-RTOS User Guide spruhd4.pdf for a complete and detailed list of the differences between the empty minimal and empty projects.

  • +
+ + diff --git a/README.md b/README.md new file mode 100644 index 0000000..d3a1663 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +## Example Summary + +This example is intended to be a starting point for new development where +a minimal footprint is needed. + +## Peripherals Exercised + +* `Board_LED0` - Indicates that the board was initialized within `main()` + +## Example Usage + +* The example lights `Board_LED0` as part of the initialization in `main()`. +Then a heartBeat task toggles the LED at a rate determined by the `arg0` +parameter for the constructed Task instance in the .c file. + +## Application Design Details + +This examples is the same as the Empty example except many development +and debug features are disabled. For example: + +* No Kernel Idle task +* No stack overflow checking +* No Logs or Asserts are enabled + + +> The ROM is being used in this example. This is controlled +> by the following lines in the *.cfg* file: + +> ``` +var ROM = xdc.useModule('ti.sysbios.rom.ROM'); + ROM.romName = ROM.CC2650; +``` +> Since the kernel in the ROM is being used, there is no logging or assert +checking done by the kernel. + +> For IAR users using any SensorTag(STK) Board, the XDS110 debugger must be +selected with the 4-wire JTAG connection within your projects' debugger +configuration. + +## References + +* For GNU and IAR users, please read the following website for details + about enabling [semi-hosting](http://processors.wiki.ti.com/index.php/TI-RTOS_Examples_SemiHosting) + in order to view console output. + +* Please refer to the __Memory Footprint Reduction__ section in the +TI-RTOS User Guide *spruhd4.pdf* for a complete and detailed list of the +differences between the empty minimal and empty projects. diff --git a/Release/.gitignore b/Release/.gitignore new file mode 100644 index 0000000..885a51a --- /dev/null +++ b/Release/.gitignore @@ -0,0 +1,6 @@ +/makefile +/objects.mk +/source/ +/sources.mk +/subdir_rules.mk +/subdir_vars.mk diff --git a/ccfg.c b/ccfg.c new file mode 100644 index 0000000..ba9c9a1 --- /dev/null +++ b/ccfg.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015, 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. + */ + +/* + * ======== ccfg.c ======== + * Customer Configuration for CC26xx and CC13xx devices. This file is used to + * configure Boot ROM, start-up code, and SW radio behaviour. + * + * By default, driverlib startup_files/ccfg.c settings are used. However, if + * changes are required there are two means to do so: + * + * 1. Remove this file and copy driverlib's startup_files/ccfg.c file in + * its place. Make all changes to the file. Changes made are local to + * the project and will not affect other projects. + * + * 2. Perform changes to driverlib startup_files/ccfg.c file. Changes + * made to this file will be applied to all projects. This file must + * remain unmodified. + */ + +#define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM 0x0 +#include diff --git a/makefile.defs b/makefile.defs new file mode 100644 index 0000000..5a0353c --- /dev/null +++ b/makefile.defs @@ -0,0 +1,24 @@ +#File used to help "Clean Project" in CCS completely clean the kernel files +CFG_SRCDIR = ../src + +ifneq (,$(findstring :,$(WINDIR)$(windir)$(COMSPEC)$(comspec))) + # if Windows, use copy to touch file dates + TOUCH = copy /b $(subst /,\,$@)+,, $(subst /,\,$@) +else + TOUCH = touch $@ +endif + +# include Config generated top-level makefile +-include $(CFG_SRCDIR)/makefile.libs + +ifneq (clean,$(MAKECMDGOALS)) +# ensure this file is reloaded when .cfg files change but after config runs +$(CFG_SRCDIR)/makefile.libs: $(GEN_OPTS) $(CFG_SRCS) + -@$(if $(wildcard $@),$(TOUCH),:) +endif + +#add generated makefile to list of files to delete during a clean +GEN_MISC_FILES__QUOTED += "$(CFG_SRCDIR)/makefile.libs" + +#add generated source dir to list of directories to delete during a clean +#GEN_MISC_DIRS__QTD += "$(CFG_SRCDIR)" diff --git a/release.cfg b/release.cfg new file mode 100644 index 0000000..20c51a2 --- /dev/null +++ b/release.cfg @@ -0,0 +1,638 @@ +/* + * Copyright (c) 2015-2017, 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. + */ + + + +/* ================ Boot configuration ================ */ +var Boot = xdc.useModule('ti.sysbios.family.arm.cc26xx.Boot'); +/* + * This module contains family specific Boot APIs and configuration settings. + * See the SYS/BIOS API guide for more information. + */ + + + +/* ================ Clock configuration ================ */ +var Clock = xdc.useModule('ti.sysbios.knl.Clock'); +/* + * When using Power and calibrateRCOSC is set to true, this should be set to 10. + * The timer used by the Clock module supports TickMode_DYNAMIC. This enables us + * to set the tick period to 10 us without generating the overhead of additional + * interrupts. + * + * Note: The calibrateRCOSC parameter is set within the Power configuration + * structure in the "Board.c" file. + */ +Clock.tickPeriod = 10; + + + +/* ================ Defaults (module) configuration ================ */ +var Defaults = xdc.useModule('xdc.runtime.Defaults'); +/* + * A flag to allow module names to be loaded on the target. Module name + * strings are placed in the .const section for debugging purposes. + * + * Pick one: + * - true (default) + * Setting this parameter to true will include name strings in the .const + * section so that Errors and Asserts are easier to debug. + * - false + * Setting this parameter to false will reduce footprint in the .const + * section. As a result, Error and Assert messages will contain an + * "unknown module" prefix instead of the actual module name. + * + * When using BIOS in ROM: + * This option must be set to false. + */ +//Defaults.common$.namedModule = true; +Defaults.common$.namedModule = false; + + + +/* ================ Error configuration ================ */ +var Error = xdc.useModule('xdc.runtime.Error'); +/* + * This function is called to handle all raised errors, but unlike + * Error.raiseHook, this function is responsible for completely handling the + * error with an appropriately initialized Error_Block. + * + * Pick one: + * - Error.policyDefault (default) + * Calls Error.raiseHook with an initialized Error_Block structure and logs + * the error using the module's logger. + * - Error.policySpin + * Simple alternative that traps on a while(1) loop for minimized target + * footprint. + * Using Error.policySpin, the Error.raiseHook will NOT called. + * - Error.policyMin + * Lightweight policy function that does minimum processing and returns. + */ +Error.policyFxn = Error.policyDefault; +//Error.policyFxn = Error.policySpin; +//Error.policyFxn = Error.policyMin; + +/* + * If Error.policyFxn is set to Error.policyDefault, this function is called + * whenever an error is raised by the Error module. + * + * Pick one: + * - Error.print (default) + * Errors are formatted and output via System_printf() for easier + * debugging. + * - null + * Errors are not formatted or logged. This option reduces code footprint. + * - non-null function + * Errors invoke custom user function. See the Error module documentation + * for more details. + */ +//Error.raiseHook = Error.print; +Error.raiseHook = null; +//Error.raiseHook = "&myErrorFxn"; + +/* + * If Error.policyFxn is set to Error.policyDefault, this option applies to the + * maximum number of times the Error.raiseHook function can be recursively + * invoked. This option limits the possibility of an infinite recursion that + * could lead to a stack overflow. + * The default value is 16. + */ +Error.maxDepth = 2; + + + +/* ================ Hwi configuration ================ */ +var halHwi = xdc.useModule('ti.sysbios.hal.Hwi'); +var m3Hwi = xdc.useModule('ti.sysbios.family.arm.m3.Hwi'); +/* + * Checks for Hwi (system) stack overruns while in the Idle loop. + * + * Pick one: + * - true (default) + * Checks the top word for system stack overflows during the idle loop and + * raises an Error if one is detected. + * - false + * Disabling the runtime check improves runtime performance and yields a + * reduced flash footprint. + */ +//halHwi.checkStackFlag = true; +halHwi.checkStackFlag = false; + +/* + * The following options alter the system's behavior when a hardware exception + * is detected. + * + * Pick one: + * - Hwi.enableException = true + * This option causes the default m3Hwi.excHandlerFunc function to fully + * decode an exception and dump the registers to the system console. + * This option raises errors in the Error module and displays the + * exception in ROV. + * - Hwi.enableException = false + * This option reduces code footprint by not decoding or printing the + * exception to the system console. + * It however still raises errors in the Error module and displays the + * exception in ROV. + * - Hwi.excHandlerFunc = null + * This is the most aggressive option for code footprint savings; but it + * can difficult to debug exceptions. It reduces flash footprint by + * plugging in a default while(1) trap when exception occur. This option + * does not raise an error with the Error module. + */ +//m3Hwi.enableException = true; +//m3Hwi.enableException = false; +m3Hwi.excHandlerFunc = null; + +/* + * Enable hardware exception generation when dividing by zero. + * + * Pick one: + * - 0 (default) + * Disables hardware exceptions when dividing by zero + * - 1 + * Enables hardware exceptions when dividing by zero + */ +m3Hwi.nvicCCR.DIV_0_TRP = 0; +//m3Hwi.nvicCCR.DIV_0_TRP = 1; + + + +/* ================ Idle configuration ================ */ +var Idle = xdc.useModule('ti.sysbios.knl.Idle'); +/* + * The Idle module is used to specify a list of functions to be called when no + * other tasks are running in the system. + * + * Functions added here will be run continuously within the idle task. + * + * Function signature: + * Void func(Void); + */ +//Idle.addFunc("&myIdleFunc"); + +Idle.addFunc('&Power_idleFunc'); /* add the Power module's idle function */ + + + +/* ================ Kernel (SYS/BIOS) configuration ================ */ +var BIOS = xdc.useModule('ti.sysbios.BIOS'); +/* + * Enable asserts in the BIOS library. + * + * Pick one: + * - true (default) + * Enables asserts for debugging purposes. + * - false + * Disables asserts for a reduced code footprint and better performance. + * + * When using BIOS in ROM: + * This option must be set to false. + */ +//BIOS.assertsEnabled = true; +BIOS.assertsEnabled = false; + +/* + * A flag to determine if xdc.runtime sources are to be included in a custom + * built BIOS library. + * + * Pick one: + * - false (default) + * The pre-built xdc.runtime library is provided by the respective target + * used to build the application. + * - true + * xdc.runtime library sources are to be included in the custom BIOS + * library. This option yields the most efficient library in both code + * footprint and runtime performance. + */ +//BIOS.includeXdcRuntime = false; +BIOS.includeXdcRuntime = true; + +/* + * The SYS/BIOS runtime is provided in the form of a library that is linked + * with the application. Several forms of this library are provided with the + * SYS/BIOS product. + * + * Pick one: + * - BIOS.LibType_Custom + * Custom built library that is highly optimized for code footprint and + * runtime performance. + * - BIOS.LibType_Debug + * Custom built library that is non-optimized that can be used to + * single-step through APIs with a debugger. + * + */ +BIOS.libType = BIOS.LibType_Custom; +//BIOS.libType = BIOS.LibType_Debug; + +/* + * Runtime instance creation enable flag. + * + * Pick one: + * - true (default) + * Allows Mod_create() and Mod_delete() to be called at runtime which + * requires a default heap for dynamic memory allocation. + * - false + * Reduces code footprint by disallowing Mod_create() and Mod_delete() to + * be called at runtime. Object instances are constructed via + * Mod_construct() and destructed via Mod_destruct(). + * + * When using BIOS in ROM: + * This option must be set to true. + */ +BIOS.runtimeCreatesEnabled = true; +//BIOS.runtimeCreatesEnabled = false; + +/* + * Enable logs in the BIOS library. + * + * Pick one: + * - true (default) + * Enables logs for debugging purposes. + * - false + * Disables logging for reduced code footprint and improved runtime + * performance. + * + * When using BIOS in ROM: + * This option must be set to false. + */ +//BIOS.logsEnabled = true; +BIOS.logsEnabled = false; + + + +/* ================ Memory configuration ================ */ +var Memory = xdc.useModule('xdc.runtime.Memory'); +/* + * The Memory module itself simply provides a common interface for any + * variety of system and application specific memory management policies + * implemented by the IHeap modules(Ex. HeapMem, HeapBuf). + */ + +/* + * Use HeapMem primary heap instance to use linker-defined memory region + * Add HeapTrack on top to find over-writes, invalid frees, and + * aid in finding the correct sizing of the heap and memory leaks. + */ +var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem'); +HeapMem.primaryHeapBaseAddr = "&__primary_heap_start__"; +HeapMem.primaryHeapEndAddr = "&__primary_heap_end__"; + +var heapMemParams = new HeapMem.Params(); +heapMemParams.usePrimaryHeap = true; + +//var HeapTrack = xdc.useModule('ti.sysbios.heaps.HeapTrack'); +//var heapTrackParams = new HeapTrack.Params; +//heapTrackParams.heap = HeapMem.create(heapMemParams); +//Program.global.heap0 = HeapTrack.create(heapTrackParams); +Program.global.heap0 = HeapMem.create(heapMemParams); + +Memory.defaultHeapInstance = Program.global.heap0; + + + +/* ================ Program configuration ================ */ +/* + * Program.stack must be set to 0 to allow the setting + * of the system stack size to be determined in the example's + * linker command file. + */ +Program.stack = 0; + + +/* + * Uncomment to enable Semihosting for GNU targets to print to the CCS console. + * Please read the following TIRTOS Wiki page for more information on Semihosting: + * http://processors.wiki.ti.com/index.php/TI-RTOS_Examples_SemiHosting + */ + +if (Program.build.target.$name.match(/gnu/)) { + //var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport'); +} +/* ================ ROM configuration ================ */ +/* + * To use BIOS in flash, comment out the code block below. + */ +var ROM = xdc.useModule('ti.sysbios.rom.ROM'); +ROM.romName = ROM.CC2650; + + + +/* ================ Semaphore configuration ================ */ +var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore'); +/* + * Enables global support for Task priority pend queuing. + * + * Pick one: + * - true (default) + * This allows pending tasks to be serviced based on their task priority. + * - false + * Pending tasks are services based on first in, first out basis. + * + * When using BIOS in ROM: + * This option must be set to false. + */ +//Semaphore.supportsPriority = true; +Semaphore.supportsPriority = false; + +/* + * Allows for the implicit posting of events through the semaphore, + * disable for additional code saving. + * + * Pick one: + * - true + * This allows the Semaphore module to post semaphores and events + * simultaneously. + * - false (default) + * Events must be explicitly posted to unblock tasks. + * + * When using BIOS in ROM: + * This option must be set to false. + */ +//Semaphore.supportsEvents = true; +Semaphore.supportsEvents = false; + + + +/* ================ Swi configuration ================ */ +var Swi = xdc.useModule('ti.sysbios.knl.Swi'); +/* + * A software interrupt is an object that encapsulates a function to be + * executed and a priority. Software interrupts are prioritized, preempt tasks + * and are preempted by hardware interrupt service routines. + * + * This module is included to allow Swi's in a users' application. + */ +/* + * Reduce the number of swi priorities from the default of 16. + * Decreasing the number of swi priorities yields memory savings. + */ +Swi.numPriorities = 6; + + + +/* ================ System configuration ================ */ +var System = xdc.useModule('xdc.runtime.System'); +/* + * The Abort handler is called when the system exits abnormally. + * + * Pick one: + * - System.abortStd (default) + * Call the ANSI C Standard 'abort()' to terminate the application. + * - System.abortSpin + * A lightweight abort function that loops indefinitely in a while(1) trap + * function. + * - A custom abort handler + * A user-defined function. See the System module documentation for + * details. + */ +//System.abortFxn = System.abortStd; +System.abortFxn = System.abortSpin; +//System.abortFxn = "&myAbortSystem"; + +/* + * The Exit handler is called when the system exits normally. + * + * Pick one: + * - System.exitStd (default) + * Call the ANSI C Standard 'exit()' to terminate the application. + * - System.exitSpin + * A lightweight exit function that loops indefinitely in a while(1) trap + * function. + * - A custom exit function + * A user-defined function. See the System module documentation for + * details. + */ +//System.exitFxn = System.exitStd; +System.exitFxn = System.exitSpin; +//System.exitFxn = "&myExitSystem"; + +/* + * Minimize exit handler array in the System module. The System module includes + * an array of functions that are registered with System_atexit() which is + * called by System_exit(). The default value is 8. + */ +System.maxAtexitHandlers = 2; + +/* + * Enable System_printf() to display floats. Use the longer '%f%$L%$S%$F' + * if your code has SYS/BIOS instrumentation enabled (Asserts/Error/Log), + * as is typical with the 'debug' profile. + */ +//System.extendedFormats = '%f%$L%$S%$F'; +System.extendedFormats = '%f%$S'; + +/* + * The System.SupportProxy defines a low-level implementation of System + * functions such as System_printf(), System_flush(), etc. + * + * Pick one pair: + * - SysMin + * This module maintains an internal configurable circular buffer that + * stores the output until System_flush() is called. + * The size of the circular buffer is set via SysMin.bufSize. + * - SysCallback + * SysCallback allows for user-defined implementations for System APIs. + * The SysCallback support proxy has a smaller code footprint and can be + * used to supply custom System_printf services. + * The default SysCallback functions point to stub functions. See the + * SysCallback module's documentation. + */ +//var SysMin = xdc.useModule('xdc.runtime.SysMin'); +//SysMin.bufSize = 1024; +//System.SupportProxy = SysMin; +var SysCallback = xdc.useModule('xdc.runtime.SysCallback'); +System.SupportProxy = SysCallback; +//SysCallback.abortFxn = "&myUserAbort"; +//SysCallback.exitFxn = "&myUserExit"; +//SysCallback.flushFxn = "&myUserFlush"; +//SysCallback.putchFxn = "&myUserPutch"; +//SysCallback.readyFxn = "&myUserReady"; + + + +/* ================ Task configuration ================ */ +var Task = xdc.useModule('ti.sysbios.knl.Task'); +/* + * Check task stacks for overflow conditions. + * + * Pick one: + * - true (default) + * Enables runtime checks for task stack overflow conditions during + * context switching ("from" and "to") + * - false + * Disables runtime checks for task stack overflow conditions. + * + * When using BIOS in ROM: + * This option must be set to false. + */ +//Task.checkStackFlag = true; +Task.checkStackFlag = false; + +/* + * Set the default task stack size when creating tasks. + * + * The default is dependent on the device being used. Reducing the default stack + * size yields greater memory savings. + */ +Task.defaultStackSize = 512; + +/* + * Enables the idle task. + * + * Pick one: + * - true (default) + * Creates a task with priority of 0 which calls idle hook functions. This + * option must be set to true to gain power savings provided by the Power + * module. + * - false + * No idle task is created. This option consumes less memory as no + * additional default task stack is needed. + * To gain power savings by the Power module without having the idle task, + * add Idle.run as the Task.allBlockedFunc. + */ +Task.enableIdleTask = true; +//Task.enableIdleTask = false; +//Task.allBlockedFunc = Idle.run; + +/* + * If Task.enableIdleTask is set to true, this option sets the idle task's + * stack size. + * + * Reducing the idle stack size yields greater memory savings. + */ +Task.idleTaskStackSize = 512; + +/* + * Reduce the number of task priorities. + * The default is 16. + * Decreasing the number of task priorities yield memory savings. + */ +Task.numPriorities = 6; + + + +/* ================ Text configuration ================ */ +var Text = xdc.useModule('xdc.runtime.Text'); +/* + * These strings are placed in the .const section. Setting this parameter to + * false will save space in the .const section. Error, Assert and Log messages + * will print raw ids and args instead of a formatted message. + * + * Pick one: + * - true (default) + * This option loads test string into the .const for easier debugging. + * - false + * This option reduces the .const footprint. + */ +//Text.isLoaded = true; +Text.isLoaded = false; + + + +/* ================ Types configuration ================ */ +var Types = xdc.useModule('xdc.runtime.Types'); +/* + * This module defines basic constants and types used throughout the + * xdc.runtime package. + */ + + + +/* ================ Application Specific Instances ================ */ + +/* ================ Diagnostics configuration ================ */ +//var Diags = xdc.useModule('xdc.runtime.Diags'); +/* + * You use the Diags module to set and clear bits in a module's diagnostics + * mask for the purpose of controlling diagnostics within that module. A + * module diagnostics mask controls both Assert and Log statements + * within that module, disabling these statements yields + * code savings. + */ + +/* ================ Logging configuration ================ */ +//var Log = xdc.useModule('xdc.runtime.Log'); +/* + * Modules and the application code generate Log_Event events by calling + * the Log module's functions. + * Disabling all Log statements here will allow the optimizer to completely + * remove all Log code from the application. + * + * Note: In order to generate Log events in your application both the Diags + * and the Log mask must be set. See the SYS/BIOS API guide for + * more information. + */ + +/* + * LoggingSetup configures TI-RTOS modules to capture user-specified information + * such as CPU Load, Task Load and Task Execution so that it can be + * displayed by System Analyzer. + */ +//var LoggingSetup = xdc.useModule('ti.uia.sysbios.LoggingSetup'); +//LoggingSetup.loadLoggerSize = 256; +//LoggingSetup.mainLoggerSize = 512; +//LoggingSetup.sysbiosLoggerSize = 1024; + +/* ================ Main configuration ================ */ +var Main = xdc.useModule('xdc.runtime.Main'); +/* Configuration of this Main module is used for all code not in a module */ + + + +/* ================ POSIX configuration ================ */ +//var Settings = xdc.useModule('ti.posix.tirtos.Settings'); + +if (Program.build.target.$name.match(/iar/)) { + /* + * For the IAR target, the 'ti.posix.tirtos.Settings' uses the + * MultithreadSupport module. By default, the MultithreadSupport module + * use the '--threaded_lib' library which provides a separate 'errno' + * per thread and makes other rts libraries reentrant. This library has + * a larger footprint which can be a problem for some apps, so we + * override the default and disable it here. + */ + var MultithreadSupport = + xdc.useModule('ti.sysbios.rts.iar.MultithreadSupport'); + MultithreadSupport.enableMultithreadSupport = false; +} + + +/* ================ Event configuration ================ */ +var Event = xdc.useModule('ti.sysbios.knl.Event'); + + + +/* ================ Mailbox configuration ================ */ +var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox'); + +var driversConfig = xdc.useModule('ti.drivers.Config'); +driversConfig.libType = driversConfig.LibType_NonInstrumented; diff --git a/rf_ieee_cmd.h b/rf_ieee_cmd.h new file mode 100644 index 0000000..463f023 --- /dev/null +++ b/rf_ieee_cmd.h @@ -0,0 +1,631 @@ +/****************************************************************************** +* Filename: rf_ieee_cmd.h +* Revised: 2017-11-10 10:42:47 +0100 (Fri, 10 Nov 2017) +* Revision: 18052 +* +* Description: CC13x2/CC26x2 API for IEEE 802.15.4 commands +* +* Copyright (c) 2015 - 2017, 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: +* +* 1) Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* 2) 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. +* +* 3) Neither the name of the ORGANIZATION 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 HOLDER 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. +* +******************************************************************************/ + +#ifndef __IEEE_CMD_H +#define __IEEE_CMD_H + +#ifndef __RFC_STRUCT +#define __RFC_STRUCT +#endif + +#ifndef __RFC_STRUCT_ATTR +#if defined(__GNUC__) +#define __RFC_STRUCT_ATTR __attribute__ ((aligned (4))) +#elif defined(__TI_ARM__) +#define __RFC_STRUCT_ATTR __attribute__ ((__packed__,aligned (4))) +#else +#define __RFC_STRUCT_ATTR +#endif +#endif + +//! \addtogroup rfc +//! @{ + +//! \addtogroup ieee_cmd +//! @{ + +#include +//#include "rf_mailbox.h" +//#include "rf_common_cmd.h" +#include "DeviceFamily.h" +#include DeviceFamily_constructPath(driverlib/rf_mailbox.h) +#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) + +typedef struct __RFC_STRUCT rfc_CMD_IEEE_RX_s rfc_CMD_IEEE_RX_t; +typedef struct __RFC_STRUCT rfc_CMD_IEEE_ED_SCAN_s rfc_CMD_IEEE_ED_SCAN_t; +typedef struct __RFC_STRUCT rfc_CMD_IEEE_TX_s rfc_CMD_IEEE_TX_t; +typedef struct __RFC_STRUCT rfc_CMD_IEEE_CSMA_s rfc_CMD_IEEE_CSMA_t; +typedef struct __RFC_STRUCT rfc_CMD_IEEE_RX_ACK_s rfc_CMD_IEEE_RX_ACK_t; +typedef struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_BG_s rfc_CMD_IEEE_ABORT_BG_t; +typedef struct __RFC_STRUCT rfc_CMD_IEEE_MOD_CCA_s rfc_CMD_IEEE_MOD_CCA_t; +typedef struct __RFC_STRUCT rfc_CMD_IEEE_MOD_FILT_s rfc_CMD_IEEE_MOD_FILT_t; +typedef struct __RFC_STRUCT rfc_CMD_IEEE_MOD_SRC_MATCH_s rfc_CMD_IEEE_MOD_SRC_MATCH_t; +typedef struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_FG_s rfc_CMD_IEEE_ABORT_FG_t; +typedef struct __RFC_STRUCT rfc_CMD_IEEE_STOP_FG_s rfc_CMD_IEEE_STOP_FG_t; +typedef struct __RFC_STRUCT rfc_CMD_IEEE_CCA_REQ_s rfc_CMD_IEEE_CCA_REQ_t; +typedef struct __RFC_STRUCT rfc_ieeeRxOutput_s rfc_ieeeRxOutput_t; +typedef struct __RFC_STRUCT rfc_shortAddrEntry_s rfc_shortAddrEntry_t; +typedef struct __RFC_STRUCT rfc_ieeeRxCorrCrc_s rfc_ieeeRxCorrCrc_t; + +//! \addtogroup CMD_IEEE_RX +//! @{ +#define CMD_IEEE_RX 0x2801 +//! IEEE 802.15.4 Receive Command +struct __RFC_STRUCT rfc_CMD_IEEE_RX_s { + uint16_t commandNo; //!< The command ID number 0x2801 + uint16_t status; //!< \brief An integer telling the status of the command. This value is + //!< updated by the radio CPU during operation and may be read by the + //!< system CPU at any time. + rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done + ratmr_t startTime; //!< Absolute or relative start time (depending on the value of startTrigger) + struct { + uint8_t triggerType:4; //!< The type of trigger + uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
+ //!< 1: CMD_TRIGGER can be used as an alternative trigger + uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action + uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error
+ //!< 1: A trigger in the past is triggered as soon as possible + } startTrigger; //!< Identification of the trigger that starts the operation + struct { + uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed + uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ... + } condition; + uint8_t channel; //!< \brief Channel to tune to in the start of the operation
+ //!< 0: Use existing channel
+ //!< 11--26: Use as IEEE 802.15.4 channel, i.e. frequency is (2405 + 5 × (channel - 11)) MHz
+ //!< 60--207: Frequency is (2300 + channel) MHz
+ //!< Others: Reserved + struct { + uint8_t bAutoFlushCrc:1; //!< If 1, automatically remove packets with CRC error from Rx queue + uint8_t bAutoFlushIgn:1; //!< If 1, automatically remove packets that can be ignored according to frame filtering from Rx queue + uint8_t bIncludePhyHdr:1; //!< If 1, include the received PHY header field in the stored packet; otherwise discard it + uint8_t bIncludeCrc:1; //!< If 1, include the received CRC field in the stored packet; otherwise discard it + uint8_t bAppendRssi:1; //!< If 1, append an RSSI byte to the packet in the Rx queue + uint8_t bAppendCorrCrc:1; //!< If 1, append a correlation value and CRC result byte to the packet in the Rx queue + uint8_t bAppendSrcInd:1; //!< If 1, append an index from the source matching algorithm + uint8_t bAppendTimestamp:1; //!< If 1, append a timestamp to the packet in the Rx queue + } rxConfig; + dataQueue_t* pRxQ; //!< Pointer to receive queue + rfc_ieeeRxOutput_t *pOutput; //!< Pointer to output structure (NULL: Do not store results) + struct { + uint16_t frameFiltEn:1; //!< \brief 0: Disable frame filtering
+ //!< 1: Enable frame filtering + uint16_t frameFiltStop:1; //!< \brief 0: Receive all packets to the end
+ //!< 1: Stop receiving frame once frame filtering has caused the frame to be rejected. + uint16_t autoAckEn:1; //!< \brief 0: Disable auto ACK
+ //!< 1: Enable auto ACK. + uint16_t slottedAckEn:1; //!< \brief 0: Non-slotted ACK
+ //!< 1: Slotted ACK. + uint16_t autoPendEn:1; //!< \brief 0: Auto-pend disabled
+ //!< 1: Auto-pend enabled + uint16_t defaultPend:1; //!< The value of the pending data bit in auto ACK packets that are not subject to auto-pend + uint16_t bPendDataReqOnly:1; //!< \brief 0: Use auto-pend for any packet
+ //!< 1: Use auto-pend for data request packets only + uint16_t bPanCoord:1; //!< \brief 0: Device is not PAN coordinator
+ //!< 1: Device is PAN coordinator + uint16_t maxFrameVersion:2; //!< Reject frames where the frame version field in the FCF is greater than this value + uint16_t fcfReservedMask:3; //!< Value to be AND-ed with the reserved part of the FCF; frame rejected if result is non-zero + uint16_t modifyFtFilter:2; //!< \brief Treatment of MSB of frame type field before frame-type filtering:
+ //!< 0: No modification
+ //!< 1: Invert MSB
+ //!< 2: Set MSB to 0
+ //!< 3: Set MSB to 1 + uint16_t bStrictLenFilter:1; //!< \brief 0: Accept acknowledgement frames of any length >= 5
+ //!< 1: Accept only acknowledgement frames of length 5 + } frameFiltOpt; //!< Frame filtering options + struct { + uint8_t bAcceptFt0Beacon:1; //!< \brief Treatment of frames with frame type 000 (beacon):
+ //!< 0: Reject
+ //!< 1: Accept + uint8_t bAcceptFt1Data:1; //!< \brief Treatment of frames with frame type 001 (data):
+ //!< 0: Reject
+ //!< 1: Accept + uint8_t bAcceptFt2Ack:1; //!< \brief Treatment of frames with frame type 010 (ACK):
+ //!< 0: Reject, unless running ACK receive command
+ //!< 1: Always accept + uint8_t bAcceptFt3MacCmd:1; //!< \brief Treatment of frames with frame type 011 (MAC command):
+ //!< 0: Reject
+ //!< 1: Accept + uint8_t bAcceptFt4Reserved:1; //!< \brief Treatment of frames with frame type 100 (reserved):
+ //!< 0: Reject
+ //!< 1: Accept + uint8_t bAcceptFt5Reserved:1; //!< \brief Treatment of frames with frame type 101 (reserved):
+ //!< 0: Reject
+ //!< 1: Accept + uint8_t bAcceptFt6Reserved:1; //!< \brief Treatment of frames with frame type 110 (reserved):
+ //!< 0: Reject
+ //!< 1: Accept + uint8_t bAcceptFt7Reserved:1; //!< \brief Treatment of frames with frame type 111 (reserved):
+ //!< 0: Reject
+ //!< 1: Accept + } frameTypes; //!< Frame types to receive in frame filtering + struct { + uint8_t ccaEnEnergy:1; //!< Enable energy scan as CCA source + uint8_t ccaEnCorr:1; //!< Enable correlator based carrier sense as CCA source + uint8_t ccaEnSync:1; //!< Enable sync found based carrier sense as CCA source + uint8_t ccaCorrOp:1; //!< \brief Operator to use between energy based and correlator based CCA
+ //!< 0: Report busy channel if either ccaEnergy or ccaCorr are busy
+ //!< 1: Report busy channel if both ccaEnergy and ccaCorr are busy + uint8_t ccaSyncOp:1; //!< \brief Operator to use between sync found based CCA and the others
+ //!< 0: Always report busy channel if ccaSync is busy
+ //!< 1: Always report idle channel if ccaSync is idle + uint8_t ccaCorrThr:2; //!< Threshold for number of correlation peaks in correlator based carrier sense + } ccaOpt; //!< CCA options + int8_t ccaRssiThr; //!< RSSI threshold for CCA + uint8_t __dummy0; + uint8_t numExtEntries; //!< Number of extended address entries + uint8_t numShortEntries; //!< Number of short address entries + uint32_t* pExtEntryList; //!< Pointer to list of extended address entries + uint32_t* pShortEntryList; //!< Pointer to list of short address entries + uint64_t localExtAddr; //!< The extended address of the local device + uint16_t localShortAddr; //!< The short address of the local device + uint16_t localPanID; //!< The PAN ID of the local device + uint16_t __dummy1; + uint8_t __dummy2; + struct { + uint8_t triggerType:4; //!< The type of trigger + uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
+ //!< 1: CMD_TRIGGER can be used as an alternative trigger + uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action + uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error
+ //!< 1: A trigger in the past is triggered as soon as possible + } endTrigger; //!< Trigger that causes the device to end the Rx operation + ratmr_t endTime; //!< \brief Time used together with endTrigger that causes the device to end the Rx + //!< operation +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup CMD_IEEE_ED_SCAN +//! @{ +#define CMD_IEEE_ED_SCAN 0x2802 +//! IEEE 802.15.4 Energy Detect Scan Command +struct __RFC_STRUCT rfc_CMD_IEEE_ED_SCAN_s { + uint16_t commandNo; //!< The command ID number 0x2802 + uint16_t status; //!< \brief An integer telling the status of the command. This value is + //!< updated by the radio CPU during operation and may be read by the + //!< system CPU at any time. + rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done + ratmr_t startTime; //!< Absolute or relative start time (depending on the value of startTrigger) + struct { + uint8_t triggerType:4; //!< The type of trigger + uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
+ //!< 1: CMD_TRIGGER can be used as an alternative trigger + uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action + uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error
+ //!< 1: A trigger in the past is triggered as soon as possible + } startTrigger; //!< Identification of the trigger that starts the operation + struct { + uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed + uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ... + } condition; + uint8_t channel; //!< \brief Channel to tune to in the start of the operation
+ //!< 0: Use existing channel
+ //!< 11--26: Use as IEEE 802.15.4 channel, i.e. frequency is (2405 + 5 × (channel - 11)) MHz
+ //!< 60--207: Frequency is (2300 + channel) MHz
+ //!< Others: Reserved + struct { + uint8_t ccaEnEnergy:1; //!< Enable energy scan as CCA source + uint8_t ccaEnCorr:1; //!< Enable correlator based carrier sense as CCA source + uint8_t ccaEnSync:1; //!< Enable sync found based carrier sense as CCA source + uint8_t ccaCorrOp:1; //!< \brief Operator to use between energy based and correlator based CCA
+ //!< 0: Report busy channel if either ccaEnergy or ccaCorr are busy
+ //!< 1: Report busy channel if both ccaEnergy and ccaCorr are busy + uint8_t ccaSyncOp:1; //!< \brief Operator to use between sync found based CCA and the others
+ //!< 0: Always report busy channel if ccaSync is busy
+ //!< 1: Always report idle channel if ccaSync is idle + uint8_t ccaCorrThr:2; //!< Threshold for number of correlation peaks in correlator based carrier sense + } ccaOpt; //!< CCA options + int8_t ccaRssiThr; //!< RSSI threshold for CCA + uint8_t __dummy0; + int8_t maxRssi; //!< The maximum RSSI recorded during the ED scan + struct { + uint8_t triggerType:4; //!< The type of trigger + uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
+ //!< 1: CMD_TRIGGER can be used as an alternative trigger + uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action + uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error
+ //!< 1: A trigger in the past is triggered as soon as possible + } endTrigger; //!< Trigger that causes the device to end the Rx operation + ratmr_t endTime; //!< \brief Time used together with endTrigger that causes the device to end the Rx + //!< operation +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup CMD_IEEE_TX +//! @{ +#define CMD_IEEE_TX 0x2C01 +//! IEEE 802.15.4 Transmit Command +struct __RFC_STRUCT rfc_CMD_IEEE_TX_s { + uint16_t commandNo; //!< The command ID number 0x2C01 + uint16_t status; //!< \brief An integer telling the status of the command. This value is + //!< updated by the radio CPU during operation and may be read by the + //!< system CPU at any time. + rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done + ratmr_t startTime; //!< Absolute or relative start time (depending on the value of startTrigger) + struct { + uint8_t triggerType:4; //!< The type of trigger + uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
+ //!< 1: CMD_TRIGGER can be used as an alternative trigger + uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action + uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error
+ //!< 1: A trigger in the past is triggered as soon as possible + } startTrigger; //!< Identification of the trigger that starts the operation + struct { + uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed + uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ... + } condition; + struct { + uint8_t bIncludePhyHdr:1; //!< \brief 0: Find PHY header automatically
+ //!< 1: Insert PHY header from the buffer + uint8_t bIncludeCrc:1; //!< \brief 0: Append automatically calculated CRC
+ //!< 1: Insert FCS (CRC) from the buffer + uint8_t :1; + uint8_t payloadLenMsb:5; //!< \brief Most significant bits of payload length. Should only be non-zero to create long + //!< non-standard packets for test purposes + } txOpt; + uint8_t payloadLen; //!< Number of bytes in the payload + uint8_t* pPayload; //!< Pointer to payload buffer of size payloadLen + ratmr_t timeStamp; //!< Time stamp of transmitted frame +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup CMD_IEEE_CSMA +//! @{ +#define CMD_IEEE_CSMA 0x2C02 +//! IEEE 802.15.4 CSMA-CA Command +struct __RFC_STRUCT rfc_CMD_IEEE_CSMA_s { + uint16_t commandNo; //!< The command ID number 0x2C02 + uint16_t status; //!< \brief An integer telling the status of the command. This value is + //!< updated by the radio CPU during operation and may be read by the + //!< system CPU at any time. + rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done + ratmr_t startTime; //!< Absolute or relative start time (depending on the value of startTrigger) + struct { + uint8_t triggerType:4; //!< The type of trigger + uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
+ //!< 1: CMD_TRIGGER can be used as an alternative trigger + uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action + uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error
+ //!< 1: A trigger in the past is triggered as soon as possible + } startTrigger; //!< Identification of the trigger that starts the operation + struct { + uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed + uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ... + } condition; + uint16_t randomState; //!< The state of the pseudo-random generator + uint8_t macMaxBE; //!< The IEEE 802.15.4 MAC parameter macMaxBE + uint8_t macMaxCSMABackoffs; //!< The IEEE 802.15.4 MAC parameter macMaxCSMABackoffs + struct { + uint8_t initCW:5; //!< The initialization value for the CW parameter + uint8_t bSlotted:1; //!< \brief 0: non-slotted CSMA
+ //!< 1: slotted CSMA + uint8_t rxOffMode:2; //!< \brief 0: RX stays on during CSMA backoffs
+ //!< 1: The CSMA-CA algorithm will suspend the receiver if no frame is being received
+ //!< 2: The CSMA-CA algorithm will suspend the receiver if no frame is being received, + //!< or after finishing it (including auto ACK) otherwise
+ //!< 3: The CSMA-CA algorithm will suspend the receiver immediately during back-offs + } csmaConfig; + uint8_t NB; //!< The NB parameter from the IEEE 802.15.4 CSMA-CA algorithm + uint8_t BE; //!< The BE parameter from the IEEE 802.15.4 CSMA-CA algorithm + uint8_t remainingPeriods; //!< The number of remaining periods from a paused backoff countdown + int8_t lastRssi; //!< RSSI measured at the last CCA operation + struct { + uint8_t triggerType:4; //!< The type of trigger + uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
+ //!< 1: CMD_TRIGGER can be used as an alternative trigger + uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action + uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error
+ //!< 1: A trigger in the past is triggered as soon as possible + } endTrigger; //!< Trigger that causes the device to end the CSMA-CA operation + ratmr_t lastTimeStamp; //!< Time of the last CCA operation + ratmr_t endTime; //!< \brief Time used together with endTrigger that causes the device to end the + //!< CSMA-CA operation +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup CMD_IEEE_RX_ACK +//! @{ +#define CMD_IEEE_RX_ACK 0x2C03 +//! IEEE 802.15.4 Receive Acknowledgement Command +struct __RFC_STRUCT rfc_CMD_IEEE_RX_ACK_s { + uint16_t commandNo; //!< The command ID number 0x2C03 + uint16_t status; //!< \brief An integer telling the status of the command. This value is + //!< updated by the radio CPU during operation and may be read by the + //!< system CPU at any time. + rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done + ratmr_t startTime; //!< Absolute or relative start time (depending on the value of startTrigger) + struct { + uint8_t triggerType:4; //!< The type of trigger + uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
+ //!< 1: CMD_TRIGGER can be used as an alternative trigger + uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action + uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error
+ //!< 1: A trigger in the past is triggered as soon as possible + } startTrigger; //!< Identification of the trigger that starts the operation + struct { + uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed + uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ... + } condition; + uint8_t seqNo; //!< Sequence number to expect + struct { + uint8_t triggerType:4; //!< The type of trigger + uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
+ //!< 1: CMD_TRIGGER can be used as an alternative trigger + uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action + uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error
+ //!< 1: A trigger in the past is triggered as soon as possible + } endTrigger; //!< Trigger that causes the device to give up acknowledgement reception + ratmr_t endTime; //!< \brief Time used together with endTrigger that causes the device to give up + //!< acknowledgement reception +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup CMD_IEEE_ABORT_BG +//! @{ +#define CMD_IEEE_ABORT_BG 0x2C04 +//! IEEE 802.15.4 Abort Background Level Command +struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_BG_s { + uint16_t commandNo; //!< The command ID number 0x2C04 + uint16_t status; //!< \brief An integer telling the status of the command. This value is + //!< updated by the radio CPU during operation and may be read by the + //!< system CPU at any time. + rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done + ratmr_t startTime; //!< Absolute or relative start time (depending on the value of startTrigger) + struct { + uint8_t triggerType:4; //!< The type of trigger + uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
+ //!< 1: CMD_TRIGGER can be used as an alternative trigger + uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action + uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error
+ //!< 1: A trigger in the past is triggered as soon as possible + } startTrigger; //!< Identification of the trigger that starts the operation + struct { + uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed + uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ... + } condition; +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup CMD_IEEE_MOD_CCA +//! @{ +#define CMD_IEEE_MOD_CCA 0x2001 +//! IEEE 802.15.4 Modify CCA Parameter Command +struct __RFC_STRUCT rfc_CMD_IEEE_MOD_CCA_s { + uint16_t commandNo; //!< The command ID number 0x2001 + struct { + uint8_t ccaEnEnergy:1; //!< Enable energy scan as CCA source + uint8_t ccaEnCorr:1; //!< Enable correlator based carrier sense as CCA source + uint8_t ccaEnSync:1; //!< Enable sync found based carrier sense as CCA source + uint8_t ccaCorrOp:1; //!< \brief Operator to use between energy based and correlator based CCA
+ //!< 0: Report busy channel if either ccaEnergy or ccaCorr are busy
+ //!< 1: Report busy channel if both ccaEnergy and ccaCorr are busy + uint8_t ccaSyncOp:1; //!< \brief Operator to use between sync found based CCA and the others
+ //!< 0: Always report busy channel if ccaSync is busy
+ //!< 1: Always report idle channel if ccaSync is idle + uint8_t ccaCorrThr:2; //!< Threshold for number of correlation peaks in correlator based carrier sense + } newCcaOpt; //!< New value of ccaOpt for the running background level operation + int8_t newCcaRssiThr; //!< New value of ccaRssiThr for the running background level operation +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup CMD_IEEE_MOD_FILT +//! @{ +#define CMD_IEEE_MOD_FILT 0x2002 +//! IEEE 802.15.4 Modify Frame Filtering Parameter Command +struct __RFC_STRUCT rfc_CMD_IEEE_MOD_FILT_s { + uint16_t commandNo; //!< The command ID number 0x2002 + struct { + uint16_t frameFiltEn:1; //!< \brief 0: Disable frame filtering
+ //!< 1: Enable frame filtering + uint16_t frameFiltStop:1; //!< \brief 0: Receive all packets to the end
+ //!< 1: Stop receiving frame once frame filtering has caused the frame to be rejected. + uint16_t autoAckEn:1; //!< \brief 0: Disable auto ACK
+ //!< 1: Enable auto ACK. + uint16_t slottedAckEn:1; //!< \brief 0: Non-slotted ACK
+ //!< 1: Slotted ACK. + uint16_t autoPendEn:1; //!< \brief 0: Auto-pend disabled
+ //!< 1: Auto-pend enabled + uint16_t defaultPend:1; //!< The value of the pending data bit in auto ACK packets that are not subject to auto-pend + uint16_t bPendDataReqOnly:1; //!< \brief 0: Use auto-pend for any packet
+ //!< 1: Use auto-pend for data request packets only + uint16_t bPanCoord:1; //!< \brief 0: Device is not PAN coordinator
+ //!< 1: Device is PAN coordinator + uint16_t maxFrameVersion:2; //!< Reject frames where the frame version field in the FCF is greater than this value + uint16_t fcfReservedMask:3; //!< Value to be AND-ed with the reserved part of the FCF; frame rejected if result is non-zero + uint16_t modifyFtFilter:2; //!< \brief Treatment of MSB of frame type field before frame-type filtering:
+ //!< 0: No modification
+ //!< 1: Invert MSB
+ //!< 2: Set MSB to 0
+ //!< 3: Set MSB to 1 + uint16_t bStrictLenFilter:1; //!< \brief 0: Accept acknowledgement frames of any length >= 5
+ //!< 1: Accept only acknowledgement frames of length 5 + } newFrameFiltOpt; //!< New value of frameFiltOpt for the running background level operation + struct { + uint8_t bAcceptFt0Beacon:1; //!< \brief Treatment of frames with frame type 000 (beacon):
+ //!< 0: Reject
+ //!< 1: Accept + uint8_t bAcceptFt1Data:1; //!< \brief Treatment of frames with frame type 001 (data):
+ //!< 0: Reject
+ //!< 1: Accept + uint8_t bAcceptFt2Ack:1; //!< \brief Treatment of frames with frame type 010 (ACK):
+ //!< 0: Reject, unless running ACK receive command
+ //!< 1: Always accept + uint8_t bAcceptFt3MacCmd:1; //!< \brief Treatment of frames with frame type 011 (MAC command):
+ //!< 0: Reject
+ //!< 1: Accept + uint8_t bAcceptFt4Reserved:1; //!< \brief Treatment of frames with frame type 100 (reserved):
+ //!< 0: Reject
+ //!< 1: Accept + uint8_t bAcceptFt5Reserved:1; //!< \brief Treatment of frames with frame type 101 (reserved):
+ //!< 0: Reject
+ //!< 1: Accept + uint8_t bAcceptFt6Reserved:1; //!< \brief Treatment of frames with frame type 110 (reserved):
+ //!< 0: Reject
+ //!< 1: Accept + uint8_t bAcceptFt7Reserved:1; //!< \brief Treatment of frames with frame type 111 (reserved):
+ //!< 0: Reject
+ //!< 1: Accept + } newFrameTypes; //!< New value of frameTypes for the running background level operation +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup CMD_IEEE_MOD_SRC_MATCH +//! @{ +#define CMD_IEEE_MOD_SRC_MATCH 0x2003 +//! IEEE 802.15.4 Enable/Disable Source Matching Entry Command +struct __RFC_STRUCT rfc_CMD_IEEE_MOD_SRC_MATCH_s { + uint16_t commandNo; //!< The command ID number 0x2003 + struct { + uint8_t bEnable:1; //!< \brief 0: Disable entry
+ //!< 1: Enable entry + uint8_t srcPend:1; //!< New value of the pending bit for the entry + uint8_t entryType:1; //!< \brief 0: Short address
+ //!< 1: Extended address + } options; + uint8_t entryNo; //!< Index of entry to enable or disable +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup CMD_IEEE_ABORT_FG +//! @{ +#define CMD_IEEE_ABORT_FG 0x2401 +//! IEEE 802.15.4 Abort Foreground Level Command +struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_FG_s { + uint16_t commandNo; //!< The command ID number 0x2401 +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup CMD_IEEE_STOP_FG +//! @{ +#define CMD_IEEE_STOP_FG 0x2402 +//! IEEE 802.15.4 Gracefully Stop Foreground Level Command +struct __RFC_STRUCT rfc_CMD_IEEE_STOP_FG_s { + uint16_t commandNo; //!< The command ID number 0x2402 +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup CMD_IEEE_CCA_REQ +//! @{ +#define CMD_IEEE_CCA_REQ 0x2403 +//! IEEE 802.15.4 CCA and RSSI Information Request Command +struct __RFC_STRUCT rfc_CMD_IEEE_CCA_REQ_s { + uint16_t commandNo; //!< The command ID number 0x2403 + int8_t currentRssi; //!< The RSSI currently observed on the channel + int8_t maxRssi; //!< The maximum RSSI observed on the channel since Rx was started + struct { + uint8_t ccaState:2; //!< \brief Value of the current CCA state
+ //!< 0: Idle
+ //!< 1: Busy
+ //!< 2: Invalid + uint8_t ccaEnergy:2; //!< \brief Value of the current energy detect CCA state
+ //!< 0: Idle
+ //!< 1: Busy
+ //!< 2: Invalid + uint8_t ccaCorr:2; //!< \brief Value of the current correlator based carrier sense CCA state
+ //!< 0: Idle
+ //!< 1: Busy
+ //!< 2: Invalid + uint8_t ccaSync:1; //!< \brief Value of the current sync found based carrier sense CCA state
+ //!< 0: Idle
+ //!< 1: Busy + } ccaInfo; +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup ieeeRxOutput +//! @{ +//! Output structure for CMD_IEEE_RX + +struct __RFC_STRUCT rfc_ieeeRxOutput_s { + uint8_t nTxAck; //!< Total number of transmitted ACK frames + uint8_t nRxBeacon; //!< Number of received beacon frames + uint8_t nRxData; //!< Number of received data frames + uint8_t nRxAck; //!< Number of received acknowledgement frames + uint8_t nRxMacCmd; //!< Number of received MAC command frames + uint8_t nRxReserved; //!< Number of received frames with reserved frame type + uint8_t nRxNok; //!< Number of received frames with CRC error + uint8_t nRxIgnored; //!< Number of frames received that are to be ignored + uint8_t nRxBufFull; //!< Number of received frames discarded because the Rx buffer was full + int8_t lastRssi; //!< RSSI of last received frame + int8_t maxRssi; //!< Highest RSSI observed in the operation + uint8_t __dummy0; + ratmr_t beaconTimeStamp; //!< Time stamp of last received beacon frame +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup shortAddrEntry +//! @{ +//! Structure for short address entries + +struct __RFC_STRUCT rfc_shortAddrEntry_s { + uint16_t shortAddr; //!< Short address + uint16_t panId; //!< PAN ID +} __RFC_STRUCT_ATTR; + +//! @} + +//! \addtogroup ieeeRxCorrCrc +//! @{ +//! Receive status byte that may be appended to message in receive buffer + +struct __RFC_STRUCT rfc_ieeeRxCorrCrc_s { + struct { + uint8_t corr:6; //!< The correlation value + uint8_t bIgnore:1; //!< 1 if the packet should be rejected by frame filtering, 0 otherwise + uint8_t bCrcErr:1; //!< 1 if the packet was received with CRC error, 0 otherwise + } status; +} __RFC_STRUCT_ATTR; + +//! @} + +//! @} +//! @} +#endif diff --git a/source/command_handler.c b/source/command_handler.c new file mode 100644 index 0000000..e288779 --- /dev/null +++ b/source/command_handler.c @@ -0,0 +1,384 @@ +/****************************************************************************** +* Filename: command_handler.c +* +* Description: Source file for the command handler. This module handles +* commands and command responses on the host interface. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#include "command_handler.h" +#include "host_if.h" +#include "version.h" +#include "common.h" + +#define DEFAULT_FW_ID 100 +#ifndef FW_ID +#define FW_ID DEFAULT_FW_ID +#endif + +/* driverlib header files */ +#include "DeviceFamily.h" +#include DeviceFamily_constructPath(driverlib/chipinfo.h) + + +// Storage for response packets +static CommandResponsePacket_Obj CommandHandler_commandResponse; +static CommandPingResponsePacket_Obj CommandHandler_commandPingResponse; + +// Local functions +static void CommandHandler_constructResponsePacket(CommandResponsePacket_Obj* cmdResponse, uint8_t status); +static void CommandHandler_constructPingResponsePacket(CommandPingResponsePacket_Obj* cmdPingResponse, uint8_t status); +static void CommandHandler_forwardResponsePacket(uint8_t* cmdResponse, uint16_t packetLength); +static uint8_t CommandHandler_computeFcs(uint8_t* dataBuffer, uint16_t length); +static uint8_t CommandHandler_verifyPacket(CommandPacket_Obj* cmdPacket); +static uint8_t CommandHandler_searchForPacketHeader(CommandPacket_Obj* cmdPacket); +static void CommandHandler_flushHostInterface(uint16_t expectedLength); +static uint16_t CommandHandler_getChipId(void); +static uint8_t CommandHandler_getChipRevision(void); +static uint16_t CommandHandler_getFwRevision(void); +static uint8_t CommandHandler_getFwId(void); + + +uint8_t CommandHandler_getCommand(CommandPacket_Obj* cmdPacket) +{ + // Search for packet header + uint8_t status = CommandHandler_searchForPacketHeader(cmdPacket); + if(status != COMMAND_OK) + { + return status; + } + + // Compute length of remaining packet content + uint16_t remainingLen = cmdPacket->genPacketHdr.packetLen + sizeof(CommandPacketFooter_Obj); + + // Check if command length is valid + if(remainingLen > (MAX_COMMAND_PAYLOAD_LENGTH + sizeof(CommandPacketFooter_Obj))) + { + // The length indicates that the packet is longer than maximum length of a + // command packet. + + // The remaining bytes must be read/removed from host IF + CommandHandler_flushHostInterface(remainingLen); + return COMMAND_INVALID; + } + + // Start timeout timer + + // Read the rest of the packet + HostIF_readBuffer((uint8_t*) cmdPacket->payload, remainingLen); + + status = CommandHandler_verifyPacket(cmdPacket); + return status; +} + + +void CommandHandler_respondCommand(uint8_t status) +{ + CommandHandler_constructResponsePacket(&CommandHandler_commandResponse, status); + CommandHandler_forwardResponsePacket((uint8_t*)&CommandHandler_commandResponse, sizeof(CommandHandler_commandResponse)); +} + + +void CommandHandler_respondPingCommand(uint8_t status) +{ + CommandHandler_constructPingResponsePacket(&CommandHandler_commandPingResponse, status); + CommandHandler_forwardResponsePacket((uint8_t*)&CommandHandler_commandPingResponse, sizeof(CommandHandler_commandPingResponse)); +} + + +//! \brief Construct command response packet +//! +//! \param[in] cmdResponse +//! Pointer to buffer for the command response packet +//! +//! \param[in] status +//! Status to set in the command response +//! +//! \return None +void CommandHandler_constructResponsePacket(CommandResponsePacket_Obj* cmdResponse, uint8_t status) +{ + cmdResponse->genPacketHdr.sof = START_OF_FRAME_DELIMITER; + cmdResponse->genPacketHdr.packetType = PACKET_TYPE_COMMAND_RESPONSE; + cmdResponse->genPacketHdr.packetLen = COMMAND_RESPONSE_PAYLOAD_LENGTH; + cmdResponse->status = status; + cmdResponse->cmdPacketFtr.fcs = CommandHandler_computeFcs(&cmdResponse->genPacketHdr.packetType, \ + sizeof(cmdResponse->genPacketHdr.packetType) + sizeof(cmdResponse->genPacketHdr.packetLen) + sizeof(cmdResponse->status)); + + cmdResponse->cmdPacketFtr.genPacketFooter.eof = END_OF_FRAME_DELIMITER; +} + + +//! \brief Construct command response packet +//! +//! \param[in] cmdResponse +//! Pointer to buffer for the command response packet +//! +//! \param[in] status +//! Status to set in the command response +//! +//! \return None +void CommandHandler_constructPingResponsePacket(CommandPingResponsePacket_Obj* cmdPingResponse, uint8_t status) +{ + cmdPingResponse->genPacketHdr.sof = START_OF_FRAME_DELIMITER; + + cmdPingResponse->genPacketHdr.packetType = PACKET_TYPE_COMMAND_RESPONSE; + cmdPingResponse->genPacketHdr.packetLen = COMMAND_PING_RESPONSE_PAYLOAD_LENGTH; + + cmdPingResponse->status = status; + cmdPingResponse->chipId = CommandHandler_getChipId(); + cmdPingResponse->chipRev = CommandHandler_getChipRevision(); + cmdPingResponse->fwId = CommandHandler_getFwId(); + cmdPingResponse->fwRev = CommandHandler_getFwRevision(); + + cmdPingResponse->cmdPacketFtr.fcs = CommandHandler_computeFcs(&cmdPingResponse->genPacketHdr.packetType, \ + sizeof(cmdPingResponse->genPacketHdr.packetType) + sizeof(cmdPingResponse->genPacketHdr.packetLen) + COMMAND_PING_RESPONSE_PAYLOAD_LENGTH); + + cmdPingResponse->cmdPacketFtr.genPacketFooter.eof = END_OF_FRAME_DELIMITER; +} + + +//! \brief Forward command response packet to host +//! +//! \param[in] cmdResponse +//! Pointer to command response packet +//! +//! \param[in] packetLength +//! Length of command response packet +//! +//! \return None +void CommandHandler_forwardResponsePacket(uint8_t* cmdResponse, uint16_t packetLength) +{ + HostIF_writeBuffer((uint8_t*)cmdResponse, packetLength); +} + + +//! \brief Compute frame check sequence value from a data buffer +//! +//! \param[in] dataBuffer +//! Pointer to start of the data buffer to compute FCS over. +//! +//! \param[in] length +//! Length of the data buffer to compute FCS over. +//! +//! \return Computed frame sequence value +uint8_t CommandHandler_computeFcs(uint8_t* dataBuffer, uint16_t length) +{ + uint32_t result=0; + for(int i=0; igenPacketHdr) + cmdPacket->genPacketHdr.packetLen; + + uint8_t expectedFcs = CommandHandler_computeFcs(&cmdPacket->genPacketHdr.packetType, + PACKET_TYPE_LENGTH + PACKET_LEN_LENGTH + cmdPacket->genPacketHdr.packetLen); + if(expectedFcs != *((uint8_t*)(cmdPacket) + fcsIndex)) + { + status = COMMAND_FCS_FAILED; + } + + return status; +} + + +//! \brief Search for packet header in bytes read from host interface. +//! +//! This function blocks until first byte of SOF is read from host. +//! It then blocks until a second byte is read. +//! - If the two bytes does not match SOF it returns with error. +//! - If the two bytes matches SOF, it blocks until the complete packet +//! header is read, and returns success. +//! +//! \param[in] cmdPacket +//! Pointer to buffer for command packet. If a successful packet +//! header is found, this function will populate the packet header values +//! of the given packet. +//! +//! \return COMMAND_OK or COMMAND_INVALID +static uint8_t CommandHandler_searchForPacketHeader(CommandPacket_Obj* cmdPacket) +{ + uint8_t status = COMMAND_INVALID; + uint8_t readValue = 0; + uint8_t sofByte0Value = START_OF_FRAME_DELIMITER & 0xFF; + uint8_t sofByte1Value = (START_OF_FRAME_DELIMITER & 0xFF00) >> 8; + + // Read bytes from host IF until 0xFD is found (first byte of Start of Frame) + while(readValue != sofByte0Value) + { + HostIF_readBuffer(&readValue, 1); + } + + // It is expected that next byte is second byte of SOF (0x50) + HostIF_readBuffer(&readValue, 1); + if(readValue != sofByte1Value) + { + // Packet is invalid + status = COMMAND_INVALID; + } + else + { + // Correct SOF is found. Read rest of header + cmdPacket->genPacketHdr.sof = START_OF_FRAME_DELIMITER; + HostIF_readBuffer((uint8_t*)&(cmdPacket->genPacketHdr.packetType), sizeof(GeneralPacketHeader_Obj) - SOF_LENGTH); + status = COMMAND_OK; + } + + return status; +} + + +//! \brief Read and throw bytes from Host IF. +//! +//! This function is used to flush the host interface. It can be used in +//! the case where the received command is too long (no available buffer +//! space for received command). The function blocks until the expected +//! number of bytes are read. +//! +//! \param[in] expectedLength +//! Expected number of bytes to receive and throw. +//! +//! \return None +static void CommandHandler_flushHostInterface(uint16_t expectedLength) +{ +#define READ_CHUNK_SIZE 8 + uint8_t buffer[READ_CHUNK_SIZE]; + uint16_t remainingBytes = expectedLength; + uint16_t readSize = 0; + int32_t numReadBytes; + + while(remainingBytes) + { + readSize = (remainingBytes < READ_CHUNK_SIZE) ? remainingBytes : READ_CHUNK_SIZE; + numReadBytes = HostIF_readBuffer(buffer, readSize); + remainingBytes -= readSize; + if(numReadBytes < READ_CHUNK_SIZE && remainingBytes) + { + // Number of bytes was less than the chunk size. A UART read timeout + // has probably occured. Abort this loop to avoid be stuck here + // forever waiting for data that are not received. + break; + } + } +} + + +//! \brief Get chip id +//! +//! \return Chip id hex value +static uint16_t CommandHandler_getChipId(void) +{ + ChipType_t chipType = ChipInfo_GetChipType(); + switch(chipType) + { + case CHIP_TYPE_CC1310: + return 0x1310; + case CHIP_TYPE_CC1350: + return 0x1350; + case CHIP_TYPE_CC2620: + return 0x2620; + case CHIP_TYPE_CC2630: + return 0x2630; + case CHIP_TYPE_CC2640: + return 0x2640; + case CHIP_TYPE_CC2650: + return 0x2650; +/* case CHIP_TYPE_CC2652: + return 0x2652; + case CHIP_TYPE_CC1352: + return 0x1352; + case CHIP_TYPE_CC1352P: + return 0x1353; + case CHIP_TYPE_CC1312: + return 0x1312;*/ + default: + return 0; + } +} + + +//! \brief Get chip revision +//! +//! \return Chip revision value +static uint8_t CommandHandler_getChipRevision(void) +{ + HwRevision_t hwRevision = ChipInfo_GetHwRevision(); + + switch(hwRevision) + { + case HWREV_1_0: + return 0x10; + case HWREV_2_0: + return 0x20; + case HWREV_2_1: + return 0x21; + case HWREV_2_2: + return 0x22; + case HWREV_2_3: + return 0x23; + default: + return 0; + } +} + + +//! \brief Get firmware revision +//! +//! \return Firmware major revision (MSB) and minor revision (LSB) +static uint16_t CommandHandler_getFwRevision(void) +{ + return (MAJOR_VERSION << 8) | MINOR_VERSION; +} + +//! \brief Get firmware ID +//! +//! \return Firmware Id +static uint8_t CommandHandler_getFwId(void) +{ + + return FW_ID; +} + diff --git a/source/command_handler.h b/source/command_handler.h new file mode 100644 index 0000000..7b743a4 --- /dev/null +++ b/source/command_handler.h @@ -0,0 +1,82 @@ +/****************************************************************************** +* Filename: command_handler.h +* +* Description: Header file for the command handler. This module handles +* commands and command responses on the host interface. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef COMMAND_HANDLER_H +#define COMMAND_HANDLER_H + +#include "command_packet.h" + +// Status values +#define COMMAND_OK 0 +#define COMMAND_TIMED_OUT 1 +#define COMMAND_FCS_FAILED 2 +#define COMMAND_INVALID 3 +#define COMMAND_INVALID_STATE 4 +#define COMMAND_INVALID_PARAMETER 5 + +//! \brief Get command from host interface. +//! +//! This function will block until either: +//! - A complete command is successfully received, or +//! - A complete command or parts of it is received but there are errors +//! in the command. +//! +//! \param[in] cmdPacket +//! Pointer to buffer large enough for the received command packet. +//! The buffer must be allocated by the caller. +//! +//! \return \li \c COMMAND_OK - successful reception of a command. +//! \li \c COMMAND_TIMED_OUT - Parts of the command was received but not the +//! complete command. +//! \li \c COMMAND_INVALID - The command is invalid. +extern uint8_t CommandHandler_getCommand(CommandPacket_Obj* cmdPacket); + + +//! \brief Send command response on host interface. +//! +//! \param[in] status - Status of the received host command. +extern void CommandHandler_respondCommand(uint8_t status); + + +//! \brief Send command response for CMD_PING on host interface. +//! +//! \param[in] status - Status of the received ping command. +extern void CommandHandler_respondPingCommand(uint8_t status); + +#endif + diff --git a/source/command_packet.h b/source/command_packet.h new file mode 100644 index 0000000..1289d27 --- /dev/null +++ b/source/command_packet.h @@ -0,0 +1,128 @@ +/****************************************************************************** +* Filename: command_packet.h +* +* Description: Defines for the command packet format. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef COMMAND_PACKET_H +#define COMMAND_PACKET_H + +#include "general_packet.h" + +// Command packet format +#define MAX_COMMAND_PAYLOAD_LENGTH 255 +#define FCS_LENGTH 1 +#define COMMAND_RESPONSE_PAYLOAD_LENGTH 1 +#define COMMAND_PING_RESPONSE_PAYLOAD_LENGTH 7 + +// Command packet types +#define PACKET_TYPE_COMMAND_PING 0x40 +#define PACKET_TYPE_COMMAND_START 0x41 +#define PACKET_TYPE_COMMAND_STOP 0x42 +#define PACKET_TYPE_COMMAND_PAUSE 0x43 +#define PACKET_TYPE_COMMAND_RESUME 0x44 +#define PACKET_TYPE_COMMAND_CFG_FREQUENCY 0x45 +#define PACKET_TYPE_COMMAND_CFG_PHY 0x47 + +// Test command packet types +#define PACKET_TYPE_TEST_COMMAND_TRANSMIT_SEQUENCE 0x60 + +// Command response packet types +#define PACKET_TYPE_COMMAND_RESPONSE 0x80 + +// Command packet payload fields +#define COMMAND_CFG_FREQUENCY_DATA_LENGTH 4 +#define COMMAND_CFG_FREQUENCY_FREQ_OFFSET 0 // Offset of frequency field in command data +#define COMMAND_CFG_FREQUENCY_FRACT_FREQ_OFFSET 2 // Offset of fractional frequency field in command data +#define COMMAND_CFG_PHY_DATA_LENGTH 1 +#define COMMAND_CFG_PHY_DATA_OFFSET 0 // Offset of PHY number field in command data + + +// Test Command packet payload fields +#define TEST_COMMAND_TRANSMIT_SEQUENCE_REPETITIONS_SIZE 2 +#define TEST_COMMAND_TRANSMIT_SEQUENCE_REPETITIONS_OFFSET 0 // offset from start of command data +#define TEST_COMMAND_TRANSMIT_SEQUENCE_PACKET_LENGTH_SIZE 2 +#define TEST_COMMAND_TRANSMIT_SEQUENCE_PACKET_LENGTH_OFFSET 0 // Offset from start of serie +#define TEST_COMMAND_TRANSMIT_SEQUENCE_PACKET_NUMBER_SIZE 2 +#define TEST_COMMAND_TRANSMIT_SEQUENCE_PACKET_NUMBER_OFFSET 2 // Offset from start of serie + + +// Command Response Status values +#define STATUS_OK 0 +#define STATUS_TIMEOUT 1 +#define STATUS_FCS_FAILED 2 + +// Command packet footer +#pragma pack(1) +typedef struct CommandPacketFooter_Obj +{ + uint8_t fcs; + GeneralPacketFooter_Obj genPacketFooter; +} CommandPacketFooter_Obj; + +// Command packet +#pragma pack(1) +typedef struct CommandPacket_Obj +{ + GeneralPacketHeader_Obj genPacketHdr; + uint8_t payload[MAX_COMMAND_PAYLOAD_LENGTH + sizeof(CommandPacketFooter_Obj)]; // space for payload and general packet footer +} CommandPacket_Obj; + +// Command response packet +#pragma pack(1) +typedef struct CommandResponsePacket_Obj +{ + GeneralPacketHeader_Obj genPacketHdr; + uint8_t status; + CommandPacketFooter_Obj cmdPacketFtr; +} CommandResponsePacket_Obj; + + +// Command response packet +#pragma pack(1) +typedef struct CommandPingResponsePacket_Obj +{ + GeneralPacketHeader_Obj genPacketHdr; + uint8_t status; + uint16_t chipId; + uint8_t chipRev; + uint8_t fwId; + uint16_t fwRev; + CommandPacketFooter_Obj cmdPacketFtr; +} CommandPingResponsePacket_Obj; + + + +#endif + diff --git a/source/common.c b/source/common.c new file mode 100644 index 0000000..54a4af4 --- /dev/null +++ b/source/common.c @@ -0,0 +1,76 @@ +/****************************************************************************** +* Filename: common.c +* +* Description: Source file common functionality. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include "common.h" + +inline uint32_t Common_get32BitValueLE(uint8_t* buffer) +{ + uint32_t value = 0; + value |= (uint32_t)buffer[3] << 24; + value |= (uint32_t)buffer[2] << 16; + value |= (uint32_t)buffer[1] << 8; + value |= (uint32_t)buffer[0]; + + return value; +} + + +inline uint16_t Common_get16BitValueLE(uint8_t* buffer) +{ + uint16_t value = 0; + value |= (uint16_t)buffer[1] << 8; + value |= (uint16_t)buffer[0]; + + return value; +} + + +inline void Common_set16BitValueLE(uint8_t* buffer, uint16_t value) +{ + buffer[0] = value & 0xFF; + buffer[1] = (value & 0xFF00) >> 8; +} + + +inline void Common_set32BitValueLE(uint8_t* buffer, uint32_t value) +{ + buffer[0] = value & 0xFF; + buffer[1] = (value & 0xFF00) >> 8; + buffer[2] = (value & 0xFF0000) >> 16; + buffer[3] = (value & 0xFF000000) >> 24; +} diff --git a/source/common.h b/source/common.h new file mode 100644 index 0000000..1b08950 --- /dev/null +++ b/source/common.h @@ -0,0 +1,95 @@ +/****************************************************************************** +* Filename: common.h +* +* Description: Header file for common functionality +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef COMMON_H +#define COMMON_H + +#include + +//! \brief Get little endian value of 32 bit byte field that may start at an +//! unaligned address. +//! (32 bit pointer access should be avoided at non-word aligned +//! address. Use this function instead. ) +//! +//! \param[in] buffer +//! Pointer to first byte of the 32 bit value +//! +//! \return 32 bit value +//! +extern inline uint32_t Common_get32BitValueLE(uint8_t* buffer); + + +//! \brief Get little endian value of 16 bit byte field that may start at an +//! unaligned address. +//! (16 bit pointer access should be avoided at non-word aligned +//! address. Use this function instead. ) +//! +//! \param[in] buffer +//! Pointer to first byte of the 16 bit value +//! +//! \return 16 bit value +//! +extern inline uint16_t Common_get16BitValueLE(uint8_t* buffer); + + +//! \brief Set little endian value of 16 bit byte field that may start at an +//! unaligned address. +//! (16 bit pointer access should be avoided at non-word aligned +//! address. Use this function instead. ) +//! +//! \param[out] buffer +//! Pointer to first byte of the 16 bit value +//! +//! \param[in] value to set +//! +extern inline void Common_set16BitValueLE(uint8_t* buffer, uint16_t value); + + +//! \brief Set little endian value of 32 bit byte field that may start at an +//! unaligned address. +//! (32 bit pointer access should be avoided at non-word aligned +//! address. Use this function instead. ) +//! +//! \param[out] buffer +//! Pointer to first byte of the 32 bit value +//! +//! \param[in] value to set +//! +extern inline void Common_set32BitValueLE(uint8_t* buffer, uint32_t value); + +#endif + diff --git a/source/control_task.c b/source/control_task.c new file mode 100644 index 0000000..c29a71a --- /dev/null +++ b/source/control_task.c @@ -0,0 +1,303 @@ +/****************************************************************************** +* Filename: control_task.c +* +* Description: Source file for the Control Task. This task controls the state +* of application. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#include "host_if.h" +#include "radio_if.h" +#include "control_task.h" +#include "command_packet.h" +#include "command_handler.h" +#include "test_command_handler.h" +#include "timestamp.h" +#include "task_event.h" + +#include + +// Sniffer control state. WAIT_FOR_COMMAND is initial state. +static SnifferState ControlTask_state = STATE_WAIT_FOR_COMMAND; + +// Command handling related +static CommandPacket_Obj ControlTask_command; +static uint8_t ControlTask_handleCommand(CommandPacket_Obj* command); +static uint8_t ControlTask_handleCommandStart(void); +static uint8_t ControlTask_handleCommandStop(void); +static uint8_t ControlTask_handleCommandCfgFrequency(uint8_t* commandData, uint16_t length); +static uint8_t ControlTask_handleCommandCfgPhy(uint8_t* commandData, uint16_t length); +static bool ControlTask_isCmdPing(CommandPacket_Obj* cmdPacket); + +// This function is not static to make it accessible from test task +void ControlTask_setControlState(SnifferState state); + +// Other local functions +static void ControlTask_notifyUserIfTask(void); + + +//! \brief Control task function +//! The arguments are not used. +//! +//! This task controls the state of the application. It waits for +//! commands from host. At reception of a host command it will handle +//! the command and change state accordingly. This task is blocked in the +//! function CommandHandler_getCommand until a host command is received. +//! After the first command from the host interface is received, it will +//! notify the user interface task by sending the event EVENT_ID_USER_IF_TASK_END +//! to it. This event causes the user interface task to exit itself. +//! +void controlTask(UArg a0, UArg a1) +{ + // Initialize the modules to be used by this task + HostIF_init(); + RadioIF_init(); + TaskEvent_init(); + + while (true) + { + // Wait for command from host + uint8_t status = CommandHandler_getCommand(&ControlTask_command); + if(status == COMMAND_OK) + { + // After first command is received successfully, state is changed + // to INIT and User Interface task is notified. + if(ControlTask_state == STATE_WAIT_FOR_COMMAND) + { + ControlTask_notifyUserIfTask(); + ControlTask_state = STATE_INIT; + } + + status = ControlTask_handleCommand(&ControlTask_command); + } + // Command is completed, respond to host + if(ControlTask_isCmdPing(&ControlTask_command)) + { + CommandHandler_respondPingCommand(status); + } + else + { + CommandHandler_respondCommand(status); + } + } +} + + +//! \brief handle a host command +//! +//! \param[in] cmdPacket +//! Pointer to the received command packet +//! +//! \return status that indicates successful or failed handling of the command. +//! COMMAND_OK - The command was handled successfully. +//! COMMAND_INVALID - The command is invalid (e.g. payload does not match +//! the command type.) +//! COMMAND_INVALID_STATE: The received command is not valid for the +//! current state of the sniffer. +uint8_t ControlTask_handleCommand(CommandPacket_Obj* command) +{ + uint8_t status = COMMAND_OK; + + switch(command->genPacketHdr.packetType) + { + case PACKET_TYPE_COMMAND_START: + if(ControlTask_state != STATE_STARTED) + { + status = ControlTask_handleCommandStart(); + ControlTask_state = STATE_STARTED; + } + break; + case PACKET_TYPE_COMMAND_STOP: + if(ControlTask_state != STATE_STOPPED) + { + status = ControlTask_handleCommandStop(); + ControlTask_state = STATE_STOPPED; + } + break; + case PACKET_TYPE_COMMAND_CFG_FREQUENCY: + status = ControlTask_handleCommandCfgFrequency((uint8_t*)&command->payload, command->genPacketHdr.packetLen); + break; + case PACKET_TYPE_COMMAND_CFG_PHY: + status = ControlTask_handleCommandCfgPhy((uint8_t*)&command->payload, command->genPacketHdr.packetLen); + break; + case PACKET_TYPE_COMMAND_PING: + status = COMMAND_OK; + break; + case PACKET_TYPE_TEST_COMMAND_TRANSMIT_SEQUENCE: + if(ControlTask_state != STATE_STARTED) + { + status = TestCommandHandler_transmitSequence((uint8_t*)&command->payload, command->genPacketHdr.packetLen); + } + break; + default: + status = COMMAND_INVALID; + break; + } + + return status; +} + + +//! \brief handle CMD_START +//! +//! \return status that indicates successful or failed handling of the command. +uint8_t ControlTask_handleCommandStart(void) +{ + RadioIF_startRx(); + + return COMMAND_OK; +} + + +//! \brief handle CMD_STOP +//! +//! \return status that indicates successful or failed handling of the command. +uint8_t ControlTask_handleCommandStop(void) +{ + RadioIF_stopRx(); + + // Reset timestamp module + Timestamp_init(); + + return COMMAND_OK; +} + + +//! \brief handle CMD_CFG_FREQUENCY +//! +//! \param[in] commandData +//! payload data for the CMD_CFG_FREQUENCY command. +//! +//! \param[in] length +//! length of payload data +//! +//! \return status that indicates successful or failed handling of the command. +//! COMMAND_OK - The command was handled successfully. +//! COMMAND_INVALID - The command is invalid (e.g. payload does not match +//! the command type.) +//! COMMAND_INVALID_STATE: The received command is not valid for the +//! current state of the sniffer. +uint8_t ControlTask_handleCommandCfgFrequency(uint8_t* commandData, uint16_t length) +{ + if(length != COMMAND_CFG_FREQUENCY_DATA_LENGTH) + { + // Length of data field is invalid for this command + // The command is ignored + return COMMAND_INVALID; + } + + if( (ControlTask_state != STATE_STOPPED) && (ControlTask_state != STATE_INIT) ) + { + // The command is only valid in STOPPED and INIT state + // The command is ignored in other states. + return COMMAND_INVALID_STATE; + } + + uint16_t* frequency = (uint16_t*)(commandData + COMMAND_CFG_FREQUENCY_FREQ_OFFSET); + uint16_t* fractFrequency = (uint16_t*)(commandData + COMMAND_CFG_FREQUENCY_FRACT_FREQ_OFFSET); + RadioIF_setFrequency(*frequency, *fractFrequency); + + return COMMAND_OK; +} + + +//! \brief handle CMD_CFG_PHY +//! +//! \param[in] commandData +//! payload data for the CMD_CFG_PHY command. +//! +//! \param[in] length +//! length of payload data (a length of 1 byte is expected) +//! +//! \return status that indicates successful or failed handling of the command. +//! COMMAND_OK - The command was handled successfully. +//! COMMAND_INVALID - The command is invalid (e.g. payload does not match +//! the command type.) +//! COMMAND_INVALID_STATE: The received command is not valid for the +//! current state of the sniffer. +uint8_t ControlTask_handleCommandCfgPhy(uint8_t* commandData, uint16_t length) +{ + if(length != COMMAND_CFG_PHY_DATA_LENGTH) + { + // Length of data field is invalid for this command + // The command is ignored + return COMMAND_INVALID; + } + + if( (ControlTask_state != STATE_STOPPED) && (ControlTask_state != STATE_INIT) ) + { + // The command is only valid in STOPPED and INIT state + // The command is ignored in other states. + return COMMAND_INVALID_STATE; + } + + uint8_t phyNumber = *(commandData + COMMAND_CFG_PHY_DATA_OFFSET); + + uint8_t status = COMMAND_OK; + if(!RadioIf_setPhy(phyNumber)) + { + status = COMMAND_INVALID_PARAMETER; + } + + return status; +} + + +//! \brief Notify user interface task. +//! +//! Upon reception of this notification the user interface shall exit +//! itself. +void ControlTask_notifyUserIfTask(void) +{ + Event_post(TaskEvent_Handle, EVENT_ID_USER_IF_TASK_END); +} + + +//! \brief Set application control state +//! +//! This function is used from test FW to set control state of the +//! application, for example to check that the correct command responses +//! are given dependent on control state. +void ControlTask_setControlState(SnifferState controlState) +{ + ControlTask_state = controlState; +} + + +//! \brief Check if command is CMD_PING +bool ControlTask_isCmdPing(CommandPacket_Obj* cmdPacket) +{ + return (cmdPacket->genPacketHdr.packetType == PACKET_TYPE_COMMAND_PING); +} + + diff --git a/source/control_task.h b/source/control_task.h new file mode 100644 index 0000000..7d42136 --- /dev/null +++ b/source/control_task.h @@ -0,0 +1,58 @@ +/****************************************************************************** +* Filename: control_task.h +* +* Description: Header file for the Control Task. This task controls the state +* of application. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef CONTROL_TASK_H +#define CONTROL_TASK_H + +#include + +// Control states +typedef enum SnifferState +{ + STATE_WAIT_FOR_COMMAND, + STATE_INIT, + STATE_STARTED, + STATE_STOPPED, +} SnifferState; + +//! \brief Control task function +//! The arguments are not used. +extern void controlTask(UArg a0, UArg a1); + +#endif + diff --git a/source/data_packet.h b/source/data_packet.h new file mode 100644 index 0000000..01657db --- /dev/null +++ b/source/data_packet.h @@ -0,0 +1,75 @@ +/****************************************************************************** +* Filename: data_packet.h +* +* Description: Defines for the data packet format. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#ifndef DATA_PACKET_H +#define DATA_PACKET_H + +#include + +#include "general_packet.h" + +// Data and error packet formats +#define MAX_DATA_PAYLOAD_LENGTH 2047 +#define MAX_EXTRA_RADIO_ADDED_BYTES 10 // Up to 10 extra bytes are added by the radio (Timestamp, CRC, RSSI and Status fields) +#define TIMESTAMP_LENGHT 6 +#define ERROR_REPORT_PAYLOAD_LENGTH 1 + +// Packet types +#define PACKET_TYPE_DATA 0xC0 +#define PACKET_TYPE_ERROR 0xC1 + +// Data packet +#pragma pack(1) +typedef struct DataPacket_Obj +{ + GeneralPacketHeader_Obj genPacketHeader; + uint8_t timeStamp[TIMESTAMP_LENGHT]; + uint8_t payload[MAX_DATA_PAYLOAD_LENGTH + MAX_EXTRA_RADIO_ADDED_BYTES + sizeof(GeneralPacketFooter_Obj)]; // space for payload and general packet footer +} DataPacket_Obj; + +// Error packet +#pragma pack(1) +typedef struct ErrorReportPacket_Obj +{ + GeneralPacketHeader_Obj genPacketHeader; + uint8_t error[ERROR_REPORT_PAYLOAD_LENGTH]; + GeneralPacketFooter_Obj genPacketFooter; +} ErrorReportPacket_Obj; + +#endif + diff --git a/source/data_task.c b/source/data_task.c new file mode 100644 index 0000000..68abb3b --- /dev/null +++ b/source/data_task.c @@ -0,0 +1,197 @@ +/****************************************************************************** +* Filename: data_task.c +* +* Description: Source file for the Data Task. This task process data +* received from the radio. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include +#include +#include +#include +#include "host_if.h" +#include "radio_if.h" +#include "radio_if_dataqueue.h" +#include "packet_handler.h" +#include "data_packet.h" +#include "timestamp.h" +#include "packet_queue.h" + +#include + +static void DataTask_rfCoreEventCb(uint32_t rfCoreEvent); +static void DataTask_initEventHandler(void); +static void DataTask_processPacket(void); +static void DataTask_handleBufferOverflow(void); + +#define EVENT_ID_RX_ENTRY_DONE Event_Id_01 +#define EVENT_ID_RX_BUFFER_FULL Event_Id_02 +static Event_Handle DataTask_EventHandle; + + +//! \brief Data task function +//! The arguments are not used. +//! +//! This task blocks waiting for either +//! - a new packet available in the radio interface data queue, +//! - or an event triggered when the RX buffers are full. +//! When a new packet is available it takes the packet +//! out of the queue, process the packet and forwards it to the host. +//! +void dataTask(UArg a0, UArg a1) +{ + // Initialize the modules to be used by this task + HostIF_init(); + Timestamp_init(); + PacketQueue_init(); + + DataTask_initEventHandler(); + + while (true) + { + // Event_pend blocks until one or more of the events are received + UInt events = Event_pend(DataTask_EventHandle, Event_Id_NONE, EVENT_ID_RX_ENTRY_DONE | EVENT_ID_RX_BUFFER_FULL, BIOS_WAIT_FOREVER); + + // Process the received packets + if(events & EVENT_ID_RX_ENTRY_DONE) + { + // Process all packets in the RX packet queue + while(RadioIF_hasPacket()) + { + DataTask_processPacket(); + } + } + + if(events & EVENT_ID_RX_BUFFER_FULL) + { + // Process all packets in the RX packet queue + while(RadioIF_hasPacket()) + { + DataTask_processPacket(); + } + + DataTask_handleBufferOverflow(); + } + } +} + + + +//! \brief Process a data packet +//! +//! This function first allocates a packet buffer slot on the Host IF +//! queue. Then it reads the packet from the RF Core queue, processes +//! the timestamp field and formats it according to the Host IF format. +//! Finally, it enqueues the packet on the Host IF packet queue. This will +//! signal to the Host IF packet that a new packet is ready to be sent on +//! the Host IF interface. +void DataTask_processPacket(void) +{ + // Allocate a buffer slot for the new packet + DataPacket_Obj* p = PacketQueue_allocBufferSlot(); + + // Disable task switch to make sure the processing of one packet is not interrupted. + int key = Task_disable(); + + // Take a packet from the RX packet queue + uint16_t len = RadioIF_takePacket((uint8_t*)p->payload, sizeof(p->payload)); + + len = Timestamp_extractTimestamp((uint8_t*)p->payload, len, p); + + // Do packet processing + uint16_t payloadLength = PacketHandler_processPacket(p, len); + + uint16_t packetLength = PACKET_NON_PAYLOAD_LENGTH + payloadLength; + Task_restore(key); + + // Enqueue packet on the Host IF queue + PacketQueue_enqueue(p, packetLength); +} + + +//! \brief Handle a buffer overflow. +//! +//! This function handles an RX buffer overflow and sends an error packet +//! on the Host interface. +static void DataTask_handleBufferOverflow(void) +{ + // Allocate a buffer slot for an error packet + DataPacket_Obj* p = PacketQueue_allocBufferSlot(); + + PacketHandler_processError((uint8_t*)p, RADIO_IF_STATUS_RX_BUFFER_OVERFLOW); + RadioIF_handleBufferOverflow(); + + // Enqueue error packet on the Host IF queue + PacketQueue_enqueue(p, sizeof(ErrorReportPacket_Obj)); +} + + +//! \brief Initialize event handling +//! +void DataTask_initEventHandler(void) +{ + // Create event with default parameters + DataTask_EventHandle = Event_create(NULL, NULL); + + if (DataTask_EventHandle == NULL) + { + System_abort("Event create failed"); + } + + // Register Radio timer callback function + RadioIF_registerRfCoreEventCb(&DataTask_rfCoreEventCb); +} + + +//! \brief RF Core event callback handler. +//! +//! This function handles two events from RF Core: RX_ENTRY_DONE and +//! RX_BUFFER_FULL events. +//! +//! \param[in] rfCoreEvent +//! RF Core event number +void DataTask_rfCoreEventCb(uint32_t rfCoreEvent) +{ + if(rfCoreEvent & RX_ENTRY_DONE_EVENT) + { + Event_post(DataTask_EventHandle, EVENT_ID_RX_ENTRY_DONE); + } + + if(rfCoreEvent & RX_BUFFER_FULL_EVENT) + { + Event_post(DataTask_EventHandle, EVENT_ID_RX_BUFFER_FULL); + } +} + diff --git a/source/data_task.h b/source/data_task.h new file mode 100644 index 0000000..c893e64 --- /dev/null +++ b/source/data_task.h @@ -0,0 +1,49 @@ +/****************************************************************************** +* Filename: data_task.h +* +* Description: Header file for the data Task. This task handles data received +* from the radio. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef DATA_TASK_H +#define DATA_TASK_H + +#include + +//! \brief Data task function +//! The arguments are not used. +extern void dataTask(UArg a0, UArg a1); + +#endif + diff --git a/source/general_packet.h b/source/general_packet.h new file mode 100644 index 0000000..06ea18d --- /dev/null +++ b/source/general_packet.h @@ -0,0 +1,73 @@ +/****************************************************************************** +* Filename: general_packet.h +* +* Description: Defines for the general host interface packet format. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef GENERAL_PACKET_H +#define GENERAL_PACKET_H + +#include + +// General host interface packet format +#define SOF_LENGTH 2 +#define PACKET_TYPE_LENGTH 1 +#define PACKET_LEN_LENGTH 2 +#define MAX_PAYLOAD_LENGTH 2047 +#define EOF_LENGTH 2 +#define PACKET_NON_PAYLOAD_LENGTH (SOF_LENGTH + PACKET_TYPE_LENGTH + PACKET_LEN_LENGTH + TIMESTAMP_LENGHT + EOF_LENGTH) +#define START_OF_FRAME_DELIMITER 0x5340 +#define END_OF_FRAME_DELIMITER 0x4540 + + +// General packet header +#pragma pack(1) +typedef struct GeneralPacketHeader_Obj +{ + uint16_t sof; + uint8_t packetType; + uint16_t packetLen; +} GeneralPacketHeader_Obj; + + +// General packet footer +#pragma pack(1) +typedef struct GeneralPacketFooter_Obj +{ + uint16_t eof; +} GeneralPacketFooter_Obj; + + +#endif + diff --git a/source/host_if.c b/source/host_if.c new file mode 100644 index 0000000..285ea19 --- /dev/null +++ b/source/host_if.c @@ -0,0 +1,107 @@ +/****************************************************************************** +* Filename: host_if.c +* +* Description: Source file for the host interface. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include "host_if.h" +#include "Board.h" +#include +#include +#include +#include + +static UART_Handle HostIF_Uart_Handle; +static UART_Params HostIF_uartParams; +static bool HostIF_isInitialized = false; + +// Semaphore that for protecting uart calls against simultanous access from +// multiple tasks. Simulatanous access to uart from more than one task in same +// direction is not supported by the TI-RTOS driver. +static Semaphore_Struct HostIF_semStructUart; +static Semaphore_Handle HostIF_SemUart_Handle; + +// UART read timeout +#define UART_READ_TIMEOUT_PERIOD 20000 // ticks of 10 us -> 200ms + +void HostIF_init() +{ + if(!HostIF_isInitialized) + { + UART_init(); + UART_Params_init(&HostIF_uartParams); + HostIF_uartParams.writeDataMode = UART_DATA_BINARY; + HostIF_uartParams.readDataMode = UART_DATA_BINARY; + HostIF_uartParams.readReturnMode = UART_RETURN_FULL; + HostIF_uartParams.readEcho = UART_ECHO_OFF; + HostIF_uartParams.baudRate = 921600; + HostIF_uartParams.readTimeout = UART_READ_TIMEOUT_PERIOD; + HostIF_Uart_Handle = UART_open(Board_UART0, &HostIF_uartParams); + + if (HostIF_Uart_Handle == NULL) + { + System_abort("Error opening the UART"); + } + + // Initialize the uart semaphore + Semaphore_Params semParams; + + // Construct a new binary semaphore and initialize it to 1 + Semaphore_Params_init(&semParams); + semParams.mode = Semaphore_Mode_BINARY; + Semaphore_construct(&HostIF_semStructUart, 1, &semParams); + + HostIF_SemUart_Handle = Semaphore_handle(&HostIF_semStructUart); + + HostIF_isInitialized = true; + } +} + + +void HostIF_writeBuffer(uint8_t* buffer, uint16_t len) +{ + // Suspend the task until UART is available + Semaphore_pend(HostIF_SemUart_Handle, BIOS_WAIT_FOREVER); + UART_write(HostIF_Uart_Handle, buffer, len); + + // Signal the other tasks waiting for UART semaphore + Semaphore_post(HostIF_SemUart_Handle); +} + + +int32_t HostIF_readBuffer(uint8_t* buffer, uint16_t len) +{ + return UART_read(HostIF_Uart_Handle, buffer, len); +} diff --git a/source/host_if.h b/source/host_if.h new file mode 100644 index 0000000..bcca702 --- /dev/null +++ b/source/host_if.h @@ -0,0 +1,76 @@ +/****************************************************************************** +* Filename: host_if.h +* +* Description: Header file for host interface. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef HOST_IF_H +#define HOST_IF_H + +#include + +//! \brief Initialize the host interface +//! +//! \return None +extern void HostIF_init(void); + + +//! \brief Write data to the host interface +//! +//! \param[in] buffer +//! Pointer to the buffer with data to write. +//! +//! \param[in] len +//! Length of the data buffer +//! +//! \return None +extern void HostIF_writeBuffer(uint8_t* buffer, uint16_t len); + + +//! \brief Read data from the host interface +//! +//! This function blocks until the number of bytes indicated by the 'len' +//! argument is received. +//! +//! \param[in] buffer +//! Pointer to the buffer with data to write. +//! +//! \param[in] len +//! number of bytes to read. +//! +//! \return Number of bytes read from UART or -1 if an error occured +extern int32_t HostIF_readBuffer(uint8_t* buffer, uint16_t len); + +#endif + diff --git a/source/host_if_task.c b/source/host_if_task.c new file mode 100644 index 0000000..175f22f --- /dev/null +++ b/source/host_if_task.c @@ -0,0 +1,64 @@ +/****************************************************************************** +* Filename: host_if_task.c +* +* Description: Source file for the Host IF Task. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include +#include "packet_queue.h" +#include "host_if.h" + + +//! \brief Host IF task function +//! The arguments are not used. +//! +//! This task takes packets from the Host interface queue and sends the packets +//! out on the Host interface. +//! +void hostIfTask(UArg a0, UArg a1) +{ + DataPacket_Obj* dataPacket; + uint16_t packetLength; + + while(1) + { + PacketQueue_dequeue(&dataPacket, &packetLength); + HostIF_writeBuffer((uint8_t*)dataPacket, packetLength); + // HostIF_writeBuffer blocks until the packet is written. + // The buffer slot can now be freed. + PacketQueue_freeBufferSlot(dataPacket); + } +} + diff --git a/source/host_if_task.h b/source/host_if_task.h new file mode 100644 index 0000000..a16ce2f --- /dev/null +++ b/source/host_if_task.h @@ -0,0 +1,48 @@ +/****************************************************************************** +* Filename: host_if_task.h +* +* Description: Header file for the Host IF Task. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef HOST_IF_TASK_H +#define HOST_IF_TASK_H + +#include + +//! \brief Host IF task function +//! The arguments are not used. +extern void hostIfTask(UArg a0, UArg a1); + +#endif + diff --git a/source/packet_handler.c b/source/packet_handler.c new file mode 100644 index 0000000..e451f0f --- /dev/null +++ b/source/packet_handler.c @@ -0,0 +1,184 @@ +/****************************************************************************** +* Filename: packet_handler.c +* +* Description: Source file for packet handler. This module handles data and +* and error packet, and forwarding of these packets to host. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include "packet_handler.h" +#include "host_if.h" +#include "phy_manager.h" +#include "common.h" +#include + + +// Local functions +static void PacketHandler_constructDataPacket(DataPacket_Obj* dataPacket, uint16_t payloadLength); +static void PacketHandler_constructErrorPacket(ErrorReportPacket_Obj* errorReportPacket, uint8_t error); +static void PacketHandler_convertStatusToCc1200FormatIeee154Api(uint8_t* status); +static void PacketHandler_convertStatusToCc1200FormatPropApi(uint8_t* status); + + + +extern uint16_t PacketHandler_processPacket(DataPacket_Obj* dataPacket, uint16_t payloadLength) +{ + PacketHandler_constructDataPacket(dataPacket, payloadLength); + + return payloadLength; +} + + +//! \brief Construct data packet +//! +//! The caller of this function is responsible for allocating the memory +//! large enough for a data packet, and for writing the payload of the data +//! packet before this function is called. This function will populate the +//! the rest of the datapacket. +//! +//! \param[in] dataPacket +//! Pointer to buffer for the data packet +//! +//! \param[in] payloadLength +//! Length of the payload field of the data packet +//! +//! \return None +void PacketHandler_constructDataPacket(DataPacket_Obj* dataPacket, uint16_t payloadLength) +{ + dataPacket->genPacketHeader.sof = START_OF_FRAME_DELIMITER; + dataPacket->genPacketHeader.packetType = PACKET_TYPE_DATA; + dataPacket->genPacketHeader.packetLen = TIMESTAMP_LENGHT + payloadLength; + + uint8_t* status = (uint8_t*)(dataPacket->payload + payloadLength - 1); + + if(PhyManager_getRfApi() == IEEE_802_15_4) + { + PacketHandler_convertStatusToCc1200FormatIeee154Api(status); + } + else + { + PacketHandler_convertStatusToCc1200FormatPropApi(status); + } + + uint8_t* eof = (uint8_t*)(dataPacket->payload + payloadLength); + Common_set16BitValueLE(eof, END_OF_FRAME_DELIMITER); +} + + +extern void PacketHandler_processError(uint8_t* errorPacket, uint8_t error) +{ + PacketHandler_constructErrorPacket((ErrorReportPacket_Obj*)errorPacket, error); +} + + +//! \brief Construct error packet +//! +//! The caller of this function is responsible for allocating the memory +//! large enough for an error packet. This function will populate the +//! the error packet. +//! +//! \param[in] errorReportPacket +//! Pointer to buffer for the error packet. +//! +//! \param[in] error +//! Error code to set in the error packet. +//! +//! \return None +void PacketHandler_constructErrorPacket(ErrorReportPacket_Obj* errorReportPacket, uint8_t error) +{ + errorReportPacket->genPacketHeader.sof = START_OF_FRAME_DELIMITER; + errorReportPacket->genPacketHeader.packetType = PACKET_TYPE_ERROR; + errorReportPacket->genPacketHeader.packetLen = ERROR_REPORT_PAYLOAD_LENGTH; + *errorReportPacket->error = error; + errorReportPacket->genPacketFooter.eof = END_OF_FRAME_DELIMITER; +} + + +//! \brief Convert the status byte to CC1200 format (CC26xx IEEE 15.4 API version +//! of this function). +//! +//! \param[in] status +//! Pointer to the status byte added by RF Core +//! +//! \return None +void PacketHandler_convertStatusToCc1200FormatIeee154Api(uint8_t* status) +{ + // Get value of the result bit field of the status byte (bit 7) + uint8_t result = (*status & 0x80) >> 7; + + // Initialize status byte in CC1200 format. + // Set CRC_OK false and LQI to invalid value (0) + *status = 0; + + // The following values shall give CRC_OK true in new format: + // - Result = 0 -> 'Packet received withour CRC error' + // Other values keeps CRC_OK false. + if(result == 0) + { + // Set CRC_OK -> 1 + *status |= 0x80; + } +} + + +//! \brief Convert the status byte to CC1200 format (CC13xx PROP API version +//! of this function). +//! +//! \param[in] status +//! Pointer to the status byte added by RF Core +//! +//! \return None +void PacketHandler_convertStatusToCc1200FormatPropApi(uint8_t* status) +{ + // Get value of the result bit field of the status byte (bits 6-7) + uint8_t result = (*status & 0xC0) >> 6; + + // Initialize status byte in CC1200 format. + // Set CRC_OK false and LQI to invalid value (0) + *status = 0; + + // The following values shall give CRC_OK true in new format: + // - Result = 0 -> 'Packet Received correctly, not ingored' + // - Result = 2 -> 'Packet received correct, but can be ignored' + // Other values keeps CRC_OK false. + if((result == 0) || (result == 0x2)) + { + // Set CRC_OK -> 1 + *status |= 0x80; + } +} + + + + diff --git a/source/packet_handler.h b/source/packet_handler.h new file mode 100644 index 0000000..905441d --- /dev/null +++ b/source/packet_handler.h @@ -0,0 +1,78 @@ +/****************************************************************************** +* Filename: packet_handler.h +* +* Description: Header file for packet handler. This module handles data and +* and error packet, and forwarding of these packets to host. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef PACKET_HANDLER_H +#define PACKET_HANDLER_H + +#include +#include "data_packet.h" + + +//! \brief Process data received over the air. +//! +//! The caller of this function is responsible for allocating the memory +//! large enough for a data packet, and for writing the payload of the data +//! packet before this function is called. This function will populate the +//! the rest of the datapacket, and forward it to the host. +//! +//! \param[in] dataPacket +//! Pointer to buffer large enough for a complete data packet. +//! +//! \param[in] payloadLength +//! Length of the payload data. +//! +//! \return Length of the processed packet +extern uint16_t PacketHandler_processPacket(DataPacket_Obj* dataPacket, uint16_t payloadLength); + + +//! \brief Process error condition +//! +//! This function constructs an error packet. The caller of this function is +//! responsible for allocating memory large enough for an error packet. +//! +//! \param[in] errorPacket +//! Pointer to buffer large enough for a complete error packet. +//! +//! \param[in] error +//! Error code. +//! +//! \return None +extern void PacketHandler_processError(uint8_t* errorPacket, uint8_t error); + +#endif + diff --git a/source/packet_queue.c b/source/packet_queue.c new file mode 100644 index 0000000..123de92 --- /dev/null +++ b/source/packet_queue.c @@ -0,0 +1,154 @@ +/****************************************************************************** +* Filename: packet_queue.c +* +* Description: Source file for the packet queue module. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include "packet_queue.h" +#include "data_packet.h" + +#include +#include +#include + + +#define NUM_BUFFER_SLOTS 3 + +typedef struct Message_Obj +{ + DataPacket_Obj* p; // Pointer to a data packet buffer slot + uint16_t length; // Data packet length +} Message_Obj; + + +static DataPacket_Obj PacketQueue_dataPacket[NUM_BUFFER_SLOTS]; + +// Queue of pointers to free buffer slots +static Mailbox_Handle freeQueue; + +// Queue of pointers to full (occupied) buffer slots +static Mailbox_Handle fullQueue; + +static bool PacketQueue_isInitialized = false; + + +void PacketQueue_init(void) +{ + if(!PacketQueue_isInitialized) + { + // Create mailbox objects with default error handling and parameters + freeQueue = Mailbox_create(sizeof(Message_Obj), NUM_BUFFER_SLOTS, NULL, NULL); + fullQueue = Mailbox_create(sizeof(Message_Obj), NUM_BUFFER_SLOTS, NULL, NULL); + + for(int i=0; i +#include +#include +#include +#include +#include +#include "Board.h" + +#include "host_if_task.h" +#include "data_task.h" +#include "user_if_task.h" +#include "control_task.h" + +/***** Defines *****/ +#define HOST_IF_TASK_PRIORITY 1 +#define DATA_TASK_PRIORITY 2 +#define USER_IF_TASK_PRIORITY 3 +#define CONTROL_TASK_PRIORITY 4 + + +static Task_Params hostIfTaskParams; +static Task_Params dataTaskParams; +static Task_Params userIfTaskParams; +static Task_Params controlTaskParams; + + +void task_init(void) +{ + Task_Params_init(&hostIfTaskParams); + hostIfTaskParams.priority = HOST_IF_TASK_PRIORITY; + Task_create(hostIfTask, &hostIfTaskParams, NULL); + + Task_Params_init(&dataTaskParams); + dataTaskParams.priority = DATA_TASK_PRIORITY; + Task_create(dataTask, &dataTaskParams, NULL); + + Task_Params_init(&userIfTaskParams); + userIfTaskParams.priority = USER_IF_TASK_PRIORITY; + Task_create(userIfTask, &userIfTaskParams, NULL); + + Task_Params_init(&controlTaskParams); + controlTaskParams.priority = CONTROL_TASK_PRIORITY; + Task_create(controlTask, &controlTaskParams, NULL); +} + + +//! \brief main function +int main(void) +{ + // Call board init functions. + Board_initGeneral(); + +#ifndef STATIC_TASK + // Initialize tasks + task_init(); +#endif + + // Start BIOS + BIOS_start(); + + return (0); +} + + + diff --git a/source/phy/devices/cc26x0lp/phy_io_config.c b/source/phy/devices/cc26x0lp/phy_io_config.c new file mode 100644 index 0000000..2de7074 --- /dev/null +++ b/source/phy/devices/cc26x0lp/phy_io_config.c @@ -0,0 +1,51 @@ +/****************************************************************************** +* Filename: phy_tables.c +* +* Description: Source file for PHY IO configuration +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include "../../phy_io_config.h" + + +void Phy_IoPinInit(void) +{ + // No phy specific IO pin configuration required for this board +} + + +void Phy_configureIoPins(const Phy_RfApi rfApi) +{ + // No phy specific IO pin configuration required for this board +} diff --git a/source/phy/devices/cc26x0lp/phy_tables.c b/source/phy/devices/cc26x0lp/phy_tables.c new file mode 100644 index 0000000..155beb5 --- /dev/null +++ b/source/phy/devices/cc26x0lp/phy_tables.c @@ -0,0 +1,97 @@ +/****************************************************************************** +* Filename: phy_tables.c +* +* Description: Source file PHY tables +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include "../../phy_tables.h" +#include <15.4/smartrf_settings_15_4_0.h> + +// Table of RF Proprietary PHY settings (These settings use Proprietary RF core commands) +const Phy_Prop_Obj Phy_phyTableProp[] = +{ + // No RF Proprietary settings for this device + {NULL, NULL, NULL, NULL, NULL} +}; + + +// Table of IEEE 15.4g PHY settings (These settings use Proprietary RF core commands in IEEE 802.15.4g mode) +const Phy_Prop_15_4_g_Obj Phy_phyTableProp_15_4_g[] = +{ + // No IEEE 802.15.4g settings for this device + {NULL, NULL, NULL, NULL, NULL} +}; + + +// Table of IEEE 15.4 PHY settings (These settings use IEEE 802.15.4 RF core commands) +const Phy_Ieee_15_4_Obj Phy_phyTableIeee_15_4[] = +{ + // IEEE 802.15.4 at 2.4GHz + {&Ieee154_0_cmdRadioSetup, &Ieee154_0_cmdFs, &Ieee154_0_cmdIeeeRx, &Ieee154_0_cmdIeeeTx, &Ieee154_0_mode}, + {NULL, NULL, NULL, NULL, NULL} +}; + + +// Table of all supported Rf API and PHY setting combinations +// Note: This table must match the PHY tables for each RF API +const Phy_Obj Phy_supportedPhys[] = +{ + {IEEE_802_15_4, 0}, +}; + + + +uint8_t Phy_getNumSupportedPhys(void) +{ + return sizeof(Phy_supportedPhys)/sizeof(Phy_supportedPhys[0]); +} + + +uint8_t Phy_getNumPropPhys(void) +{ + return (sizeof(Phy_phyTableProp)/sizeof(Phy_phyTableProp[0])) - 1; +} + + +uint8_t Phy_getNumProp_15_4_g_Phys(void) +{ + return (sizeof(Phy_phyTableProp_15_4_g)/sizeof(Phy_phyTableProp_15_4_g[0])) - 1; +} + + +uint8_t Phy_getNumIeee_15_4_Phys(void) +{ + return (sizeof(Phy_phyTableIeee_15_4)/sizeof(Phy_phyTableIeee_15_4[0])) - 1; +} diff --git a/source/phy/phy_if_ieee_15_4.c b/source/phy/phy_if_ieee_15_4.c new file mode 100644 index 0000000..8fbf890 --- /dev/null +++ b/source/phy/phy_if_ieee_15_4.c @@ -0,0 +1,96 @@ +/****************************************************************************** +* Filename: phy_if_ieee_15_4.c +* +* Description: Source file for PHY interface IEEE 802.15.4 +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include "phy_if_ieee_15_4.h" +#include "phy_tables.h" +#include "../radio_if_dataqueue.h" + + +void PhyIf_setFrequencyIeee_15_4(uint8_t phyIndex, uint16_t frequency, uint16_t fractFrequency) +{ + rfc_CMD_FS_t* pFsCmd = Phy_phyTableIeee_15_4[phyIndex].pFsCmd; + + pFsCmd->frequency = frequency; + pFsCmd->fractFreq = fractFrequency; +} + + +void PhyIf_configureSetupCmdIeee_15_4(uint8_t phyIndex) +{ + // No configuration required for the setup command in IEEE 802.15.4 mode +} + + +void PhyIf_configureRxCmdIeee_15_4(uint8_t phyIndex) +{ +// IEEE 15.4 mode is not supported for CC13X0 and rfc_CMD_IEEE_RX_t is not +// defined for this device +#ifndef DeviceFamily_CC13X0 + rfc_CMD_IEEE_RX_t* pIeeeRxCmd = Phy_phyTableIeee_15_4[phyIndex].pRxCmd; + + // Modify CMD_IEEE_RX command + pIeeeRxCmd->pRxQ = RadioIF_dataQueueGet(); + pIeeeRxCmd->rxConfig.bAutoFlushCrc = 0; + pIeeeRxCmd->rxConfig.bAutoFlushIgn = 0; + pIeeeRxCmd->rxConfig.bIncludePhyHdr = 1; + pIeeeRxCmd->rxConfig.bIncludeCrc = 1; + pIeeeRxCmd->rxConfig.bAppendRssi = 1; + pIeeeRxCmd->rxConfig.bAppendCorrCrc = 1; + pIeeeRxCmd->rxConfig.bAppendSrcInd = 0; + pIeeeRxCmd->rxConfig.bAppendTimestamp = 1; +#endif +} + + +void PhyIf_configureTxCmdIeee_15_4(uint8_t* packet, uint16_t packetLength, uint8_t phyIndex) +{ +// IEEE 15.4 mode is not supported for CC13X0 and rfc_CMD_IEEE_TX_t is not +// defined for this device +#ifndef DeviceFamily_CC13X0 + rfc_CMD_IEEE_TX_t* pIeeeTxCmd = Phy_phyTableIeee_15_4[phyIndex].pTxCmd; + + pIeeeTxCmd->payloadLen = packetLength; + pIeeeTxCmd->pPayload = packet; + pIeeeTxCmd->startTrigger.triggerType = TRIG_NOW; +#endif +} + + + + + diff --git a/source/phy/phy_if_ieee_15_4.h b/source/phy/phy_if_ieee_15_4.h new file mode 100644 index 0000000..18fd7ba --- /dev/null +++ b/source/phy/phy_if_ieee_15_4.h @@ -0,0 +1,91 @@ +/****************************************************************************** +* Filename: phy_if_ieee_15_4.h +* +* Description: Header file for PHY interface IEEE 802.15.4 mode +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef PHY_IF_IEEE_15_4_H +#define PHY_IF_IEEE_15_4_H + +#include + +//! \brief Configure RF Core Setup command for the IEEE 802.15.4 PHYs +//! +//! \param[in] phyIndex +//! Index of the PHY setting in the table of IEEE 802.15.4 PHY settings +//! +//! \return None +void PhyIf_configureSetupCmdIeee_15_4(uint8_t phyIndex); + + +//! \brief Configure RF Core RX command for the IEEE 802.15.4 PHYs +//! +//! \param[in] phyIndex +//! Index of the PHY setting in the table of IEEE 802.15.4 PHY settings +//! +//! \return None +void PhyIf_configureRxCmdIeee_15_4(uint8_t phyIndex); + + +//! \brief Configure RF Core TX command for the IEEE 802.15.4 PHYs +//! +//! \param[in] packet +//! Pointer to packet +//! +//! \param[in] packetLength +//! Length of the packet +//! +//! \param[in] phyIndex +//! Index of the PHY setting in the table of IEEE 802.15.4 PHY settings +//! +//! \return None +void PhyIf_configureTxCmdIeee_15_4(uint8_t* packet, uint16_t packetLength, uint8_t phyIndex); + + +//! \brief Set frequency value +//! +//! \param[in] phyIndex +//! Index of the PHY setting in the table of IEEE 802.15.4 PHY settings +//! +//! \param[in] frequency +//! Frequency in MHz +//! +//! \param[in] fractFrequency +//! Fractional frequency in 1 MHz/65536 fractions. +//! +//! \return None +void PhyIf_setFrequencyIeee_15_4(uint8_t phyIndex, uint16_t frequency, uint16_t fractFrequency); + +#endif + diff --git a/source/phy/phy_if_prop.c b/source/phy/phy_if_prop.c new file mode 100644 index 0000000..62214f6 --- /dev/null +++ b/source/phy/phy_if_prop.c @@ -0,0 +1,103 @@ +/****************************************************************************** +* Filename: phy_if_prop.c +* +* Description: Source file for PHY interface proprietary +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include "phy_if_prop.h" +#include "phy_tables.h" +#include "../radio_if_dataqueue.h" + + +void PhyIf_setFrequencyProp(uint8_t phyIndex, uint16_t frequency, uint16_t fractFrequency) +{ +// Proprietary mode is not supported for CC26X0 and CMD_PROP_RADIO_DIV_SETUP is not +// defined for this device +#ifndef DeviceFamily_CC26X0 + rfc_CMD_PROP_RADIO_DIV_SETUP_t* pSetupCmd = Phy_phyTableProp[phyIndex].pSetupCmd; + rfc_CMD_FS_t* pFsCmd = Phy_phyTableProp[phyIndex].pFsCmd; + + pSetupCmd->centerFreq = frequency; + + pFsCmd->frequency = frequency; + pFsCmd->fractFreq = fractFrequency; +#endif +} + + +void PhyIf_configureSetupCmdProp(uint8_t phyIndex) +{ + // No configuration done for Setup command +} + + +void PhyIf_configureRxCmdProp(uint8_t phyIndex) +{ + rfc_CMD_PROP_RX_t* pPropRxCmd = Phy_phyTableProp[phyIndex].pRxCmd; + + // Modify CMD_PROP_RX command + pPropRxCmd->pQueue = RadioIF_dataQueueGet(); + pPropRxCmd->rxConf.bAutoFlushIgnored = 1; + pPropRxCmd->rxConf.bAutoFlushCrcErr = 0; + pPropRxCmd->maxPktLen = 0x80; + pPropRxCmd->pktConf.bRepeatOk = 1; + pPropRxCmd->pktConf.bRepeatNok = 1; + + // Append 1 status byte, 1 RSSI byte and 4 bytes timestamp + pPropRxCmd->rxConf.bAppendStatus = 1; + pPropRxCmd->rxConf.bAppendRssi = 1; + pPropRxCmd->rxConf.bAppendTimestamp = 1; + + // Append CRC bytes + pPropRxCmd->rxConf.bIncludeCrc = 0x1; +} + + +void PhyIf_configureTxCmdProp(uint8_t* packet, uint16_t packetLength, uint8_t phyIndex) +{ + rfc_CMD_PROP_TX_t* pPropTxCmd = Phy_phyTableProp[phyIndex].pTxCmd; + + pPropTxCmd->pktLen = packetLength; + pPropTxCmd->pPkt = packet; + pPropTxCmd->startTrigger.triggerType = TRIG_NOW; +} + + + + + + + + diff --git a/source/phy/phy_if_prop.h b/source/phy/phy_if_prop.h new file mode 100644 index 0000000..3ee56dd --- /dev/null +++ b/source/phy/phy_if_prop.h @@ -0,0 +1,91 @@ +/****************************************************************************** +* Filename: phy_if_prop.h +* +* Description: Header file for PHY interface proprietary +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef PHY_IF_PROP_H +#define PHY_IF_PROP_H + +#include + +//! \brief Configure RF Core Setup command for the proprietary PHYs +//! +//! \param[in] phyIndex +//! Index of the PHY setting in the table of proprietary PHY settings +//! +//! \return None +void PhyIf_configureSetupCmdProp(uint8_t phyIndex); + + +//! \brief Configure RF Core RX command for the proprietary PHYs +//! +//! \param[in] phyIndex +//! Index of the PHY setting in the table of proprietary PHY settings +//! +//! \return None +void PhyIf_configureRxCmdProp(uint8_t phyIndex); + + +//! \brief Configure RF Core TX command for the proprietary PHYs +//! +//! \param[in] packet +//! Pointer to packet +//! +//! \param[in] packetLength +//! Length of the packet +//! +//! \param[in] phyIndex +//! Index of the PHY setting in the table of proprietary PHY settings +//! +//! \return None +void PhyIf_configureTxCmdProp(uint8_t* packet, uint16_t packetLength, uint8_t phyIndex); + + +//! \brief Set frequency value +//! +//! \param[in] phyIndex +//! Index of the PHY setting in the table of proprietary PHY settings +//! +//! \param[in] frequency +//! Frequency in MHz +//! +//! \param[in] fractFrequency +//! Fractional frequency in 1 MHz/65536 fractions. +//! +//! \return None +void PhyIf_setFrequencyProp(uint8_t phyIndex, uint16_t frequency, uint16_t fractFrequency); + +#endif + diff --git a/source/phy/phy_if_prop_15_4g.c b/source/phy/phy_if_prop_15_4g.c new file mode 100644 index 0000000..5ec894b --- /dev/null +++ b/source/phy/phy_if_prop_15_4g.c @@ -0,0 +1,106 @@ +/****************************************************************************** +* Filename: phy_if_prop_15_4g.c +* +* Description: Source file for PHY interface proprietary +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include "phy_if_prop_15_4g.h" +#include "phy_tables.h" +#include "../radio_if_dataqueue.h" + + +void PhyIf_setFrequencyProp_15_4g(uint8_t phyIndex, uint16_t frequency, uint16_t fractFrequency) +{ +// Proprietary 15.4g mode is not supported for CC26X0 and CMD_PROP_RADIO_DIV_SETUP is not +// defined for this device +#ifndef DeviceFamily_CC26X0 + rfc_CMD_PROP_RADIO_DIV_SETUP_t* pSetupCmd = Phy_phyTableProp_15_4_g[phyIndex].pSetupCmd; + rfc_CMD_FS_t* pFsCmd = Phy_phyTableProp_15_4_g[phyIndex].pFsCmd; + + + pSetupCmd->centerFreq = frequency; + + pFsCmd->frequency = frequency; + pFsCmd->fractFreq = fractFrequency; +#endif +} + + +void PhyIf_configureSetupCmdProp_15_4g(uint8_t phyIndex) +{ + // No configuration required for the setup command in IEEE 802.15.4g mode +} + + +void PhyIf_configureRxCmdProp_15_4g(uint8_t phyIndex) +{ + rfc_CMD_PROP_RX_ADV_t* pPropRxAdvCmd = Phy_phyTableProp_15_4_g[phyIndex].pRxCmd; + + // Modify CMD_PROP_RX_ADV command + pPropRxAdvCmd->pQueue = RadioIF_dataQueueGet(); + pPropRxAdvCmd->rxConf.bAutoFlushIgnored = 1; + pPropRxAdvCmd->rxConf.bAutoFlushCrcErr = 0; + pPropRxAdvCmd->maxPktLen = 2047; + pPropRxAdvCmd->pktConf.bRepeatOk = 1; + pPropRxAdvCmd->pktConf.bRepeatNok = 1; + + pPropRxAdvCmd->rxConf.bIncludeHdr = 0x1; + pPropRxAdvCmd->rxConf.bAppendRssi = 0x1; + pPropRxAdvCmd->rxConf.bAppendTimestamp = 0x1; + pPropRxAdvCmd->rxConf.bAppendStatus = 0x1; + + // Append CRC bytes + pPropRxAdvCmd->rxConf.bIncludeCrc = 0x1; +} + + +void PhyIf_configureTxCmdProp_15_4g(uint8_t* packet, uint16_t packetLength, uint8_t phyIndex) +{ + rfc_CMD_PROP_TX_ADV_t* pPropTxAdvCmd = Phy_phyTableProp_15_4_g[phyIndex].pTxCmd; + + // TRIG_ABSTIME with current time is used instaed of TRIG_NOW because of a + // bug in RF Core with the combination of 15.4g and TRIG_NOW (?) + + pPropTxAdvCmd->pktLen = packetLength; + pPropTxAdvCmd->pPkt = packet; + pPropTxAdvCmd->startTrigger.triggerType = TRIG_ABSTIME; + pPropTxAdvCmd->startTrigger.pastTrig = 1; + pPropTxAdvCmd->startTime = RF_getCurrentTime(); +} + + + + + diff --git a/source/phy/phy_if_prop_15_4g.h b/source/phy/phy_if_prop_15_4g.h new file mode 100644 index 0000000..b0012ef --- /dev/null +++ b/source/phy/phy_if_prop_15_4g.h @@ -0,0 +1,91 @@ +/****************************************************************************** +* Filename: phy_if_prop_15_4g.h +* +* Description: Header file for PHY interface proprietary IEEE 802.15.4g mode +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef PHY_IF_PROP_15_4_G_H +#define PHY_IF_PROP_15_4_G_H + +#include + +//! \brief Configure RF Core Setup command for the proprietary IEEE 802.15.4g PHYs +//! +//! \param[in] phyIndex +//! Index of the PHY setting in the table of proprietary PHY settings +//! +//! \return None +void PhyIf_configureSetupCmdProp_15_4g(uint8_t phyIndex); + + +//! \brief Configure RF Core RX command for the proprietary IEEE 802.15.4g PHYs +//! +//! \param[in] phyIndex +//! Index of the PHY setting in the table of proprietary IEEE 802.15.4g PHY settings +//! +//! \return None +void PhyIf_configureRxCmdProp_15_4g(uint8_t phyIndex); + + +//! \brief Configure RF Core TX command for the proprietary IEEE 802.15.4g PHYs +//! +//! \param[in] packet +//! Pointer to packet +//! +//! \param[in] packetLength +//! Length of the packet +//! +//! \param[in] phyIndex +//! Index of the PHY setting in the table of proprietary IEEE 802.15.4g PHY settings +//! +//! \return None +void PhyIf_configureTxCmdProp_15_4g(uint8_t* packet, uint16_t packetLength, uint8_t phyIndex); + + +//! \brief Set frequency value +//! +//! \param[in] phyIndex +//! Index of the PHY setting in the table of proprietary IEEE 802.15.4g PHY settings +//! +//! \param[in] frequency +//! Frequency in MHz +//! +//! \param[in] fractFrequency +//! Fractional frequency in 1 MHz/65536 fractions. +//! +//! \return None +void PhyIf_setFrequencyProp_15_4g(uint8_t phyIndex, uint16_t frequency, uint16_t fractFrequency); + +#endif + diff --git a/source/phy/phy_io_config.h b/source/phy/phy_io_config.h new file mode 100644 index 0000000..6260c54 --- /dev/null +++ b/source/phy/phy_io_config.h @@ -0,0 +1,56 @@ +/****************************************************************************** +* Filename: phy_io_config.h +* +* Description: Header file for PHY IO configuration +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef PHY_IO_CONFIG_H +#define PHY_IO_CONFIG_H + + +#include "phy_rf_api.h" + + +//! \brief Initialize IO pins dependent on RF API +//! +//! \return +extern void Phy_IoPinInit(void); + +//! \brief Configure IO pins for the current RF API +//! +//! \return +extern void Phy_configureIoPins(const Phy_RfApi rfApi); + +#endif + diff --git a/source/phy/phy_manager.c b/source/phy/phy_manager.c new file mode 100644 index 0000000..d5749d8 --- /dev/null +++ b/source/phy/phy_manager.c @@ -0,0 +1,277 @@ +/****************************************************************************** +* Filename: phy_manager.c +* +* Description: Source file PHY manager functionality. +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include "phy_manager.h" +#include "phy_tables.h" +#include "phy_io_config.h" +#include "phy_if_prop.h" +#include "phy_if_prop_15_4g.h" +#include "phy_if_ieee_15_4.h" + +// Local functions +static bool PhyManager_isPhyNumberValid(uint8_t phyNumber); +static void PhyManager_configureCommands(void); + +// The currently used RF API (Proprietary, Proprietary in IEEE 802.15.4g mode, or IEEE 802.15.4) +// The default RF API is PROPRIETARY +static Phy_RfApi PhyManager_currentRfApi = PROPRIETARY; + +// The currently used PHY index (the index of the current setting in the table of settings for the currently used RF API) +// The default selected PHY index is 0 (that is the first PHY setting in the PHY table) +static uint8_t PhyManager_currentPhyIndex = 0; + +// Function pointer definitions for PHY interface functions +typedef void (*setFreqFunc)(uint8_t tableIndex, uint16_t frequency, uint16_t fractFrequency); +typedef void (*cfgSetupCmdFunc)(uint8_t phyIndex); +typedef void (*cfgRxCmdFunc)(uint8_t phyIndex); +typedef void (*cfgTxCmdFunc)(uint8_t* packet, uint16_t packetLength, uint8_t phyIndex); + +// A struct object with PHY interface function pointers +typedef struct Phy_Api_Obj +{ + setFreqFunc setFrequency; + cfgSetupCmdFunc configureSetupCmd; + cfgRxCmdFunc configureRxCmd; + cfgTxCmdFunc configureTxCmd; +} Phy_Api_Obj; + + +// Table of PHY interface functions. There is one array element for each PHY type, where each element contains function pointer to PHY interface functions +// +// Note!: The order of these elements must be in exactly the same order as the enums in the RfApi enum type, since +// the value of the RfApi is used as index in the array. +Phy_Api_Obj phyApis[] = +{ + {PhyIf_setFrequencyProp, PhyIf_configureSetupCmdProp, PhyIf_configureRxCmdProp, PhyIf_configureTxCmdProp}, // PHY interface functions for RF Proprietary PHYs + {PhyIf_setFrequencyProp_15_4g, PhyIf_configureSetupCmdProp_15_4g, PhyIf_configureRxCmdProp_15_4g, PhyIf_configureTxCmdProp_15_4g}, // PHY interface functions for PHYs using RF Proprietary in IEEE 802.15.4g mode + {PhyIf_setFrequencyIeee_15_4, PhyIf_configureSetupCmdIeee_15_4, PhyIf_configureRxCmdIeee_15_4, PhyIf_configureTxCmdIeee_15_4} // PHY interface functions for PHYs using IEEE 802.15.4 mode +}; + + +void PhyManager_init(void) +{ + Phy_IoPinInit(); +} + + +bool PhyManager_setPhy(uint8_t phyNumber) +{ + // Check that PHY number is valid + if(!PhyManager_isPhyNumberValid(phyNumber)) + { + return false; + } + + // Set currently used RfApi and Phy index + PhyManager_currentRfApi = Phy_supportedPhys[phyNumber].rfApi; + PhyManager_currentPhyIndex = Phy_supportedPhys[phyNumber].phyIndex; + + // Configure RF commands for currently selected PHY setting + PhyManager_configureCommands(); + + // Configure IO pins for currently selected RF API + Phy_configureIoPins(PhyManager_currentRfApi); + + return true; +} + + +void PhyManager_setFrequency(uint16_t frequency, uint16_t fractFrequency) +{ + phyApis[PhyManager_currentRfApi].setFrequency(PhyManager_currentPhyIndex, frequency, fractFrequency); +} + + +RF_RadioSetup* PhyManager_getSetupCmd(void) +{ + if(PhyManager_currentRfApi == PROPRIETARY) + { + return (RF_RadioSetup*)Phy_phyTableProp[PhyManager_currentPhyIndex].pSetupCmd; + } + else if(PhyManager_currentRfApi == PROPRIETARY_15_4_G) + { + return (RF_RadioSetup*)Phy_phyTableProp_15_4_g[PhyManager_currentPhyIndex].pSetupCmd; + } + else if(PhyManager_currentRfApi == IEEE_802_15_4) + { + return (RF_RadioSetup*)Phy_phyTableIeee_15_4[PhyManager_currentPhyIndex].pSetupCmd; + } + + return NULL; +} + + +RF_Op* PhyManager_getFsCmd(void) +{ + if(PhyManager_currentRfApi == PROPRIETARY) + { + return (RF_Op*)Phy_phyTableProp[PhyManager_currentPhyIndex].pFsCmd; + } + else if(PhyManager_currentRfApi == PROPRIETARY_15_4_G) + { + return (RF_Op*)Phy_phyTableProp_15_4_g[PhyManager_currentPhyIndex].pFsCmd; + } + else if(PhyManager_currentRfApi == IEEE_802_15_4) + { + return (RF_Op*)Phy_phyTableIeee_15_4[PhyManager_currentPhyIndex].pFsCmd; + } + + return NULL; +} + + +RF_Op* PhyManager_getRxCmd(void) +{ + if(PhyManager_currentRfApi == PROPRIETARY) + { + return (RF_Op*)Phy_phyTableProp[PhyManager_currentPhyIndex].pRxCmd; + } + else if(PhyManager_currentRfApi == PROPRIETARY_15_4_G) + { + return (RF_Op*)Phy_phyTableProp_15_4_g[PhyManager_currentPhyIndex].pRxCmd; + } + else if(PhyManager_currentRfApi == IEEE_802_15_4) + { + return (RF_Op*)Phy_phyTableIeee_15_4[PhyManager_currentPhyIndex].pRxCmd; + } + + return NULL; +} + + +RF_Op* PhyManager_getTxCmd(void) +{ + if(PhyManager_currentRfApi == PROPRIETARY) + { + return (RF_Op*)Phy_phyTableProp[PhyManager_currentPhyIndex].pTxCmd; + } + else if(PhyManager_currentRfApi == PROPRIETARY_15_4_G) + { + return (RF_Op*)Phy_phyTableProp_15_4_g[PhyManager_currentPhyIndex].pTxCmd; + } + else if(PhyManager_currentRfApi == IEEE_802_15_4) + { + return (RF_Op*)Phy_phyTableIeee_15_4[PhyManager_currentPhyIndex].pTxCmd; + } + + return NULL; +} + + +RF_Mode* PhyManager_getRfMode(void) +{ + if(PhyManager_currentRfApi == PROPRIETARY) + { + return (RF_Mode*)Phy_phyTableProp[PhyManager_currentPhyIndex].pRfMode; + } + else if(PhyManager_currentRfApi == PROPRIETARY_15_4_G) + { + return (RF_Mode*)Phy_phyTableProp_15_4_g[PhyManager_currentPhyIndex].pRfMode; + } + else if(PhyManager_currentRfApi == IEEE_802_15_4) + { + return (RF_Mode*)Phy_phyTableIeee_15_4[PhyManager_currentPhyIndex].pRfMode; + } + + return NULL; +} + + +void PhyManager_configureTxCommand(uint8_t* packet, uint16_t packetLength) +{ + phyApis[PhyManager_currentRfApi].configureTxCmd(packet, packetLength, PhyManager_currentPhyIndex); +} + + +extern Phy_RfApi PhyManager_getRfApi(void) +{ + return PhyManager_currentRfApi; +} + + +//! \brief Configure RF Core commands +//! Note: The configuration of RF command used for TX is handled in a +//! separate function, and not in this. +//! +//! \return None +void PhyManager_configureCommands(void) +{ + phyApis[PhyManager_currentRfApi].configureSetupCmd(PhyManager_currentPhyIndex); + phyApis[PhyManager_currentRfApi].configureRxCmd(PhyManager_currentPhyIndex); +} + + +//! \brief Check if PHY number is valid +//! +//! \param[in] phyNumber +//! PHY number +//! +//! \return true if PHY number is valid, and false otherwise +bool PhyManager_isPhyNumberValid(uint8_t phyNumber) +{ + if(phyNumber > (Phy_getNumSupportedPhys() - 1)) + { + return false; + } + + Phy_RfApi rfApi = Phy_supportedPhys[phyNumber].rfApi; + uint8_t phyIndex = Phy_supportedPhys[phyNumber].phyIndex; + + bool status = false; + if(rfApi == PROPRIETARY) + { + status = phyIndex > (Phy_getNumPropPhys() - 1) ? false : true; + } + else if(rfApi == PROPRIETARY_15_4_G) + { + status = phyIndex > (Phy_getNumProp_15_4_g_Phys() - 1) ? false : true; + } + else if(rfApi == IEEE_802_15_4) + { + status = phyIndex > (Phy_getNumIeee_15_4_Phys() - 1) ? false : true; + } + + return status; +} + + + + + + + diff --git a/source/phy/phy_manager.h b/source/phy/phy_manager.h new file mode 100644 index 0000000..9f28e5e --- /dev/null +++ b/source/phy/phy_manager.h @@ -0,0 +1,125 @@ +/****************************************************************************** +* Filename: phy_manager.h +* +* Description: Header file for PHY manager functionality +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef PHY_MANAGER_H +#define PHY_MANAGER_H + +#include +// TI-RTOS radio driver +#include + +#include "phy_rf_api.h" + + +//! \brief Initialize PHY manager +//! +void PhyManager_init(void); + + +//! \brief Set PHY (RF API and PHY setting) +//! +//! \param[in] phyNumber +//! The number of the PHY to use. This number decodes into an RF API and a PHY setting +//! +//! \return true if phyNumber is valid, or false otherwise +extern bool PhyManager_setPhy(uint8_t phyNumber); + + + +//! \brief Set frequency value for currently used PHY +//! +//! \param[in] frequency +//! Frequency in MHz +//! +//! \param[in] fractFrequency +//! Fractional frequency in 1 MHz/65536 fractions. +//! +//! \return None +extern void PhyManager_setFrequency(uint16_t frequency, uint16_t fractFrequency); + + +//! \brief Configure RF command used for TX +//! +//! \param[in] packet +//! Pointer to packet +//! +//! \param[in] packetLength +//! Length of the packet +//! +//! \return None +extern void PhyManager_configureTxCommand(uint8_t* packet, uint16_t packetLength); + + +//! \brief Get pointer to the currently used RF Core Setup Command (for example: CMD_PROP_RADIO_DIV_SETUP) +//! +//! \return Pointer to RF Core Setup command +extern RF_RadioSetup* PhyManager_getSetupCmd(void); + + +//! \brief Get pointer to the currently used RF Core FS Command (CMD_FS) +//! +//! \return Pointer to RF Core FS command +extern RF_Op* PhyManager_getFsCmd(void); + + +//! \brief Get pointer to the currently used RF Core RX Command (for example: CMD_PROP_RX) +//! +//! \return Pointer to RF Core RX command +extern RF_Op* PhyManager_getRxCmd(void); + + +//! \brief Get pointer to the currently used RF Core TX Command (for example: CMD_PROP_TX) +//! +//! \return Pointer to RF Core TX command +extern RF_Op* PhyManager_getTxCmd(void); + + +//! \brief Get pointer to the currently used RF mode object +//! +//! \return Pointer to RF mode object +extern RF_Mode* PhyManager_getRfMode(void); + + +//! \brief Get currently used RF API type +//! (With RF API it is meant the RF Core API type, for example Proprietary, +//! proprietary in IEEE 802.15.4g mode, or IEEE 802.15.4) +//! +//! \return Pointer to RF mode object +extern Phy_RfApi PhyManager_getRfApi(void); + +#endif + diff --git a/source/phy/phy_rf_api.h b/source/phy/phy_rf_api.h new file mode 100644 index 0000000..a4351ef --- /dev/null +++ b/source/phy/phy_rf_api.h @@ -0,0 +1,53 @@ +/****************************************************************************** +* Filename: phy_rf_api.h +* +* Description: Header file for PHY RF API types +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef PHY_RF_API_H +#define PHY_RF_API_H + + +// RF API types +typedef enum Phy_RfApi +{ + PROPRIETARY=0, + PROPRIETARY_15_4_G=1, + IEEE_802_15_4=2, +} Phy_RfApi; + + + +#endif + diff --git a/source/phy/phy_tables.h b/source/phy/phy_tables.h new file mode 100644 index 0000000..a8d20c1 --- /dev/null +++ b/source/phy/phy_tables.h @@ -0,0 +1,141 @@ +/****************************************************************************** +* Filename: phy_tables.h +* +* Description: Header file for PHY tables +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef PHY_TABLES_H +#define PHY_TABLES_H + +// TI-RTOS radio driver +#include + + + +// There are no rf_ieee_cmd.h for DeviceFamily_CC13X0 +#ifndef DeviceFamily_CC13X0 +// A separate include file is required for IEEE command definitions. +// RF.h does not include the header file for this. +//#include "DeviceFamily.h" +//#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h) +#include "rf_ieee_cmd.h" +#else +// For DeviceFamily_CC13X0 define the IEEE 15.4 RF commands as void +// These are not used for CC13X0, but required to build the project. +#define rfc_CMD_IEEE_RX_t void +#define rfc_CMD_IEEE_TX_t void +#endif + +#include "phy_rf_api.h" + + +// Struct definition for RF Proprietary PHY settings +typedef struct Phy_Prop_Obj +{ + rfc_CMD_PROP_RADIO_DIV_SETUP_t* pSetupCmd; + rfc_CMD_FS_t* pFsCmd; + rfc_CMD_PROP_RX_t* pRxCmd; + rfc_CMD_PROP_TX_t* pTxCmd; + RF_Mode* pRfMode; +} Phy_Prop_Obj; + + +// Struct definition for IEEE 802.15.4g Proprietary PHY settings +typedef struct Phy_Prop_15_4_g_Obj +{ + rfc_CMD_PROP_RADIO_DIV_SETUP_t* pSetupCmd; + rfc_CMD_FS_t* pFsCmd; + rfc_CMD_PROP_RX_ADV_t* pRxCmd; + rfc_CMD_PROP_TX_ADV_t* pTxCmd; + RF_Mode* pRfMode; +} Phy_Prop_15_4_g_Obj; + + +// Struct definition for IEEE 802.15.4 PHY settings +typedef struct Phy_Ieee_15_4_Obj +{ + rfc_CMD_RADIO_SETUP_t* pSetupCmd; + rfc_CMD_FS_t* pFsCmd; + rfc_CMD_IEEE_RX_t* pRxCmd; + rfc_CMD_IEEE_TX_t* pTxCmd; + RF_Mode* pRfMode; +} Phy_Ieee_15_4_Obj; + + +// Struct definition for a PHY (That is combination of RF API and PHY setting) +typedef struct Phy_Obj +{ + Phy_RfApi rfApi; + uint8_t phyIndex; +} Phy_Obj; + + +// Table of proprietary PHY settings +extern const Phy_Prop_Obj Phy_phyTableProp[]; + +// Table of proprietary IEEE 802.15.4g PHY settings +extern const Phy_Prop_15_4_g_Obj Phy_phyTableProp_15_4_g[]; + +// Table of IEEE 802.15.4 PHY settings +extern const Phy_Ieee_15_4_Obj Phy_phyTableIeee_15_4[]; + +// Table of all supported PHYs (Combinations of RF API and setting) +extern const Phy_Obj Phy_supportedPhys[]; + + +//! \brief Get number of supported PHYs (Combinations of RF API and setting) +//! +//! \return Number of supported PHYs +extern uint8_t Phy_getNumSupportedPhys(void); + + +//! \brief Get number of proprietary PHY settings +//! +//! \return Number of proprietary PHY settings +extern uint8_t Phy_getNumPropPhys(void); + + +//! \brief Get number of proprietary IEEE 802.15.4g PHY settings +//! +//! \return Number of proprietary IEEE 802.15.4g PHY settings +extern uint8_t Phy_getNumProp_15_4_g_Phys(void); + + +//! \brief Get number of IEEE 802.15.4 PHY settings +//! +//! \return Number of IEEE 802.15.4 PHY settings +extern uint8_t Phy_getNumIeee_15_4_Phys(void); + +#endif + diff --git a/source/radio_if.c b/source/radio_if.c new file mode 100644 index 0000000..5dafda9 --- /dev/null +++ b/source/radio_if.c @@ -0,0 +1,296 @@ +/****************************************************************************** +* Filename: radio_if.c +* +* Description: Source file for configuration of the radio interface. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#include "radio_if.h" +#include "radio_if_dataqueue.h" +#include "phy_manager.h" + +// TI-RTOS radio driver +#include + +// TI-RTOS +#include + +// Default PHY number (the PHY number selected at startup) +#define DEFAULT_PHY_NUMBER 0 + +uint8_t RadioIF_numBufferOverflow = 0; +RF_Object RadioIF_RF_Obj; +RF_Handle RadioIF_Rf_Handle; +RF_CmdHandle RadioIF_Cmd_Handle; + +static bool RadioIF_isInitialized = false; +static ratOverflowCb RadioIF_ratCbFunc = NULL; + +static rfCoreEventCb RadioIF_rfCoreEventCbFunc = NULL; +// Local functions +//static void RadioIF_ratCallback(RF_Handle h, RF_RatHandle rh, RF_EventMask e, uint32_t timeout); +static void RadioIF_ratCallback(RF_Handle h, RF_CmdHandle X, RF_EventMask e); +static void RadioIF_flushDataQueue(void); +static void RadioIF_enableRadioTimerOverflowCallback(void); +static void RadioIF_startRfCoreRx(void); +static void RadioIF_rfCoreEventCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e); +static void RadioIF_registerRfCoreEventCbApiSpecific(rfCoreEventCb func); + +// Radio Timer Channel available for user code (Cortex M3) +#define RAT_CHANNEL_USER 5 + +void RadioIF_init(void) +{ + if(!RadioIF_isInitialized) + { + RadioIF_dataQueueInit(); + PhyManager_setPhy(DEFAULT_PHY_NUMBER); + RadioIF_isInitialized = true; + } +} + + +void RadioIF_startRx(void) +{ + RadioIF_flushDataQueue(); + RadioIF_startRfCoreRx(); + RadioIF_enableRadioTimerOverflowCallback(); +} + + +void RadioIF_stopRx(void) +{ + // Cancel and flush CMD_PROP_RX + RF_flushCmd(RadioIF_Rf_Handle, RF_CMDHANDLE_FLUSH_ALL, 0); + + // Close RF driver + RF_close(RadioIF_Rf_Handle); + + // Clear RX queue entries and reset queue + RadioIF_flushDataQueue(); +} + + +uint8_t RadioIF_getStatus(void) +{ + uint8_t status = RADIO_IF_STATUS_OK; + + if(RadioIF_numBufferOverflow>0) + { + status = RADIO_IF_STATUS_RX_BUFFER_OVERFLOW; + } + + return status; +} + + +//! \brief Clears all entries in the radio data queue and resets +//! read and write pointers. +//! +//! \return None +void RadioIF_flushDataQueue(void) +{ + rfc_CMD_CLEAR_RX_t cmd; + cmd.commandNo = CMD_CLEAR_RX; + cmd.pQueue = RadioIF_dataQueueGet(); + RF_runImmediateCmd(RadioIF_Rf_Handle, (uint32_t*)&cmd); + RadioIF_resetDataQueue(); +} + + +void RadioIF_handleBufferOverflow(void) +{ + // Make sure this function is not interrupted by HWI or task switch + int key = Hwi_disable(); + RadioIF_flushDataQueue(); + + // Restart the RF Core in RX + RadioIF_startRfCoreRx(); + + // Update status + RadioIF_numBufferOverflow=0; + Hwi_restore(key); +} + + +void RadioIF_setFrequency(uint16_t frequency, uint16_t fractFrequency) +{ + PhyManager_setFrequency(frequency, fractFrequency); +} + + +void RadioIF_initTx(void) +{ + RF_Params rfParams; + RF_Params_init(&rfParams); + + // Open RF driver + RadioIF_Rf_Handle = RF_open(&RadioIF_RF_Obj, PhyManager_getRfMode(), PhyManager_getSetupCmd(), &rfParams); + + // Issue the RF Core FS command + RF_postCmd(RadioIF_Rf_Handle, PhyManager_getFsCmd(), RF_PriorityNormal, NULL, 0); +} + + +void RadioIF_sendPacket(uint8_t* packet, uint16_t packetLength) +{ + PhyManager_configureTxCommand(packet, packetLength); + + // For IEEE 802.15.4 we must subscribe to the RF_EventLastFGCmdDone event, otherwise the function hangs + #define RF_EventLastFGCmdDone (1 << 3) + RF_EventMask result = RF_runCmd(RadioIF_Rf_Handle, PhyManager_getTxCmd(), RF_PriorityNormal, NULL, (RF_EventLastCmdDone | RF_EventLastFGCmdDone)); +} + + +void RadioIF_disableTx(void) +{ + // Cancel and flush CMD_PROP_RX + RF_flushCmd(RadioIF_Rf_Handle, RF_CMDHANDLE_FLUSH_ALL, 0); + + // Close RF driver + RF_close(RadioIF_Rf_Handle); +} + + +//! \brief Callback function called upon RAT events +//! +//! \return None +//void RadioIF_ratCallback(RF_Handle h, RF_RatHandle rh, RF_EventMask e, uint32_t timeout) +void RadioIF_ratCallback(RF_Handle h, RF_CmdHandle X, RF_EventMask e) +{ + if(e & RF_EventRatCh) + { + if(RadioIF_ratCbFunc) + { + uint32_t currentTime = RF_getCurrentTime(); + RadioIF_ratCbFunc(currentTime); + + // Re-enable overflow interrupt + RadioIF_enableRadioTimerOverflowCallback(); + } + } +} + + +void RadioIF_enableRadioTimerOverflowCallback(void) +{ + uint32_t compareTime = 0; + uint32_t currentTime = RF_getCurrentTime(); + + // Set compareTime to next MSB number of RAT timer with the rest of bytes 0x0 + // (0x10000000, 0x20000000, 0x30000000, ....) + compareTime = (currentTime & 0xF0000000) + 0x10000000; + +/* RF_RatConfigCompare ratCompareCfg; + ratCompareCfg.callback = &RadioIF_ratCallback; + ratCompareCfg.channel = RF_RatChannelAny; + ratCompareCfg.timeout = compareTime; + + // Configure RAT compare callback at timer overflow value + RF_RatHandle ratHandle = RF_ratCompare(RadioIF_Rf_Handle, &ratCompareCfg, NULL); +*/ + rfc_CMD_SET_RAT_CMP_t ratCmpCmd; + int8_t ratHandle = RF_ratCompare(RadioIF_Rf_Handle, &ratCmpCmd, compareTime, &RadioIF_ratCallback); + +} + + +void RadioIF_registerRatOverflowCb(ratOverflowCb func) +{ + RadioIF_ratCbFunc = func; +} + + +bool RadioIf_setPhy(uint8_t phyNumber) +{ + return PhyManager_setPhy(phyNumber); +} + + +//! \brief Start RF Core in RX +//! +//! \return None +void RadioIF_startRfCoreRx(void) +{ + RF_Params rfParams; + RF_Params_init(&rfParams); + + // Open RF driver + RadioIF_Rf_Handle = RF_open(&RadioIF_RF_Obj, PhyManager_getRfMode(), PhyManager_getSetupCmd(), &rfParams); + + // Issue CMD_FS + RF_runCmd(RadioIF_Rf_Handle, PhyManager_getFsCmd(), RF_PriorityNormal, NULL, 0); + + // Issue Rf Core RX command to start RX + RadioIF_Cmd_Handle = RF_postCmd(RadioIF_Rf_Handle, PhyManager_getRxCmd(), RF_PriorityNormal, &RadioIF_rfCoreEventCallback, IRQ_RX_BUF_FULL | IRQ_RX_ENTRY_DONE); +} + + +extern void RadioIF_registerRfCoreEventCb(rfCoreEventCb func) +{ + RadioIF_registerRfCoreEventCbApiSpecific(func); +} + + +//! \brief Callback function called upon RF Core events +//! +//! \return None +void RadioIF_rfCoreEventCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e) +{ + uint32_t events = 0; + + if(e & RF_EventRxEntryDone) + { + events |= RX_ENTRY_DONE_EVENT; + } + + if(e & RF_EventRxBufFull) + { + events |= RX_BUFFER_FULL_EVENT; + if(PhyManager_getRfApi() == IEEE_802_15_4) + { + // Abort RX command (For IEEE 15.4 API RX does not end automatically on this event) + RF_cancelCmd(RadioIF_Rf_Handle, RadioIF_Cmd_Handle, 0); + } + } + + if(events && RadioIF_rfCoreEventCbFunc) + { + RadioIF_rfCoreEventCbFunc(events); + } +} + +void RadioIF_registerRfCoreEventCbApiSpecific(rfCoreEventCb func) +{ + RadioIF_rfCoreEventCbFunc = func; +} diff --git a/source/radio_if.h b/source/radio_if.h new file mode 100644 index 0000000..7e8519a --- /dev/null +++ b/source/radio_if.h @@ -0,0 +1,163 @@ +/****************************************************************************** +* Filename: radio_if.h +* +* Description: Header file for configuration of the radio interface. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef RADIO_IF_H +#define RADIO_IF_H + +#include +#include + +#define RADIO_TIMER_FREQUENCY_MHZ 4 // 4 MHz +#define RADIO_TIMER_HALF_CYCLE_VALUE 0x80000000 +#define RADIO_TIMER_FIRST_QUARTER_CYCLE_VALUE 0x40000000 +#define RADIO_TIMER_THIRD_QUARTER_CYCLE_VALUE 0xC0000000 + + +// Selected IRQ event numbers from rf_mailbox +#define RX_ENTRY_DONE_EVENT 1 +#define RX_BUFFER_FULL_EVENT 2 + + +// Radio Interface status +typedef enum RadioIfStatus +{ + RADIO_IF_STATUS_OK, + RADIO_IF_STATUS_RX_BUFFER_OVERFLOW, +} RadioIfStatus; + +//! Typedef for RAT timer overflow callback function +//! The ratCbTime is the time when the callback happened +typedef void (*ratOverflowCb)(uint32_t ratCbTime); + +typedef void (*rxEntryDoneCb)(void); +typedef void (*rfCoreEventCb)(uint32_t rfCoreEvent); + +//! \brief Initialize the radio interface +//! +//! \return None +extern void RadioIF_init(void); + + +//! \brief Start radio receive mode +//! +//! \return None +extern void RadioIF_startRx(void); + + +//! \brief Stop radio receive mode +//! +//! \return None +extern void RadioIF_stopRx(void); + + +//! \brief Get status of the radio interface. +//! +//! \return One of the values defined by RadioIfStatus +extern uint8_t RadioIF_getStatus(void); + + +//! \brief Handle an RX buffer overflow situation +//! +//! \return None +extern void RadioIF_handleBufferOverflow(void); + + +//! \brief Set frequency value +//! The radio shall be stopped before calling this function. The new +//! frequency takes effect when the radio is restarted after calling +//! this function. +//! +//! \param[in] frequency +//! Frequency in MHz +//! +//! \param[in] fractFrequency +//! Fractional frequency in 1 MHz/65536 fractions. +//! +//! \return None +extern void RadioIF_setFrequency(uint16_t frequency, uint16_t fractFrequency); + + +//! \brief Initialize radio for packet transmit +//! +//! \return None +extern void RadioIF_initTx(void); + + +//! \brief Send packet. +//! The radio shall be stopped before calling this function. +//! +//! \param[in] packet +//! Pointer to packet data buffer +//! +//! \param[in] packetLength +//! Length of packet data buffer +//! +//! \return None +extern void RadioIF_sendPacket(uint8_t* packet, uint16_t packetLength); + + +//! \brief Deinitialize/disable radio for packet transmit +//! This function does clean up and close RF driver after packet transmit. +//! +//! \return None +extern void RadioIF_disableTx(void); + + +//! \brief Register function for Radio timer overflow callback +//! +//! The callback function will be called two timer per timer cycle +//! (When timer reaches half cycle value and when it wraps around) +//! +//! \return None +extern void RadioIF_registerRatOverflowCb(ratOverflowCb func); + + +extern void RadioIF_registerRxEntryDoneCb(rxEntryDoneCb func); +extern void RadioIF_registerRfCoreEventCb(rfCoreEventCb func); + +//! \brief Set PHY (RF API and PHY setting) +//! +//! \param[in] phyNumber +//! The number of the PHY to use. This number decodes into an RF API and a PHY setting. +//! (Examples of RF API are Proprietary, Proprietary in IEEE 802.15.4g mode, and +//! IEEE 802.15.4) +//! +//! \return true if phyNumber is valid, or false otherwise +extern bool RadioIf_setPhy(uint8_t phyNumber); + +#endif + diff --git a/source/radio_if_dataqueue.c b/source/radio_if_dataqueue.c new file mode 100644 index 0000000..bc1c082 --- /dev/null +++ b/source/radio_if_dataqueue.c @@ -0,0 +1,281 @@ +/****************************************************************************** +* Filename: radio_if_dataqueue.c +* +* Description: Source file for configuration of the radio interface data queue. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + + +#include "radio_if_dataqueue.h" +#include "phy_manager.h" +#include "common.h" +#include "DeviceFamily.h" +#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h) +#include DeviceFamily_constructPath(driverlib/rf_mailbox.h) +#include DeviceFamily_constructPath(driverlib/rf_data_entry.h) +#include + + +// Defines for the data queue +#define RF_QUEUE_DATA_ENTRY_HEADER_SIZE 8 // Header size of a Generic Data Entry +#define RF_QUEUE_QUEUE_ALIGN_PADDING(length) (4-((length + RF_QUEUE_DATA_ENTRY_HEADER_SIZE)%4)) // Padding offset + +#define RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(numEntries, dataSize, appendedBytes) \ +(numEntries*(RF_QUEUE_DATA_ENTRY_HEADER_SIZE + dataSize + appendedBytes + RF_QUEUE_QUEUE_ALIGN_PADDING(dataSize + appendedBytes))) + +#define MAX_LENGTH 2047 // Max length the radio will accept +#ifndef NUM_DATA_ENTRIES +#define NUM_DATA_ENTRIES 3 // Number of data entries +#endif + + +// In 802.15.4G mode (using CMD_PROP_RX_ADV) the entries will contain the following: +// 2 header bytes (RF_cmdPropRxAdv.rxConf.bIncludeHdr = 0x1, RF_cmdPropRxAdv.hdrConf.numHdrBits = 16) +// 1 RSSI byte (RF_cmdPropRxAdv.rxConf.bAppendRssi = 0x1) +// 1 status byte (RF_cmdPropRxAdv.rxConf.bAppendStatus = 0x1) +// 4 CRC bytes (RF_cmdPropRxAdv.rxConf.bIncludeCrc = 0x1, RF_cmdPropRxAdv.formatConf.whitenMode = 0x4) +// 4 Timestamp bytes (RF_cmdPropRxAdv.rxConf.bAppendTimestamp = 0x1) +#define NUM_APPENDED_BYTES 12 +#define ENTRY_LENGTH_CONFIG_SIZE 2 + +static dataQueue_t RadioIF_dataQueue; + + + +#if defined(DeviceFamily_CC13X0) || defined(DeviceFamily_CC26X0) +// Place the RX buffer in GPRAM for CC13x0 family to save SRAM space +#ifdef __ICCARM__ +#pragma location=".gpram" +#elif __TI_COMPILER_VERSION__ +#pragma DATA_SECTION(RadioIF_rxDataBuffer, ".gpram_data") +#endif +#endif +// Storage for the data entries +static uint8_t RadioIF_rxDataBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES, MAX_LENGTH, NUM_APPENDED_BYTES)]; + +// Data entry pointer to keep track of read items +static rfc_dataEntryGeneral_t* RadioIF_readEntry; + +// Local functions +static uint8_t RadioIF_createDataQueue(dataQueue_t *dataQueue, uint8_t *buf, uint16_t buf_len, uint8_t numEntries, uint16_t length); +static void RadioIF_nextEntry(void); +static void handle154gPacket(uint8_t* buffer, uint16_t elementLength); +static inline bool isFourOctetFcsType(uint8_t phyHeaderLowByte); +static inline void invertBytes(uint8_t* buffer, uint8_t length); + +void RadioIF_dataQueueInit(void) +{ + RadioIF_createDataQueue(&RadioIF_dataQueue, RadioIF_rxDataBuffer, sizeof(RadioIF_rxDataBuffer), NUM_DATA_ENTRIES, MAX_LENGTH + NUM_APPENDED_BYTES); +} + + +dataQueue_t* RadioIF_dataQueueGet(void) +{ + return &RadioIF_dataQueue; +} + + +bool RadioIF_hasPacket(void) +{ + return (RadioIF_readEntry->status == DATA_ENTRY_FINISHED); +} + + +uint16_t RadioIF_takePacket(uint8_t* buffer, uint16_t maxLen) +{ + if(!RadioIF_hasPacket()) return 0; + + uint16_t elementLength = Common_get16BitValueLE(&RadioIF_readEntry->data); + + // Discard packets larger than buffer size + if(elementLength <= maxLen) + { + memcpy(buffer, (uint8_t*)(&RadioIF_readEntry->data + ENTRY_LENGTH_CONFIG_SIZE), elementLength); + + if(PhyManager_getRfApi() == PROPRIETARY_15_4_G) + { + // Perform required buffer modications for IEEE 802.15.4g packets + handle154gPacket(buffer, elementLength); + } + } + + // free the entry for radio to use + RadioIF_nextEntry(); + + return elementLength; +} + + +void RadioIF_resetDataQueue(void) +{ + uint8_t* firstEntry = RadioIF_rxDataBuffer; + + // Set read pointer and data queue current entry pointer both to first entry + RadioIF_dataQueue.pCurrEntry = firstEntry; + RadioIF_readEntry = (rfc_dataEntryGeneral_t*)firstEntry; +} + + +//! \brief Free current read entry for radio to use, and move to next entry +//! +//! \return None +void RadioIF_nextEntry(void) +{ + // Set status to pending + RadioIF_readEntry->status = DATA_ENTRY_PENDING; + + // Move read entry pointer to next entry + RadioIF_readEntry = (rfc_dataEntryGeneral_t*)RadioIF_readEntry->pNextEntry; +} + + +//! \brief Create data queue +//! +//! \param[in] dataQueue +//! Pointer to data queue object +//! +//! \param[in] buf +//! Buffer for RX data entries +//! +//! \param[in] bufLength +//! Buffer length +//! +//! \param[in] numEntries +//! Number of data entries +//! +//! \param[in] length +//! Length of each data entry +//! +//! \return 0 if configuration is successful or 1 if queue does not fit in buffer. +uint8_t RadioIF_createDataQueue(dataQueue_t *dataQueue, uint8_t *buf, uint16_t bufLength, uint8_t numEntries, uint16_t length) +{ + if (bufLength < (numEntries * (length + RF_QUEUE_DATA_ENTRY_HEADER_SIZE + RF_QUEUE_QUEUE_ALIGN_PADDING(length)))) + { + // queue does not fit into buffer + return (1); + } + + // Padding needed for 4-byte alignment? + uint8_t pad = 4-((length + RF_QUEUE_DATA_ENTRY_HEADER_SIZE)%4); + + // Configure each data entry + uint8_t *first_entry = buf; + int i; + for (i = 0; i < numEntries; i++) + { + buf = first_entry + i * (RF_QUEUE_DATA_ENTRY_HEADER_SIZE + length + pad); + ((rfc_dataEntry_t*)buf)->status = DATA_ENTRY_PENDING; // Pending - starting state + ((rfc_dataEntry_t*)buf)->config.type = DATA_ENTRY_TYPE_GEN; // General Data Entry + ((rfc_dataEntry_t*)buf)->config.lenSz = ENTRY_LENGTH_CONFIG_SIZE; // Two bytes length indicator + ((rfc_dataEntry_t*)buf)->length = length; // Total length of data field + + ((rfc_dataEntryGeneral_t*)buf)->pNextEntry = &(((rfc_dataEntryGeneral_t*)buf)->data)+length+pad; + } + + // Make circular Last.Next -> First + ((rfc_dataEntry_t*)buf)->pNextEntry = first_entry; + + // Create Data Entry Queue and configure for circular buffer Data Entries + dataQueue->pCurrEntry = first_entry; + dataQueue->pLastEntry = NULL; + + // Set read pointer to first entry + RadioIF_readEntry = (rfc_dataEntryGeneral_t*)first_entry; + + return (0); +} + + +//! \brief Check if a 15.4g packet has 4 or 2 bytes FCS type +//! +//! \param[in] phyHeaderLowByte +//! Low byte of PHY header as read from RFCore in MSbit format +//! +//! \return true for 4 octet FCS, false for 2 octects FCS +static inline bool isFourOctetFcsType(uint8_t phyHeaderLowByte) +{ + // FCS Type is bit 3 MSB -> bit 4 LSB + return (~phyHeaderLowByte & 0x10); +} + +//! \brief Inverts all the bits for each byte in buffer +//! +//! \param[in] buffer +//! Pointer to start of data buffer +//! +//! \param[in] length +//! Buffer length (number of bytes to invert) +static inline void invertBytes(uint8_t* buffer, uint8_t length) +{ + for(int i=0; i= NUM_APPENDED_BYTES) + { + // Find CRC offset from buffer start + uint16_t crcOffset = elementLength - 4 - 1 - 4 - 1; // Subtract the appended 4 bytes CRC, 1 byte RSSI, 4 bytes timestamp and 1 byte RSSI + + // Invert the 4 CRC byte values + invertBytes(&buffer[crcOffset], 4); + } + } +} + + + + + + diff --git a/source/radio_if_dataqueue.h b/source/radio_if_dataqueue.h new file mode 100644 index 0000000..f3658de --- /dev/null +++ b/source/radio_if_dataqueue.h @@ -0,0 +1,93 @@ +/****************************************************************************** +* Filename: radio_if_dataqueue.h +* +* Description: Header file for configuration of the radio interface data queue. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef RADIO_IF_DATAQUEUE_H +#define RADIO_IF_DATAQUEUE_H + + +/* driverlib header files */ +#include "DeviceFamily.h" +#include DeviceFamily_constructPath(driverlib/rf_data_entry.h) +#include + +// Length of field added by Rf Core +#define RADIO_IF_RSSI_LEN 1 +#define RADIO_IF_TIMESTAMP_LEN 4 +#define RADIO_IF_STATUS_LEN 1 + +//! \brief Initialize the radio data queue +//! +//! \return None +extern void RadioIF_dataQueueInit(void); + + +//! \brief Get pointer to radio data queue +//! +//! \return Pointer to data queue +extern dataQueue_t* RadioIF_dataQueueGet(void); + + +//! \brief Check if the data queue has received one or more packets +//! +//! \return true if one or more packets are received, false otherwise. +extern bool RadioIF_hasPacket(void); + + +//! \brief Take a packet from the data queue +//! +//! This function will copy data from the data queue to the buffer given +//! as parameter. +//! +//! \param[in] buffer +//! Pointer to buffer where the radio packet will be copied. This +//! buffer must be allocated by the caller. +//! +//! \param[in] maxLen +//! Max number of bytes to copy. +//! +//! \return number of bytes copied to the data buffer. +extern uint16_t RadioIF_takePacket(uint8_t* buffer, uint16_t maxLen); + + +//! \brief Resets data queue internally used read and write pointers +//! +//! \return None +extern void RadioIF_resetDataQueue(void); + + +#endif + diff --git a/source/smartrf_settings/cc26x0lp/15.4/smartrf_settings_15_4_0.c b/source/smartrf_settings/cc26x0lp/15.4/smartrf_settings_15_4_0.c new file mode 100644 index 0000000..e6a50e3 --- /dev/null +++ b/source/smartrf_settings/cc26x0lp/15.4/smartrf_settings_15_4_0.c @@ -0,0 +1,219 @@ +//********************************************************************************* +// Generated by SmartRF Studio version 2.7.0 (build #21) +// Tested for SimpleLink SDK version: No known SDK for this device +// Device: CC2650 Rev. 2.2 +// +//********************************************************************************* + + +//********************************************************************************* +// Parameter summary +// IEEE Channel: 11 +// Frequency: 2405 MHz +// SFD: 0 +// Preamble (32 bit): 01010101... +// TX Power: 5 dBm + +#include "DeviceFamily.h" +#include DeviceFamily_constructPath(driverlib/rf_mailbox.h) +#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) +//#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h) +#include "rf_ieee_cmd.h" +#include +#include "smartrf_settings_15_4_0.h" + + +// TI-RTOS RF Mode Object +RF_Mode Ieee154_0_mode = +{ + .rfMode = RF_MODE_IEEE_15_4, + .cpePatchFxn = 0, + .mcePatchFxn = 0, + .rfePatchFxn = 0, +}; + +// Overrides for CMD_RADIO_SETUP +static uint32_t pOverrides[] = +{ + // override_synth_ieee_15_4.xml + // Synth: Set recommended RTRIM to 5 + HW_REG_OVERRIDE(0x4038,0x0035), + // Synth: Set Fref to 3.43 MHz + (uint32_t)0x000784A3, + // Synth: Set loop bandwidth after lock to 80 kHz + (uint32_t)0xA47E0583, + // Synth: Set loop bandwidth after lock to 80 kHz + (uint32_t)0xEAE00603, + // Synth: Set loop bandwidth after lock to 80 kHz + (uint32_t)0x00010623, + // Synth: Configure PLL bias + HW32_ARRAY_OVERRIDE(0x405C,1), + // Synth: Configure PLL bias + (uint32_t)0x1801F800, + // Synth: Configure PLL latency + HW32_ARRAY_OVERRIDE(0x402C,1), + // Synth: Configure PLL latency + (uint32_t)0x00608402, + // Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering + (uint32_t)0x02010403, + // Synth: Configure extra PLL filtering + HW32_ARRAY_OVERRIDE(0x4034,1), + // Synth: Configure extra PLL filtering + (uint32_t)0x177F0408, + // Synth: Configure extra PLL filtering + (uint32_t)0x38000463, + // override_phy_ieee_15_4.xml + // Synth: Increase synth programming timeout + (uint32_t)0x05000243, + // Rx: Adjust Rx FIFO threshold to avoid overflow + (uint32_t)0x002082C3, + // override_frontend_id.xml + // Rx: Set RSSI offset to adjust reported RSSI by -2 dB + (uint32_t)0x000288A3, + // Rx: Configure LNA bias current trim offset + (uint32_t)0x000F8883, + // Rx: Adjust AGC DC filter + HW_REG_OVERRIDE(0x50DC,0x002B), + // Disable pointer check in RF Core to allow for using GPRAM for buffers + (uint32_t)0x00018063, + (uint32_t)0xFFFFFFFF, +}; + + +// CMD_RADIO_SETUP +// Radio Setup Command for Pre-Defined Schemes +rfc_CMD_RADIO_SETUP_t Ieee154_0_cmdRadioSetup = +{ + .commandNo = 0x0802, + .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, + .mode = 0x01, + .__dummy0 = 0x00, + .config.frontEndMode = 0x0, + .config.biasMode = 0x0, + .config.analogCfgMode = 0x0, + .config.bNoFsPowerUp = 0x0, + .txPower = 0x9330, + .pRegOverride = pOverrides, +}; + +// CMD_FS +// Frequency Synthesizer Programming Command +rfc_CMD_FS_t Ieee154_0_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 = 0x0965, + .fractFreq = 0x0000, + .synthConf.bTxMode = 0x1, + .synthConf.refFreq = 0x0, + .__dummy0 = 0x00, + .__dummy1 = 0x00, + .__dummy2 = 0x00, + .__dummy3 = 0x0000, +}; + +// CMD_IEEE_TX +// The command ID number 0x2C01 +rfc_CMD_IEEE_TX_t Ieee154_0_cmdIeeeTx = +{ + .commandNo = 0x2C01, + .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, + .txOpt.bIncludePhyHdr = 0x0, + .txOpt.bIncludeCrc = 0x0, + .txOpt.payloadLenMsb = 0x0, + .payloadLen = 0x1E, + .pPayload = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx + .timeStamp = 0x00000000, +}; + +// CMD_IEEE_RX +// The command ID number 0x2801 +rfc_CMD_IEEE_RX_t Ieee154_0_cmdIeeeRx = +{ + .commandNo = 0x2801, + .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, + .channel = 0x00, + .rxConfig.bAutoFlushCrc = 0x0, + .rxConfig.bAutoFlushIgn = 0x0, + .rxConfig.bIncludePhyHdr = 0x0, + .rxConfig.bIncludeCrc = 0x0, + .rxConfig.bAppendRssi = 0x1, + .rxConfig.bAppendCorrCrc = 0x1, + .rxConfig.bAppendSrcInd = 0x0, + .rxConfig.bAppendTimestamp = 0x0, + .pRxQ = 0, // INSERT APPLICABLE POINTER: (dataQueue_t*)&xxx + .pOutput = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx + .frameFiltOpt.frameFiltEn = 0x0, + .frameFiltOpt.frameFiltStop = 0x0, + .frameFiltOpt.autoAckEn = 0x0, + .frameFiltOpt.slottedAckEn = 0x0, + .frameFiltOpt.autoPendEn = 0x0, + .frameFiltOpt.defaultPend = 0x0, + .frameFiltOpt.bPendDataReqOnly = 0x0, + .frameFiltOpt.bPanCoord = 0x0, + .frameFiltOpt.maxFrameVersion = 0x3, + .frameFiltOpt.fcfReservedMask = 0x0, + .frameFiltOpt.modifyFtFilter = 0x0, + .frameFiltOpt.bStrictLenFilter = 0x0, + .frameTypes.bAcceptFt0Beacon = 0x1, + .frameTypes.bAcceptFt1Data = 0x1, + .frameTypes.bAcceptFt2Ack = 0x1, + .frameTypes.bAcceptFt3MacCmd = 0x1, + .frameTypes.bAcceptFt4Reserved = 0x1, + .frameTypes.bAcceptFt5Reserved = 0x1, + .frameTypes.bAcceptFt6Reserved = 0x1, + .frameTypes.bAcceptFt7Reserved = 0x1, + .ccaOpt.ccaEnEnergy = 0x0, + .ccaOpt.ccaEnCorr = 0x0, + .ccaOpt.ccaEnSync = 0x0, + .ccaOpt.ccaCorrOp = 0x1, + .ccaOpt.ccaSyncOp = 0x1, + .ccaOpt.ccaCorrThr = 0x0, + .ccaRssiThr = 0x64, + .__dummy0 = 0x00, + .numExtEntries = 0x00, + .numShortEntries = 0x00, + .pExtEntryList = 0, // INSERT APPLICABLE POINTER: (uint32_t*)&xxx + .pShortEntryList = 0, // INSERT APPLICABLE POINTER: (uint32_t*)&xxx + .localExtAddr = 0x0000000012345678, + .localShortAddr = 0xABBA, + .localPanID = 0x0000, + .__dummy1 = 0x000000, + .endTrigger.triggerType = 0x1, + .endTrigger.bEnaCmd = 0x0, + .endTrigger.triggerNo = 0x0, + .endTrigger.pastTrig = 0x0, + .endTime = 0x00000000, +}; diff --git a/source/smartrf_settings/cc26x0lp/15.4/smartrf_settings_15_4_0.h b/source/smartrf_settings/cc26x0lp/15.4/smartrf_settings_15_4_0.h new file mode 100644 index 0000000..f8e56e9 --- /dev/null +++ b/source/smartrf_settings/cc26x0lp/15.4/smartrf_settings_15_4_0.h @@ -0,0 +1,30 @@ +#ifndef _SMARTRF_SETTINGS_15_4_0_H_ +#define _SMARTRF_SETTINGS_15_4_0_H_ + +//********************************************************************************* +// Generated by SmartRF Studio version 2.7.0 (build #21) +// Tested for SimpleLink SDK version: No known SDK for this device +// Device: CC2650 Rev. 2.2 +// +//********************************************************************************* +#include "DeviceFamily.h" +#include DeviceFamily_constructPath(driverlib/rf_mailbox.h) +#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) +//#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h) +#include "rf_ieee_cmd.h" +#include + + +// TI-RTOS RF Mode Object +extern RF_Mode Ieee154_0_mode; + + +// RF Core API commands +extern rfc_CMD_RADIO_SETUP_t Ieee154_0_cmdRadioSetup; +extern rfc_CMD_FS_t Ieee154_0_cmdFs; +extern rfc_CMD_IEEE_TX_t Ieee154_0_cmdIeeeTx; +extern rfc_CMD_IEEE_RX_t Ieee154_0_cmdIeeeRx; + + +#endif // _SMARTRF_SETTINGS_15_4_0_H_ + diff --git a/source/task_event.c b/source/task_event.c new file mode 100644 index 0000000..8074e4c --- /dev/null +++ b/source/task_event.c @@ -0,0 +1,69 @@ +/****************************************************************************** +* Filename: task_event.c +* +* Description: Source file for task event module. This module handles event +* signalling between the tasks in the system. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include +#include +#include "task_event.h" + +#include + +Event_Handle TaskEvent_Handle; + +static bool isInitialized = false; + +void TaskEvent_init(void) +{ + if(!isInitialized) + { + /* Default instance configuration params */ + TaskEvent_Handle = Event_create(NULL, NULL); + + if (TaskEvent_Handle == NULL) + { + System_abort("Event create failed"); + } + + isInitialized=true; + } +} + + + + + diff --git a/source/task_event.h b/source/task_event.h new file mode 100644 index 0000000..68f95a5 --- /dev/null +++ b/source/task_event.h @@ -0,0 +1,53 @@ +/****************************************************************************** +* Filename: task_event.h +* +* Description: Header file for task event module. This module handles event +* signalling between the tasks in the system. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef TASK_EVENT_H +#define TASK_EVENT_H + +#include + +#define EVENT_ID_USER_IF_TASK_END Event_Id_00 + +// Event handle to be shared between tasks +extern Event_Handle TaskEvent_Handle; + +//! \brief Initialize event system +extern void TaskEvent_init(void); + +#endif + diff --git a/source/test_command_handler.c b/source/test_command_handler.c new file mode 100644 index 0000000..ea1f6ba --- /dev/null +++ b/source/test_command_handler.c @@ -0,0 +1,202 @@ +/****************************************************************************** +* Filename: test_command_handler.c +* +* Description: Source file for test command handler. This module handles test +* commands. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include "test_command_handler.h" +#include "command_packet.h" +#include "command_handler.h" +#include "phy_manager.h" +#include "radio_if.h" + +#define TRANSMIT_SEQUENCE_MAX_PAYLOAD_LENGTH 2047 +#define PACKET_LENGHT_OFFSET_15_4_G -4 // Length offset setting for packet header length used for 15.4g settings +#define HEADER_LENGTH_15_4_G 2 // Header for 15.4G support +#define HEADER_LENGTH 0 // No header for Easylink support + +static uint8_t packet[TRANSMIT_SEQUENCE_MAX_PAYLOAD_LENGTH]; + +void TestCommandHandle_initializePacketPayload(uint8_t* packet, uint16_t packetLength); +void TestCommandHandle_initializePacketHeader(uint8_t* packet, uint16_t packetLength); +uint8_t TestCommandHandler_transmitOneSequence(uint8_t* commandData, uint16_t length); +void TestCommandHandler_transmitSeries(uint16_t packetLen, uint16_t numPackets); + +uint8_t TestCommandHandler_transmitSequence(uint8_t* commandData, uint16_t length) +{ + RadioIF_init(); + RadioIF_initTx(); + + if( (length < TEST_COMMAND_TRANSMIT_SEQUENCE_REPETITIONS_SIZE + TEST_COMMAND_TRANSMIT_SEQUENCE_PACKET_LENGTH_SIZE + TEST_COMMAND_TRANSMIT_SEQUENCE_PACKET_NUMBER_SIZE) + || (length % 2)) + { + RadioIF_disableTx(); + return COMMAND_INVALID; + } + + TestCommandHandle_initializePacketPayload(packet, TRANSMIT_SEQUENCE_MAX_PAYLOAD_LENGTH); + + uint8_t* pSequenceRepetitions = (commandData + TEST_COMMAND_TRANSMIT_SEQUENCE_REPETITIONS_OFFSET); + uint16_t sequenceRepetitions = *(uint16_t*)pSequenceRepetitions; + + for(int i = 0; i < sequenceRepetitions; i++) + { + uint8_t status = TestCommandHandler_transmitOneSequence(commandData, length); + if(status != COMMAND_OK) + { + RadioIF_disableTx(); + return status; + } + } + + RadioIF_disableTx(); + return COMMAND_OK; +} + + +//! \brief Transmit packet sequence +//! +//! \param[in] commandData +//! payload data for the TEST_CMD_TRANSMIT_SEQUENCE. +//! +//! \param[in] length +//! length of payload data +//! +//! \return status that indicates successful or failed handling of the command. +//! COMMAND_OK - The command was handled successfully. +//! COMMAND_INVALID - The command is invalid (e.g. payload does not match +//! the command type.) +uint8_t TestCommandHandler_transmitOneSequence(uint8_t* commandData, uint16_t length) +{ + uint16_t numSeries = (length - TEST_COMMAND_TRANSMIT_SEQUENCE_REPETITIONS_SIZE) / (TEST_COMMAND_TRANSMIT_SEQUENCE_PACKET_LENGTH_SIZE + TEST_COMMAND_TRANSMIT_SEQUENCE_PACKET_NUMBER_SIZE); + + for(int i = 0; i < numSeries; i++) + { + uint8_t* serieStart = (commandData + TEST_COMMAND_TRANSMIT_SEQUENCE_REPETITIONS_SIZE); + serieStart += i * (TEST_COMMAND_TRANSMIT_SEQUENCE_PACKET_LENGTH_SIZE + TEST_COMMAND_TRANSMIT_SEQUENCE_PACKET_NUMBER_SIZE); + + uint8_t* pPacketLen = serieStart + TEST_COMMAND_TRANSMIT_SEQUENCE_PACKET_LENGTH_OFFSET; + uint16_t packetLen = *(uint16_t*)pPacketLen; + + uint8_t* pNumPackets = serieStart + TEST_COMMAND_TRANSMIT_SEQUENCE_PACKET_NUMBER_OFFSET; + uint16_t numPackets = *(uint16_t*)pNumPackets; + + if(packetLen > MAX_PAYLOAD_LENGTH) + { + return COMMAND_INVALID; + } + + TestCommandHandler_transmitSeries(packetLen, numPackets); + } + + return COMMAND_OK; +} + + +//! \brief Transmit packet series +//! A series is a number of packets with same packet length +//! +//! \param[in] packetLen +//! Packet length +//! +//! \param[in] numPackets +//! Number of packets +//! +//! \return None +void TestCommandHandler_transmitSeries(uint16_t packetLen, uint16_t numPackets) +{ + TestCommandHandle_initializePacketHeader(packet, packetLen); + + for(int i = 0; i < numPackets; i++) + { + RadioIF_sendPacket(packet, packetLen); + } +} + + +//! \brief Initialize packet payload +//! The payload is initialized as a 1 byte counter +//! +//! \param[in] packet +//! Pointer to packet buffer +//! +//! \param[in] packetLength +//! Length of the packet +//! +//! \return None +void TestCommandHandle_initializePacketPayload(uint8_t* packet, uint16_t packetLength) +{ + int headerLen = HEADER_LENGTH; + if(PhyManager_getRfApi() == PROPRIETARY_15_4_G) + { + headerLen = HEADER_LENGTH_15_4_G; + } + + for(int i = headerLen; i < packetLength; i++) + { + packet[i] = i; + } +} + + +//! \brief Initialize packet header +//! Set packet header for 802.15.4g frame format and whitenMode=7 +//! +//! \param[in] packet +//! Pointer to packet buffer +//! +//! \param[in] packetLength +//! Length of the packet +//! +//! \return None +void TestCommandHandle_initializePacketHeader(uint8_t* packet, uint16_t packetLength) +{ + if(PhyManager_getRfApi() == PROPRIETARY_15_4_G) + { + // create the 15_4_g header (2 bytes used here) + packet[0] = (packetLength-HEADER_LENGTH_15_4_G - (PACKET_LENGHT_OFFSET_15_4_G)) & 0xFF; + packet[1] = ((packetLength-HEADER_LENGTH_15_4_G - (PACKET_LENGHT_OFFSET_15_4_G)) & 0xFF00) >> 8; + + // Set bit 11 in header to enable whitening for whitenMode=7 + packet[1] |= 1 << 3; + } +} + + + + + + diff --git a/source/test_command_handler.h b/source/test_command_handler.h new file mode 100644 index 0000000..ee99a41 --- /dev/null +++ b/source/test_command_handler.h @@ -0,0 +1,59 @@ +/****************************************************************************** +* Filename: test_command_handler.h +* +* Description: Header file for test command handler. This module handles test +* commands. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef TEST_COMMAND_HANDLER_H +#define TEST_COMMAND_HANDLER_H + +#include + +//! \brief execute a TEST_CMD_TRANSMIT_SEQUENCE command +//! +//! \param[in] commandData +//! payload data for the TEST_CMD_TRANSMIT_SEQUENCE. +//! +//! \param[in] length +//! length of payload data +//! +//! \return status that indicates successful or failed handling of the command. +//! COMMAND_OK - The command was handled successfully. +//! COMMAND_INVALID - The command is invalid (e.g. payload does not match +//! the command type.) +extern uint8_t TestCommandHandler_transmitSequence(uint8_t* commandData, uint16_t length); + +#endif + diff --git a/source/timestamp.c b/source/timestamp.c new file mode 100644 index 0000000..b6796a9 --- /dev/null +++ b/source/timestamp.c @@ -0,0 +1,221 @@ +/****************************************************************************** +* Filename: timestamp.c +* +* Description: Source file timestamp functionality. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include "timestamp.h" +#include "common.h" +#include "radio_if.h" +#include "radio_if_dataqueue.h" +#include "phy_manager.h" +#include + + +// Local functions +static uint64_t Timestamp_convertToUs(uint32_t radioTimestamp, uint8_t tickFrequency); +static void Timestamp_setPacketTimestamp(uint64_t timeStampUs, DataPacket_Obj* dataPacket); +static void Timestamp_ratOverflowCb(uint32_t ratCbTime); + +static uint64_t Timestamp_getFullRadioTimestamp(uint32_t radioTimeStamp); + +// Local variables +// These variables are not static to allow access from test application +uint32_t Timestamp_ratOverflowCounter = 0; // Keeps track of how many times the radio timer has wrapped around +uint32_t Timestamp_lastRatCbTime = 0; + +// defines +#define NUM_TIMESTAMP_BYTES 6 // 6 Timestamp bytes in data packet +#define NUM_BITS_PER_BYTE 8 + +void Timestamp_init(void) +{ + // Reset local variables + Timestamp_ratOverflowCounter = 0; + + // Register Radio timer callback function + RadioIF_registerRatOverflowCb(&Timestamp_ratOverflowCb); +} + + +uint16_t Timestamp_getRatOverflowCounter(void) +{ + return Timestamp_ratOverflowCounter; +} + + +uint16_t Timestamp_extractTimestamp(uint8_t* packetBuffer, uint16_t length, DataPacket_Obj* dataPacket) +{ + uint32_t radioTimestamp = 0; + + if(PhyManager_getRfApi() == IEEE_802_15_4) + { + int timestampIndex = length - RADIO_IF_TIMESTAMP_LEN; + radioTimestamp = Common_get32BitValueLE(&packetBuffer[timestampIndex]); + } + else + { + int timestampIndex = (length - RADIO_IF_STATUS_LEN - RADIO_IF_TIMESTAMP_LEN); + uint16_t statusIndex = length - RADIO_IF_STATUS_LEN; + radioTimestamp = Common_get32BitValueLE(&packetBuffer[timestampIndex]); + + // Remove timestamp bytes from data packet payload + uint8_t status = packetBuffer[statusIndex]; + packetBuffer[timestampIndex] = status; // Overwrites first timestamp byte + } + + // Set timestamp of data packet + uint64_t timeStampUs = Timestamp_convertToUs(radioTimestamp, RADIO_TIMER_FREQUENCY_MHZ); + Timestamp_setPacketTimestamp(timeStampUs, dataPacket); + + // Return updated payload length after timestamp bytes are removed + return length -= RADIO_IF_TIMESTAMP_LEN; +} + + +//! \brief Convert the 4 bytes timestamp value set by RF Core to 8 bytes timestamp +//! in microseconds. +//! +//! \param[in] radioTimestamp +//! Timestamp set by RF Core +//! +//! \param[in] tickFrequency +//! Tick frequency of Radio timer +//! +//! \return Timestamp in microseconds +uint64_t Timestamp_convertToUs(uint32_t radioTimestamp, uint8_t tickFrequency) +{ + // Add contribution from the overflow counter + uint64_t fullRadioTimeStamp = Timestamp_getFullRadioTimestamp(radioTimestamp); + + if(tickFrequency != 0) + { + return fullRadioTimeStamp/tickFrequency; + } + + return 0; +} + + +//! \brief Set 6 bytes timestamp field in data packet +//! +//! \param[in] timeStampUs +//! Timestamp in microseconds. +//! +//! \param[out] dataPacket +//! Pointer to data packet +//! +//! \return None +void Timestamp_setPacketTimestamp(uint64_t timeStampUs, DataPacket_Obj* dataPacket) +{ + // Set the 6 timestamp bytes in data packet in little endian order + for(int i = 0; i < NUM_TIMESTAMP_BYTES; i++) + { + uint8_t mumBitShifts = i * NUM_BITS_PER_BYTE; + dataPacket->timeStamp[i] = (timeStampUs & ((uint64_t)0xFF << mumBitShifts)) >> mumBitShifts; + } +} + + +//! \brief Get full radio timestamp including contributions from overflow counter +//! +//! \param[in] radioTimeStamp +//! 4 bytes timestamp as set by RF Core. +//! +//! \return 8 bytes extended timestamp with same resolution as radio timestamp +uint64_t Timestamp_getFullRadioTimestamp(uint32_t radioTimeStamp) +{ + uint64_t fullRadioTimeStamp = radioTimeStamp; + + // The Radio timer overflow callback may happen just before or just after + // a packet is received. This must be accounted for when wrap counter + // contribution is added to the packet's timestamp. + + // Temporarily disable SWI when the local variables are accessed. These + // variables are both accessed by the RAT Overflow callback function + // (which runs in SWI context) and this function. + uint32_t key = Swi_disable(); + + if(Timestamp_ratOverflowCounter > 0) + { + uint32_t tempOverflowCounter = Timestamp_ratOverflowCounter; + + if((radioTimeStamp > RADIO_TIMER_THIRD_QUARTER_CYCLE_VALUE) && (Timestamp_lastRatCbTime < RADIO_TIMER_FIRST_QUARTER_CYCLE_VALUE)) + { + // The packet was received just before timer wrap, but wrap counter has already been increased. + // We need to subtract 1 from the temporary wrap counter value for this packet. + tempOverflowCounter--; + } + else if((radioTimeStamp < RADIO_TIMER_FIRST_QUARTER_CYCLE_VALUE) && (Timestamp_lastRatCbTime > RADIO_TIMER_THIRD_QUARTER_CYCLE_VALUE)) + { + // The packet was received just after timer wrap, but wrap counter has not yet been increased. + // We need to add 1 to the temporary wrap counter value for this packet. + tempOverflowCounter++; + } + + fullRadioTimeStamp += ((uint64_t)tempOverflowCounter << 32); + } + + // Re-enable SWI before return from function + Swi_restore(key); + + return fullRadioTimeStamp; +} + + +//! \brief Callback function for Radio Timer (RAT) interrupt +//! +//! This function updates the file scope variables +//! Timestamp_ratOverflowCounter and Timestamp_lastRatCbTime. +//! +//! \param[in] ratCbTime +//! The time (value of RAT timer) when the callback happened +//! +//! \return None +void Timestamp_ratOverflowCb(uint32_t ratCbTime) +{ + // If the new RAT Callback time is less than last RAT callback time + // the RAT timer has wrapped around since last callback. + if(ratCbTime < Timestamp_lastRatCbTime) + { + Timestamp_ratOverflowCounter++; + } + + Timestamp_lastRatCbTime = ratCbTime; +} + + + + diff --git a/source/timestamp.h b/source/timestamp.h new file mode 100644 index 0000000..5fbd11c --- /dev/null +++ b/source/timestamp.h @@ -0,0 +1,76 @@ +/****************************************************************************** +* Filename: timestamp.h +* +* Description: Header file for timestamp functionality +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef TIMESTAMP_H +#define TIMESTAMP_H + +#include "data_packet.h" + +//! \brief Initialize timestamp module +//! This function resets the timestamp timer overflow counter. +//! +//! \return None +extern void Timestamp_init(void); + + +//! \brief Get current value of radio timer overflow counter +//! +//! \return Radio timer overflow counter value +extern uint16_t Timestamp_getRatOverflowCounter(void); + + +//! \brief Extract timestamp from radio packet +//! +//! The timestamp bytes of radio packet payload is extracted and removed +//! from the radio packet payload. The length and data packet timestamp +//! field are updated. +//! +//! \param[in] packetBuffer +//! Pointer to buffer for the data packet as read from radio +//! +//! \param[in] length +//! Length of the payload field of the data packet. +//! +//! \param[in/out] Pointer to data packet to update +//! +//! \return Updated payload length after timestamp bytes are removed +extern uint16_t Timestamp_extractTimestamp(uint8_t* packetBuffer, uint16_t length, DataPacket_Obj* dataPacket); + + + +#endif + diff --git a/source/user_if_task.c b/source/user_if_task.c new file mode 100644 index 0000000..6c22e73 --- /dev/null +++ b/source/user_if_task.c @@ -0,0 +1,109 @@ +/****************************************************************************** +* Filename: user_if_task.c +* +* Description: User Interface task function implementation. This task handles +* periodic updates of the user interface. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "Board.h" + +#include "host_if.h" +#include "task_event.h" +#include "version.h" + +// Period of user updates (1 second) +#define USER_IF_TIMEOUT_PERIOD 100000 // ticks of 10 us + +// Pin table +static PIN_Config UserIfTask_pinTable[] = +{ + Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, + PIN_TERMINATE +}; +static PIN_Handle UserIfTask_ledPin_Handle; +static PIN_State UserIfTask_ledPinState; + +#define USER_MESSAGE "TI Packet Sniffer ver." +static const char UserIfTask_message[] = USER_MESSAGE VERSION_STRING "\n"; + + +//! \brief User Interface task function +//! The arguments are not used. +//! +//! This task will periodically output a message to the host interface +//! and blink an LED to inform the user that the sniffer is running. The +//! period of the user updates is set to once per second. This task will +//! run until the event EVENT_ID_USER_IF_TASK_END is received. This task +// will exit when receiving EVENT_ID_USER_IF_TASK_END. +//! +void userIfTask(UArg a0, UArg a1) +{ + // Initialize the modules to be used by this task + HostIF_init(); + TaskEvent_init(); + + // Open LED pins + UserIfTask_ledPin_Handle = PIN_open(&UserIfTask_ledPinState, UserIfTask_pinTable); + if(!UserIfTask_ledPin_Handle) + { + System_abort("Error initializing board LED pins\n"); + } + + while(1) + { + // Let task sleep for timeout period + Task_sleep(USER_IF_TIMEOUT_PERIOD); + + // Update user interface + HostIF_writeBuffer((uint8_t*)UserIfTask_message, sizeof(UserIfTask_message)); + PIN_setOutputValue(UserIfTask_ledPin_Handle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1)); + + // Wait for end task event + UInt events = Event_pend(TaskEvent_Handle, EVENT_ID_USER_IF_TASK_END, Event_Id_NONE, BIOS_NO_WAIT); + if(events & EVENT_ID_USER_IF_TASK_END) + { + // End this task + PIN_close(UserIfTask_ledPin_Handle); + Task_exit(); + } + } +} diff --git a/source/user_if_task.h b/source/user_if_task.h new file mode 100644 index 0000000..f69a3ac --- /dev/null +++ b/source/user_if_task.h @@ -0,0 +1,50 @@ +/****************************************************************************** +* Filename: user_if_task.h +* +* Description: Header file for the User Interface Task. This task handles +* periodic updates of the user interface. +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef USER_IF_TASK_H +#define USER_IF_TASK_H + + +#include + +//! \brief User Interface task function +//! The arguments are not used. +extern void userIfTask(UArg a0, UArg a1); + +#endif + diff --git a/source/version.h b/source/version.h new file mode 100644 index 0000000..795dbf1 --- /dev/null +++ b/source/version.h @@ -0,0 +1,47 @@ +/****************************************************************************** +* Filename: version.h +* +* Description: version number +* +* Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ +* +* +* 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. +* +******************************************************************************/ +#ifndef VERSION_H +#define VERSION_H + + +#define MAJOR_VERSION 1 +#define MINOR_VERSION 5 +#define VERSION_STRING "1.5.0" + +#endif + diff --git a/src/.exclude b/src/.exclude new file mode 100644 index 0000000..8c86331 --- /dev/null +++ b/src/.exclude @@ -0,0 +1 @@ +This file exists to prevent Eclipse/CDT from adding the C sources contained in this directory (or below) to any enclosing project. diff --git a/src/makefile.libs b/src/makefile.libs new file mode 100644 index 0000000..645f7d3 --- /dev/null +++ b/src/makefile.libs @@ -0,0 +1,62 @@ +# +# This file was generated based on the configuration script: +# C:\Users\gongt\workspace_v8\sniffer_CC2650STK\release.cfg +# +# This makefile may be included in other makefiles that need to build +# the libraries containing the compiled source files generated as +# part of the configuration step. + +# +# ======== GEN_SRC_DIR ========= +# The path to the sources generated during configuration +# +# This path must be either absolute or relative to the build directory. +# +# The absolute path to the generated source directory (at the time the +# sources were generated) is: +# C:\Users\gongt\workspace_v8\sniffer_CC2650STK\src +# +GEN_SRC_DIR ?= ../src + +ifeq (,$(wildcard $(GEN_SRC_DIR))) +$(error "ERROR: GEN_SRC_DIR must be set to the directory containing the generated sources") +endif + +# +# ======== .force ======== +# The .force goal is used to force the build of any goal that names it as +# a prerequisite +# +.PHONY: .force + +# +# ======== library macros ======== +# +sysbios_SRC = $(GEN_SRC_DIR)/sysbios +sysbios_LIB = $(GEN_SRC_DIR)/sysbios/rom_sysbios.aem3 + +# +# ======== dependencies ======== +# +all: $(sysbios_LIB) +clean: .sysbios_clean + + +# ======== convenient build goals ======== +.PHONY: sysbios +sysbios: $(GEN_SRC_DIR)/sysbios/rom_sysbios.aem3 + +# CDT managed make executables depend on $(OBJS) +OBJS += $(sysbios_LIB) + +# +# ======== rules ======== +# +$(sysbios_LIB): .force + @echo making $@ ... + @$(MAKE) -C $(sysbios_SRC) + +.sysbios_clean: + @echo cleaning $(sysbios_SRC) ... + -@$(MAKE) --no-print-directory -C $(sysbios_SRC) clean + diff --git a/src/sysbios/m3_Hwi_asm.obj b/src/sysbios/m3_Hwi_asm.obj new file mode 100644 index 0000000..7be357d Binary files /dev/null and b/src/sysbios/m3_Hwi_asm.obj differ diff --git a/src/sysbios/m3_Hwi_asm_switch.obj b/src/sysbios/m3_Hwi_asm_switch.obj new file mode 100644 index 0000000..7e267b2 Binary files /dev/null and b/src/sysbios/m3_Hwi_asm_switch.obj differ diff --git a/src/sysbios/m3_IntrinsicsSupport_asm.obj b/src/sysbios/m3_IntrinsicsSupport_asm.obj new file mode 100644 index 0000000..022e8e3 Binary files /dev/null and b/src/sysbios/m3_IntrinsicsSupport_asm.obj differ diff --git a/src/sysbios/m3_TaskSupport_asm.obj b/src/sysbios/m3_TaskSupport_asm.obj new file mode 100644 index 0000000..1761699 Binary files /dev/null and b/src/sysbios/m3_TaskSupport_asm.obj differ diff --git a/src/sysbios/makefile b/src/sysbios/makefile new file mode 100644 index 0000000..55696d7 --- /dev/null +++ b/src/sysbios/makefile @@ -0,0 +1,107 @@ + +XOPTS = -I"C:/ti/xdctools_3_32_00_06_core/packages/" -Dxdc_target_types__=C:/ti/tirtos_cc13xx_cc26xx_2_21_00_06/products/bios_6_46_01_37/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M3 + +vpath % C:/ti/tirtos_cc13xx_cc26xx_2_21_00_06/products/bios_6_46_01_37/packages/ti/sysbios/ +vpath %.c C:/ti/xdctools_3_32_00_06_core/packages/ + +CCOPTS = --endian=little -mv7M3 --abi=eabi -q -ms --opt_for_speed=0 --program_level_compile -o3 -g --optimize_with_debug -Dti_sysbios_knl_Task_minimizeLatency__D=FALSE -Dti_sysbios_family_arm_cc26xx_Boot_driverlibVersion=2 -Dti_sysbios_knl_Clock_stopCheckNext__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_enableException__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_disablePriority__D=32U -Dti_sysbios_family_arm_m3_Hwi_numSparseInterrupts__D=0U + +XDC_ROOT = C:/ti/xdctools_3_32_00_06_core/packages/ + +BIOS_ROOT = C:/ti/tirtos_cc13xx_cc26xx_2_21_00_06/products/bios_6_46_01_37/packages/ti/sysbios/ + +BIOS_DEFS = -Dti_sysbios_BIOS_swiEnabled__D=TRUE -Dti_sysbios_BIOS_taskEnabled__D=TRUE -Dti_sysbios_BIOS_clockEnabled__D=TRUE -Dti_sysbios_BIOS_runtimeCreatesEnabled__D=TRUE -Dti_sysbios_knl_Task_moduleStateCheckFlag__D=FALSE -Dti_sysbios_knl_Task_objectCheckFlag__D=FALSE -Dti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS -Dti_sysbios_knl_Swi_DISABLE_ALL_HOOKS -Dti_sysbios_BIOS_smpEnabled__D=FALSE -Dti_sysbios_Build_useHwiMacros -Dti_sysbios_knl_Swi_numPriorities__D=6 -Dti_sysbios_knl_Task_deleteTerminatedTasks__D=FALSE -Dti_sysbios_knl_Task_numPriorities__D=6 -Dti_sysbios_knl_Task_checkStackFlag__D=FALSE -Dti_sysbios_knl_Task_initStackFlag__D=TRUE -Dti_sysbios_knl_Task_DISABLE_ALL_HOOKS -Dti_sysbios_knl_Clock_TICK_SOURCE=ti_sysbios_knl_Clock_TickSource_TIMER -Dti_sysbios_knl_Clock_TICK_MODE=ti_sysbios_knl_Clock_TickMode_DYNAMIC -Dti_sysbios_hal_Core_delegate_getId=ti_sysbios_hal_CoreNull_getId__E -Dti_sysbios_hal_Core_delegate_interruptCore=ti_sysbios_hal_CoreNull_interruptCore__E -Dti_sysbios_hal_Core_delegate_lock=ti_sysbios_hal_CoreNull_lock__E -Dti_sysbios_hal_Core_delegate_unlock=ti_sysbios_hal_CoreNull_unlock__E -Dti_sysbios_hal_Core_numCores__D=1 -Dti_sysbios_hal_CoreNull_numCores__D=1 -Dti_sysbios_utils_Load_taskEnabled__D=TRUE -Dti_sysbios_utils_Load_swiEnabled__D=FALSE -Dti_sysbios_utils_Load_hwiEnabled__D=FALSE -Dti_sysbios_family_arm_m3_Hwi_dispatcherSwiSupport__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_dispatcherTaskSupport__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_dispatcherAutoNestingSupport__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_dispatcherIrpTrackingSupport__D=TRUE -Dti_sysbios_knl_Semaphore_supportsEvents__D=FALSE -Dti_sysbios_knl_Semaphore_supportsPriority__D=FALSE -Dxdc_runtime_Assert_DISABLE_ALL -Dxdc_runtime_Log_DISABLE_ALL + +BIOS_INC = -I"C:/ti/tirtos_cc13xx_cc26xx_2_21_00_06/products/bios_6_46_01_37/packages/" + +TARGET_INC = -I"C:/ti/tirtos_cc13xx_cc26xx_2_21_00_06/products/bios_6_46_01_37/packages/" + +INCS = $(BIOS_INC) $(TARGET_INC) --include_path="C:/Users/gongt/workspace_v8/sniffer_CC2650STK/source/smartrf_settings/cc26x0lp" --include_path="C:/Users/gongt/workspace_v8/sniffer_CC2650STK/source/phy" --include_path="C:/Users/gongt/workspace_v8/sniffer_CC2650STK/source" --include_path="C:/Users/gongt/workspace_v8/sniffer_CC2650STK" --include_path="C:/Users/gongt/workspace_v8/sniffer_CC2650STK" --include_path="C:/ti/tirtos_cc13xx_cc26xx_2_21_00_06/products/cc26xxware_2_24_03_17272" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" -IC:/ti/tirtos_cc13xx_cc26xx_2_21_00_06/products/bios_6_46_01_37/packages/ + +CC = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include +ASM = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include +AR = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armar rq + +DEL = C:/ti/xdctools_3_32_00_06_core/packages/../bin/rm -f +CP = C:/ti/xdctools_3_32_00_06_core/packages/../bin/cp -f + +define RM + $(if $(wildcard $1),$(DEL) $1,:) +endef + +define ASSEMBLE + @echo asmem3 $< ... + @$(ASM) $(BIOS_DEFS) $(XOPTS) $(INCS) $< +endef + +all: rom_sysbios.aem3 + +m3_Hwi_asm.obj: family/arm/m3/Hwi_asm.sv7M makefile + @-$(call RM, $@) + $(ASSEMBLE) --output_file=m3_Hwi_asm.obj + +m3_Hwi_asm_switch.obj: family/arm/m3/Hwi_asm_switch.sv7M makefile + @-$(call RM, $@) + $(ASSEMBLE) --output_file=m3_Hwi_asm_switch.obj + +m3_IntrinsicsSupport_asm.obj: family/arm/m3/IntrinsicsSupport_asm.sv7M makefile + @-$(call RM, $@) + $(ASSEMBLE) --output_file=m3_IntrinsicsSupport_asm.obj + +m3_TaskSupport_asm.obj: family/arm/m3/TaskSupport_asm.sv7M makefile + @-$(call RM, $@) + $(ASSEMBLE) --output_file=m3_TaskSupport_asm.obj + + +rom_sysbios.obj: BIOS.c knl/Clock.c knl/Idle.c knl/Intrinsics.c knl/Event.c knl/Mailbox.c knl/Queue.c knl/Semaphore.c knl/Swi.c knl/Swi_andn.c knl/Task.c family/arm/m3/Hwi.c family/arm/m3/TaskSupport.c family/arm/cc26xx/Boot.c family/arm/cc26xx/Timer.c family/arm/cc26xx/TimestampProvider.c hal/Hwi.c hal/Hwi_stack.c hal/Hwi_startup.c heaps/HeapMem.c gates/GateHwi.c gates/GateMutex.c xdc/runtime/xdc_noinit.c xdc/runtime/Assert.c xdc/runtime/Core-mem.c xdc/runtime/Core-smem.c xdc/runtime/Core-label.c xdc/runtime/Core-params.c xdc/runtime/Diags.c xdc/runtime/Error.c xdc/runtime/Gate.c xdc/runtime/Log.c xdc/runtime/Memory.c xdc/runtime/Registry.c xdc/runtime/Startup.c xdc/runtime/System.c xdc/runtime/SysCallback.c xdc/runtime/Text.c xdc/runtime/Timestamp.c makefile + @-$(call RM, $@) + @echo clem3 $< ... + @$(CC) $(BIOS_DEFS) $(XOPTS) $(INCS) --output_file=rom_sysbios.obj \ + $(BIOS_ROOT)BIOS.c \ + $(BIOS_ROOT)knl/Clock.c \ + $(BIOS_ROOT)knl/Idle.c \ + $(BIOS_ROOT)knl/Intrinsics.c \ + $(BIOS_ROOT)knl/Event.c \ + $(BIOS_ROOT)knl/Mailbox.c \ + $(BIOS_ROOT)knl/Queue.c \ + $(BIOS_ROOT)knl/Semaphore.c \ + $(BIOS_ROOT)knl/Swi.c \ + $(BIOS_ROOT)knl/Swi_andn.c \ + $(BIOS_ROOT)knl/Task.c \ + $(BIOS_ROOT)family/arm/m3/Hwi.c \ + $(BIOS_ROOT)family/arm/m3/TaskSupport.c \ + $(BIOS_ROOT)family/arm/cc26xx/Boot.c \ + $(BIOS_ROOT)family/arm/cc26xx/Timer.c \ + $(BIOS_ROOT)family/arm/cc26xx/TimestampProvider.c \ + $(BIOS_ROOT)hal/Hwi.c \ + $(BIOS_ROOT)hal/Hwi_stack.c \ + $(BIOS_ROOT)hal/Hwi_startup.c \ + $(BIOS_ROOT)heaps/HeapMem.c \ + $(BIOS_ROOT)gates/GateHwi.c \ + $(BIOS_ROOT)gates/GateMutex.c \ + $(XDC_ROOT)xdc/runtime/xdc_noinit.c \ + $(XDC_ROOT)xdc/runtime/Assert.c \ + $(XDC_ROOT)xdc/runtime/Core-mem.c \ + $(XDC_ROOT)xdc/runtime/Core-smem.c \ + $(XDC_ROOT)xdc/runtime/Core-label.c \ + $(XDC_ROOT)xdc/runtime/Core-params.c \ + $(XDC_ROOT)xdc/runtime/Diags.c \ + $(XDC_ROOT)xdc/runtime/Error.c \ + $(XDC_ROOT)xdc/runtime/Gate.c \ + $(XDC_ROOT)xdc/runtime/Log.c \ + $(XDC_ROOT)xdc/runtime/Memory.c \ + $(XDC_ROOT)xdc/runtime/Registry.c \ + $(XDC_ROOT)xdc/runtime/Startup.c \ + $(XDC_ROOT)xdc/runtime/System.c \ + $(XDC_ROOT)xdc/runtime/SysCallback.c \ + $(XDC_ROOT)xdc/runtime/Text.c \ + $(XDC_ROOT)xdc/runtime/Timestamp.c \ + +rom_sysbios.aem3: rom_sysbios.obj m3_Hwi_asm.obj m3_Hwi_asm_switch.obj m3_IntrinsicsSupport_asm.obj m3_TaskSupport_asm.obj + @-$(call RM, $@) + @echo arem3 $^ ... + @$(AR) $@ $^ C:/ti/tirtos_cc13xx_cc26xx_2_21_00_06/products/bios_6_46_01_37/packages/ti/sysbios/rom/cortexm/cc26xx/golden/CC26xx/rom_sysbios_config.obj + +clean: + @$(DEL) ..\makefile.libs + @-$(call RM, *) diff --git a/src/sysbios/rom_sysbios.aem3 b/src/sysbios/rom_sysbios.aem3 new file mode 100644 index 0000000..62ea148 Binary files /dev/null and b/src/sysbios/rom_sysbios.aem3 differ diff --git a/src/sysbios/rom_sysbios.obj b/src/sysbios/rom_sysbios.obj new file mode 100644 index 0000000..2dfa472 Binary files /dev/null and b/src/sysbios/rom_sysbios.obj differ diff --git a/targetConfigs/CC2650F128.ccxml b/targetConfigs/CC2650F128.ccxml new file mode 100644 index 0000000..e4914b5 --- /dev/null +++ b/targetConfigs/CC2650F128.ccxml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/targetConfigs/readme.txt b/targetConfigs/readme.txt new file mode 100644 index 0000000..af97b62 --- /dev/null +++ b/targetConfigs/readme.txt @@ -0,0 +1,9 @@ +The 'targetConfigs' folder contains target-configuration (.ccxml) files, automatically generated based +on the device and connection settings specified in your project on the Properties > General page. + +Please note that in automatic target-configuration management, changes to the project's device and/or +connection settings will either modify an existing or generate a new target-configuration file. Thus, +if you manually edit these auto-generated files, you may need to re-apply your changes. Alternatively, +you may create your own target-configuration file for this project and manage it manually. You can +always switch back to automatic target-configuration management by checking the "Manage the project's +target-configuration automatically" checkbox on the project's Properties > General page. \ No newline at end of file