Slight naming refactoring, and removed bloat .vramTable from linker

This commit is contained in:
Edvard Pettersen 2018-07-18 17:41:04 +02:00
parent a18cac1e0c
commit c333e9f783
16 changed files with 150 additions and 118 deletions

View File

@ -74,8 +74,8 @@ CONTIKI_CPU_SOURCEFILES += batmon-sensor.c gpio-hal-arch.c
CONTIKI_CPU_SOURCEFILES += int-master-arch.c
### RF source files
CONTIKI_CPU_SOURCEFILES += rf-core.c rf-data-queue.c
CONTIKI_CPU_SOURCEFILES += ieee-addr.c ble-addr.c
CONTIKI_CPU_SOURCEFILES += rf-sched.c rf-data-queue.c
CONTIKI_CPU_SOURCEFILES += rf-ieee-addr.c rf-ble-addr.c
CONTIKI_CPU_SOURCEFILES += rf-ble-beacond.c
ifeq ($(SUPPORTS_PROP_MODE),1)

View File

@ -38,8 +38,8 @@
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#ifndef SIMPLELINK_CONF_H_
#define SIMPLELINK_CONF_H_
#ifndef CC13XX_CC26XX_CONF_H_
#define CC13XX_CC26XX_CONF_H_
/*---------------------------------------------------------------------------*/
#include "cc13xx-cc26xx-def.h"
@ -390,6 +390,6 @@
#endif /* SLIP_ARCH_CONF_ENABLED */
/** @} */
/*---------------------------------------------------------------------------*/
#endif /* SIMPLELINK_CONF_H_ */
#endif /* CC13XX_CC26XX_CONF_H_ */
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -37,19 +37,18 @@
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/ble-hal.h"
#include "net/linkaddr.h"
#include "ble-addr.h"
#include <string.h>
#include "rf-ble-addr.h"
/*---------------------------------------------------------------------------*/
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(inc/hw_memmap.h)
#include DeviceFamily_constructPath(inc/hw_fcfg1.h)
#include DeviceFamily_constructPath(inc/hw_ccfg.h)
/*---------------------------------------------------------------------------*/
#include <string.h>
/*---------------------------------------------------------------------------*/
#define BLE_MAC_PRIMARY_ADDRESS (FCFG1_BASE + FCFG1_O_MAC_BLE_0)
#define BLE_MAC_SECONDARY_ADDRESS (CCFG_BASE + CCFG_O_IEEE_BLE_0)
/*---------------------------------------------------------------------------*/

View File

@ -44,8 +44,6 @@
#include "sys/etimer.h"
#include "net/netstack.h"
#include "net/linkaddr.h"
#include "rf-ble-beacond.h"
/*---------------------------------------------------------------------------*/
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/chipinfo.h)
@ -54,9 +52,10 @@
#include <ti/drivers/rf/RF.h>
/*---------------------------------------------------------------------------*/
#include "netstack-settings.h"
#include "rf-ble-addr.h"
#include "rf-ble-beacond.h"
#include "rf-core.h"
#include "ble-addr.h"
#include "rf-settings.h"
/*---------------------------------------------------------------------------*/
#include <stdbool.h>
#include <stdint.h>

View File

