Prop RF driver now complete
This commit is contained in:
parent
430ba24bbd
commit
0102628245
@ -64,6 +64,7 @@ CONTIKI_CPU_SOURCEFILES += rtimer-arch.c clock-arch.c
|
|||||||
CONTIKI_CPU_SOURCEFILES += watchdog-arch.c putchar-arch.c
|
CONTIKI_CPU_SOURCEFILES += watchdog-arch.c putchar-arch.c
|
||||||
CONTIKI_CPU_SOURCEFILES += uart0-arch.c
|
CONTIKI_CPU_SOURCEFILES += uart0-arch.c
|
||||||
CONTIKI_CPU_SOURCEFILES += proprietary-rf.c proprietary-rf-settings.c
|
CONTIKI_CPU_SOURCEFILES += proprietary-rf.c proprietary-rf-settings.c
|
||||||
|
CONTIKI_CPU_SOURCEFILES += ieee-addr.c
|
||||||
|
|
||||||
### CPU-dependent debug source files
|
### CPU-dependent debug source files
|
||||||
DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c
|
DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c
|
||||||
|
128
arch/cpu/simplelink/dev/dot-15-4g.h
Normal file
128
arch/cpu/simplelink/dev/dot-15-4g.h
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Texas Instruments Incorporated - http://www.ti.com/
|
||||||
|
* 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 copyright holder 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.
|
||||||
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* \addtogroup rf-core
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* \defgroup rf-core-15-4g-modes IEEE 802.15.4g Frequency Bands and Modes
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* \file
|
||||||
|
* Header file with descriptors for the various modes of operation defined in
|
||||||
|
* IEEE 802.15.4g
|
||||||
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#ifndef DOT_15_4G_H_
|
||||||
|
#define DOT_15_4G_H_
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#include "contiki.h"
|
||||||
|
|
||||||
|
#include "driverlib/rf_mailbox.h"
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* IEEE 802.15.4g frequency band identifiers (Table 68f) */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_169 0 /* 169.400–169.475 (Europe) - 169 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_450 1 /* 450–470 (US FCC Part 22/90) - 450 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_470 2 /* 470–510 (China) - 470 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_780 3 /* 779–787 (China) - 780 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_863 4 /* 863–870 (Europe) - 863 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_896 5 /* 896–901 (US FCC Part 90) - 896 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_901 6 /* 901–902 (US FCC Part 24) - 901 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_915 7 /* 902–928 (US) - 915 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_917 8 /* 917–923.5 (Korea) - 917 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_920 9 /* 920–928 (Japan) - 920 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_928 10 /* 928–960 (US, non-contiguous) - 928 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_950 11 /* 950–958 (Japan) - 950 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_1427 12 /* 1427–1518 (US and Canada, non-contiguous) - 1427 MHz band */
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_2450 13 /* 2400–2483.5 2450 MHz band */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Default band selection to band 4 - 863MHz */
|
||||||
|
#ifdef DOT_15_4G_CONF_FREQUENCY_BAND_ID
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_ID DOT_15_4G_CONF_FREQUENCY_BAND_ID
|
||||||
|
#else
|
||||||
|
#define DOT_15_4G_FREQUENCY_BAND_ID DOT_15_4G_FREQUENCY_BAND_863
|
||||||
|
#endif
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/*
|
||||||
|
* Channel count, spacing and other params relating to the selected band. We
|
||||||
|
* currently only support some of the bands defined in .15.4g and for those
|
||||||
|
* bands we only support operating mode #1 (Table 134).
|
||||||
|
*
|
||||||
|
* DOT_15_4G_CHAN0_FREQUENCY is specified here in KHz
|
||||||
|
*/
|
||||||
|
#if DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_470
|
||||||
|
#define DOT_15_4G_CHANNEL_MAX 198
|
||||||
|
#define DOT_15_4G_CHANNEL_SPACING 200
|
||||||
|
#define DOT_15_4G_CHAN0_FREQUENCY 470200
|
||||||
|
#define PROP_MODE_CONF_LO_DIVIDER 0x0A
|
||||||
|
#define SMARTRF_SETTINGS_CONF_BAND_OVERRIDES HW32_ARRAY_OVERRIDE(0x405C,1), \
|
||||||
|
(uint32_t)0x18000280,
|
||||||
|
|
||||||
|
#elif DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_780
|
||||||
|
#define DOT_15_4G_CHANNEL_MAX 38
|
||||||
|
#define DOT_15_4G_CHANNEL_SPACING 200
|
||||||
|
#define DOT_15_4G_CHAN0_FREQUENCY 779200
|
||||||
|
#define PROP_MODE_CONF_LO_DIVIDER 0x06
|
||||||
|
|
||||||
|
#elif DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_863
|
||||||
|
#define DOT_15_4G_CHANNEL_MAX 33
|
||||||
|
#define DOT_15_4G_CHANNEL_SPACING 200
|
||||||
|
#define DOT_15_4G_CHAN0_FREQUENCY 863125
|
||||||
|
#define PROP_MODE_CONF_LO_DIVIDER 0x05
|
||||||
|
|
||||||
|
#elif DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_915
|
||||||
|
#define DOT_15_4G_CHANNEL_MAX 128
|
||||||
|
#define DOT_15_4G_CHANNEL_SPACING 200
|
||||||
|
#define DOT_15_4G_CHAN0_FREQUENCY 902200
|
||||||
|
#define PROP_MODE_CONF_LO_DIVIDER 0x05
|
||||||
|
|
||||||
|
#elif DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_920
|
||||||
|
#define DOT_15_4G_CHANNEL_MAX 37
|
||||||
|
#define DOT_15_4G_CHANNEL_SPACING 200
|
||||||
|
#define DOT_15_4G_CHAN0_FREQUENCY 920600
|
||||||
|
#define PROP_MODE_CONF_LO_DIVIDER 0x05
|
||||||
|
|
||||||
|
#elif DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_950
|
||||||
|
#define DOT_15_4G_CHANNEL_MAX 32
|
||||||
|
#define DOT_15_4G_CHANNEL_SPACING 200
|
||||||
|
#define DOT_15_4G_CHAN0_FREQUENCY 951000
|
||||||
|
#define PROP_MODE_CONF_LO_DIVIDER 0x05
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error The selected frequency band is not supported
|
||||||
|
#endif
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#endif /* DOT_15_4G_H_ */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
* @}
|
||||||
|
*/
|
90
arch/cpu/simplelink/dev/ieee-addr.c
Normal file
90
arch/cpu/simplelink/dev/ieee-addr.c
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
|
||||||
|
* 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 copyright holder 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.
|
||||||
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* \addtogroup cc26xx-ieee-addr
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* \file
|
||||||
|
* Driver for the CC13xx/CC26xx IEEE addresses
|
||||||
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#include "contiki.h"
|
||||||
|
#include "net/linkaddr.h"
|
||||||
|
#include "ieee-addr.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
ieee_addr_cpy_to(uint8_t *dst, uint8_t len)
|
||||||
|
{
|
||||||
|
if(IEEE_ADDR_CONF_HARDCODED) {
|
||||||
|
uint8_t ieee_addr_hc[8] = IEEE_ADDR_CONF_ADDRESS;
|
||||||
|
|
||||||
|
memcpy(dst, &ieee_addr_hc[8 - len], len);
|
||||||
|
} else {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Reading from primary location... */
|
||||||
|
uint8_t *location = (uint8_t *)IEEE_ADDR_LOCATION_PRIMARY;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ...unless we can find a byte != 0xFF in secondary
|
||||||
|
*
|
||||||
|
* Intentionally checking all 8 bytes here instead of len, because we
|
||||||
|
* are checking validity of the entire IEEE address irrespective of the
|
||||||
|
* actual number of bytes the caller wants to copy over.
|
||||||
|
*/
|
||||||
|
for(i = 0; i < 8; i++) {
|
||||||
|
if(((uint8_t *)IEEE_ADDR_LOCATION_SECONDARY)[i] != 0xFF) {
|
||||||
|
/* A byte in the secondary location is not 0xFF. Use the secondary */
|
||||||
|
location = (uint8_t *)IEEE_ADDR_LOCATION_SECONDARY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We have chosen what address to read the IEEE address from. Do so,
|
||||||
|
* inverting byte order
|
||||||
|
*/
|
||||||
|
for(i = 0; i < len; i++) {
|
||||||
|
dst[i] = location[len - 1 - i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if IEEE_ADDR_NODE_ID
|
||||||
|
dst[len - 1] = IEEE_ADDR_NODE_ID & 0xFF;
|
||||||
|
dst[len - 2] = IEEE_ADDR_NODE_ID >> 8;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/** @} */
|
105
arch/cpu/simplelink/dev/ieee-addr.h
Normal file
105
arch/cpu/simplelink/dev/ieee-addr.h
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
|
||||||
|
* 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 copyright holder 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.
|
||||||
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* \addtogroup cc26xx
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* \defgroup cc26xx-ieee-addr CC13xx/CC26xx IEEE Address Control
|
||||||
|
*
|
||||||
|
* Driver for the retrieval of an IEEE address from flash
|
||||||
|
*
|
||||||
|
* The user can specify a hardcoded IEEE address through the
|
||||||
|
* IEEE_ADDR_CONF_HARDCODED configuration macro.
|
||||||
|
*
|
||||||
|
* If the user does not hard-code an address, then one will be read from either
|
||||||
|
* the primary location (InfoPage) or from the secondary location (on flash).
|
||||||
|
*
|
||||||
|
* In order to allow the user to easily program nodes with addresses, the
|
||||||
|
* secondary location is given priority: If it contains a valid address then
|
||||||
|
* it will be chosen in favour of the one on InfoPage.
|
||||||
|
*
|
||||||
|
* In this context, an address is valid if at least one of the 8 bytes does not
|
||||||
|
* equal 0xFF. If all 8 bytes are 0xFF, then the primary location will be used.
|
||||||
|
*
|
||||||
|
* In all cases, the address is assumed to be written little-endian.
|
||||||
|
*
|
||||||
|
* Lastly, it is possible to override the 2 LSB's of the address by using the
|
||||||
|
* NODE_ID make variable.
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* \file
|
||||||
|
* Header file with register and macro declarations for the cc26xx IEEE address
|
||||||
|
* driver
|
||||||
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#ifndef IEEE_ADDR_H_
|
||||||
|
#define IEEE_ADDR_H_
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#include "contiki.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* \name IEEE address locations
|
||||||
|
*
|
||||||
|
* The address of the secondary location can be configured by the platform
|
||||||
|
* or example
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define IEEE_ADDR_LOCATION_PRIMARY 0x500012F0 /**< Primary IEEE address location */
|
||||||
|
|
||||||
|
#ifdef IEEE_ADDR_CONF_LOCATION_SECONDARY
|
||||||
|
#define IEEE_ADDR_LOCATION_SECONDARY IEEE_ADDR_CONF_LOCATION_SECONDARY
|
||||||
|
#else
|
||||||
|
#define IEEE_ADDR_LOCATION_SECONDARY 0x0001FFC8 /**< Secondary IEEE address location */
|
||||||
|
#endif
|
||||||
|
/** @} */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* \brief Copy the node's IEEE address to a destination memory area
|
||||||
|
* \param dst A pointer to the destination area where the IEEE address is to be
|
||||||
|
* written
|
||||||
|
* \param len The number of bytes to write to destination area
|
||||||
|
*
|
||||||
|
* This function will copy \e len LS bytes and it will invert byte order in
|
||||||
|
* the process. The factory address on devices is normally little-endian,
|
||||||
|
* therefore you should expect dst to store the address in a big-endian order.
|
||||||
|
*/
|
||||||
|
void ieee_addr_cpy_to(uint8_t *dst, uint8_t len);
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#endif /* IEEE_ADDR_H_ */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
* @}
|
||||||
|
*/
|
@ -43,8 +43,10 @@
|
|||||||
#include "sys/clock.h"
|
#include "sys/clock.h"
|
||||||
#include "sys/rtimer.h"
|
#include "sys/rtimer.h"
|
||||||
#include "sys/cc.h"
|
#include "sys/cc.h"
|
||||||
|
#include "dev/watchdog.h"
|
||||||
#include "proprietary-rf.h"
|
#include "proprietary-rf.h"
|
||||||
#include "rf-core.h"
|
#include "rf-core.h"
|
||||||
|
#include "dot-15-4g.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* RF core and RF HAL API */
|
/* RF core and RF HAL API */
|
||||||
#include <inc/hw_rfc_dbell.h>
|
#include <inc/hw_rfc_dbell.h>
|
||||||
@ -63,6 +65,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <assert.h>
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@ -231,87 +234,10 @@ static uint8_t tx_buf[TX_BUF_HDR_LEN + TX_BUF_PAYLOAD_LEN] CC_ALIGN(4);
|
|||||||
/* RF driver */
|
/* RF driver */
|
||||||
static RF_Object rfObject;
|
static RF_Object rfObject;
|
||||||
static RF_Handle rfHandle;
|
static RF_Handle rfHandle;
|
||||||
|
static RF_CmdHandle rxCmdHandle = RF_ALLOC_ERROR;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* CMD_PROP_TX_ADV */
|
PROCESS(rf_core_process, "CC13xx / CC26xx RF driver");
|
||||||
rfc_CMD_PROP_TX_ADV_t smartrf_settings_cmd_prop_tx_adv =
|
|
||||||
{
|
|
||||||
.commandNo = 0x3803,
|
|
||||||
.status = 0x0000,
|
|
||||||
.pNextOp = 0,
|
|
||||||
.startTime = 0x00000000,
|
|
||||||
.startTrigger.triggerType = 0x0,
|
|
||||||
.startTrigger.bEnaCmd = 0x0,
|
|
||||||
.startTrigger.triggerNo = 0x0,
|
|
||||||
.startTrigger.pastTrig = 0x0,
|
|
||||||
.condition.rule = 0x1,
|
|
||||||
.condition.nSkip = 0x0,
|
|
||||||
.pktConf.bFsOff = 0x0,
|
|
||||||
.pktConf.bUseCrc = 0x1,
|
|
||||||
.pktConf.bCrcIncSw = 0x0, /* .4g mode */
|
|
||||||
.pktConf.bCrcIncHdr = 0x0, /* .4g mode */
|
|
||||||
.numHdrBits = 0x10 /* 16: .4g mode */,
|
|
||||||
.pktLen = 0x0000,
|
|
||||||
.startConf.bExtTxTrig = 0x0,
|
|
||||||
.startConf.inputMode = 0x0,
|
|
||||||
.startConf.source = 0x0,
|
|
||||||
.preTrigger.triggerType = TRIG_REL_START,
|
|
||||||
.preTrigger.bEnaCmd = 0x0,
|
|
||||||
.preTrigger.triggerNo = 0x0,
|
|
||||||
.preTrigger.pastTrig = 0x1,
|
|
||||||
.preTime = 0x00000000,
|
|
||||||
.syncWord = 0x0055904e,
|
|
||||||
.pPkt = 0,
|
|
||||||
};
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* CMD_PROP_RX_ADV */
|
|
||||||
rfc_CMD_PROP_RX_ADV_t smartrf_settings_cmd_prop_rx_adv =
|
|
||||||
{
|
|
||||||
.commandNo = 0x3804,
|
|
||||||
.status = 0x0000,
|
|
||||||
.pNextOp = 0,
|
|
||||||
.startTime = 0x00000000,
|
|
||||||
.startTrigger.triggerType = 0x0,
|
|
||||||
.startTrigger.bEnaCmd = 0x0,
|
|
||||||
.startTrigger.triggerNo = 0x0,
|
|
||||||
.startTrigger.pastTrig = 0x0,
|
|
||||||
.condition.rule = 0x1,
|
|
||||||
.condition.nSkip = 0x0,
|
|
||||||
.pktConf.bFsOff = 0x0,
|
|
||||||
.pktConf.bRepeatOk = 0x1,
|
|
||||||
.pktConf.bRepeatNok = 0x1,
|
|
||||||
.pktConf.bUseCrc = 0x1,
|
|
||||||
.pktConf.bCrcIncSw = 0x0, /* .4g mode */
|
|
||||||
.pktConf.bCrcIncHdr = 0x0, /* .4g mode */
|
|
||||||
.pktConf.endType = 0x0,
|
|
||||||
.pktConf.filterOp = 0x1,
|
|
||||||
.rxConf.bAutoFlushIgnored = 0x1,
|
|
||||||
.rxConf.bAutoFlushCrcErr = 0x1,
|
|
||||||
.rxConf.bIncludeHdr = 0x0,
|
|
||||||
.rxConf.bIncludeCrc = 0x0,
|
|
||||||
.rxConf.bAppendRssi = 0x1,
|
|
||||||
.rxConf.bAppendTimestamp = 0x0,
|
|
||||||
.rxConf.bAppendStatus = 0x1,
|
|
||||||
.syncWord0 = 0x0055904e,
|
|
||||||
.syncWord1 = 0x00000000,
|
|
||||||
.maxPktLen = 0x0000, /* To be populated by the driver. */
|
|
||||||
.hdrConf.numHdrBits = 0x10, /* 16: .4g mode */
|
|
||||||
.hdrConf.lenPos = 0x0, /* .4g mode */
|
|
||||||
.hdrConf.numLenBits = 0x0B, /* 11 = 0x0B .4g mode */
|
|
||||||
.addrConf.addrType = 0x0,
|
|
||||||
.addrConf.addrSize = 0x0,
|
|
||||||
.addrConf.addrPos = 0x0,
|
|
||||||
.addrConf.numAddr = 0x0,
|
|
||||||
.lenOffset = -4, /* .4g mode */
|
|
||||||
.endTrigger.triggerType = TRIG_NEVER,
|
|
||||||
.endTrigger.bEnaCmd = 0x0,
|
|
||||||
.endTrigger.triggerNo = 0x0,
|
|
||||||
.endTrigger.pastTrig = 0x0,
|
|
||||||
.endTime = 0x00000000,
|
|
||||||
.pAddr = 0,
|
|
||||||
.pQueue = 0,
|
|
||||||
.pOutput = 0,
|
|
||||||
};
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static uint8_t
|
static uint8_t
|
||||||
rf_transmitting(void)
|
rf_transmitting(void)
|
||||||
{
|
{
|
||||||
@ -324,6 +250,95 @@ rf_receiving(void)
|
|||||||
return smartrf_settings_cmd_prop_rx_adv.status == ACTIVE;
|
return smartrf_settings_cmd_prop_rx_adv.status == ACTIVE;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static uint8_t
|
||||||
|
rf_is_on(void)
|
||||||
|
{
|
||||||
|
return rf_receiving() | rf_transmitting();
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
rf_rx_callback(RF_Handle client, RF_CmdHandle command, RF_EventMask events)
|
||||||
|
{
|
||||||
|
if (events & RF_EventRxEntryDone) {
|
||||||
|
process_poll(&rf_core_process);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static uint8_t
|
||||||
|
rf_start_rx()
|
||||||
|
{
|
||||||
|
rtimer_clock_t t0;
|
||||||
|
volatile rfc_CMD_PROP_RX_ADV_t *cmd_rx_adv;
|
||||||
|
|
||||||
|
cmd_rx_adv = (rfc_CMD_PROP_RX_ADV_t *)&smartrf_settings_cmd_prop_rx_adv;
|
||||||
|
cmd_rx_adv->status = IDLE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the max Packet length. This is for the payload only, therefore
|
||||||
|
* 2047 - length offset
|
||||||
|
*/
|
||||||
|
cmd_rx_adv->maxPktLen = DOT_4G_MAX_FRAME_LEN - cmd_rx_adv->lenOffset;
|
||||||
|
|
||||||
|
rxCmdHandle = RF_postCmd(rfHandle, (RF_Op*)&smartrf_settings_cmd_prop_rx_adv, RF_PriorityNormal, &rf_rx_callback, RF_EventRxEntryDone);
|
||||||
|
if (rxCmdHandle == RF_ALLOC_ERROR) {
|
||||||
|
return RF_CORE_CMD_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
t0 = RTIMER_NOW();
|
||||||
|
|
||||||
|
while(cmd_rx_adv->status != ACTIVE &&
|
||||||
|
(RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + ENTER_RX_WAIT_TIMEOUT)));
|
||||||
|
|
||||||
|
/* Wait to enter RX */
|
||||||
|
if(cmd_rx_adv->status != ACTIVE) {
|
||||||
|
PRINTF("rf_cmd_prop_rx: CMDSTA=0x%08lx, status=0x%04x\n",
|
||||||
|
md_status, cmd_rx_adv->status);
|
||||||
|
rf_switch_off();
|
||||||
|
return RF_CORE_CMD_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RF_CORE_CMD_OK;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static int
|
||||||
|
rf_stop_rx(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* If we are off, do nothing */
|
||||||
|
if(!rf_receiving()) {
|
||||||
|
return RF_CORE_CMD_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Abort any ongoing operation. Don't care about the result. */
|
||||||
|
RF_cancelCmd(rfHandle, RF_CMDHANDLE_FLUSH_ALL, 1);
|
||||||
|
|
||||||
|
/* Todo: maybe do a RF_pendCmd() to synchronise with command execution. */
|
||||||
|
|
||||||
|
if(smartrf_settings_cmd_prop_rx_adv.status == PROP_DONE_STOPPED ||
|
||||||
|
smartrf_settings_cmd_prop_rx_adv.status == PROP_DONE_ABORT) {
|
||||||
|
/* Stopped gracefully */
|
||||||
|
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
|
||||||
|
ret = RF_CORE_CMD_OK;
|
||||||
|
} else {
|
||||||
|
PRINTF("rx_off_prop: status=0x%04x\n",
|
||||||
|
smartrf_settings_cmd_prop_rx_adv.status);
|
||||||
|
ret = RF_CORE_CMD_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}/*---------------------------------------------------------------------------*/
|
||||||
|
static uint8_t
|
||||||
|
rf_run_setup()
|
||||||
|
{
|
||||||
|
RF_runCmd(rfHandle, (RF_Op*)&smartrf_settings_cmd_prop_radio_div_setup, RF_PriorityNormal, NULL, 0);
|
||||||
|
if (((volatile RF_Op*)&smartrf_settings_cmd_prop_radio_div_setup)->status != PROP_DONE_OK) {
|
||||||
|
return RF_CORE_CMD_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RF_CORE_CMD_OK;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
static radio_value_t
|
static radio_value_t
|
||||||
get_rssi(void)
|
get_rssi(void)
|
||||||
{
|
{
|
||||||
@ -354,7 +369,7 @@ get_channel(void)
|
|||||||
{
|
{
|
||||||
uint32_t freq_khz;
|
uint32_t freq_khz;
|
||||||
|
|
||||||
freq_khz = RF_cmdFs.frequency * 1000;
|
freq_khz = smartrf_settings_cmd_prop_fs.frequency * 1000;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For some channels, fractFreq * 1000 / 65536 will return 324.99xx.
|
* For some channels, fractFreq * 1000 / 65536 will return 324.99xx.
|
||||||
@ -362,7 +377,7 @@ get_channel(void)
|
|||||||
* function returning channel - 1 instead of channel. Thus, we do a quick
|
* function returning channel - 1 instead of channel. Thus, we do a quick
|
||||||
* positive integer round up.
|
* positive integer round up.
|
||||||
*/
|
*/
|
||||||
freq_khz += (((RF_cmdFs.fractFreq * 1000) + 65535) / 65536);
|
freq_khz += (((smartrf_settings_cmd_prop_fs.fractFreq * 1000) + 65535) / 65536);
|
||||||
|
|
||||||
return (freq_khz - DOT_15_4G_CHAN0_FREQUENCY) / DOT_15_4G_CHANNEL_SPACING;
|
return (freq_khz - DOT_15_4G_CHAN0_FREQUENCY) / DOT_15_4G_CHANNEL_SPACING;
|
||||||
}
|
}
|
||||||
@ -370,26 +385,28 @@ get_channel(void)
|
|||||||
static void
|
static void
|
||||||
set_channel(uint8_t channel)
|
set_channel(uint8_t channel)
|
||||||
{
|
{
|
||||||
uint32_t new_freq;
|
uint32_t new_freq;
|
||||||
uint16_t freq, frac;
|
uint16_t freq, frac;
|
||||||
|
|
||||||
new_freq = DOT_15_4G_CHAN0_FREQUENCY + (channel * DOT_15_4G_CHANNEL_SPACING);
|
new_freq = DOT_15_4G_CHAN0_FREQUENCY + (channel * DOT_15_4G_CHANNEL_SPACING);
|
||||||
|
|
||||||
freq = (uint16_t)(new_freq / 1000);
|
freq = (uint16_t)(new_freq / 1000);
|
||||||
frac = (new_freq - (freq * 1000)) * 65536 / 1000;
|
frac = (new_freq - (freq * 1000)) * 65536 / 1000;
|
||||||
|
|
||||||
PRINTF("set_channel: %u = 0x%04x.0x%04x (%lu)\n", channel, freq, frac,
|
PRINTF("set_channel: %u = 0x%04x.0x%04x (%lu)\n", channel, freq, frac,
|
||||||
new_freq);
|
new_freq);
|
||||||
|
|
||||||
RF_cmdPropRadioDivSetup.centerFreq = freq;
|
smartrf_settings_cmd_prop_radio_div_setup.centerFreq = freq;
|
||||||
RF_cmdFs.frequency = freq;
|
smartrf_settings_cmd_prop_fs.frequency = freq;
|
||||||
RF_cmdFs.fractFreq = frac;
|
smartrf_settings_cmd_prop_fs.fractFreq = frac;
|
||||||
|
|
||||||
// Start FS command asynchronously. We don't care when it is finished.
|
// Todo: Need to re-run setup command when deviation from previous frequency
|
||||||
// "Error" checking is implicitly done later in the RX/TX command
|
// is too large
|
||||||
// which will return an error if the synth is not working.
|
// rf_run_setup();
|
||||||
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
|
|
||||||
|
|
||||||
|
// We don't care whether the FS command is successful because subsequent
|
||||||
|
// TX and RX commands will tell us indirectly.
|
||||||
|
RF_postCmd(rfHandle, (RF_Op*)&smartrf_settings_cmd_prop_fs, RF_PriorityNormal, NULL, 0);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static uint8_t
|
static uint8_t
|
||||||
@ -435,44 +452,6 @@ set_tx_power(radio_value_t power)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static uint8_t
|
|
||||||
rf_start_rx()
|
|
||||||
{
|
|
||||||
uint32_t cmd_status;
|
|
||||||
rtimer_clock_t t0;
|
|
||||||
volatile rfc_CMD_PROP_RX_ADV_t *cmd_rx_adv;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
cmd_rx_adv = (rfc_CMD_PROP_RX_ADV_t *)&smartrf_settings_cmd_prop_rx_adv;
|
|
||||||
cmd_rx_adv->status = IDLE;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the max Packet length. This is for the payload only, therefore
|
|
||||||
* 2047 - length offset
|
|
||||||
*/
|
|
||||||
cmd_rx_adv->maxPktLen = DOT_4G_MAX_FRAME_LEN - cmd_rx_adv->lenOffset;
|
|
||||||
|
|
||||||
// Todo: subscribe events
|
|
||||||
RF_CmdHandle cmd = RF_postCmd(rfHandle, (RF_Op*)&smartrf_settings_cmd_prop_rx_adv, RF_PriorityNormal, NULL, 0);
|
|
||||||
if (cmd == RF_ALLOC_ERROR) {
|
|
||||||
return RF_CORE_CMD_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
t0 = RTIMER_NOW();
|
|
||||||
|
|
||||||
while(cmd_rx_adv->status != ACTIVE &&
|
|
||||||
(RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + ENTER_RX_WAIT_TIMEOUT)));
|
|
||||||
|
|
||||||
/* Wait to enter RX */
|
|
||||||
if(cmd_rx_adv->status != ACTIVE) {
|
|
||||||
PRINTF("rf_cmd_prop_rx: CMDSTA=0x%08lx, status=0x%04x\n",
|
|
||||||
cmd_status, cmd_rx_adv->status);
|
|
||||||
return RF_CORE_CMD_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RF_CORE_CMD_OK;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
static void
|
||||||
init_rx_buffers(void)
|
init_rx_buffers(void)
|
||||||
{
|
{
|
||||||
@ -492,71 +471,6 @@ init_rx_buffers(void)
|
|||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
rx_off_prop(void)
|
|
||||||
{
|
|
||||||
uint32_t cmd_status;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* If we are off, do nothing */
|
|
||||||
if(!rf_is_on()) {
|
|
||||||
return RF_CORE_CMD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Abort any ongoing operation. Don't care about the result. */
|
|
||||||
RF_cancelCmd(rfHandle, RF_CMDHANDLE_FLUSH_ALL, 1);
|
|
||||||
RF_yield(rfHandle);
|
|
||||||
|
|
||||||
while(rf_is_on());
|
|
||||||
|
|
||||||
if(smartrf_settings_cmd_prop_rx_adv.status == PROP_DONE_STOPPED ||
|
|
||||||
smartrf_settings_cmd_prop_rx_adv.status == PROP_DONE_ABORT) {
|
|
||||||
/* Stopped gracefully */
|
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
|
|
||||||
ret = RF_CORE_CMD_OK;
|
|
||||||
} else {
|
|
||||||
PRINTF("rx_off_prop: status=0x%04x\n",
|
|
||||||
smartrf_settings_cmd_prop_rx_adv.status);
|
|
||||||
ret = RF_CORE_CMD_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static int
|
|
||||||
init(void)
|
|
||||||
{
|
|
||||||
RF_Params params;
|
|
||||||
RF_Params_init(¶ms);
|
|
||||||
params.nInactivityTimeout = 0; // disable automatic power-down
|
|
||||||
// just to not interfere with stack timing
|
|
||||||
|
|
||||||
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, ¶ms);
|
|
||||||
assert(rfHandle != NULL);
|
|
||||||
|
|
||||||
/* Initialise RX buffers */
|
|
||||||
memset(rx_buf, 0, sizeof(rx_buf));
|
|
||||||
|
|
||||||
/* Set of RF Core data queue. Circular buffer, no last entry */
|
|
||||||
rx_data_queue.pCurrEntry = rx_buf[0];
|
|
||||||
rx_data_queue.pLastEntry = NULL;
|
|
||||||
|
|
||||||
/* Initialize current read pointer to first element (used in ISR) */
|
|
||||||
rx_read_entry = rx_buf[0];
|
|
||||||
|
|
||||||
smartrf_settings_cmd_prop_rx_adv.pQueue = &rx_data_queue;
|
|
||||||
smartrf_settings_cmd_prop_rx_adv.pOutput = (uint8_t *)&rx_stats;
|
|
||||||
|
|
||||||
set_channel(RF_CORE_CHANNEL);
|
|
||||||
|
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
|
||||||
|
|
||||||
process_start(&rf_core_process, NULL);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static int
|
|
||||||
prepare(const void *payload, unsigned short payload_len)
|
prepare(const void *payload, unsigned short payload_len)
|
||||||
{
|
{
|
||||||
int len = MIN(payload_len, TX_BUF_PAYLOAD_LEN);
|
int len = MIN(payload_len, TX_BUF_PAYLOAD_LEN);
|
||||||
@ -570,9 +484,17 @@ transmit(unsigned short transmit_len)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
uint8_t was_off = 0;
|
uint8_t was_off = 0;
|
||||||
uint32_t cmd_status;
|
|
||||||
volatile rfc_CMD_PROP_TX_ADV_t *cmd_tx_adv;
|
volatile rfc_CMD_PROP_TX_ADV_t *cmd_tx_adv;
|
||||||
|
|
||||||
|
if (rf_transmitting()) {
|
||||||
|
PRINTF("transmit: not allowed while transmitting\n");
|
||||||
|
return RADIO_TX_ERR;
|
||||||
|
} else if (rf_receiving()) {
|
||||||
|
rf_stop_rx();
|
||||||
|
} else {
|
||||||
|
was_off = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Length in .15.4g PHY HDR. Includes the CRC but not the HDR itself */
|
/* Length in .15.4g PHY HDR. Includes the CRC but not the HDR itself */
|
||||||
uint16_t total_length;
|
uint16_t total_length;
|
||||||
|
|
||||||
@ -599,10 +521,6 @@ transmit(unsigned short transmit_len)
|
|||||||
cmd_tx_adv->pktLen = transmit_len + DOT_4G_PHR_LEN;
|
cmd_tx_adv->pktLen = transmit_len + DOT_4G_PHR_LEN;
|
||||||
cmd_tx_adv->pPkt = tx_buf;
|
cmd_tx_adv->pPkt = tx_buf;
|
||||||
|
|
||||||
was_off = rx_
|
|
||||||
/* Abort RX */
|
|
||||||
rx_off_prop();
|
|
||||||
|
|
||||||
// TODO: Register callback
|
// TODO: Register callback
|
||||||
RF_CmdHandle txHandle = RF_postCmd(rfHandle, (RF_Op*)&cmd_tx_adv, RF_PriorityNormal, NULL, 0);
|
RF_CmdHandle txHandle = RF_postCmd(rfHandle, (RF_Op*)&cmd_tx_adv, RF_PriorityNormal, NULL, 0);
|
||||||
if (txHandle == RF_ALLOC_ERROR)
|
if (txHandle == RF_ALLOC_ERROR)
|
||||||
@ -613,8 +531,7 @@ transmit(unsigned short transmit_len)
|
|||||||
return RADIO_TX_ERR;
|
return RADIO_TX_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we enter here, TX actually started */
|
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
|
||||||
ENERGEST_SWITCH(ENERGEST_TYPE_LISTEN, ENERGEST_TYPE_TRANSMIT);
|
|
||||||
|
|
||||||
// watchdog_periodic();
|
// watchdog_periodic();
|
||||||
|
|
||||||
@ -631,16 +548,16 @@ transmit(unsigned short transmit_len)
|
|||||||
ret = RADIO_TX_ERR;
|
ret = RADIO_TX_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
|
||||||
* Update ENERGEST state here, before a potential call to off(), which
|
|
||||||
* will correctly update it if required.
|
|
||||||
*/
|
|
||||||
ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN);
|
|
||||||
|
|
||||||
/* Workaround. Set status to IDLE */
|
/* Workaround. Set status to IDLE */
|
||||||
cmd_tx_adv->status = RF_CORE_RADIO_OP_STATUS_IDLE;
|
cmd_tx_adv->status = IDLE;
|
||||||
|
|
||||||
rf_start_rx();
|
if (was_off) {
|
||||||
|
RF_yield(rfHandle);
|
||||||
|
} else {
|
||||||
|
rf_start_rx();
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -691,7 +608,6 @@ static int
|
|||||||
channel_clear(void)
|
channel_clear(void)
|
||||||
{
|
{
|
||||||
uint8_t was_off = 0;
|
uint8_t was_off = 0;
|
||||||
uint32_t cmd_status;
|
|
||||||
int8_t rssi = RF_CMD_CCA_REQ_RSSI_UNKNOWN;
|
int8_t rssi = RF_CMD_CCA_REQ_RSSI_UNKNOWN;
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
@ -719,7 +635,7 @@ channel_clear(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(rssi >= rssi_threshold) {
|
if(rssi >= rssi_threshold) {
|
||||||
eturn RF_CCA_BUSY;
|
return RF_CCA_BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RF_CCA_CLEAR;
|
return RF_CCA_CLEAR;
|
||||||
@ -728,7 +644,7 @@ channel_clear(void)
|
|||||||
static int
|
static int
|
||||||
receiving_packet(void)
|
receiving_packet(void)
|
||||||
{
|
{
|
||||||
if(!rf_is_on()) {
|
if(!rf_receiving()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -838,16 +754,10 @@ get_value(radio_param_t param, radio_value_t *value)
|
|||||||
static radio_result_t
|
static radio_result_t
|
||||||
set_value(radio_param_t param, radio_value_t value)
|
set_value(radio_param_t param, radio_value_t value)
|
||||||
{
|
{
|
||||||
uint8_t was_off = 0;
|
|
||||||
radio_result_t rv = RADIO_RESULT_OK;
|
|
||||||
|
|
||||||
switch(param) {
|
switch(param) {
|
||||||
case RADIO_PARAM_POWER_MODE:
|
case RADIO_PARAM_POWER_MODE:
|
||||||
if(value == RADIO_POWER_MODE_ON) {
|
if(value == RADIO_POWER_MODE_ON) {
|
||||||
if(rf_switch_on() != RF_CORE_CMD_OK) {
|
// Powering on happens implicitly
|
||||||
PRINTF("set_value: on() failed (1)\n");
|
|
||||||
return RADIO_RESULT_ERROR;
|
|
||||||
}
|
|
||||||
return RADIO_RESULT_OK;
|
return RADIO_RESULT_OK;
|
||||||
}
|
}
|
||||||
if(value == RADIO_POWER_MODE_OFF) {
|
if(value == RADIO_POWER_MODE_OFF) {
|
||||||
@ -874,51 +784,36 @@ set_value(radio_param_t param, radio_value_t value)
|
|||||||
value > OUTPUT_POWER_MAX) {
|
value > OUTPUT_POWER_MAX) {
|
||||||
return RADIO_RESULT_INVALID_VALUE;
|
return RADIO_RESULT_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
soft_off_prop();
|
|
||||||
|
|
||||||
set_tx_power(value);
|
set_tx_power(value);
|
||||||
|
|
||||||
if(soft_on_prop() != RF_CORE_CMD_OK) {
|
|
||||||
PRINTF("set_value: soft_on_prop() failed\n");
|
|
||||||
rv = RADIO_RESULT_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RADIO_RESULT_OK;
|
return RADIO_RESULT_OK;
|
||||||
case RADIO_PARAM_RX_MODE:
|
case RADIO_PARAM_RX_MODE:
|
||||||
return RADIO_RESULT_OK;
|
return RADIO_RESULT_OK;
|
||||||
case RADIO_PARAM_CCA_THRESHOLD:
|
case RADIO_PARAM_CCA_THRESHOLD:
|
||||||
rssi_threshold = (int8_t)value;
|
rssi_threshold = (int8_t)value;
|
||||||
|
return RADIO_RESULT_OK;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return RADIO_RESULT_NOT_SUPPORTED;
|
return RADIO_RESULT_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we reach here we had no errors. Apply new settings */
|
/* If we reach here we had no errors. Apply new settings */
|
||||||
if(!rf_is_on()) {
|
if (rf_receiving()) {
|
||||||
was_off = 1;
|
rf_stop_rx();
|
||||||
if(rf_switch_on() != RF_CORE_CMD_OK) {
|
if (rf_run_setup() != RF_CORE_CMD_OK) {
|
||||||
PRINTF("set_value: on() failed (2)\n");
|
return RADIO_RESULT_ERROR;
|
||||||
|
}
|
||||||
|
rf_start_rx();
|
||||||
|
} else if (rf_transmitting()) {
|
||||||
|
// Should not happen. TX is always synchronous and blocking.
|
||||||
|
// Todo: maybe remove completely here.
|
||||||
|
PRINTF("set_value: cannot apply new value while transmitting. \n");
|
||||||
return RADIO_RESULT_ERROR;
|
return RADIO_RESULT_ERROR;
|
||||||
}
|
} else {
|
||||||
|
// was powered off. Nothing to do. New values will be
|
||||||
|
// applied automatically on next power-up.
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rx_off_prop() != RF_CORE_CMD_OK) {
|
return RADIO_RESULT_OK;
|
||||||
PRINTF("set_value: rx_off_prop() failed\n");
|
|
||||||
rv = RADIO_RESULT_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(soft_on_prop() != RF_CORE_CMD_OK) {
|
|
||||||
PRINTF("set_value: rx_on_prop() failed\n");
|
|
||||||
rv = RADIO_RESULT_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we were off, turn back off */
|
|
||||||
if(was_off) {
|
|
||||||
rf_switch_off();
|
|
||||||
}
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static radio_result_t
|
static radio_result_t
|
||||||
@ -933,8 +828,64 @@ set_object(radio_param_t param, const void *src, size_t size)
|
|||||||
return RADIO_RESULT_NOT_SUPPORTED;
|
return RADIO_RESULT_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static int
|
||||||
|
rf_init(void)
|
||||||
|
{
|
||||||
|
RF_Params params;
|
||||||
|
RF_Params_init(¶ms);
|
||||||
|
params.nInactivityTimeout = 0; // disable automatic power-down
|
||||||
|
// just to not interfere with stack timing
|
||||||
|
|
||||||
|
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&smartrf_settings_cmd_prop_radio_div_setup, ¶ms);
|
||||||
|
assert(rfHandle != NULL);
|
||||||
|
|
||||||
|
/* Initialise RX buffers */
|
||||||
|
memset(rx_buf, 0, sizeof(rx_buf));
|
||||||
|
|
||||||
|
/* Set of RF Core data queue. Circular buffer, no last entry */
|
||||||
|
rx_data_queue.pCurrEntry = rx_buf[0];
|
||||||
|
rx_data_queue.pLastEntry = NULL;
|
||||||
|
|
||||||
|
/* Initialize current read pointer to first element (used in ISR) */
|
||||||
|
rx_read_entry = rx_buf[0];
|
||||||
|
|
||||||
|
smartrf_settings_cmd_prop_rx_adv.pQueue = &rx_data_queue;
|
||||||
|
smartrf_settings_cmd_prop_rx_adv.pOutput = (uint8_t *)&rx_stats;
|
||||||
|
|
||||||
|
set_channel(RF_CORE_CHANNEL);
|
||||||
|
|
||||||
|
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
||||||
|
|
||||||
|
process_start(&rf_core_process, NULL);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
PROCESS_THREAD(rf_core_process, ev, data)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
|
||||||
|
do {
|
||||||
|
watchdog_periodic();
|
||||||
|
packetbuf_clear();
|
||||||
|
len = NETSTACK_RADIO.read(packetbuf_dataptr(), PACKETBUF_SIZE);
|
||||||
|
|
||||||
|
if(len > 0) {
|
||||||
|
packetbuf_set_datalen(len);
|
||||||
|
|
||||||
|
NETSTACK_MAC.input();
|
||||||
|
}
|
||||||
|
} while(len > 0);
|
||||||
|
}
|
||||||
|
PROCESS_END();
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
const struct radio_driver prop_mode_driver = {
|
const struct radio_driver prop_mode_driver = {
|
||||||
init,
|
rf_init,
|
||||||
prepare,
|
prepare,
|
||||||
transmit,
|
transmit,
|
||||||
send,
|
send,
|
||||||
|
@ -136,46 +136,46 @@ static uint32_t pOverrides[] =
|
|||||||
|
|
||||||
// CMD_PROP_RADIO_DIV_SETUP
|
// CMD_PROP_RADIO_DIV_SETUP
|
||||||
// Proprietary Mode Radio Setup Command for All Frequency Bands
|
// Proprietary Mode Radio Setup Command for All Frequency Bands
|
||||||
rfc_CMD_PROP_RADIO_DIV_SETUP_t RF_cmdPropRadioDivSetup =
|
rfc_CMD_PROP_RADIO_DIV_SETUP_t smartrf_settings_cmd_prop_radio_div_setup =
|
||||||
{
|
{
|
||||||
.commandNo = 0x3807,
|
.commandNo = 0x3807,
|
||||||
.status = 0x0000,
|
.status = 0x0000,
|
||||||
.pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
|
.pNextOp = 0,
|
||||||
.startTime = 0x00000000,
|
.startTime = 0x00000000,
|
||||||
.startTrigger.triggerType = 0x0,
|
.startTrigger.triggerType = 0x0,
|
||||||
.startTrigger.bEnaCmd = 0x0,
|
.startTrigger.bEnaCmd = 0x0,
|
||||||
.startTrigger.triggerNo = 0x0,
|
.startTrigger.triggerNo = 0x0,
|
||||||
.startTrigger.pastTrig = 0x0,
|
.startTrigger.pastTrig = 0x0,
|
||||||
.condition.rule = 0x1,
|
.condition.rule = 0x1,
|
||||||
.condition.nSkip = 0x0,
|
.condition.nSkip = 0x0,
|
||||||
.modulation.modType = 0x1,
|
.modulation.modType = 0x1,
|
||||||
.modulation.deviation = 0x64,
|
.modulation.deviation = 0x64,
|
||||||
.modulation.deviationStepSz = 0x0,
|
.symbolRate.preScale = 0xf,
|
||||||
.symbolRate.preScale = 0xF,
|
.symbolRate.rateWord = 0x8000,
|
||||||
.symbolRate.rateWord = 0x8000,
|
.rxBw = 0x24,
|
||||||
.symbolRate.decimMode = 0x0,
|
.preamConf.nPreamBytes = 0x3,
|
||||||
.rxBw = 0x52,
|
.preamConf.preamMode = 0x0,
|
||||||
.preamConf.nPreamBytes = 0x4,
|
.formatConf.nSwBits = 0x18,
|
||||||
.preamConf.preamMode = 0x0,
|
.formatConf.bBitReversal = 0x0,
|
||||||
.formatConf.nSwBits = 0x20,
|
.formatConf.bMsbFirst = 0x1,
|
||||||
.formatConf.bBitReversal = 0x0,
|
.formatConf.fecMode = 0x0,
|
||||||
.formatConf.bMsbFirst = 0x1,
|
|
||||||
.formatConf.fecMode = 0x0,
|
/* 7: .4g mode with dynamic whitening and CRC choice */
|
||||||
.formatConf.whitenMode = 0x0,
|
.formatConf.whitenMode = 0x7,
|
||||||
.config.frontEndMode = 0x0,
|
.config.frontEndMode = 0x00, /* Set by the driver */
|
||||||
.config.biasMode = 0x1,
|
.config.biasMode = 0x00, /* Set by the driver */
|
||||||
.config.analogCfgMode = 0x0,
|
.config.analogCfgMode = 0x0,
|
||||||
.config.bNoFsPowerUp = 0x0,
|
.config.bNoFsPowerUp = 0x0,
|
||||||
.txPower = 0x9F3F,
|
.txPower = 0x00, /* Driver sets correct value */
|
||||||
.pRegOverride = pOverrides,
|
.pRegOverride = pOverrides,
|
||||||
.centerFreq = 0x0364,
|
.intFreq = 0x8000,
|
||||||
.intFreq = 0x8000,
|
.centerFreq = 868,
|
||||||
.loDivider = 0x05,
|
.loDivider = 0x05,
|
||||||
};
|
};
|
||||||
|
|
||||||
// CMD_FS
|
// CMD_FS
|
||||||
// Frequency Synthesizer Programming Command
|
// Frequency Synthesizer Programming Command
|
||||||
rfc_CMD_FS_t RF_cmdFs =
|
rfc_CMD_FS_t smartrf_settings_cmd_prop_fs =
|
||||||
{
|
{
|
||||||
.commandNo = 0x0803,
|
.commandNo = 0x0803,
|
||||||
.status = 0x0000,
|
.status = 0x0000,
|
||||||
@ -196,3 +196,84 @@ rfc_CMD_FS_t RF_cmdFs =
|
|||||||
.__dummy2 = 0x00,
|
.__dummy2 = 0x00,
|
||||||
.__dummy3 = 0x0000,
|
.__dummy3 = 0x0000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* CMD_PROP_TX_ADV */
|
||||||
|
rfc_CMD_PROP_TX_ADV_t smartrf_settings_cmd_prop_tx_adv =
|
||||||
|
{
|
||||||
|
.commandNo = 0x3803,
|
||||||
|
.status = 0x0000,
|
||||||
|
.pNextOp = 0,
|
||||||
|
.startTime = 0x00000000,
|
||||||
|
.startTrigger.triggerType = 0x0,
|
||||||
|
.startTrigger.bEnaCmd = 0x0,
|
||||||
|
.startTrigger.triggerNo = 0x0,
|
||||||
|
.startTrigger.pastTrig = 0x0,
|
||||||
|
.condition.rule = 0x1,
|
||||||
|
.condition.nSkip = 0x0,
|
||||||
|
.pktConf.bFsOff = 0x0,
|
||||||
|
.pktConf.bUseCrc = 0x1,
|
||||||
|
.pktConf.bCrcIncSw = 0x0, /* .4g mode */
|
||||||
|
.pktConf.bCrcIncHdr = 0x0, /* .4g mode */
|
||||||
|
.numHdrBits = 0x10 /* 16: .4g mode */,
|
||||||
|
.pktLen = 0x0000,
|
||||||
|
.startConf.bExtTxTrig = 0x0,
|
||||||
|
.startConf.inputMode = 0x0,
|
||||||
|
.startConf.source = 0x0,
|
||||||
|
.preTrigger.triggerType = TRIG_REL_START,
|
||||||
|
.preTrigger.bEnaCmd = 0x0,
|
||||||
|
.preTrigger.triggerNo = 0x0,
|
||||||
|
.preTrigger.pastTrig = 0x1,
|
||||||
|
.preTime = 0x00000000,
|
||||||
|
.syncWord = 0x0055904e,
|
||||||
|
.pPkt = 0,
|
||||||
|
};
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* CMD_PROP_RX_ADV */
|
||||||
|
rfc_CMD_PROP_RX_ADV_t smartrf_settings_cmd_prop_rx_adv =
|
||||||
|
{
|
||||||
|
.commandNo = 0x3804,
|
||||||
|
.status = 0x0000,
|
||||||
|
.pNextOp = 0,
|
||||||
|
.startTime = 0x00000000,
|
||||||
|
.startTrigger.triggerType = 0x0,
|
||||||
|
.startTrigger.bEnaCmd = 0x0,
|
||||||
|
.startTrigger.triggerNo = 0x0,
|
||||||
|
.startTrigger.pastTrig = 0x0,
|
||||||
|
.condition.rule = 0x1,
|
||||||
|
.condition.nSkip = 0x0,
|
||||||
|
.pktConf.bFsOff = 0x0,
|
||||||
|
.pktConf.bRepeatOk = 0x1,
|
||||||
|
.pktConf.bRepeatNok = 0x1,
|
||||||
|
.pktConf.bUseCrc = 0x1,
|
||||||
|
.pktConf.bCrcIncSw = 0x0, /* .4g mode */
|
||||||
|
.pktConf.bCrcIncHdr = 0x0, /* .4g mode */
|
||||||
|
.pktConf.endType = 0x0,
|
||||||
|
.pktConf.filterOp = 0x1,
|
||||||
|
.rxConf.bAutoFlushIgnored = 0x1,
|
||||||
|
.rxConf.bAutoFlushCrcErr = 0x1,
|
||||||
|
.rxConf.bIncludeHdr = 0x0,
|
||||||
|
.rxConf.bIncludeCrc = 0x0,
|
||||||
|
.rxConf.bAppendRssi = 0x1,
|
||||||
|
.rxConf.bAppendTimestamp = 0x0,
|
||||||
|
.rxConf.bAppendStatus = 0x1,
|
||||||
|
.syncWord0 = 0x0055904e,
|
||||||
|
.syncWord1 = 0x00000000,
|
||||||
|
.maxPktLen = 0x0000, /* To be populated by the driver. */
|
||||||
|
.hdrConf.numHdrBits = 0x10, /* 16: .4g mode */
|
||||||
|
.hdrConf.lenPos = 0x0, /* .4g mode */
|
||||||
|
.hdrConf.numLenBits = 0x0B, /* 11 = 0x0B .4g mode */
|
||||||
|
.addrConf.addrType = 0x0,
|
||||||
|
.addrConf.addrSize = 0x0,
|
||||||
|
.addrConf.addrPos = 0x0,
|
||||||
|
.addrConf.numAddr = 0x0,
|
||||||
|
.lenOffset = -4, /* .4g mode */
|
||||||
|
.endTrigger.triggerType = TRIG_NEVER,
|
||||||
|
.endTrigger.bEnaCmd = 0x0,
|
||||||
|
.endTrigger.triggerNo = 0x0,
|
||||||
|
.endTrigger.pastTrig = 0x0,
|
||||||
|
.endTime = 0x00000000,
|
||||||
|
.pAddr = 0,
|
||||||
|
.pQueue = 0,
|
||||||
|
.pOutput = 0,
|
||||||
|
};
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -13,16 +13,14 @@
|
|||||||
#include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h)
|
#include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h)
|
||||||
#include <ti/drivers/rf/RF.h>
|
#include <ti/drivers/rf/RF.h>
|
||||||
|
|
||||||
|
|
||||||
// TI-RTOS RF Mode Object
|
// TI-RTOS RF Mode Object
|
||||||
extern RF_Mode RF_prop;
|
extern RF_Mode RF_prop;
|
||||||
|
|
||||||
|
|
||||||
// RF Core API commands
|
// RF Core API commands
|
||||||
extern rfc_CMD_PROP_RADIO_DIV_SETUP_t RF_cmdPropRadioDivSetup;
|
extern rfc_CMD_PROP_RADIO_DIV_SETUP_t smartrf_settings_cmd_prop_radio_div_setup;
|
||||||
extern rfc_CMD_FS_t RF_cmdFs;
|
extern rfc_CMD_FS_t smartrf_settings_cmd_prop_fs;
|
||||||
extern rfc_CMD_PROP_TX_t RF_cmdPropTx;
|
extern rfc_CMD_PROP_TX_ADV_t smartrf_settings_cmd_prop_tx_adv;
|
||||||
extern rfc_CMD_PROP_RX_t RF_cmdPropRx;
|
extern rfc_CMD_PROP_RX_ADV_t smartrf_settings_cmd_prop_rx_adv;
|
||||||
|
|
||||||
|
|
||||||
#endif // _PROPRIETARY_RF_SETTINGS_H_
|
#endif // _PROPRIETARY_RF_SETTINGS_H_
|
||||||
|
@ -57,27 +57,20 @@
|
|||||||
|
|
||||||
#include "uart0-arch.h"
|
#include "uart0-arch.h"
|
||||||
|
|
||||||
//#include "leds.h"
|
#include "leds.h"
|
||||||
//#include "lpm.h"
|
|
||||||
//#include "gpio-interrupt.h"
|
//#include "gpio-interrupt.h"
|
||||||
//#include "dev/oscillators.h"
|
#include "ieee-addr.h"
|
||||||
//#include "ieee-addr.h"
|
|
||||||
//#include "vims.h"
|
|
||||||
//#include "dev/cc26xx-uart.h"
|
|
||||||
//#include "dev/soc-rtc.h"
|
|
||||||
//#include "rf-core/rf-core.h"
|
|
||||||
//#include "sys_ctrl.h"
|
|
||||||
//#include "uart.h"
|
//#include "uart.h"
|
||||||
//#include "sys/clock.h"
|
#include "sys/clock.h"
|
||||||
//#include "sys/rtimer.h"
|
#include "sys/rtimer.h"
|
||||||
//#include "sys/node-id.h"
|
#include "sys/node-id.h"
|
||||||
//#include "sys/platform.h"
|
#include "sys/platform.h"
|
||||||
//#include "lib/random.h"
|
#include "lib/random.h"
|
||||||
//#include "lib/sensors.h"
|
#include "lib/sensors.h"
|
||||||
//#include "button-sensor.h"
|
#include "button-sensor.h"
|
||||||
//#include "dev/serial-line.h"
|
#include "dev/serial-line.h"
|
||||||
//#include "net/mac/framer/frame802154.h"
|
#include "net/mac/framer/frame802154.h"
|
||||||
//
|
|
||||||
//#include "driverlib/driverlib_release.h"
|
//#include "driverlib/driverlib_release.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -111,25 +104,25 @@ fade(unsigned char l)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
//static void
|
static void
|
||||||
//set_rf_params(void)
|
set_rf_params(void)
|
||||||
//{
|
{
|
||||||
// uint16_t short_addr;
|
uint16_t short_addr;
|
||||||
// uint8_t ext_addr[8];
|
uint8_t ext_addr[8];
|
||||||
//
|
|
||||||
// ieee_addr_cpy_to(ext_addr, 8);
|
ieee_addr_cpy_to(ext_addr, 8);
|
||||||
//
|
|
||||||
// short_addr = ext_addr[7];
|
short_addr = ext_addr[7];
|
||||||
// short_addr |= ext_addr[6] << 8;
|
short_addr |= ext_addr[6] << 8;
|
||||||
//
|
|
||||||
// NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
|
NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
|
||||||
// NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr);
|
NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr);
|
||||||
// NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, RF_CORE_CHANNEL);
|
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, RF_CORE_CHANNEL);
|
||||||
// NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8);
|
NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8);
|
||||||
//
|
|
||||||
// /* also set the global node id */
|
/* also set the global node id */
|
||||||
// node_id = short_addr;
|
node_id = short_addr;
|
||||||
//}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
platform_init_stage_one()
|
platform_init_stage_one()
|
||||||
@ -178,8 +171,8 @@ platform_init_stage_two()
|
|||||||
//
|
//
|
||||||
// serial_line_init();
|
// serial_line_init();
|
||||||
//
|
//
|
||||||
// /* Populate linkaddr_node_addr */
|
/* Populate linkaddr_node_addr */
|
||||||
// ieee_addr_cpy_to(linkaddr_node_addr.u8, LINKADDR_SIZE);
|
ieee_addr_cpy_to(linkaddr_node_addr.u8, LINKADDR_SIZE);
|
||||||
//
|
//
|
||||||
fade(Board_GPIO_LED0);
|
fade(Board_GPIO_LED0);
|
||||||
}
|
}
|
||||||
@ -187,13 +180,13 @@ platform_init_stage_two()
|
|||||||
void
|
void
|
||||||
platform_init_stage_three()
|
platform_init_stage_three()
|
||||||
{
|
{
|
||||||
// radio_value_t chan, pan;
|
radio_value_t chan, pan;
|
||||||
//
|
|
||||||
// set_rf_params();
|
set_rf_params();
|
||||||
//
|
|
||||||
// NETSTACK_RADIO.get_value(RADIO_PARAM_CHANNEL, &chan);
|
NETSTACK_RADIO.get_value(RADIO_PARAM_CHANNEL, &chan);
|
||||||
// NETSTACK_RADIO.get_value(RADIO_PARAM_PAN_ID, &pan);
|
NETSTACK_RADIO.get_value(RADIO_PARAM_PAN_ID, &pan);
|
||||||
//
|
|
||||||
LOG_DBG("With DriverLib v%u.%u\n", DRIVERLIB_RELEASE_GROUP,
|
LOG_DBG("With DriverLib v%u.%u\n", DRIVERLIB_RELEASE_GROUP,
|
||||||
DRIVERLIB_RELEASE_BUILD);
|
DRIVERLIB_RELEASE_BUILD);
|
||||||
//LOG_INFO(BOARD_STRING "\n");
|
//LOG_INFO(BOARD_STRING "\n");
|
||||||
@ -202,8 +195,8 @@ platform_init_stage_three()
|
|||||||
ChipInfo_ChipFamilyIs_CC13x0() ? "Yes" : "No",
|
ChipInfo_ChipFamilyIs_CC13x0() ? "Yes" : "No",
|
||||||
ChipInfo_SupportsBLE() ? "Yes" : "No",
|
ChipInfo_SupportsBLE() ? "Yes" : "No",
|
||||||
ChipInfo_SupportsPROPRIETARY() ? "Yes" : "No");
|
ChipInfo_SupportsPROPRIETARY() ? "Yes" : "No");
|
||||||
//LOG_INFO(" RF: Channel %d, PANID 0x%04X\n", chan, pan);
|
LOG_INFO(" RF: Channel %d, PANID 0x%04X\n", chan, pan);
|
||||||
//LOG_INFO(" Node ID: %d\n", node_id);
|
LOG_INFO(" Node ID: %d\n", node_id);
|
||||||
//
|
//
|
||||||
// process_start(&sensors_process, NULL);
|
// process_start(&sensors_process, NULL);
|
||||||
fade(Board_GPIO_LED1);
|
fade(Board_GPIO_LED1);
|
||||||
|
Loading…
Reference in New Issue
Block a user