Fixed doxygen

This commit is contained in:
Edvard Pettersen 2018-07-23 14:35:37 +02:00
parent abe82f3d8e
commit 1d0f6227dc
16 changed files with 317 additions and 247 deletions

View File

@ -45,6 +45,14 @@
#include "rf/rf.h"
/*---------------------------------------------------------------------------*/
#ifndef BOARD_CONF_HAS_SENSORS
#define BOARD_CONF_HAS_SENSORS 0
#endif
#ifndef BOARD_CONF_SENSORS_ENABLE
#define BOARD_CONF_SENSORS_ENABLE BOARD_CONF_HAS_SENSORS
#endif
/*---------------------------------------------------------------------------*/
/**
* \name GPIO HAL configuration.
*

View File

@ -26,14 +26,16 @@
* 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
* Driver for the retrieval of an BLE address from flash
* \addtogroup cc13xx-cc26xx-rf-ble-addr
* @{
*
* \file
* Implementation of the CC13xx/CC26xx IEEE addresses driver.
* \author
* Michael Spoerk <mi.spoerk@gmail.com>
* Michael Spoerk <mi.spoerk@gmail.com>
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
@ -131,3 +133,5 @@ ble_addr_to_eui64_cpy(uint8_t *dst)
return ble_addr_to_eui64(dst, ble_addr);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -26,15 +26,20 @@
* 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
* Driver for the retrieval of an BLE address from flash
* \addtogroup cc13xx-cc26xx-rf
* @{
*
* \defgroup cc13xx-cc26xx-rf-ble-addr Driver for CC13xx/CC26xx BLE addresses
*
* @{
*
* \file
* Header file for the CC13xx/CC26xx BLE address driver.
* \author
* Michael Spoerk <mi.spoerk@gmail.com>
* Michael Spoerk <mi.spoerk@gmail.com>
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#ifndef BLE_ADDR_H_
@ -44,6 +49,12 @@
#include <stdint.h>
/*---------------------------------------------------------------------------*/
/**
* \brief Retrieve the pointer to where the BLE address is stored.
*
* This function will return the primary address from info page, unless a
* valid address is found in the secondary address from CCFG.
*/
uint8_t* ble_addr_ptr(void);
/*---------------------------------------------------------------------------*/
/**

View File

@ -1,6 +1,5 @@
/*
* Copyright (c) 2015, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2017, University of Bristol - http://www.bristol.ac.uk/
* Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -28,22 +27,23 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup rf-core-ble
* \addtogroup cc13xx-cc26xx-rf-ble
* @{
*
* \file
* Implementation of the CC13xx/CC26xx RF BLE driver
* Implementation for the CC13xx/CC26xx BLE Beacon Daemon.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "sys/process.h"
#include "sys/clock.h"
#include "sys/cc.h"
#include "sys/clock.h"
#include "sys/etimer.h"
#include "net/netstack.h"
#include "sys/process.h"
#include "net/linkaddr.h"
#include "net/netstack.h"
/*---------------------------------------------------------------------------*/
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/chipinfo.h)
@ -155,7 +155,7 @@ rf_ble_beacond_init(void)
ble_beacond.handle = ble_open(&rf_params);
if (ble_beacond.handle == NULL) {
if(ble_beacond.handle == NULL) {
return RF_BLE_BEACOND_ERROR;
}
@ -165,11 +165,11 @@ rf_ble_beacond_init(void)
rf_ble_beacond_result_t
rf_ble_beacond_start(clock_time_t interval, const char *name)
{
if (interval == 0) {
if(interval == 0) {
return RF_BLE_BEACOND_ERROR;
}
if (name == NULL) {
if(name == NULL) {
return RF_BLE_BEACOND_ERROR;
}
@ -177,7 +177,7 @@ rf_ble_beacond_start(clock_time_t interval, const char *name)
const size_t name_len = strlen(name);
if ((name_len == 0) ||
if((name_len == 0) ||
(name_len >= BLE_ADV_NAME_BUF_LEN)) {
return RF_BLE_BEACOND_ERROR;
}
@ -213,7 +213,7 @@ rf_ble_set_tx_power(int8_t dBm)
{
rf_result_t res;
if (!TX_POWER_IN_RANGE(dBm)) {
if(!TX_POWER_IN_RANGE(dBm)) {
return RADIO_RESULT_INVALID_VALUE;
}
@ -232,7 +232,7 @@ rf_ble_get_tx_power(void)
int8_t dbm;
res = rf_get_tx_power(ble_beacond.rf_handle, TX_POWER_TABLE, &dbm)
if (res != RF_RESULT_OK) {
if(res != RF_RESULT_OK) {
return ~(int8_t)0;
}
@ -245,9 +245,9 @@ ble_beacon_burst(uint8_t channels_bm, uint8_t *data, uint8_t len)
rf_result_t res;
uint8_t channel;
for (channel = BLE_ADV_CHANNEL_MIN; channel <= BLE_ADV_CHANNEL_MAX; ++channel) {
for(channel = BLE_ADV_CHANNEL_MIN; channel <= BLE_ADV_CHANNEL_MAX; ++channel) {
const uint8_t channel_bv = (1 << (channel - BLE_ADV_CHANNEL_MIN));
if ((channel_bv & channels_bm) == 0) {
if((channel_bv & channels_bm) == 0) {
continue;
}
@ -258,7 +258,7 @@ ble_beacon_burst(uint8_t channels_bm, uint8_t *data, uint8_t len)
res = ble_sched_beacon(NULL, 0);
if (res != RF_RESULT_OK) {
if(res != RF_RESULT_OK) {
return RF_BLE_BEACOND_ERROR;
}
}
@ -332,7 +332,4 @@ rf_ble_get_tx_power(void) { return ~(int8_t)(0); }
/*---------------------------------------------------------------------------*/
#endif /* RF_BLE_BEACON_ENABLE */
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/
/** @} */

View File

@ -1,6 +1,5 @@
/*
* Copyright (c) 2015, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2017, University of Bristol - http://www.bristol.ac.uk/
* Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -28,24 +27,25 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup rf-core
* \addtogroup cc13xx-cc26xx-rf
* @{
*
* \defgroup rf-core-ble CC13xx/CC26xx BLE driver
* \defgroup cc13xx-cc26xx-rf-ble CC13xx/CC26xx BLE Beacon Daemon
*
* @{
*
* \file
* Header file for the CC13xx/CC26xx BLE driver
* Header file for the CC13xx/CC26xx BLE Beacon Daemon.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#ifndef RF_BLE_BEACOND_H_
#define RF_BLE_BEACOND_H_
/*---------------------------------------------------------------------------*/
#include "contiki.h"
/*---------------------------------------------------------------------------*/
#include <stdint.h>
/*---------------------------------------------------------------------------*/
typedef enum {
@ -53,6 +53,7 @@ typedef enum {
RF_BLE_BEACOND_ERROR,
RF_BLE_BEACOND_DISABLED,
} rf_ble_beacond_result_t;
/*---------------------------------------------------------------------------*/
/**
* \brief Set the device name to use with the BLE advertisement/beacon daemon
* \param interval The interval (ticks) between two consecutive beacon bursts
@ -65,7 +66,7 @@ typedef enum {
rf_ble_beacond_result_t rf_ble_beacond_init(void);
/**
* \brief Start the BLE advertisement/beacon daemon
* \brief Start the BLE advertisement/beacon daemon
* \return RF_CORE_CMD_OK: Success, RF_CORE_CMD_ERROR: Failure
*
* Before calling this function, the name to advertise must first be set by
@ -99,8 +100,8 @@ int8_t rf_ble_is_active(void);
rf_ble_beacond_result_t rf_ble_set_tx_power(int8_t dbm);
/**
* \brief Get TX power for BLE advertisements
* \return The TX power for BLE advertisements
* \brief Get TX power for BLE advertisements
* \return The TX power for BLE advertisements
*/
int8_t rf_ble_get_tx_power(void);
/*---------------------------------------------------------------------------*/

View File

@ -27,13 +27,14 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup simplelink
* \addtogroup cc13xx-cc26xx-rf-data-queue
* @{
*
* \file
* Implementation of common CC13xx/CC26xx RF functionality
* Implementation of the CC13xx/CC26xx RF data queue.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
@ -75,9 +76,11 @@ static rx_data_queue_t rx_data_queue;
static void
rx_bufs_init(void)
{
data_entry_t *data_entry;
size_t i;
for (i = 0; i < RX_BUF_CNT; ++i) {
data_entry_t *const data_entry = &(rx_data_queue.bufs[i].data_entry);
for(i = 0; i < RX_BUF_CNT; ++i) {
data_entry = &(rx_data_queue.bufs[i].data_entry);
data_entry->status = DATA_ENTRY_PENDING;
data_entry->config.type = DATA_ENTRY_TYPE_GEN;
@ -94,7 +97,7 @@ static void
rx_bufs_reset(void)
{
size_t i;
for (i = 0; i < RX_BUF_CNT; ++i) {
for(i = 0; i < RX_BUF_CNT; ++i) {
data_entry_t *const data_entry = &(rx_data_queue.bufs[i].data_entry);
/* Clear length bytes */
@ -155,3 +158,4 @@ data_queue_release_entry(void)
rx_data_queue.curr_entry = (data_entry_t*)(curr_entry->pNextEntry);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -27,6 +27,19 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc13xx-cc26xx-rf
* @{
*
* \defgroup cc13xx-cc26xx-rf-data-queue RF data queue for CC13xx/CC26xx
*
* @{
*
* \file
* Header file of the CC13xx/CC26xx RF data queue.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#ifndef RF_DATA_QUEUE_H_
#define RF_DATA_QUEUE_H_
@ -43,12 +56,13 @@ typedef dataQueue_t data_queue_t;
typedef rfc_dataEntryGeneral_t data_entry_t;
/*---------------------------------------------------------------------------*/
data_queue_t* data_queue_init(size_t lensz);
/*---------------------------------------------------------------------------*/
void data_queue_reset(void);
/*---------------------------------------------------------------------------*/
void data_queue_reset(void);
data_entry_t* data_queue_current_entry(void);
/*---------------------------------------------------------------------------*/
void data_queue_release_entry(void);
void data_queue_release_entry(void);
/*---------------------------------------------------------------------------*/
#endif /* RF_DATA_QUEUE_H_ */
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -27,18 +27,19 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup rf-core
* \addtogroup cc13xx-cc26xx-rf
* @{
*
* \defgroup rf-core-15-4g-modes IEEE 802.15.4g Frequency Bands and Modes
* \defgroup cc13xx-cc26xx-rf-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
* Header file with descriptors for the various modes of operation
* defined in IEEE 802.15.4g.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#ifndef DOT_15_4G_H_
@ -149,19 +150,19 @@
static inline uint32_t
dot_15_4g_freq(const uint16_t chan)
{
const uint32_t chan0 = DOT_15_4G_CHAN0_FREQ;
const uint32_t spacing = DOT_15_4G_FREQ_SPACING;
const uint32_t chan_min = DOT_15_4G_CHAN_MIN;
return (chan0 + spacing * ((uint32_t)chan - chan_min));
const uint32_t chan0 = DOT_15_4G_CHAN0_FREQ;
const uint32_t spacing = DOT_15_4G_FREQ_SPACING;
const uint32_t chan_min = DOT_15_4G_CHAN_MIN;
return (chan0 + spacing * ((uint32_t)chan - chan_min));
}
/*---------------------------------------------------------------------------*/
static inline bool
dot_15_4g_chan_in_range(const uint16_t chan)
{
const uint16_t chan_min = DOT_15_4G_CHAN_MIN;
const uint16_t chan_max = DOT_15_4G_CHAN_MAX;
return ((chan >= chan_min) &&
(chan <= chan_max));
const uint16_t chan_min = DOT_15_4G_CHAN_MIN;
const uint16_t chan_max = DOT_15_4G_CHAN_MAX;
return ((chan >= chan_min) &&
(chan <= chan_max));
}
/*---------------------------------------------------------------------------*/
#define DOT_15_4G_DEFAULT_CHAN IEEE802154_DEFAULT_CHANNEL

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -10,7 +10,6 @@
* 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.
@ -28,13 +27,14 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc26xx-ieee-addr
* \addtogroup cc13xx-cc26xx-rf-ieee-addr
* @{
*
* \file
* Driver for the CC13xx/CC26xx IEEE addresses
* Implementation of the CC13xx/CC26xx IEEE addresses driver.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
@ -50,22 +50,23 @@
#include <stdint.h>
#include <string.h>
/*---------------------------------------------------------------------------*/
#define IEEE_ADDR_HARDCODED IEEE_ADDR_CONF_HARDCODED
#define IEEE_ADDR_ADDRESS IEEE_ADDR_CONF_ADDRESS
/*---------------------------------------------------------------------------*/
#define IEEE_MAC_PRIMARY_ADDRESS (FCFG1_BASE + FCFG1_O_MAC_15_4_0)
#define IEEE_MAC_SECONDARY_ADDRESS (CCFG_BASE + CCFG_O_IEEE_MAC_0)
/*---------------------------------------------------------------------------*/
#define IEEE_ADDR_SIZE 8
/*---------------------------------------------------------------------------*/
int
ieee_addr_cpy_to(uint8_t *dst, uint8_t len)
{
if (len > IEEE_ADDR_SIZE) {
if(len > LINKADDR_SIZE) {
return -1;
}
if(IEEE_ADDR_CONF_HARDCODED) {
const uint8_t ieee_addr_hc[IEEE_ADDR_SIZE] = IEEE_ADDR_CONF_ADDRESS;
if(IEEE_ADDR_HARDCODED) {
const uint8_t ieee_addr_hc[LINKADDR_SIZE] = IEEE_ADDR_ADDRESS;
memcpy(dst, &ieee_addr_hc[IEEE_ADDR_SIZE - len], len);
memcpy(dst, &ieee_addr_hc[LINKADDR_SIZE - len], len);
} else {
int i;
@ -76,13 +77,13 @@ ieee_addr_cpy_to(uint8_t *dst, uint8_t len)
volatile const uint8_t *ieee_addr = primary;
/*
* ...unless we can find a byte != 0xFF in secondary
* ...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 address irrespective of the
* are checking validity of the entire address respective of the
* actual number of bytes the caller wants to copy over.
*/
for(i = 0; i < IEEE_ADDR_SIZE; i++) {
for(i = 0; i < len; i++) {
if(secondary[i] != 0xFF) {
/* A byte in the secondary location is not 0xFF. Use the secondary */
ieee_addr = secondary;
@ -92,7 +93,7 @@ ieee_addr_cpy_to(uint8_t *dst, uint8_t len)
/*
* We have chosen what address to read the address from. Do so,
* inverting byte order
* in inverted byte order.
*/
for(i = 0; i < len; i++) {
dst[i] = ieee_addr[len - 1 - i];

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -10,7 +10,6 @@
* 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.
@ -28,14 +27,13 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc26xx
* \addtogroup cc13xx-cc26xx-cpu
* @{
*
* \defgroup cc26xx-ieee-addr CC13xx/CC26xx IEEE Address Control
* \defgroup cc13xx-cc26xx-rf-ieee-addr CC13xx/CC26xx IEEE Address Control
*
* Driver for the retrieval of an IEEE address from flash
* 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.
@ -57,8 +55,9 @@
* @{
*
* \file
* Header file with register and macro declarations for the cc26xx IEEE address
* driver
* Header file for the CC13xx/CC26xx IEEE address driver.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#ifndef IEEE_ADDR_H_
@ -67,15 +66,15 @@
#include "contiki.h"
/*---------------------------------------------------------------------------*/
/**
* \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
* \brief Copy the device's IEEE address to a destination buffer.
* \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
* \return 0 : Returned successfully
* -1 : Returned with error
*
* 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,
* This function will copy \p len bytes in LSB 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.
*/
int ieee_addr_cpy_to(uint8_t *dst, uint8_t len);

View File

@ -27,17 +27,18 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup rf-core
* \addtogroup cc13xx-cc26xx-rf
* @{
*
* \defgroup rf-core-ieee CC13xx/CC26xx IEEE mode driver
* \defgroup cc13xx-cc26xx-rf-ieee IEEE-mode driver for CC13xx/CC26xx
*
* @{
*
* \file
* Implementation of the CC13xx/CC26xx IEEE mode NETSTACK_RADIO driver
* Implementation of the CC13xx/CC26xx IEEE-mode NETSTACK_RADIO driver.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
@ -300,7 +301,7 @@ init_rf_params(void)
static rf_result_t
set_channel(uint8_t channel)
{
if (!dot_15_4g_chan_in_range(channel)) {
if(!dot_15_4g_chan_in_range(channel)) {
PRINTF("set_channel: illegal channel %d, defaults to %d\n",
(int)channel, DOT_15_4G_DEFAULT_CHAN);
channel = DOT_15_4G_DEFAULT_CHAN;
@ -311,7 +312,7 @@ set_channel(uint8_t channel)
* set_channel() to cause a synth calibration, since channel must be in
* range 11-26.
*/
if (channel == cmd_rx.channel) {
if(channel == cmd_rx.channel) {
/* We are already calibrated to this channel */
return true;
}
@ -342,7 +343,7 @@ check_rat_overflow(void)
{
const bool was_off = !rx_is_active();
if (was_off) {
if(was_off) {
RF_runDirectCmd(ieee_radio.rf_handle, CMD_NOP);
}
@ -351,12 +352,12 @@ check_rat_overflow(void)
static bool initial_iteration = true;
static uint32_t last_value;
if (initial_iteration) {
if(initial_iteration) {
/* First time checking overflow will only store the current value */
initial_iteration = false;
} else {
/* Overflow happens in the last quarter of the RAT range */
if ((current_value + RAT_ONE_QUARTER) < last_value) {
if((current_value + RAT_ONE_QUARTER) < last_value) {
/* Overflow detected */
ieee_radio.rat.last_overflow = RTIMER_NOW();
ieee_radio.rat.overflow_count += 1;
@ -365,7 +366,7 @@ check_rat_overflow(void)
last_value = current_value;
if (was_off) {
if(was_off) {
RF_yield(ieee_radio.rf_handle);
}
}
@ -379,9 +380,9 @@ rat_to_timestamp(const uint32_t rat_ticks)
/* If the timestamp is in the 4th quarter and the last overflow was recently,
* assume that the timestamp refers to the time before the overflow */
if (rat_ticks > RAT_THREE_QUARTERS) {
if(rat_ticks > RAT_THREE_QUARTERS) {
const rtimer_clock_t one_quarter = (RAT_ONE_QUARTER * RTIMER_SECOND) / RAT_SECOND;
if (RTIMER_CLOCK_LT(RTIMER_NOW(), ieee_radio.rat.last_overflow + one_quarter)) {
if(RTIMER_CLOCK_LT(RTIMER_NOW(), ieee_radio.rat.last_overflow + one_quarter)) {
adjusted_overflow_count -= 1;
}
}
@ -396,7 +397,7 @@ rat_to_timestamp(const uint32_t rat_ticks)
static int
init(void)
{
if (ieee_radio.rf_handle) {
if(ieee_radio.rf_handle) {
PRINTF("init: Radio already initialized\n");
return RF_RESULT_OK;
}
@ -413,7 +414,7 @@ init(void)
ieee_radio.rf_handle = netstack_open(&rf_params);
if (ieee_radio.rf_handle == NULL) {
if(ieee_radio.rf_handle == NULL) {
PRINTF("init: unable to open IEEE RF driver\n");
return RF_RESULT_ERROR;
}
@ -450,7 +451,7 @@ transmit(unsigned short transmit_len)
{
rf_result_t res;
if (ieee_radio.send_on_cca && channel_clear() != 1) {
if(ieee_radio.send_on_cca && channel_clear() != 1) {
PRINTF("transmit: channel wasn't clear\n");
return RADIO_TX_COLLISION;
}
@ -460,7 +461,7 @@ transmit(unsigned short transmit_len)
* Control Field byte, that is the first byte in the frame.
*/
const bool ack_request = (bool)(ieee_radio.tx_buf[FRAME_FCF_OFFSET] & FRAME_ACK_REQUEST);
if (ack_request) {
if(ack_request) {
/* Yes, turn on chaining */
cmd_tx.condition.rule = COND_STOP_ON_FALSE;
@ -479,11 +480,11 @@ transmit(unsigned short transmit_len)
res = netstack_sched_ieee_tx(ack_request);
if (res != RF_RESULT_OK) {
if(res != RF_RESULT_OK) {
return RADIO_TX_ERR;
}
if (ack_request) {
if(ack_request) {
switch(cmd_rx_ack.status) {
/* CMD_IEEE_RX_ACK timed out, i.e. never received ACK */
case IEEE_DONE_TIMEOUT: return RADIO_TX_NOACK;
@ -513,10 +514,10 @@ read(void *buf, unsigned short buf_len)
const rtimer_clock_t t0 = RTIMER_NOW();
/* Only wait if the Radio timer is accessing the entry */
while ((data_entry->status == DATA_ENTRY_BUSY) &&
while((data_entry->status == DATA_ENTRY_BUSY) &&
RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + TIMEOUT_DATA_ENTRY_BUSY));
if (data_entry->status != DATA_ENTRY_FINISHED) {
if(data_entry->status != DATA_ENTRY_FINISHED) {
/* No available data */
return -1;
}
@ -545,7 +546,7 @@ read(void *buf, unsigned short buf_len)
const lensz_t frame_len = *(lensz_t*)frame_ptr;
/* Sanity check that Frame is at least Frame Shave bytes long */
if (frame_len < FRAME_SHAVE) {
if(frame_len < FRAME_SHAVE) {
PRINTF("read: frame too short len=%d\n", frame_len);
data_queue_release_entry();
@ -556,7 +557,7 @@ read(void *buf, unsigned short buf_len)
const unsigned short payload_len = (unsigned short)(frame_len - FRAME_SHAVE);
/* Sanity check that Payload fits in Buffer */
if (payload_len > buf_len) {
if(payload_len > buf_len) {
PRINTF("read: payload too large for buffer len=%d buf_len=%d\n", payload_len, buf_len);
data_queue_release_entry();
@ -573,7 +574,7 @@ read(void *buf, unsigned short buf_len)
const uint32_t rat_ticks = *(uint32_t*)(payload_ptr + payload_len + 4);
ieee_radio.last.timestamp = rat_to_timestamp(rat_ticks);
if (!ieee_radio.poll_mode) {
if(!ieee_radio.poll_mode) {
/* Not in poll mode: packetbuf should not be accessed in interrupt context. */
/* In poll mode, the last packet RSSI and link quality can be obtained through */
/* RADIO_PARAM_LAST_RSSI and RADIO_PARAM_LAST_LINK_QUALITY */
@ -592,23 +593,23 @@ cca_request(cmd_cca_req_t *cmd_cca_req)
const bool rx_is_idle = !rx_is_active();
if (rx_is_idle) {
if(rx_is_idle) {
res = netstack_sched_rx(false);
if (res != RF_RESULT_OK) {
if(res != RF_RESULT_OK) {
return RF_RESULT_ERROR;
}
}
const rtimer_clock_t t0 = RTIMER_NOW();
while ((cmd_rx.status != ACTIVE) &&
while((cmd_rx.status != ACTIVE) &&
RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + TIMEOUT_ENTER_RX_WAIT));
RF_Stat stat = RF_StatRadioInactiveError;
if (rx_is_active()) {
if(rx_is_active()) {
stat = RF_runImmediateCmd(ieee_radio.rf_handle, (uint32_t*)&cmd_cca_req);
}
if (rx_is_idle) {
if(rx_is_idle) {
netstack_stop_rx();
}
@ -624,7 +625,7 @@ channel_clear(void)
memset(&cmd_cca_req, 0x0, sizeof(cmd_cca_req_t));
cmd_cca_req.commandNo = CMD_IEEE_CCA_REQ;
if (cca_request(&cmd_cca_req) != RF_RESULT_OK) {
if(cca_request(&cmd_cca_req) != RF_RESULT_OK) {
return 0;
}
@ -639,12 +640,12 @@ receiving_packet(void)
memset(&cmd_cca_req, 0x0, sizeof(cmd_cca_req_t));
cmd_cca_req.commandNo = CMD_IEEE_CCA_REQ;
if (cca_request(&cmd_cca_req) != RF_RESULT_OK) {
if(cca_request(&cmd_cca_req) != RF_RESULT_OK) {
return 0;
}
/* If we are transmitting (can only be an ACK here), we are not receiving */
if ((cmd_cca_req.ccaInfo.ccaEnergy == CCA_STATE_BUSY) &&
if((cmd_cca_req.ccaInfo.ccaEnergy == CCA_STATE_BUSY) &&
(cmd_cca_req.ccaInfo.ccaCorr == CCA_STATE_BUSY) &&
(cmd_cca_req.ccaInfo.ccaSync == CCA_STATE_BUSY)) {
PRINTF("receiving_packet: we were TXing ACK\n");
@ -666,16 +667,16 @@ pending_packet(void)
/* Go through RX Circular buffer and check each data entry status */
do {
const uint8_t status = curr_entry->status;
if ((status == DATA_ENTRY_FINISHED) ||
if((status == DATA_ENTRY_FINISHED) ||
(status == DATA_ENTRY_BUSY)) {
num_pending += 1;
}
/* Stop when we have looped the circular buffer */
curr_entry = (data_entry_t *)curr_entry->pNextEntry;
} while (curr_entry != read_entry);
} while(curr_entry != read_entry);
if ((num_pending > 0) && !ieee_radio.poll_mode) {
if((num_pending > 0) && !ieee_radio.poll_mode) {
process_poll(&rf_sched_process);
}
@ -688,7 +689,7 @@ on(void)
{
rf_result_t res;
if (ieee_radio.rf_is_on) {
if(ieee_radio.rf_is_on) {
PRINTF("on: Radio already on\n");
return RF_RESULT_OK;
}
@ -697,7 +698,7 @@ on(void)
res = netstack_sched_rx(true);
if (res != RF_RESULT_OK) {
if(res != RF_RESULT_OK) {
return RF_RESULT_ERROR;
}
@ -708,7 +709,7 @@ on(void)
static int
off(void)
{
if (!ieee_radio.rf_is_on) {
if(!ieee_radio.rf_is_on) {
PRINTF("off: Radio already off\n");
return RF_RESULT_OK;
}
@ -724,7 +725,7 @@ get_value(radio_param_t param, radio_value_t *value)
{
rf_result_t res;
if (!value) {
if(!value) {
return RADIO_RESULT_INVALID_VALUE;
}
@ -755,13 +756,13 @@ get_value(radio_param_t param, radio_value_t *value)
/* RX mode */
case RADIO_PARAM_RX_MODE:
*value = 0;
if (cmd_rx.frameFiltOpt.frameFiltEn) {
if(cmd_rx.frameFiltOpt.frameFiltEn) {
*value |= (radio_value_t)RADIO_RX_MODE_ADDRESS_FILTER;
}
if (cmd_rx.frameFiltOpt.autoAckEn) {
if(cmd_rx.frameFiltOpt.autoAckEn) {
*value |= (radio_value_t)RADIO_RX_MODE_AUTOACK;
}
if (ieee_radio.poll_mode) {
if(ieee_radio.poll_mode) {
*value |= (radio_value_t)RADIO_RX_MODE_POLL_MODE;
}
return RADIO_RESULT_OK;
@ -835,12 +836,12 @@ set_value(radio_param_t param, radio_value_t value)
/* Power Mode */
case RADIO_PARAM_POWER_MODE:
if (value == RADIO_POWER_MODE_ON) {
if(value == RADIO_POWER_MODE_ON) {
return (on() == RF_RESULT_OK)
? RADIO_RESULT_OK
: RADIO_RESULT_ERROR;
} else if (value == RADIO_POWER_MODE_OFF) {
} else if(value == RADIO_POWER_MODE_OFF) {
off();
return RADIO_RESULT_OK;
}
@ -849,7 +850,7 @@ set_value(radio_param_t param, radio_value_t value)
/* Channel */
case RADIO_PARAM_CHANNEL:
if (!dot_15_4g_chan_in_range(value)) {
if(!dot_15_4g_chan_in_range(value)) {
return RADIO_RESULT_INVALID_VALUE;
}
set_channel((uint8_t)value);
@ -858,7 +859,7 @@ set_value(radio_param_t param, radio_value_t value)
/* PAN ID */
case RADIO_PARAM_PAN_ID:
cmd_rx.localPanID = (uint16_t)value;
if (!ieee_radio.rf_is_on) {
if(!ieee_radio.rf_is_on) {
return RADIO_RESULT_OK;
}
@ -871,7 +872,7 @@ set_value(radio_param_t param, radio_value_t value)
/* 16bit address */
case RADIO_PARAM_16BIT_ADDR:
cmd_rx.localShortAddr = (uint16_t)value;
if (!ieee_radio.rf_is_on) {
if(!ieee_radio.rf_is_on) {
return RADIO_RESULT_OK;
}
@ -883,7 +884,7 @@ set_value(radio_param_t param, radio_value_t value)
/* RX Mode */
case RADIO_PARAM_RX_MODE: {
if (value & ~(RADIO_RX_MODE_ADDRESS_FILTER |
if(value & ~(RADIO_RX_MODE_ADDRESS_FILTER |
RADIO_RX_MODE_AUTOACK | RADIO_RX_MODE_POLL_MODE)) {
return RADIO_RESULT_INVALID_VALUE;
}
@ -900,17 +901,17 @@ set_value(radio_param_t param, radio_value_t value)
const bool old_poll_mode = ieee_radio.poll_mode;
ieee_radio.poll_mode = (value & RADIO_RX_MODE_POLL_MODE) != 0;
if (old_poll_mode == ieee_radio.poll_mode) {
if(old_poll_mode == ieee_radio.poll_mode) {
/* Do not turn the radio off and on, just send an update command */
memcpy(&cmd_mod_filt.newFrameFiltOpt, &(rf_cmd_ieee_rx.frameFiltOpt), sizeof(rf_cmd_ieee_rx.frameFiltOpt));
const RF_Stat stat = RF_runImmediateCmd(ieee_radio.rf_handle, (uint32_t*)&cmd_mod_filt);
if (stat != RF_StatCmdDoneSuccess) {
if(stat != RF_StatCmdDoneSuccess) {
PRINTF("setting address filter failed: stat=0x%02X\n", stat);
return RADIO_RESULT_ERROR;
}
return RADIO_RESULT_OK;
}
if (!ieee_radio.rf_is_on) {
if(!ieee_radio.rf_is_on) {
return RADIO_RESULT_OK;
}
@ -931,7 +932,7 @@ set_value(radio_param_t param, radio_value_t value)
/* TX Power */
case RADIO_PARAM_TXPOWER:
if (!TX_POWER_IN_RANGE((int8_t)value)) {
if(!TX_POWER_IN_RANGE((int8_t)value)) {
return RADIO_RESULT_INVALID_VALUE;
}
res = rf_set_tx_power(ieee_radio.rf_handle, TX_POWER_TABLE, (int8_t)value);
@ -942,7 +943,7 @@ set_value(radio_param_t param, radio_value_t value)
/* CCA Threshold */
case RADIO_PARAM_CCA_THRESHOLD:
cmd_rx.ccaRssiThr = (int8_t)value;
if (!ieee_radio.rf_is_on) {
if(!ieee_radio.rf_is_on) {
return RADIO_RESULT_OK;
}
@ -960,7 +961,7 @@ set_value(radio_param_t param, radio_value_t value)
static radio_result_t
get_object(radio_param_t param, void *dest, size_t size)
{
if (!dest) {
if(!dest) {
return RADIO_RESULT_INVALID_VALUE;
}
@ -1000,7 +1001,7 @@ set_object(radio_param_t param, const void *src, size_t size)
{
rf_result_t res;
if (!src) {
if(!src) {
return RADIO_RESULT_INVALID_VALUE;
}
@ -1008,17 +1009,17 @@ set_object(radio_param_t param, const void *src, size_t size)
/* 64-bit address */
case RADIO_PARAM_64BIT_ADDR: {
const size_t destSize = sizeof(cmd_rx.localExtAddr);
if (size != destSize) {
if(size != destSize) {
return RADIO_RESULT_INVALID_VALUE;
}
const uint8_t *pSrc = (const uint8_t *)src;
volatile uint8_t *pDest = (uint8_t *)&(cmd_rx.localExtAddr);
for (size_t i = 0; i < destSize; ++i) {
for(size_t i = 0; i < destSize; ++i) {
pDest[i] = pSrc[destSize - 1 - i];
}
if (!rx_is_active()) {
if(!rx_is_active()) {
return RADIO_RESULT_OK;
}

View File

@ -27,13 +27,18 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup rf-core-prop
* \addtogroup cc13xx-cc26xx-rf
* @{
*
* \defgroup cc13xx-cc26xx-rf-prop Prop-mode driver for CC13xx/CC26xx
*
* @{
*
* \file
* Implementation of the CC13xx prop mode NETSTACK_RADIO driver
* Implementation of the CC13xx/CC26xx prop-mode NETSTACK_RADIO driver.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
@ -218,23 +223,23 @@ get_rssi(void)
const bool rx_is_idle = !rx_is_active();
if (rx_is_idle) {
if(rx_is_idle) {
res = netstack_sched_rx(false);
if (res != RF_RESULT_OK) {
if(res != RF_RESULT_OK) {
return RF_GET_RSSI_ERROR_VAL;
}
}
const rtimer_clock_t t0 = RTIMER_NOW();
while ((cmd_rx.status != ACTIVE) &&
while((cmd_rx.status != ACTIVE) &&
RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + TIMEOUT_ENTER_RX_WAIT));
int8_t rssi = RF_GET_RSSI_ERROR_VAL;
if (rx_is_active()) {
if(rx_is_active()) {
rssi = RF_getRssi(prop_radio.rf_handle);
}
if (rx_is_idle) {
if(rx_is_idle) {
netstack_stop_rx();
}
@ -262,13 +267,13 @@ set_channel(uint16_t channel)
{
rf_result_t res;
if (!dot_15_4g_chan_in_range(channel)) {
if(!dot_15_4g_chan_in_range(channel)) {
PRINTF("set_channel: illegal channel %d, defaults to %d\n",
(int)channel, DOT_15_4G_DEFAULT_CHAN);
channel = DOT_15_4G_DEFAULT_CHAN;
}
if (channel == prop_radio.channel) {
if(channel == prop_radio.channel) {
/* We are already calibrated to this channel */
return RF_RESULT_OK;
}
@ -285,7 +290,7 @@ set_channel(uint16_t channel)
res = netstack_sched_fs();
if (res != RF_RESULT_OK) {
if(res != RF_RESULT_OK) {
return res;
}
@ -327,7 +332,7 @@ transmit(unsigned short transmit_len)
{
rf_result_t res;
if (tx_is_active()) {
if(tx_is_active()) {
PRINTF("transmit: not allowed while transmitting\n");
return RADIO_TX_ERR;
}
@ -371,10 +376,10 @@ read(void *buf, unsigned short buf_len)
const rtimer_clock_t t0 = RTIMER_NOW();
/* Only wait if the Radio is accessing the entry */
while ((data_entry->status == DATA_ENTRY_BUSY) &&
while((data_entry->status == DATA_ENTRY_BUSY) &&
RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + TIMEOUT_DATA_ENTRY_BUSY));
if (data_entry->status != DATA_ENTRY_FINISHED) {
if(data_entry->status != DATA_ENTRY_FINISHED) {
/* No available data */
return -1;
}
@ -404,7 +409,7 @@ read(void *buf, unsigned short buf_len)
const lensz_t frame_len = *(lensz_t*)frame_ptr;
/* Sanity check that Frame is at least Frame Shave bytes long */
if (frame_len < FRAME_SHAVE) {
if(frame_len < FRAME_SHAVE) {
PRINTF("read: frame too short len=%d\n", frame_len);
data_queue_release_entry();
@ -415,7 +420,7 @@ read(void *buf, unsigned short buf_len)
const unsigned short payload_len = (unsigned short)(frame_len - FRAME_SHAVE);
/* Sanity check that Payload fits in Buffer */
if (payload_len > buf_len) {
if(payload_len > buf_len) {
PRINTF("read: payload too large for buffer len=%d buf_len=%d\n", payload_len, buf_len);
data_queue_release_entry();
@ -441,7 +446,7 @@ cca_request(void)
{
const int8_t rssi = get_rssi();
if (rssi == RF_GET_RSSI_ERROR_VAL) {
if(rssi == RF_GET_RSSI_ERROR_VAL) {
return CCA_STATE_INVALID;
}
@ -453,7 +458,7 @@ cca_request(void)
static int
channel_clear(void)
{
if (tx_is_active()) {
if(tx_is_active()) {
PRINTF("channel_clear: called while in TX\n");
return 0;
}
@ -467,7 +472,7 @@ channel_clear(void)
static int
receiving_packet(void)
{
if (!rx_is_active()) {
if(!rx_is_active()) {
return 0;
}
@ -487,16 +492,16 @@ pending_packet(void)
/* Go through RX Circular buffer and check their status */
do {
const uint8_t status = curr_entry->status;
if ((status == DATA_ENTRY_FINISHED) ||
if((status == DATA_ENTRY_FINISHED) ||
(status == DATA_ENTRY_BUSY)) {
num_pending += 1;
}
/* Stop when we have looped the circular buffer */
curr_entry = (data_entry_t *)curr_entry->pNextEntry;
} while (curr_entry != read_entry);
} while(curr_entry != read_entry);
if (num_pending > 0) {
if(num_pending > 0) {
process_poll(&rf_sched_process);
}
@ -509,7 +514,7 @@ on(void)
{
rf_result_t res;
if (prop_radio.rf_is_on) {
if(prop_radio.rf_is_on) {
PRINTF("on: Radio already on\n");
return RF_RESULT_OK;
}
@ -518,7 +523,7 @@ on(void)
res = netstack_sched_rx(true);
if (res != RF_RESULT_OK) {
if(res != RF_RESULT_OK) {
return RF_RESULT_ERROR;
}
@ -529,7 +534,7 @@ on(void)
static int
off(void)
{
if (!prop_radio.rf_is_on) {
if(!prop_radio.rf_is_on) {
PRINTF("off: Radio already off\n");
return RF_RESULT_OK;
}
@ -545,7 +550,7 @@ get_value(radio_param_t param, radio_value_t *value)
{
rf_result_t res;
if (!value) {
if(!value) {
return RADIO_RESULT_INVALID_VALUE;
}
@ -627,7 +632,7 @@ set_value(radio_param_t param, radio_value_t value)
: RADIO_RESULT_ERROR;
case RADIO_PARAM_TXPOWER:
if (!TX_POWER_IN_RANGE((int8_t)value)) {
if(!TX_POWER_IN_RANGE((int8_t)value)) {
return RADIO_RESULT_INVALID_VALUE;
}
res = rf_set_tx_power(prop_radio.rf_handle, TX_POWER_TABLE, (int8_t)value);
@ -662,7 +667,7 @@ set_object(radio_param_t param, const void *src, size_t size)
static int
init(void)
{
if (prop_radio.rf_handle) {
if(prop_radio.rf_handle) {
PRINTF("init: Radio already initialized\n");
return RF_RESULT_OK;
}
@ -683,7 +688,7 @@ init(void)
/* Open RF Driver */
prop_radio.rf_handle = netstack_open(&rf_params);
if (prop_radio.rf_handle == NULL) {
if(prop_radio.rf_handle == NULL) {
PRINTF("init: unable to open RF driver\n");
return RF_RESULT_ERROR;
}
@ -716,5 +721,6 @@ const struct radio_driver prop_mode_driver = {
};
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -31,15 +31,14 @@
* \addtogroup cc13xx-cc26xx-cpu
* @{
*
* \defgroup rf-core Common functionality for the CC13xx/CC26xx RF
* \defgroup cc13xx-cc26xx-rf RF specific files for CC13xx/CC26xx
*
* @{
*
* \file
* Header file of common CC13xx/CC26xx RF functionality
* Header file of common CC13xx/CC26xx RF functionality.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#ifndef RF_CORE_H_

View File

@ -28,11 +28,13 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup
* \addtogroup cc13xx-cc26xx-rf-sched
* @{
*
* \file
* Implementation of common CC13xx/CC26xx RF functionality
* Implementation of the CC13xx/CC26xx RF scheduler.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
@ -101,11 +103,11 @@ cmd_rx_cb(RF_Handle client, RF_CmdHandle command, RF_EventMask events)
(void)client;
(void)command;
if (events & RF_EventRxEntryDone) {
if(events & RF_EventRxEntryDone) {
process_poll(&rf_sched_process);
}
if (events & RF_EventRxBufFull) {
if(events & RF_EventRxBufFull) {
rx_buf_full = true;
process_poll(&rf_sched_process);
}
@ -138,7 +140,7 @@ cmd_rx_disable(void)
{
const bool is_active = cmd_rx_is_active();
if (is_active) {
if(is_active) {
CMD_STATUS(netstack_cmd_rx) = DONE_STOPPED;
RF_cancelCmd(&rf_netstack, cmd_rx_handle, RF_ABORT_GRACEFULLY);
cmd_rx_handle = 0;
@ -152,7 +154,7 @@ cmd_rx_restore(uint_fast8_t rx_key)
{
const bool was_active = (rx_key != 0) ? true : false;
if (!was_active) {
if(!was_active) {
return RF_RESULT_OK;
}
@ -172,7 +174,7 @@ cmd_rx_restore(uint_fast8_t rx_key)
RF_EventRxEntryDone | RF_EventRxBufFull
);
if (!CMD_HANDLE_OK(cmd_rx_handle)) {
if(!CMD_HANDLE_OK(cmd_rx_handle)) {
PRINTF("cmd_rx_restore: unable to schedule RX command handle=%d status=0x%04x",
cmd_rx_handle, CMD_STATUS(netstack_cmd_rx));
return RF_RESULT_ERROR;
@ -246,14 +248,13 @@ netstack_sched_fs(void)
/*
* For IEEE-mode, restarting CMD_IEEE_RX re-calibrates the synth by using the
* channel field in the CMD_IEEE_RX command. It is assumed this field is
* already configured before this function is called.
* However, if CMD_IEEE_RX wasn't active, manually calibrate the synth
* with CMD_FS.
* already configured before this function is called. However, if
* CMD_IEEE_RX wasn't active, manually calibrate the synth with CMD_FS.
*
* For Prop-mode, the synth is always manually calibrated with CMD_FS.
*/
#if (RF_MODE == RF_CORE_MODE_2_4_GHZ)
if (rx_key) {
if(rx_key) {
cmd_rx_restore(rx_key);
return RF_RESULT_OK;
}
@ -276,7 +277,7 @@ netstack_sched_fs(void)
synth_error = (EVENTS_CMD_DONE(events))
&& (CMD_STATUS(netstack_cmd_fs) == ERROR_SYNTH_PROG);
} while (synth_error && (num_tries++ < CMD_FS_RETRIES));
} while(synth_error && (num_tries++ < CMD_FS_RETRIES));
cmd_rx_restore(rx_key);
@ -305,9 +306,9 @@ netstack_sched_ieee_tx(bool ack_request)
* run the RX_ACK command. Therefore, turn on RX before starting the
* chained TX command.
*/
if (rx_needed) {
if(rx_needed) {
res = netstack_sched_rx(false);
if (res != RF_RESULT_OK) {
if(res != RF_RESULT_OK) {
return res;
}
}
@ -321,13 +322,13 @@ netstack_sched_ieee_tx(bool ack_request)
0
);
if (!CMD_HANDLE_OK(tx_handle)) {
if(!CMD_HANDLE_OK(tx_handle)) {
PRINTF("netstack_sched_tx: unable to schedule TX command handle=%d status=0x%04x\n",
tx_handle, CMD_STATUS(netstack_cmd_tx));
return RF_RESULT_ERROR;
}
if (rx_is_active) {
if(rx_is_active) {
ENERGEST_SWITCH(ENERGEST_TYPE_LISTEN, ENERGEST_TYPE_TRANSMIT);
} else {
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
@ -337,17 +338,17 @@ netstack_sched_ieee_tx(bool ack_request)
RF_EventMask tx_events = RF_pendCmd(&rf_netstack, tx_handle, 0);
/* Stop RX if it was turned on only for ACK */
if (rx_needed) {
if(rx_needed) {
netstack_stop_rx();
}
if (rx_is_active) {
if(rx_is_active) {
ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN);
} else {
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
}
if (!EVENTS_CMD_DONE(tx_events)) {
if(!EVENTS_CMD_DONE(tx_events)) {
PRINTF("netstack_sched_tx: TX command pend error events=0x%08llx status=0x%04x\n",
tx_events, CMD_STATUS(netstack_cmd_tx));
return RF_RESULT_ERROR;
@ -375,7 +376,7 @@ netstack_sched_prop_tx(void)
0
);
if (!CMD_HANDLE_OK(tx_handle)) {
if(!CMD_HANDLE_OK(tx_handle)) {
PRINTF("netstack_sched_tx: unable to schedule TX command handle=%d status=0x%04x\n",
tx_handle, CMD_STATUS(netstack_cmd_tx));
return RF_RESULT_ERROR;
@ -387,7 +388,7 @@ netstack_sched_prop_tx(void)
*/
const bool rx_key = cmd_rx_disable();
if (rx_key) {
if(rx_key) {
ENERGEST_SWITCH(ENERGEST_TYPE_LISTEN, ENERGEST_TYPE_TRANSMIT);
} else {
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
@ -398,13 +399,13 @@ netstack_sched_prop_tx(void)
cmd_rx_restore(rx_key);
if (rx_key) {
if(rx_key) {
ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN);
} else {
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
}
if (!EVENTS_CMD_DONE(tx_events)) {
if(!EVENTS_CMD_DONE(tx_events)) {
PRINTF("netstack_sched_tx: TX command pend error events=0x%08llx status=0x%04x\n",
tx_events, CMD_STATUS(netstack_cmd_tx));
return RF_RESULT_ERROR;
@ -416,7 +417,7 @@ netstack_sched_prop_tx(void)
rf_result_t
netstack_sched_rx(bool start)
{
if (cmd_rx_is_active()) {
if(cmd_rx_is_active()) {
PRINTF("netstack_sched_rx: already in RX\n");
return RF_RESULT_OK;
}
@ -437,7 +438,7 @@ netstack_sched_rx(bool start)
RF_EventRxEntryDone | RF_EventRxBufFull
);
if (!CMD_HANDLE_OK(cmd_rx_handle)) {
if(!CMD_HANDLE_OK(cmd_rx_handle)) {
PRINTF("netstack_sched_rx: unable to schedule RX command handle=%d status=0x%04x\n",
cmd_rx_handle, CMD_STATUS(netstack_cmd_rx));
return RF_RESULT_ERROR;
@ -445,7 +446,7 @@ netstack_sched_rx(bool start)
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
if (start) {
if(start) {
rf_is_on = true;
process_poll(&rf_sched_process);
}
@ -456,7 +457,7 @@ netstack_sched_rx(bool start)
rf_result_t
netstack_stop_rx(void)
{
if (!cmd_rx_is_active()) {
if(!cmd_rx_is_active()) {
PRINTF("netstack_stop_rx: RX not active\n");
return RF_RESULT_OK;
}
@ -497,7 +498,7 @@ ble_sched_beacon(RF_Callback cb, RF_EventMask bm_event)
bm_event
);
if (!CMD_HANDLE_OK(beacon_handle)) {
if(!CMD_HANDLE_OK(beacon_handle)) {
PRINTF("ble_sched_beacon: unable to schedule BLE Beacon command handle=%d status=0x%04x\n",
beacon_handle, CMD_STATUS(ble_cmd_beacon));
return RF_RESULT_ERROR;
@ -507,7 +508,7 @@ ble_sched_beacon(RF_Callback cb, RF_EventMask bm_event)
/* Wait until Beacon operation finishes */
RF_EventMask beacon_events = RF_pendCmd(&rf_ble, beacon_handle, 0);
if (!EVENTS_CMD_DONE(beacon_events)) {
if(!EVENTS_CMD_DONE(beacon_events)) {
PRINTF("ble_sched_beacon: Beacon command pend error events=0x%08llx status=0x%04x\n",
beacon_events, CMD_STATUS(ble_cmd_beacon));
@ -532,12 +533,12 @@ PROCESS_THREAD(rf_sched_process, ev, data)
(ev == PROCESS_EVENT_TIMER));
/* start the synth re-calibration timer once. */
if (rf_is_on) {
if(rf_is_on) {
rf_is_on = false;
etimer_set(&synth_recal_timer, synth_recal_interval());
}
if (ev == PROCESS_EVENT_POLL) {
if(ev == PROCESS_EVENT_POLL) {
do {
watchdog_periodic();
@ -548,7 +549,7 @@ PROCESS_THREAD(rf_sched_process, ev, data)
* RX will stop if the RX buffers are full. In this case, restart
* RX after we've freed at least on packet.
*/
if (rx_buf_full) {
if(rx_buf_full) {
PRINTF("rf_core: RX buf full, restart RX status=0x%04x\n", CMD_STATUS(netstack_cmd_rx));
rx_buf_full = false;
@ -567,7 +568,7 @@ PROCESS_THREAD(rf_sched_process, ev, data)
}
/* Scheduling CMD_FS will re-calibrate the synth. */
if ((ev == PROCESS_EVENT_TIMER) &&
if((ev == PROCESS_EVENT_TIMER) &&
etimer_expired(&synth_recal_timer)) {
PRINTF("rf_core: Re-calibrate synth\n");
netstack_sched_fs();

View File

@ -28,11 +28,17 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup rf-core
* \addtogroup cc13xx-cc26xx-rf
* @{
*
* \defgroup cc13xx-cc26xx-rf-sched RF Scheduler for CC13xx/CC26xx
*
* @{
*
* \file
* Header file of the CC13xx/CC26xx RF scheduler.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#ifndef RF_SCHED_H_
@ -52,25 +58,41 @@ typedef enum {
RF_RESULT_ERROR,
} rf_result_t;
/*---------------------------------------------------------------------------*/
/* Common */
/**
* \name Common RF scheduler functionality.
*
* @{
*/
rf_result_t rf_yield(void);
rf_result_t rf_set_tx_power(RF_Handle handle, RF_TxPowerTable_Entry *table, int8_t dbm);
rf_result_t rf_get_tx_power(RF_Handle handle, RF_TxPowerTable_Entry *table, int8_t *dbm);
/** @} */
/*---------------------------------------------------------------------------*/
/* Netstack radio: IEEE-mode or prop-mode */
/**
* \name Nestack Radio scheduler functionality.
*
* Either for Prop-mode or IEEE-mode Radio driver.
*
* @{
*/
RF_Handle netstack_open(RF_Params *params);
rf_result_t netstack_sched_fs(void);
rf_result_t netstack_sched_ieee_tx(bool ack_request);
rf_result_t netstack_sched_prop_tx(void);
rf_result_t netstack_sched_rx(bool start);
rf_result_t netstack_stop_rx(void);
/** @} */
/*---------------------------------------------------------------------------*/
/* BLE radio: BLE Beacon Daemon */
/**
* \name BLE Radio scheduler functionality.
*
* Only for the BLE Beacon Daemon.
*
* @{
*/
RF_Handle ble_open(RF_Params *params);
rf_result_t ble_sched_beacon(RF_Callback cb, RF_EventMask bm_event);
/** @} */
/*---------------------------------------------------------------------------*/
#endif /* RF_SCHED_H_ */
/*---------------------------------------------------------------------------*/

View File

@ -59,12 +59,12 @@
#include DeviceFamily_constructPath(driverlib/driverlib_release.h)
#include DeviceFamily_constructPath(driverlib/chipinfo.h)
#include DeviceFamily_constructPath(driverlib/vims.h)
#include DeviceFamily_constructPath(inc/hw_cpu_scs.h)
#include <ti/drivers/dpl/HwiP.h>
#include <ti/drivers/I2C.h>
#include <ti/drivers/NVS.h>
#include <ti/drivers/PIN.h>
#include <ti/drivers/pin/PINCC26XX.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/SPI.h>
#include <ti/drivers/TRNG.h>
@ -92,30 +92,31 @@
*/
extern void Board_initHook(void);
/*---------------------------------------------------------------------------*/
#ifdef BOARD_CONF_HAS_SENSORS
#define BOARD_HAS_SENSORS BOARD_CONF_HAS_SENSORS
#else
#define BOARD_HAS_SENSORS 1
#endif
/*---------------------------------------------------------------------------*/
/* Fade a specified LED */
/*
* \brief Fade a specified LED.
*/
static void
fade(unsigned char l)
fade(PIN_Id pin)
{
volatile int i;
int k;
int j;
for(k = 0; k < 800; ++k) {
j = (k > 400) ? 800 - k : k;
volatile uint32_t i;
uint32_t k;
uint32_t j;
uint32_t pivot = 800;
uint32_t pivot_half = pivot / 2;
leds_single_on(l);
for(i = 0; i < j; ++i) { __asm("nop"); }
leds_single_off(l);
for(i = 0; i < 400 - j; ++i) { __asm("nop"); }
for(k = 0; k < pivot; ++k) {
j = (k > pivot_half) ? pivot - k : k;
PINCC26XX_setOutputValue(pin, 1);
for (i = 0; i < j; ++i) { __asm__ __volatile__ ("nop"); }
PINCC26XX_setOutputValue(pin, 0);
for (i = 0; i < pivot_half - j; ++i) { __asm__ __volatile__ ("nop"); }
}
}
/*---------------------------------------------------------------------------*/
/* Configure RF params for the radio driver */
/*
* \brief Configure RF params for the radio driver.
*/
static void
set_rf_params(void)
{
@ -163,7 +164,7 @@ platform_init_stage_one(void)
gpio_hal_init();
leds_init();
fade(LEDS_RED);
fade(Board_PIN_RLED);
/* TI Drivers init */
#if TI_UART_CONF_ENABLE
@ -181,7 +182,7 @@ platform_init_stage_one(void)
TRNG_init();
fade(LEDS_GREEN);
fade(Board_PIN_GLED);
/* NoRTOS must be called last */
NoRTOS_start();
@ -213,7 +214,7 @@ platform_init_stage_two(void)
button_hal_init();
fade(LEDS_RED);
fade(Board_PIN_RLED);
}
/*---------------------------------------------------------------------------*/
void
@ -246,11 +247,11 @@ platform_init_stage_three(void)
LOG_INFO("RF: Channel %d, PANID 0x%04X\n", chan, pan);
LOG_INFO("Node ID: %d\n", node_id);
#if BOARD_HAS_SENSORS
#if BOARD_CONF_SENSORS_ENABLE
process_start(&sensors_process, NULL);
#endif
fade(LEDS_GREEN);
fade(Board_PIN_GLED);
}
/*---------------------------------------------------------------------------*/
void