@ -27,64 +27,40 @@
* 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-cpu
* @{
*
* \defgroup rf-common Common functionality fpr the CC13xx/CC26xx RF
* \defgroup rf-core Common functionality for the CC13xx/CC26xx RF
*
* @{
*
* \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_
#define RF_CORE_H_
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "sys/process.h"
#include "rf-ble-beacond.h"
/*---------------------------------------------------------------------------*/
#include <ti/drivers/rf/RF.h>
/*---------------------------------------------------------------------------*/
#include <stdbool.h>
/*---------------------------------------------------------------------------*/
/**
* \name Different modes the RF can operate on, denoted by which frequency
* band said mode operates on. Currently supports the following modes:
* - Sub-1 GHz, called prop-mode
* - 2.4 GHz, called ieee-mode
*
* @{
*/
#define RF_MODE_SUB_1_GHZ (1 << 0)
#define RF_MODE_2_4_GHZ (1 << 1)
/* Bitmask of supported RF modes */
#define RF_MODE_BM ( RF_MODE_SUB_1_GHZ \
| RF_MODE_2_4_GHZ \
)
/*---------------------------------------------------------------------------*/
PROCESS_NAME(rf_core_process);
/*---------------------------------------------------------------------------*/
typedef enum {
RF_RESULT_OK = 0,
RF_RESULT_ERROR,
} rf_result_t;
/*---------------------------------------------------------------------------*/
/* Common */
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 */
RF_Handle netstack_open(RF_Params *params);
rf_result_t netstack_sched_fs(void);
rf_result_t netstack_sched_ieee_tx(bool recieve_ack);
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 */
RF_Handle ble_open(RF_Params *params);
rf_result_t ble_sched_beacon(RF_Callback cb, RF_EventMask bm_event);
/** @} */
/*---------------------------------------------------------------------------*/
#endif /* RF_CORE_H_ */
/*---------------------------------------------------------------------------*/

View File

@ -40,7 +40,7 @@
#include "contiki.h"
#include "net/linkaddr.h"
#include "ieee-addr.h"
#include "rf-ieee-addr.h"
/*---------------------------------------------------------------------------*/
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(inc/hw_memmap.h)

View File

@ -68,9 +68,9 @@
/* SimpleLink Platform RF dev */
#include "rf-data-queue.h"
#include "rf-core.h"
#include "dot-15-4g.h"
#include "netstack-settings.h"
#include RF_IEEE_SETTINGS
#include "rf-sched.h"
#include "rf-15-4g.h"
#include "ieee-settings.h"
/*---------------------------------------------------------------------------*/
#include <stdint.h>
#include <stddef.h>
@ -428,7 +428,7 @@ init(void)
ctimer_set(&ieee_radio.rat.overflow_timer, two_quarters, rat_overflow_cb, NULL);
/* Start RF process */
process_start(&rf_core_process, NULL);
process_start(&rf_sched_process, NULL);
return RF_RESULT_OK;
}
@ -671,7 +671,7 @@ pending_packet(void)
} while (curr_entry != read_entry);
if ((num_pending > 0) && !ieee_radio.poll_mode) {
process_poll(&rf_core_process);
process_poll(&rf_sched_process);
}
/* If we didn't find an entry at status finished or busy, no frames are pending */

View File

@ -297,15 +297,19 @@ set_channel(uint16_t channel)
static uint8_t
calculate_lqi(int8_t rssi)
{
/* Note : Currently the LQI value is simply the energy detect measurement.
/*
* Note : Currently the LQI value is simply the energy detect measurement.
* A more accurate value could be derived by using the correlation
* value along with the RSSI value. */
* value along with the RSSI value.
*/
rssi = CLAMP(rssi, ED_RF_POWER_MIN_DBM, ED_RF_POWER_MAX_DBM);
/* Create energy detect measurement by normalizing and scaling RF power level.
/*
* Create energy detect measurement by normalizing and scaling RF power level.
* Note : The division operation below is designed for maximum accuracy and
* best granularity. This is done by grouping the math operations to
* compute the entire numerator before doing any division. */
* best granularity. This is done by grouping the math operations to
* compute the entire numerator before doing any division.
*/
return (MAC_SPEC_ED_MAX * (rssi - ED_RF_POWER_MIN_DBM)) / (ED_RF_POWER_MAX_DBM - ED_RF_POWER_MIN_DBM);
}
/*---------------------------------------------------------------------------*/

View File

@ -27,9 +27,8 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup simplelink
* \addtogroup
* @{
*
* \file
@ -46,7 +45,6 @@
#include "net/packetbuf.h"
#include "net/mac/mac.h"
#include "rf-core.h"
/*---------------------------------------------------------------------------*/
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
@ -54,8 +52,10 @@
#include <ti/drivers/rf/RF.h>
/*---------------------------------------------------------------------------*/
#include "rf-core.h"
#include "rf-sched.h"
#include "rf-data-queue.h"
#include "netstack-settings.h"
#include "rf-settings.h"
/*---------------------------------------------------------------------------*/
#include <stdbool.h>
#include <stdint.h>
@ -100,13 +100,13 @@ cmd_rx_cb(RF_Handle client, RF_CmdHandle command, RF_EventMask events)
(void)command;
if (events & RF_EventRxEntryDone) {
process_poll(&rf_core_process);
process_poll(&rf_sched_process);
}
if (events & RF_EventRxBufFull) {
rx_buf_full = true;
process_poll(&rf_core_process);
process_poll(&rf_sched_process);
}
}
/*---------------------------------------------------------------------------*/
@ -275,7 +275,7 @@ netstack_sched_fs(void)
}
/*---------------------------------------------------------------------------*/
rf_result_t
netstack_sched_ieee_tx(bool recieve_ack)
netstack_sched_ieee_tx(bool ack_request)
{
rf_result_t res;
@ -286,15 +286,15 @@ netstack_sched_ieee_tx(bool recieve_ack)
sched_params.endTime = 0;
sched_params.allowDelay = RF_AllowDelayAny;
const bool is_active = cmd_rx_is_active();
const bool rx_ack_required = (recieve_ack && !is_active);
const bool rx_is_active = cmd_rx_is_active();
const bool rx_needed = (ack_request && !rx_is_active);
/*
* If we expect ACK after transmission, RX must be running to be able to
* run the RX_ACK command. Therefore, turn on RX before starting the
* chained TX command.
*/
if (rx_ack_required) {
if (rx_needed) {
res = netstack_sched_rx(false);
if (res != RF_RESULT_OK) {
return res;
@ -316,7 +316,7 @@ netstack_sched_ieee_tx(bool recieve_ack)
return RF_RESULT_ERROR;
}
if (is_active) {
if (rx_is_active) {
ENERGEST_SWITCH(ENERGEST_TYPE_LISTEN, ENERGEST_TYPE_TRANSMIT);
} else {
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
@ -326,11 +326,11 @@ netstack_sched_ieee_tx(bool recieve_ack)
RF_EventMask tx_events = RF_pendCmd(&rf_netstack, tx_handle, 0);
/* Stop RX if it was turned on only for ACK */
if (rx_ack_required) {
if (rx_needed) {
netstack_stop_rx();
}
if (is_active) {
if (rx_is_active) {
ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN);
} else {
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
@ -436,7 +436,7 @@ netstack_sched_rx(bool start)
if (start) {
rf_is_on = true;
process_poll(&rf_core_process);
process_poll(&rf_sched_process);
}
return RF_RESULT_OK;
@ -508,9 +508,9 @@ ble_sched_beacon(RF_Callback cb, RF_EventMask bm_event)
return RF_RESULT_OK;
}
/*---------------------------------------------------------------------------*/
PROCESS(rf_core_process, "RF Core Process");
PROCESS(rf_sched_process, "RF Core Process");
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(rf_core_process, ev, data)
PROCESS_THREAD(rf_sched_process, ev, data)
{
int len;

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2018, 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
* @{
*
* \file
* Header file of the CC13xx/CC26xx RF scheduler.
*/
/*---------------------------------------------------------------------------*/
#ifndef RF_SCHED_H_
#define RF_SCHED_H_
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "sys/process.h"
#include "rf-ble-beacond.h"
/*---------------------------------------------------------------------------*/
#include <ti/drivers/rf/RF.h>
/*---------------------------------------------------------------------------*/
#include <stdbool.h>
/*---------------------------------------------------------------------------*/
PROCESS_NAME(rf_sched_process);
/*---------------------------------------------------------------------------*/
typedef enum {
RF_RESULT_OK = 0,
RF_RESULT_ERROR,
} rf_result_t;
/*---------------------------------------------------------------------------*/
/* Common */
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 */
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 */
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

@ -107,10 +107,6 @@ static void (* const resetVectors[16])(void) =
defaultHandler, // The PendSV handler
defaultHandler // The SysTick handler
};
__attribute__ ((section(".ramVecs")))
static unsigned long ramVectors[50];
//*****************************************************************************
//
// The following are arrays of pointers to constructor functions that need to
@ -194,14 +190,6 @@ void localProgramStart(void)
__init_array_start[i]();
}
/* Copy from reset vector table into RAM vector table */
memcpy(ramVectors, resetVectors, 16*4);
/* fill remaining vectors with default handler */
for (i=16; i < 50; i++) {
ramVectors[i] = (unsigned long)defaultHandler;
}
/* Call the application's entry point. */
main();

View File

@ -35,31 +35,10 @@
/*---------------------------------------------------------------------------*/
#include <ti/devices/DeviceFamily.h>
/*---------------------------------------------------------------------------*/
/* Prop-mode RF settings configuration */
#ifdef RF_CONF_PROP_SETTINGS
# define RF_PROP_SETTINGS RF_CONF_PROP_SETTINGS
#else
# define RF_PROP_SETTINGS "prop-settings.h"
#endif
/* IEEE-mode RF settings configuration */
#ifdef RF_CONF_IEEE_SETTINGS
# define RF_IEEE_SETTINGS RF_CONF_IEEE_SETTINGS
#else
# define RF_IEEE_SETTINGS "ieee-settings.h"
#endif
/* BLE RF settings configuration */
#ifdef RF_CONF_BLE_SETTINGS
# define RF_BLE_SETTINGS RF_CONF_BLE_SETTINGS
#else
# define RF_BLE_SETTINGS "ble-settings.h"
#endif
/*---------------------------------------------------------------------------*/
/* Prop-mode RF settings */
#if (RF_MODE == RF_MODE_SUB_1_GHZ)
#include RF_PROP_SETTINGS
#include "prop-settings.h"
#define netstack_mode rf_prop_mode
#define netstack_cmd_radio_setup rf_cmd_prop_radio_div_setup
@ -70,7 +49,7 @@
/* IEEE-mode RF settings */
#elif (RF_MODE == RF_MODE_2_4_GHZ)
#include RF_IEEE_SETTINGS
#include "ieee-settings.h"
#define netstack_mode rf_ieee_mode
#define netstack_cmd_radio_setup rf_cmd_ieee_radio_setup
@ -83,22 +62,27 @@
#endif
/*---------------------------------------------------------------------------*/
/* BLE RF settings */
#include RF_BLE_SETTINGS
#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
#include "ble-settings.h"
#define ble_mode rf_ble_mode
#define ble_cmd_radio_setup rf_ble_cmd_radio_setup
#define ble_adv_par rf_ble_adv_par
#define ble_cmd_beacon rf_ble_cmd_ble_adv_nc
/*---------------------------------------------------------------------------*/
#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
#include "ble-settings.h"
#define ble_mode rf_ble_mode
#define ble_cmd_radio_setup rf_cmd_ble5_radio_setup
#define ble_adv_par rf_ble5_adv_aux_par
#define ble_cmd_beacon rf_cmd_ble5_adv_aux
/*---------------------------------------------------------------------------*/
#else
# error "Unsupported DeviceFamily_PARENT for BLE settings"
#endif

View File

@ -72,13 +72,13 @@
#include <ti/drivers/UART.h>
/*---------------------------------------------------------------------------*/
/* Arch driver implementations */
#include "button-sensor.h"
#include "board-peripherals.h"
#include "uart0-arch.h"
/*---------------------------------------------------------------------------*/
#include "ieee-addr.h"
#include "rf-core.h"
#include "rf-ieee-addr.h"
#include "rf-ble-beacond.h"
#include "button-sensor.h"
/*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <string.h>