Merge branch 'develop' into bugfix/mcast-stats
This commit is contained in:
commit
ba8f8b9bda
|
@ -33,6 +33,7 @@ COOJA.testlog
|
|||
*.native
|
||||
*.nrf52dk
|
||||
*.openmote-cc2538
|
||||
*.simplelink
|
||||
*.sky
|
||||
*.firmware
|
||||
*.srf06-cc26xx
|
||||
|
|
|
@ -22,3 +22,9 @@
|
|||
[submodule "tools/motelist"]
|
||||
path = tools/motelist
|
||||
url = https://github.com/contiki-ng/motelist
|
||||
[submodule "arch/cpu/simplelink-cc13xx-cc26xx/lib/coresdk_cc13xx_cc26xx"]
|
||||
path = arch/cpu/simplelink-cc13xx-cc26xx/lib/coresdk_cc13xx_cc26xx
|
||||
url = https://github.com/contiki-ng/coresdk_cc13xx_cc26xx.git
|
||||
[submodule "arch/cpu/cc26xx-cc13xx/lib/cc2640r2-sdk"]
|
||||
path = arch/cpu/cc26xx-cc13xx/lib/cc2640r2-sdk
|
||||
url = https://github.com/contiki-ng/cc2640r2-sdk.git
|
||||
|
|
|
@ -17,10 +17,14 @@ CPU_STARTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CPU_START_SOURCEFILES
|
|||
### Compilation rules
|
||||
CUSTOM_RULE_LINK = 1
|
||||
|
||||
### Resolve any potential circular dependencies between the linked libraries
|
||||
### See: https://stackoverflow.com/questions/5651869/gcc-what-are-the-start-group-and-end-group-command-line-options/5651895
|
||||
TARGET_LIBFLAGS := -Wl,--start-group $(TARGET_LIBFILES) -lm -Wl,--end-group
|
||||
|
||||
.SECONDEXPANSION:
|
||||
|
||||
%.elf: $(CPU_STARTFILES) $$(CONTIKI_OBJECTFILES) %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(LDSCRIPT)
|
||||
$(TRACE_LD)
|
||||
$(Q)$(LD) $(LDFLAGS) ${filter-out $(LDSCRIPT) %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -lm -o $@
|
||||
$(Q)$(LD) $(LDFLAGS) ${filter-out $(LDSCRIPT) %.a,$^} ${filter %.a,$^} $(TARGET_LIBFLAGS) -o $@
|
||||
|
||||
include $(CONTIKI)/arch/cpu/arm/cortex-m/Makefile.cortex-m
|
||||
|
|
|
@ -1,13 +1,28 @@
|
|||
CONTIKI_ARM_DIRS += cortex-m/cm4
|
||||
|
||||
CFLAGS += -mcpu=cortex-m4
|
||||
|
||||
LDFLAGS += -mcpu=cortex-m4
|
||||
LDFLAGS += -T $(LDSCRIPT)
|
||||
LDFLAGS += -Wl,--gc-sections,--sort-section=alignment
|
||||
LDFLAGS += -Wl,-Map=$(CONTIKI_NG_PROJECT_MAP),--cref,--no-warn-mismatch
|
||||
|
||||
OBJCOPY_FLAGS += --gap-fill 0xff
|
||||
|
||||
### Build syscalls for newlib
|
||||
MODULES += os/lib/newlib
|
||||
|
||||
CPU_STARTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CPU_START_SOURCEFILES)}}
|
||||
|
||||
### Compilation rules
|
||||
CUSTOM_RULE_LINK=1
|
||||
CUSTOM_RULE_LINK = 1
|
||||
|
||||
%.elf: $(TARGET_STARTFILES) %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(CONTIKI_NG_TARGET_LIB) $(TARGET_LIBS)
|
||||
### Resolve any potential circular dependencies between the linked libraries
|
||||
### See: https://stackoverflow.com/questions/5651869/gcc-what-are-the-start-group-and-end-group-command-line-options/5651895
|
||||
TARGET_LIBFLAGS := -Wl,--start-group $(TARGET_LIBFILES) -Wl,--end-group
|
||||
|
||||
%.elf: $(CPU_STARTFILES) %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(CONTIKI_NG_TARGET_LIB) $(TARGET_LIBS)
|
||||
$(TRACE_LD)
|
||||
$(Q)$(CC) $(LDFLAGS) ${filter %.o %.a,$^} -o $@
|
||||
$(Q)$(LD) $(LDFLAGS) ${filter %.o %.a,$^} $(TARGET_LIBFLAGS) -o $@
|
||||
|
||||
include $(CONTIKI)/arch/cpu/arm/cortex-m/Makefile.cortex-m
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
#define PIN_TO_NUM(pin) (pin % 8)
|
||||
#define PIN_TO_PORT_BASE(pin) GPIO_PORT_TO_BASE(PIN_TO_PORT(pin))
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define gpio_hal_arch_init() do { /* Do nothing */ } while(0)
|
||||
|
||||
#define gpio_hal_arch_interrupt_enable(p) do { \
|
||||
GPIO_ENABLE_INTERRUPT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \
|
||||
NVIC_EnableIRQ(PIN_TO_PORT(p)); \
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
TI_XXWARE_PATH = lib/cc2640r2-sdk
|
||||
|
||||
include $(CONTIKI_CPU)/Makefile.cc26xx-cc13xx
|
|
@ -7,7 +7,8 @@ ifeq (,$(wildcard $(TI_XXWARE)))
|
|||
$(error "")
|
||||
endif
|
||||
|
||||
### cc26xxware sources under driverlib will be added to the MODULES list
|
||||
### cc26xxware / cc26x0r2fware sources under driverlib will be added to the
|
||||
### MODULES list
|
||||
TI_XXWARE_SRC = $(CPU_ABS_PATH)/$(TI_XXWARE_PATH)/driverlib
|
||||
|
||||
### The directory with startup sources will be added to the CONTIKI_CPU_DIRS
|
||||
|
|
|
@ -76,6 +76,7 @@ SECTIONS
|
|||
*(.data*)
|
||||
_edata = .;
|
||||
} > SRAM AT > FLASH
|
||||
_ldata = LOADADDR(.data);
|
||||
|
||||
.ARM.exidx :
|
||||
{
|
||||
|
|
|
@ -53,7 +53,11 @@ gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
|
|||
gpio_hal_pin_cfg_t tmp;
|
||||
|
||||
/* Clear settings that we are about to change, keep everything else */
|
||||
#ifdef ThisLibraryIsFor_CC26x0R2_HaltIfViolated
|
||||
config = ti_lib_ioc_port_configure_get(pin);
|
||||
#else
|
||||
config = ti_lib_rom_ioc_port_configure_get(pin);
|
||||
#endif
|
||||
config &= ~CONFIG_MASK;
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
|
@ -94,7 +98,11 @@ gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin)
|
|||
uint32_t config;
|
||||
|
||||
cfg = 0;
|
||||
#ifdef ThisLibraryIsFor_CC26x0R2_HaltIfViolated
|
||||
config = ti_lib_ioc_port_configure_get(pin);
|
||||
#else
|
||||
config = ti_lib_rom_ioc_port_configure_get(pin);
|
||||
#endif
|
||||
|
||||
/* Pull */
|
||||
tmp = config & IOC_IOPULL_M;
|
||||
|
|
|
@ -53,12 +53,19 @@
|
|||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define gpio_hal_arch_interrupt_enable(p) interrupt_enable(p)
|
||||
#define gpio_hal_arch_interrupt_disable(p) ti_lib_rom_ioc_int_disable(p)
|
||||
#define gpio_hal_arch_init() do { /* Do nothing */ } while(0)
|
||||
|
||||
#define gpio_hal_arch_interrupt_enable(p) interrupt_enable(p)
|
||||
|
||||
#ifdef ThisLibraryIsFor_CC26x0R2_HaltIfViolated
|
||||
#define gpio_hal_arch_interrupt_disable(p) ti_lib_ioc_int_disable(p)
|
||||
#define gpio_hal_arch_pin_set_input(p) ti_lib_ioc_pin_type_gpio_input(p)
|
||||
#define gpio_hal_arch_pin_set_output(p) ti_lib_ioc_pin_type_gpio_output(p)
|
||||
#else
|
||||
#define gpio_hal_arch_interrupt_disable(p) ti_lib_rom_ioc_int_disable(p)
|
||||
#define gpio_hal_arch_pin_set_input(p) ti_lib_rom_ioc_pin_type_gpio_input(p)
|
||||
#define gpio_hal_arch_pin_set_output(p) ti_lib_rom_ioc_pin_type_gpio_output(p)
|
||||
|
||||
#endif
|
||||
#define gpio_hal_arch_set_pin(p) ti_lib_gpio_set_dio(p)
|
||||
#define gpio_hal_arch_clear_pin(p) ti_lib_gpio_clear_dio(p)
|
||||
#define gpio_hal_arch_toggle_pin(p) ti_lib_gpio_toggle_dio(p)
|
||||
|
@ -73,7 +80,11 @@ static inline void
|
|||
interrupt_enable(gpio_hal_pin_t pin)
|
||||
{
|
||||
ti_lib_gpio_clear_event_dio(pin);
|
||||
#ifndef ThisLibraryIsFor_CC26x0R2_HaltIfViolated
|
||||
ti_lib_rom_ioc_int_enable(pin);
|
||||
#else
|
||||
ti_lib_ioc_int_enable(pin);
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* GPIO_HAL_ARCH_H_ */
|
||||
|
|
|
@ -130,10 +130,18 @@ spi_arch_lock_and_open(spi_device_t *dev)
|
|||
/* SPI configuration */
|
||||
ti_lib_ssi_int_disable(spi_controller[dev->spi_controller].ssi_base, SSI_RXOR | SSI_RXFF | SSI_RXTO | SSI_TXFF);
|
||||
ti_lib_ssi_int_clear(spi_controller[dev->spi_controller].ssi_base, SSI_RXOR | SSI_RXTO);
|
||||
ti_lib_rom_ssi_config_set_exp_clk(spi_controller[dev->spi_controller].ssi_base, ti_lib_sys_ctrl_clock_get(),
|
||||
|
||||
#ifdef ThisLibraryIsFor_CC26x0R2_HaltIfViolated
|
||||
ti_lib_ssi_config_set_exp_clk(spi_controller[dev->spi_controller].ssi_base, ti_lib_sys_ctrl_clock_get(),
|
||||
get_mode(dev), SSI_MODE_MASTER, dev->spi_bit_rate, 8);
|
||||
ti_lib_rom_ioc_pin_type_ssi_master(spi_controller[dev->spi_controller].ssi_base, dev->pin_spi_miso,
|
||||
ti_lib_ioc_pin_type_ssi_master(spi_controller[dev->spi_controller].ssi_base, dev->pin_spi_miso,
|
||||
dev->pin_spi_mosi, IOID_UNUSED, dev->pin_spi_sck);
|
||||
#else
|
||||
ti_lib_rom_ssi_config_set_exp_clk(spi_controller[dev->spi_controller].ssi_base, ti_lib_sys_ctrl_clock_get(),
|
||||
get_mode(dev), SSI_MODE_MASTER, dev->spi_bit_rate, 8);
|
||||
ti_lib_rom_ioc_pin_type_ssi_master(spi_controller[dev->spi_controller].ssi_base, dev->pin_spi_miso,
|
||||
dev->pin_spi_mosi, IOID_UNUSED, dev->pin_spi_sck);
|
||||
#endif
|
||||
|
||||
ti_lib_ssi_enable(spi_controller[dev->spi_controller].ssi_base);
|
||||
|
||||
|
@ -205,14 +213,20 @@ spi_arch_transfer(spi_device_t *dev,
|
|||
for(i = 0; i < totlen; i++) {
|
||||
c = i < wlen ? write_buf[i] : 0;
|
||||
ti_lib_ssi_data_put(spi_controller[dev->spi_controller].ssi_base, (uint8_t)c);
|
||||
#ifdef ThisLibraryIsFor_CC26x0R2_HaltIfViolated
|
||||
ti_lib_ssi_data_get(spi_controller[dev->spi_controller].ssi_base, &c);
|
||||
#else
|
||||
ti_lib_rom_ssi_data_get(spi_controller[dev->spi_controller].ssi_base, &c);
|
||||
#endif
|
||||
if(i < rlen) {
|
||||
inbuf[i] = (uint8_t)c;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ThisLibraryIsFor_CC26x0R2_HaltIfViolated
|
||||
while(ti_lib_ssi_data_get_non_blocking(spi_controller[dev->spi_controller].ssi_base, &c)) ;
|
||||
#else
|
||||
while(ti_lib_rom_ssi_data_get_non_blocking(spi_controller[dev->spi_controller].ssi_base, &c)) ;
|
||||
|
||||
#endif
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 0c01cfd363fd421d43baaa52af551a4ce8bf9e2b
|
|
@ -162,8 +162,10 @@ lpm_shutdown(uint32_t wakeup_pin, uint32_t io_pull, uint32_t wake_on)
|
|||
ti_lib_aon_wuc_mcu_power_off_config(MCU_VIRT_PWOFF_DISABLE);
|
||||
|
||||
/* Latch the IOs in the padring and enable I/O pad sleep mode */
|
||||
#if !defined(ThisLibraryIsFor_CC26x0R2_HaltIfViolated)
|
||||
ti_lib_pwr_ctrl_io_freeze_enable();
|
||||
|
||||
#endif
|
||||
/* Turn off VIMS cache, CRAM and TRAM - possibly not required */
|
||||
ti_lib_prcm_cache_retention_disable();
|
||||
ti_lib_vims_mode_set(VIMS_BASE, VIMS_MODE_OFF);
|
||||
|
@ -191,7 +193,12 @@ wake_up(void)
|
|||
ti_lib_sys_ctrl_aon_sync();
|
||||
|
||||
/* Adjust recharge settings */
|
||||
#ifdef ThisLibraryIsFor_CC26x0R2_HaltIfViolated
|
||||
// May need to change to XOSC_IN_LOW_POWER_MODE
|
||||
ti_lib_sys_ctrl_adjust_recharge_after_power_down(XOSC_IN_HIGH_POWER_MODE);
|
||||
#else
|
||||
ti_lib_sys_ctrl_adjust_recharge_after_power_down();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Release the request to the uLDO
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Graz University of Technology
|
||||
* Copyright (c) 2018, University of Bristol - http://www.bristol.ac.uk/
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -34,6 +35,7 @@
|
|||
*
|
||||
* \author
|
||||
* Michael Spoerk <michael.spoerk@tugraz.at>
|
||||
* Jinyan BAI <onefreebjy@outlook.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -63,6 +65,9 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "rf-core/ble-hal/rf-ble-cmd.h"
|
||||
#if RADIO_CONF_BLE5
|
||||
#include "rf_patches/rf_patch_cpe_bt5.h"
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "BLE-RADIO"
|
||||
|
@ -117,9 +122,15 @@ ticks_to_unit(rtimer_clock_t value, uint32_t unit)
|
|||
return (uint32_t)temp;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if RADIO_CONF_BLE5
|
||||
#define CMD_BUFFER_SIZE 28
|
||||
#define PARAM_BUFFER_SIZE 48
|
||||
#define OUTPUT_BUFFER_SIZE 24
|
||||
#else
|
||||
#define CMD_BUFFER_SIZE 24
|
||||
#define PARAM_BUFFER_SIZE 36
|
||||
#define OUTPUT_BUFFER_SIZE 24
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* ADVERTISING data structures */
|
||||
#define ADV_RX_BUFFERS_OVERHEAD 8
|
||||
|
@ -358,11 +369,23 @@ on(void)
|
|||
oscillators_request_hf_xosc();
|
||||
if(!rf_core_is_accessible()) {
|
||||
/* boot the rf core */
|
||||
if(rf_core_boot() != RF_CORE_CMD_OK) {
|
||||
LOG_ERR("ble_controller_reset() could not boot rf-core\n");
|
||||
return BLE_RESULT_ERROR;
|
||||
}
|
||||
|
||||
/* boot and apply Bluetooth 5 Patch */
|
||||
if(rf_core_power_up() != RF_CORE_CMD_OK) {
|
||||
LOG_ERR("rf_core_boot: rf_core_power_up() failed\n");
|
||||
rf_core_power_down();
|
||||
return RF_CORE_CMD_ERROR;
|
||||
}
|
||||
|
||||
#if RADIO_CONF_BLE5
|
||||
/* Apply Bluetooth 5 patch, if applicable */
|
||||
rf_patch_cpe_bt5();
|
||||
#endif
|
||||
if(rf_core_start_rat() != RF_CORE_CMD_OK) {
|
||||
LOG_ERR("rf_core_boot: rf_core_start_rat() failed\n");
|
||||
rf_core_power_down();
|
||||
return RF_CORE_CMD_ERROR;
|
||||
}
|
||||
rf_core_setup_interrupts(0);
|
||||
oscillators_switch_to_hf_xosc();
|
||||
|
||||
|
@ -845,7 +868,11 @@ connection_rx(ble_conn_param_t *param)
|
|||
|
||||
while(RX_ENTRY_STATUS(param->rx_queue_current) == DATA_ENTRY_FINISHED) {
|
||||
rx_data = RX_ENTRY_DATA_PTR(param->rx_queue_current);
|
||||
#if RADIO_CONF_BLE5
|
||||
len = RX_ENTRY_DATA_LENGTH(param->rx_queue_current) - 7 - 2; /* last 9 bytes are status, timestamp, ... */
|
||||
#else
|
||||
len = RX_ENTRY_DATA_LENGTH(param->rx_queue_current) - 6 - 2; /* last 8 bytes are status, timestamp, ... */
|
||||
#endif
|
||||
channel = (rx_data[len + 3] & 0x3F);
|
||||
frame_type = rx_data[0] & 0x03;
|
||||
more_data = (rx_data[0] & 0x10) >> 4;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Graz University of Technology
|
||||
* Copyright (c) 2018, University of Bristol - http://www.bristol.ac.uk/
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -36,6 +37,7 @@
|
|||
*
|
||||
* \author
|
||||
* Michael Spoerk <michael.spoerk@tugraz.at>
|
||||
* Jinyan BAI <onefreebjy@outlook.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
|
@ -57,6 +59,62 @@ static uint16_t tx_power = 0x3161; /* 0 dBm */
|
|||
/*static uint16_t tx_power = 0x0CCB; / * -15 dBm * / */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* BLE overrides */
|
||||
#if RADIO_CONF_BLE5
|
||||
uint32_t ble_overrides_common[] =
|
||||
{
|
||||
/* Rx: Set LNA IB trim value based on the selected defaultPhy.mainMode setting. (NOTE: The value 0x8 is a placeholder. The value to use should be set during run-time by radio driver function.) */
|
||||
ADI_HALFREG_OVERRIDE(0,4,0xF,0x8),
|
||||
/* Rx: Set LNA IB offset used for automatic software compensation to 0 */
|
||||
(uint32_t)0x00008883,
|
||||
/* Synth: Use 24 MHz crystal, enable extra PLL filtering */
|
||||
(uint32_t)0x02010403,
|
||||
/* Synth: Set fine top and bottom code to 127 and 0 */
|
||||
HW_REG_OVERRIDE(0x4020, 0x7F00),
|
||||
/* Synth: Configure faster calibration */
|
||||
HW32_ARRAY_OVERRIDE(0x4004, 1),
|
||||
/* Synth: Configure faster calibration */
|
||||
(uint32_t)0x1C0C0618,
|
||||
/* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC00401A1,
|
||||
/* Synth: Configure faster calibration */
|
||||
(uint32_t)0x21010101,
|
||||
/* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC0040141,
|
||||
/* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00214AD3,
|
||||
/* Synth: Decrease synth programming time-out by 90 us (0x0298 RAT ticks = 166 us) */
|
||||
(uint32_t)0x02980243,
|
||||
/* Bluetooth 5: Set correct total clock accuracy for received AuxPtr assuming local sleep clock of 50 ppm */
|
||||
(uint32_t)0x0E490823,
|
||||
/* override_frontend_id.xml */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
|
||||
uint32_t ble_overrides_1Mbps[] =
|
||||
{
|
||||
/* Rx: Set LNA IB trim to normal trim value. (NOTE: The value 0x8 is a placeholder. The value to use should be set during run-time by radio driver function.) */
|
||||
ADI_HALFREG_OVERRIDE(0,4,0xF,0x8),
|
||||
/* Rx: Configure AGC to use gain table for improved performance */
|
||||
HW_REG_OVERRIDE(0x6084, 0x05F8),
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
|
||||
uint32_t ble_overrides_2Mbps[] =
|
||||
{
|
||||
/* Rx: Set LNA IB trim to normal trim value. (NOTE: The value 0x8 is a placeholder. The value to use should be set during run-time by radio driver function.) */
|
||||
ADI_HALFREG_OVERRIDE(0,4,0xF,0x8),
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
|
||||
uint32_t ble_overrides_coded[] =
|
||||
{
|
||||
/* Rx: Set LNA IB trim to 0xF (maximum) */
|
||||
ADI_HALFREG_OVERRIDE(0,4,0xF,0xF),
|
||||
/* Rx: Override AGC target gain to improve performance */
|
||||
HW_REG_OVERRIDE(0x6088, 0x0018),
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
#else
|
||||
static uint32_t ble_overrides[] = {
|
||||
0x00364038, /* Synth: Set RTRIM (POTAILRESTRIM) to 6 */
|
||||
0x000784A3, /* Synth: Set FREF = 3.43 MHz (24 MHz / 7) */
|
||||
|
@ -67,6 +125,7 @@ static uint32_t ble_overrides[] = {
|
|||
0x008F88B3, /* GPIO mode: https://e2e.ti.com/support/wireless_connectivity/proprietary_sub_1_ghz_simpliciti/f/156/t/488244?*/
|
||||
0xFFFFFFFF, /* End of override list */
|
||||
};
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
rf_ble_cmd_send(uint8_t *command)
|
||||
|
@ -97,14 +156,29 @@ rf_ble_cmd_wait(uint8_t *command)
|
|||
unsigned short
|
||||
rf_ble_cmd_setup_ble_mode(void)
|
||||
{
|
||||
#if RADIO_CONF_BLE5
|
||||
rfc_CMD_BLE5_RADIO_SETUP_t cmd;
|
||||
|
||||
/* Create radio setup command */
|
||||
rf_core_init_radio_op((rfc_radioOp_t *)&cmd, sizeof(cmd), CMD_BLE5_RADIO_SETUP);
|
||||
|
||||
cmd.startTrigger.bEnaCmd = 0;
|
||||
cmd.defaultPhy.mainMode = 1;
|
||||
cmd.defaultPhy.coding = 1;
|
||||
cmd.pRegOverrideCommon = ble_overrides_common;
|
||||
cmd.pRegOverride1Mbps = ble_overrides_1Mbps;
|
||||
cmd.pRegOverride2Mbps = ble_overrides_2Mbps;
|
||||
cmd.pRegOverrideCoded = ble_overrides_coded;
|
||||
#else
|
||||
rfc_CMD_RADIO_SETUP_t cmd;
|
||||
|
||||
/* Create radio setup command */
|
||||
rf_core_init_radio_op((rfc_radioOp_t *)&cmd, sizeof(cmd), CMD_RADIO_SETUP);
|
||||
|
||||
cmd.txPower = tx_power;
|
||||
cmd.pRegOverride = ble_overrides;
|
||||
cmd.mode = 0;
|
||||
cmd.pRegOverride = ble_overrides;
|
||||
#endif
|
||||
cmd.txPower = tx_power;
|
||||
|
||||
/* Send Radio setup to RF Core */
|
||||
if(rf_ble_cmd_send((uint8_t *)&cmd) != RF_BLE_CMD_OK) {
|
||||
|
@ -116,14 +190,26 @@ rf_ble_cmd_setup_ble_mode(void)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* ADVERTISING functions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rf_ble_cmd_create_adv_cmd(uint8_t *command, uint8_t channel,
|
||||
uint8_t *param, uint8_t *output)
|
||||
{
|
||||
#if RADIO_CONF_BLE5
|
||||
rfc_CMD_BLE5_ADV_t *c = (rfc_CMD_BLE5_ADV_t *)command;
|
||||
|
||||
memset(c, 0x00, sizeof(rfc_CMD_BLE5_ADV_t));
|
||||
|
||||
c->commandNo = CMD_BLE5_ADV;
|
||||
c->rangeDelay = 0;
|
||||
|
||||
c->txPower = tx_power;
|
||||
#else
|
||||
rfc_CMD_BLE_ADV_t *c = (rfc_CMD_BLE_ADV_t *)command;
|
||||
|
||||
memset(c, 0x00, sizeof(rfc_CMD_BLE_ADV_t));
|
||||
c->commandNo = CMD_BLE_ADV;
|
||||
#endif
|
||||
c->condition.rule = COND_NEVER;
|
||||
c->whitening.bOverride = 0;
|
||||
c->channel = channel;
|
||||
|
@ -162,12 +248,113 @@ rf_ble_cmd_create_adv_params(uint8_t *param, dataQueue_t *rx_queue,
|
|||
p->endTrigger.triggerType = TRIG_NEVER;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* INITIATOR functions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rf_ble_cmd_create_initiator_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
|
||||
uint8_t *output, uint32_t start_time)
|
||||
{
|
||||
#if RADIO_CONF_BLE5
|
||||
rfc_CMD_BLE5_INITIATOR_t *c = (rfc_CMD_BLE5_INITIATOR_t *)cmd;
|
||||
|
||||
memset(c, 0x00, sizeof(rfc_CMD_BLE5_INITIATOR_t));
|
||||
|
||||
c->commandNo = CMD_BLE5_INITIATOR;
|
||||
c->condition.rule = COND_NEVER;
|
||||
c->whitening.bOverride = 0;
|
||||
c->channel = channel;
|
||||
c->pParams = (rfc_ble5InitiatorPar_t *)params;
|
||||
c->startTrigger.triggerType = TRIG_ABSTIME;
|
||||
c->startTime = start_time;
|
||||
c->pOutput = (rfc_ble5ScanInitOutput_t *)output;
|
||||
|
||||
c->txPower = tx_power;
|
||||
c->rangeDelay = 0;
|
||||
#else
|
||||
rfc_CMD_BLE_INITIATOR_t *c = (rfc_CMD_BLE_INITIATOR_t *)cmd;
|
||||
|
||||
memset(c, 0x00, sizeof(rfc_CMD_BLE_INITIATOR_t));
|
||||
|
||||
c->commandNo = CMD_BLE_INITIATOR;
|
||||
c->condition.rule = COND_NEVER;
|
||||
c->whitening.bOverride = 0;
|
||||
c->channel = channel;
|
||||
c->pParams = (rfc_bleInitiatorPar_t *)params;
|
||||
c->startTrigger.triggerType = TRIG_ABSTIME;
|
||||
c->startTime = start_time;
|
||||
c->pOutput = (rfc_bleInitiatorOutput_t *)output;
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rf_ble_cmd_create_initiator_params(uint8_t *param, dataQueue_t *rx_queue,
|
||||
uint32_t initiator_time,
|
||||
ble_addr_type_t own_addr_type, uint8_t *own_addr,
|
||||
ble_addr_type_t peer_addr_type, uint8_t *peer_addr,
|
||||
uint32_t connect_time, uint8_t *conn_req_data)
|
||||
{
|
||||
#if RADIO_CONF_BLE5
|
||||
rfc_ble5InitiatorPar_t *p = (rfc_ble5InitiatorPar_t *)param;
|
||||
p->backoffPar.bLastSucceeded = 0;
|
||||
p->backoffPar.bLastFailed = 0;
|
||||
p->maxWaitTimeForAuxCh = 0;
|
||||
p->rxStartTime = 0;
|
||||
p->rxListenTime = 0;
|
||||
#else
|
||||
rfc_bleInitiatorPar_t *p = (rfc_bleInitiatorPar_t *)param;
|
||||
#endif
|
||||
p->pRxQ = rx_queue;
|
||||
p->rxConfig.bAutoFlushIgnored = 1;
|
||||
p->rxConfig.bAutoFlushCrcErr = 0;
|
||||
p->rxConfig.bAutoFlushEmpty = 1;
|
||||
p->rxConfig.bIncludeLenByte = 1;
|
||||
p->rxConfig.bIncludeCrc = 0;
|
||||
p->rxConfig.bAppendRssi = 1;
|
||||
p->rxConfig.bAppendStatus = 1;
|
||||
p->rxConfig.bAppendTimestamp = 1;
|
||||
|
||||
/* p->initConfig.bUseWhiteList = 0; */
|
||||
p->initConfig.bUseWhiteList = 1;
|
||||
p->initConfig.bDynamicWinOffset = 0;
|
||||
p->initConfig.deviceAddrType = own_addr_type;
|
||||
p->initConfig.peerAddrType = peer_addr_type;
|
||||
p->initConfig.bStrictLenFilter = 1;
|
||||
|
||||
p->connectReqLen = 22;
|
||||
p->pConnectReqData = conn_req_data;
|
||||
p->pDeviceAddress = (uint16_t *)own_addr;
|
||||
p->pWhiteList = (rfc_bleWhiteListEntry_t *)peer_addr;
|
||||
p->connectTime = connect_time;
|
||||
p->timeoutTrigger.triggerType = TRIG_REL_START;
|
||||
p->timeoutTime = initiator_time;
|
||||
p->endTrigger.triggerType = TRIG_NEVER;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CONNECTION slave functions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rf_ble_cmd_create_slave_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
|
||||
uint8_t *output, uint32_t start_time)
|
||||
{
|
||||
#if RADIO_CONF_BLE5
|
||||
rfc_CMD_BLE5_SLAVE_t *c = (rfc_CMD_BLE5_SLAVE_t *)cmd;
|
||||
|
||||
memset(c, 0x00, sizeof(rfc_CMD_BLE5_SLAVE_t));
|
||||
|
||||
c->commandNo = CMD_BLE5_SLAVE;
|
||||
c->condition.rule = COND_NEVER;
|
||||
c->whitening.bOverride = 0;
|
||||
c->channel = channel;
|
||||
c->pParams = (rfc_ble5SlavePar_t *)params;
|
||||
c->startTrigger.triggerType = TRIG_ABSTIME;
|
||||
c->startTime = start_time;
|
||||
c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
|
||||
|
||||
c->phyMode.mainMode = 1;
|
||||
c->phyMode.coding = 1;
|
||||
c->txPower = tx_power;
|
||||
c->rangeDelay = 0;
|
||||
#else
|
||||
rfc_CMD_BLE_SLAVE_t *c = (rfc_CMD_BLE_SLAVE_t *)cmd;
|
||||
|
||||
memset(c, 0x00, sizeof(rfc_CMD_BLE_SLAVE_t));
|
||||
|
@ -181,6 +368,7 @@ rf_ble_cmd_create_slave_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
|
|||
c->startTrigger.pastTrig = 0;
|
||||
c->startTime = start_time;
|
||||
c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
|
@ -190,8 +378,13 @@ rf_ble_cmd_create_slave_params(uint8_t *params, dataQueue_t *rx_queue,
|
|||
uint8_t crc_init_2, uint32_t win_size,
|
||||
uint32_t window_widening, uint8_t first_packet)
|
||||
{
|
||||
#if RADIO_CONF_BLE5
|
||||
rfc_ble5SlavePar_t *p = (rfc_ble5SlavePar_t *)params;
|
||||
p->maxRxPktLen = 255;
|
||||
p->maxLenLowRate = 0;
|
||||
#else
|
||||
rfc_bleSlavePar_t *p = (rfc_bleSlavePar_t *)params;
|
||||
|
||||
#endif
|
||||
p->pRxQ = rx_queue;
|
||||
p->pTxQ = tx_queue;
|
||||
p->rxConfig.bAutoFlushIgnored = 1;
|
||||
|
@ -230,6 +423,91 @@ rf_ble_cmd_create_slave_params(uint8_t *params, dataQueue_t *rx_queue,
|
|||
p->endTrigger.triggerType = TRIG_NEVER;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CONNECTION master functions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rf_ble_cmd_create_master_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
|
||||
uint8_t *output, uint32_t start_time)
|
||||
{
|
||||
#if RADIO_CONF_BLE5
|
||||
rfc_CMD_BLE5_MASTER_t *c = (rfc_CMD_BLE5_MASTER_t *)cmd;
|
||||
|
||||
memset(c, 0x00, sizeof(rfc_CMD_BLE5_MASTER_t));
|
||||
|
||||
c->commandNo = CMD_BLE5_MASTER;
|
||||
c->condition.rule = COND_NEVER;
|
||||
c->whitening.bOverride = 0;
|
||||
c->channel = channel;
|
||||
c->pParams = (rfc_ble5MasterPar_t *)params;
|
||||
c->startTrigger.triggerType = TRIG_ABSTIME;
|
||||
c->startTime = start_time;
|
||||
c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
|
||||
|
||||
c->phyMode.mainMode = 1;
|
||||
c->phyMode.coding = 1;
|
||||
c->txPower = tx_power;
|
||||
c->rangeDelay = 0;
|
||||
#else
|
||||
rfc_CMD_BLE_MASTER_t *c = (rfc_CMD_BLE_MASTER_t *)cmd;
|
||||
|
||||
memset(c, 0x00, sizeof(rfc_CMD_BLE_MASTER_t));
|
||||
|
||||
c->commandNo = CMD_BLE_MASTER;
|
||||
c->condition.rule = COND_NEVER;
|
||||
c->whitening.bOverride = 0;
|
||||
c->channel = channel;
|
||||
c->pParams = (rfc_bleMasterPar_t *)params;
|
||||
c->startTrigger.triggerType = TRIG_ABSTIME;
|
||||
c->startTime = start_time;
|
||||
c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rf_ble_cmd_create_master_params(uint8_t *params, dataQueue_t *rx_queue,
|
||||
dataQueue_t *tx_queue, uint32_t access_address,
|
||||
uint8_t crc_init_0, uint8_t crc_init_1,
|
||||
uint8_t crc_init_2, uint8_t first_packet)
|
||||
{
|
||||
#if RADIO_CONF_BLE5
|
||||
rfc_ble5MasterPar_t *p = (rfc_ble5MasterPar_t *)params;
|
||||
p->maxRxPktLen = 255;
|
||||
p->maxLenLowRate = 0;
|
||||
#else
|
||||
rfc_bleMasterPar_t *p = (rfc_bleMasterPar_t *)params;
|
||||
#endif
|
||||
p->pRxQ = rx_queue;
|
||||
p->pTxQ = tx_queue;
|
||||
p->rxConfig.bAutoFlushIgnored = 1;
|
||||
p->rxConfig.bAutoFlushCrcErr = 1;
|
||||
p->rxConfig.bAutoFlushEmpty = 1;
|
||||
p->rxConfig.bIncludeLenByte = 1;
|
||||
p->rxConfig.bIncludeCrc = 0;
|
||||
p->rxConfig.bAppendRssi = 1;
|
||||
p->rxConfig.bAppendStatus = 1;
|
||||
p->rxConfig.bAppendTimestamp = 1;
|
||||
|
||||
if(first_packet) {
|
||||
/* set parameters for first packet according to TI Technical Reference Manual */
|
||||
p->seqStat.lastRxSn = 1;
|
||||
p->seqStat.lastTxSn = 1;
|
||||
p->seqStat.nextTxSn = 0;
|
||||
p->seqStat.bFirstPkt = 1;
|
||||
p->seqStat.bAutoEmpty = 0;
|
||||
p->seqStat.bLlCtrlTx = 0;
|
||||
p->seqStat.bLlCtrlAckRx = 0;
|
||||
p->seqStat.bLlCtrlAckPending = 0;
|
||||
}
|
||||
|
||||
p->maxPkt = 12;
|
||||
p->accessAddress = access_address;
|
||||
p->crcInit0 = crc_init_0;
|
||||
p->crcInit1 = crc_init_1;
|
||||
p->crcInit2 = crc_init_2;
|
||||
p->endTrigger.triggerType = TRIG_REL_START;
|
||||
p->endTime = (uint32_t)15 * 4000; /* a connection event must end after 10 ms */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* DATA queue functions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
|
|
|
@ -106,6 +106,45 @@ void rf_ble_cmd_create_adv_params(uint8_t *param, dataQueue_t *rx_queue,
|
|||
uint8_t scan_resp_data_len, uint8_t *scan_resp_data,
|
||||
ble_addr_type_t own_addr_type, uint8_t *own_addr);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Creates a BLE radio command structure that sets up
|
||||
* BLE initiation event when sent to the radio core
|
||||
* \param cmd A pointer to command that is created
|
||||
* \param channel The BLE data channel used for the connection event
|
||||
* \param params A pointer to the radio command parameters
|
||||
* \param output A pointer to the radio command output
|
||||
* \param start_time
|
||||
* The time in rf_core_ticks when the connection event will start
|
||||
*/
|
||||
void rf_ble_cmd_create_initiator_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
|
||||
uint8_t *output, uint32_t start_time);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Creates BLE radio command parameters that are used to set up
|
||||
* BLE initiation event on the radio core
|
||||
* \param param A pointer to parameter structure that is created
|
||||
* \param rx_queue A pointer to the RX queue that is used
|
||||
* \param initiator_window
|
||||
* T
|
||||
* \param own_addr_type
|
||||
* Either BLE_ADDR_TYPE_PUBLIC or BLE_ADDR_TYPE_RANDOM
|
||||
* \param own_addr A pointer to the device address that is used as own address
|
||||
* \param peer_addr_type
|
||||
* Either BLE_ADDR_TYPE_PUBLIC or BLE_ADDR_TYPE_RANDOM
|
||||
* \param peer_addr A pointer to the device address that is used as peer address
|
||||
* \param connect_time
|
||||
The first possible start time of the first connection event
|
||||
* \param conn_req_data A pointer to the connect request data
|
||||
*/
|
||||
void rf_ble_cmd_create_initiator_params(uint8_t *param, dataQueue_t *rx_queue,
|
||||
uint32_t initiator_window,
|
||||
ble_addr_type_t own_addr_type, uint8_t *own_addr,
|
||||
ble_addr_type_t peer_addr_type, uint8_t *peer_addr,
|
||||
uint32_t connect_time,
|
||||
uint8_t *conn_req_data);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Creates a BLE radio command structure that sets up a single
|
||||
|
@ -148,6 +187,44 @@ void rf_ble_cmd_create_slave_params(uint8_t *param, dataQueue_t *rx_queue,
|
|||
uint8_t crc_init_2, uint32_t win_size,
|
||||
uint32_t window_widening, uint8_t first_packet);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Creates a BLE radio command structure that sets up
|
||||
* BLE connection event when sent to the radio core
|
||||
* \param cmd A pointer to command that is created
|
||||
* \param channel The BLE data channel used for the connection event
|
||||
* \param params A pointer to the radio command parameters
|
||||
* \param output A pointer to the radio command output
|
||||
* \param start_time
|
||||
* The time in rf_core_ticks when the connection event will start
|
||||
*/
|
||||
void rf_ble_cmd_create_master_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
|
||||
uint8_t *output, uint32_t start_time);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Creates BLE radio command parameters that are used to set up
|
||||
* BLE connection event on the radio core
|
||||
* \param params A pointer to parameter structure that is created
|
||||
* \param rx_queue A pointer to the RX queue that is used
|
||||
* \param tx_queue A pointer to the TX queue that is used
|
||||
* \param access_address
|
||||
* The access address of the used BLE connection
|
||||
* \param crc_init_0
|
||||
* Part of the initialization of the CRC checksum
|
||||
* \param crc_init_1
|
||||
* Part of the initialization of the CRC checksum
|
||||
* \param crc_init_2
|
||||
* Part of the initialization of the CRC checksum
|
||||
* \param first_packet
|
||||
* 1 for the first packet of the BLE connection so that the
|
||||
* connection is properly initialized
|
||||
*/
|
||||
void rf_ble_cmd_create_master_params(uint8_t *params, dataQueue_t *rx_queue,
|
||||
dataQueue_t *tx_queue, uint32_t access_address,
|
||||
uint8_t crc_init_0, uint8_t crc_init_1,
|
||||
uint8_t crc_init_2, uint8_t first_packet);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Adds a data buffer to a BLE transmission queue
|
||||
|
|
|
@ -399,6 +399,11 @@ rf_core_set_modesel()
|
|||
} else if(chip_type == CHIP_TYPE_CC1350) {
|
||||
HWREG(PRCM_BASE + PRCM_O_RFCMODESEL) = PRCM_RFCMODESEL_CURR_MODE5;
|
||||
rv = RF_CORE_CMD_OK;
|
||||
#ifdef ThisLibraryIsFor_CC26x0R2_HaltIfViolated
|
||||
} else if (chip_type == CHIP_TYPE_CC2640R2) {
|
||||
HWREG(PRCM_BASE + PRCM_O_RFCMODESEL) = PRCM_RFCMODESEL_CURR_MODE1;
|
||||
rv = RF_CORE_CMD_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -90,6 +90,7 @@
|
|||
|
||||
/* IOC API */
|
||||
#define ti_lib_rom_ioc_port_configure_set ROM_IOCPortConfigureSet
|
||||
#if !defined(ThisLibraryIsFor_CC26x0R2_HaltIfViolated)
|
||||
#define ti_lib_rom_ioc_port_configure_get ROM_IOCPortConfigureGet
|
||||
#define ti_lib_rom_ioc_io_shutdown_set ROM_IOCIOShutdownSet
|
||||
#define ti_lib_rom_ioc_io_mode_set ROM_IOCIOModeSet
|
||||
|
@ -109,6 +110,7 @@
|
|||
#define ti_lib_rom_ioc_pin_type_ssi_slave ROM_IOCPinTypeSsiSlave
|
||||
#define ti_lib_rom_ioc_pin_type_i2c ROM_IOCPinTypeI2c
|
||||
#define ti_lib_rom_ioc_pin_type_aux ROM_IOCPinTypeAux
|
||||
#endif
|
||||
|
||||
/* PRCM API */
|
||||
#define ti_lib_rom_prcm_inf_clock_configure_set ROM_PRCMInfClockConfigureSet
|
||||
|
|
|
@ -200,8 +200,14 @@
|
|||
#define ti_lib_chipinfo_get_device_id_hw_rev_code(...) ChipInfo_GetDeviceIdHwRevCode(__VA_ARGS__)
|
||||
#define ti_lib_chipinfo_get_chip_type(...) ChipInfo_GetChipType(__VA_ARGS__)
|
||||
#define ti_lib_chipinfo_get_chip_family(...) ChipInfo_GetChipFamily(__VA_ARGS__)
|
||||
#ifdef ThisLibraryIsFor_CC26x0R2_HaltIfViolated
|
||||
#define ti_lib_chipinfo_chip_family_is_cc26xx(...) ChipInfo_ChipFamilyIs_CC26x0(__VA_ARGS__)
|
||||
#define ti_lib_chipinfo_chip_family_is_cc13xx(...) ChipInfo_ChipFamilyIs_CC13x0(__VA_ARGS__)
|
||||
#define ti_lib_chipinfo_chip_family_is_cc26x0r2(...) ChipInfo_ChipFamilyIs_CC26x0R2(__VA_ARGS__)
|
||||
#else
|
||||
#define ti_lib_chipinfo_chip_family_is_cc26xx(...) ChipInfo_ChipFamilyIsCC26xx(__VA_ARGS__)
|
||||
#define ti_lib_chipinfo_chip_family_is_cc13xx(...) ChipInfo_ChipFamilyIsCC13xx(__VA_ARGS__)
|
||||
#endif
|
||||
#define ti_lib_chipinfo_get_hw_revision(...) ChipInfo_GetHwRevision(__VA_ARGS__)
|
||||
#define ti_lib_chipinfo_hw_revision_is_1_0(...) ChipInfo_HwRevisionIs_1_0(__VA_ARGS__)
|
||||
#define ti_lib_chipinfo_hw_revision_is_gteq_2_0(...) ChipInfo_HwRevisionIs_GTEQ_2_0(__VA_ARGS__)
|
||||
|
@ -388,8 +394,10 @@
|
|||
#define ti_lib_pwr_ctrl_source_get(...) PowerCtrlSourceGet(__VA_ARGS__)
|
||||
#define ti_lib_pwr_ctrl_reset_source_get(...) PowerCtrlResetSourceGet(__VA_ARGS__)
|
||||
#define ti_lib_pwr_ctrl_reset_source_clear(...) PowerCtrlResetSourceClear(__VA_ARGS__)
|
||||
#if !defined(ThisLibraryIsFor_CC26x0R2_HaltIfViolated)
|
||||
#define ti_lib_pwr_ctrl_io_freeze_enable(...) PowerCtrlIOFreezeEnable(__VA_ARGS__)
|
||||
#define ti_lib_pwr_ctrl_io_freeze_disable(...) PowerCtrlIOFreezeDisable(__VA_ARGS__)
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* rfc.h */
|
||||
#include "driverlib/rfc.h"
|
||||
|
|
|
@ -43,6 +43,12 @@ static gpio_hal_pin_cfg_t pin_cfg[GPIO_HAL_PIN_COUNT];
|
|||
static uint8_t pin_state[GPIO_HAL_PIN_COUNT];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_init(void)
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin)
|
||||
{
|
||||
if(pin >= GPIO_HAL_PIN_COUNT) {
|
||||
|
|
|
@ -25,9 +25,9 @@ ifneq ($(NRF52_WITHOUT_SOFTDEVICE),1)
|
|||
NRF52_SOFTDEVICE := $(shell find $(NRF52_SDK_ROOT) -name *iot*_softdevice.hex | head -n 1)
|
||||
endif
|
||||
$(info SoftDevice: $(NRF52_SOFTDEVICE))
|
||||
LINKER_SCRIPT := $(CONTIKI_CPU)/ld/nrf52-$(NRF52_DK_REVISION)-sd.ld
|
||||
LDSCRIPT := $(CONTIKI_CPU)/ld/nrf52-$(NRF52_DK_REVISION)-sd.ld
|
||||
else
|
||||
LINKER_SCRIPT := $(CONTIKI_CPU)/ld/nrf52.ld
|
||||
LDSCRIPT := $(CONTIKI_CPU)/ld/nrf52.ld
|
||||
endif
|
||||
|
||||
OUTPUT_FILENAME := $(CONTIKI_PROJECT)
|
||||
|
@ -140,7 +140,7 @@ CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
|||
|
||||
# keep every function in separate section. This will allow linker to dump unused functions
|
||||
LDFLAGS += -Xlinker -Map=$(CONTIKI_NG_PROJECT_MAP)
|
||||
LDFLAGS += -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
|
||||
LDFLAGS += -mabi=aapcs -L $(TEMPLATE_PATH)
|
||||
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
# let linker to dump unused sections
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
|
@ -174,7 +174,7 @@ OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
|
|||
|
||||
CLEAN += nrf52832.a
|
||||
|
||||
TARGET_LIBS= nrf52832.a $(NRF52_SDK_ROOT)/components/iot/ble_6lowpan/lib/ble_6lowpan.a
|
||||
TARGET_LIBS = nrf52832.a $(NRF52_SDK_ROOT)/components/iot/ble_6lowpan/lib/ble_6lowpan.a
|
||||
|
||||
nrf52832.a: $(OBJECTS)
|
||||
$(TRACE_AR)
|
||||
|
|
|
@ -0,0 +1,152 @@
|
|||
################################################################################
|
||||
### CC13xx/CC26xx CPU makefile
|
||||
|
||||
CC13x2_CC26x2_PRE_RTM ?= 1
|
||||
|
||||
# Core SDK is placed as a submodule under arch/cpu/cc13xx-cc26xx/lib.
|
||||
# Do a sanity check that Core SDK submodule has been initialized.
|
||||
ifndef CORE_SDK
|
||||
CORE_SDK := $(CONTIKI_CPU)/lib/coresdk_cc13xx_cc26xx
|
||||
CORE_SDK_INIT := $(shell [ -f $(CORE_SDK)/.git ] && echo 1)
|
||||
|
||||
ifneq ($(CORE_SDK_INIT),1)
|
||||
$(error The Core SDK submodule is not available. Please run 'git submodule update --init --recursive')
|
||||
endif
|
||||
# Note that Core SDK can be overriden with a user-specified SimpleLink SDK.
|
||||
# As long as the SimpleLink SDK matches the device in use and is of a reasonable
|
||||
# newer version, then it should be no different than using Core SDK.
|
||||
else
|
||||
# Do a sanity check the path exists.
|
||||
CORE_SDK_VALID := $(shell [ -d $(CORE_SDK) ] && echo 1)
|
||||
|
||||
ifneq ($(CORE_SDK_VALID),1)
|
||||
$(error User-specified CORE_SDK is not a valid path.)
|
||||
endif
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
### Device Family
|
||||
|
||||
# CC13x2/CC26x2 has to differentiate both pre-RTM and RTM devices. As of now,
|
||||
# pre-RTM is suffixed with _v1 while RTM is suffixed with _v2. This will be
|
||||
# removed when CC13x2/CC26x2 RTMs. For now, provide a switch to choose
|
||||
# either pre-RTM or RTM.
|
||||
# Also note that the devices name is cc13x2_cc26x2 for all CC13x2/CC26x2
|
||||
# devices, while the library name is individual for each device family.
|
||||
ifeq ($(SUBFAMILY),cc13x2-cc26x2)
|
||||
ifeq ($(CC13x2_CC26x2_PRE_RTM),1)
|
||||
SDK_DEVICES_NAME := cc13x2_cc26x2_v1
|
||||
SDK_LIB_NAME := $(DEVICE_FAMILY_LC)_v1
|
||||
else
|
||||
SDK_DEVICES_NAME := cc13x2_cc26x2_v2
|
||||
SDK_LIB_NAME := $(DEVICE_FAMILY_LC)_v2
|
||||
endif
|
||||
# CC13x0/CC26x0 does not have this, with both its devices name and library
|
||||
# name the same as its own device family name.
|
||||
else
|
||||
SDK_DEVICES_NAME := $(DEVICE_FAMILY_LC)
|
||||
SDK_LIB_NAME := $(DEVICE_FAMILY_LC)
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
### CC13xx/CC26xx CPU files
|
||||
|
||||
# Both ccfg-conf.c and startup_cc13xx_cc26xx_gcc.c is located locally in
|
||||
# the arch/cpu/cc13xx-cc26xx folder.
|
||||
CPU_START_SOURCEFILES += ccfg-conf.c startup_cc13xx_cc26xx_gcc.c
|
||||
|
||||
# CPU-dependent source files
|
||||
CONTIKI_CPU_SOURCEFILES += rtimer-arch.c clock-arch.c
|
||||
CONTIKI_CPU_SOURCEFILES += watchdog-arch.c dbg-arch.c
|
||||
CONTIKI_CPU_SOURCEFILES += uart0-arch.c slip-arch.c
|
||||
CONTIKI_CPU_SOURCEFILES += gpio-hal-arch.c int-master-arch.c
|
||||
CONTIKI_CPU_SOURCEFILES += random.c trng-arch.c
|
||||
CONTIKI_CPU_SOURCEFILES += spi-arch.c
|
||||
|
||||
# RF source files
|
||||
CONTIKI_CPU_SOURCEFILES += sched.c data-queue.c
|
||||
CONTIKI_CPU_SOURCEFILES += ieee-addr.c ble-addr.c
|
||||
CONTIKI_CPU_SOURCEFILES += ble-beacond.c
|
||||
|
||||
ifeq ($(SUPPORTS_PROP_MODE),1)
|
||||
CONTIKI_CPU_SOURCEFILES += prop-mode.c prop-settings.c prop-tx-power.c
|
||||
endif
|
||||
|
||||
ifeq ($(SUPPORTS_IEEE_MODE),1)
|
||||
CONTIKI_CPU_SOURCEFILES += ieee-mode.c ieee-settings.c ieee-tx-power.c
|
||||
endif
|
||||
|
||||
ifeq ($(SUPPORTS_BLE_BEACON),1)
|
||||
CONTIKI_CPU_SOURCEFILES += ble-settings.c ble-tx-power.c
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
### Modules and paths
|
||||
|
||||
# Core SDK paths
|
||||
SDK_NORTOS := $(CORE_SDK)/kernel/nortos
|
||||
SDK_SOURCE := $(CORE_SDK)/source
|
||||
SDK_DRIVERS := $(CORE_SDK)/source/ti/drivers
|
||||
SDK_DEVICES := $(CORE_SDK)/source/ti/devices/$(SDK_DEVICES_NAME)
|
||||
|
||||
EXTERNALDIRS += $(SDK_SOURCE) $(SDK_NORTOS)
|
||||
|
||||
# CPU-dependent debug source files
|
||||
MODULES += os/lib/dbg-io
|
||||
|
||||
# CPU-dependent directories
|
||||
CONTIKI_CPU_DIRS += . dev $(SUBFAMILY)
|
||||
CONTIKI_CPU_DIRS += rf rf-settings rf-settings/$(DEVICE_FAMILY_LC)
|
||||
|
||||
CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(DEBUG_IO_SOURCEFILES)
|
||||
|
||||
################################################################################
|
||||
### Compiler configuration
|
||||
|
||||
# A weird behaviour of GCC garbage collector has been observed, where
|
||||
# unitialized global variables with global linkage (aka non-static) put in the
|
||||
# COMMON section weren't analyzed by the garbage collector at all. No idea why.
|
||||
# The solution is to disable the common section, which subsequently places all
|
||||
# unitialized global variables with global linkage in the .bss section,
|
||||
# allowing the GC to analyze the variables. This is especially an issue with
|
||||
# Board.h files, as they rely heavily on global variables placed in COMMON to
|
||||
# be garbage collected if unused.
|
||||
CFLAGS += -fno-common
|
||||
|
||||
################################################################################
|
||||
### Linker configuration
|
||||
|
||||
# Linker flags
|
||||
LDFLAGS += --entry resetISR
|
||||
LDFLAGS += --specs=nano.specs
|
||||
LDFLAGS += -nostartfiles
|
||||
LDFLAGS += -static
|
||||
|
||||
# Linker script
|
||||
LDSCRIPT := $(CONTIKI_CPU)/$(SUBFAMILY)/$(SUBFAMILY).lds
|
||||
|
||||
# Globally linked libraries
|
||||
TARGET_LIBFILES += -lc -lgcc -lnosys -lm
|
||||
|
||||
################################################################################
|
||||
### Specialized build targets
|
||||
|
||||
.PHONY: FORCE
|
||||
FORCE:
|
||||
|
||||
# Always re-build ieee-addr.o in case the command line passes a new NODEID
|
||||
$(OBJECTDIR)/ieee-addr.o: ieee-addr.c FORCE | $(OBJECTDIR)
|
||||
$(TRACE_CC)
|
||||
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# Always re-build ccfg-conf.c so any changes to CCFG configuration
|
||||
# always applies
|
||||
$(OBJECTDIR)/ccfg-conf.o: ccfg-conf.c FORCE | $(OBJECTDIR)
|
||||
$(TRACE_CC)
|
||||
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
################################################################################
|
||||
### Sub-family Makefile
|
||||
|
||||
# Include the Sub-family Makefile specific for the specified device
|
||||
include $(CONTIKI_CPU)/$(SUBFAMILY)/Makefile.$(SUBFAMILY)
|
|
@ -0,0 +1,11 @@
|
|||
################################################################################
|
||||
### CC13x0/CC26x0 CPU makefile
|
||||
|
||||
# Simplelink SDK pre-compiled libraries
|
||||
TARGET_LIBFILES += $(SDK_NORTOS)/lib/nortos_$(SDK_LIB_NAME).am3g
|
||||
TARGET_LIBFILES += $(SDK_DRIVERS)/rf/lib/rf_multiMode_$(SDK_LIB_NAME).am3g
|
||||
TARGET_LIBFILES += $(SDK_DRIVERS)/lib/drivers_$(SDK_LIB_NAME).am3g
|
||||
TARGET_LIBFILES += $(SDK_DEVICES)/driverlib/bin/gcc/driverlib.lib
|
||||
|
||||
# CC13x0/CC26x0 is a Cortex-M3 architecture
|
||||
include $(CONTIKI)/arch/cpu/arm/cortex-m/cm3/Makefile.cm3
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* Template:
|
||||
* Copyright (c) 2012 ARM LIMITED
|
||||
* All rights reserved.
|
||||
*
|
||||
* CC13xx-CC26xx:
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* 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-cm3 CC13xx/CC26xx CMSIS
|
||||
*
|
||||
* CC13xx/CC26xx Cortex-M3 CMSIS definitions
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* CMSIS Cortex-M3 core peripheral access layer header file for CC13xx/CC26xx
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef CC13XX_CC26XX_CM3_H_
|
||||
#define CC13XX_CC26XX_CM3_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Interrupt Number Definition
|
||||
* @{
|
||||
*/
|
||||
typedef enum cc13xx_cc26xx_cm3_irq_e {
|
||||
/* Cortex-M3 Processor Exceptions */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_RESET = -15, /**< 1 Reset */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_NMI = -14, /**< 2 NMI */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_HARD_FAULT = -13, /**< 3 Hard fault */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_MPU_FAULT = -12, /**< 4 MPU fault */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_BUS_FAULT = -11, /**< 5 Bus fault */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_USAGE_FAULT = -10, /**< 6 Usage fault */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_SV_CALL = -5, /**< 11 SVCall */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_DEBUG_MON = -4, /**< 12 Debug monitor */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_PEND_SV = -2, /**< 14 PendSV */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_SYS_TICK = -1, /**< 15 SysTick */
|
||||
|
||||
/* CC13xx/CC26xx interrupts */
|
||||
CC13XX_CC26XX_CM3_IRQ_EDGE_DETECT = 0, /**< 16 AON edge detect */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_I2C = 1, /**< 17 I2C */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_RF_CPE1 = 2, /**< 18 RF Command and Packet Engine 1 */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_AON_SPI_SLAVE = 3, /**< 19 AON SpiSplave Rx, Tx and CS */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_AON_RTC = 4, /**< 20 AON RTC */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_UART0 = 5, /**< 21 UART0 Rx and Tx */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_AON_AUX_SWEV0 = 6, /**< 22 Sensor Controller software event 0, through AON domain*/
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_SSI0 = 7, /**< 23 SSI0 Rx and Tx */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_SSI1 = 8, /**< 24 SSI1 Rx and Tx */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_RF_CPE0 = 9, /**< 25 RF Command and Packet Engine 0 */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_RF_HW = 10, /**< 26 RF Core Hardware */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_RF_CMD_ACK = 11, /**< 27 RF Core Command Acknowledge */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_I2S = 12, /**< 28 I2S */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_AON_AUX_SWEV1 = 13, /**< 29 Sensor Controller software event 1, through AON domain*/
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_WATCHDOG = 14, /**< 30 Watchdog timer */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_GPTIMER_0A = 15, /**< 31 Timer 0 subtimer A */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_GPTIMER_0B = 16, /**< 32 Timer 0 subtimer B */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_GPTIMER_1A = 17, /**< 33 Timer 1 subtimer A */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_GPTIMER_1B = 18, /**< 34 Timer 1 subtimer B */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_GPTIMER_2A = 19, /**< 35 Timer 2 subtimer A */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_GPTIMER_2B = 20, /**< 36 Timer 2 subtimer B */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_GPTIMER_3A = 21, /**< 37 Timer 3 subtimer A */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_GPTIMER_3B = 22, /**< 38 Timer 3 subtimer B */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_CRYPTO = 23, /**< 39 Crypto Core Result available */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_UDMA = 24, /**< 40 uDMA Software */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_UDMA_ERR = 25, /**< 41 uDMA Error */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_FLASH_CTRL = 26, /**< 42 Flash controller */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_SW0 = 27, /**< 43 Software Event 0 */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_AUX_COM_EVENT = 28, /**< 44 AUX combined event, directly to MCU domain*/
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_AON_PRG0 = 29, /**< 45 AON programmable 0 */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_PROG = 30, /**< 46 Dynamic Programmable interrupt (default source: PRCM)*/
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_AUX_COMPA = 31, /**< 47 AUX Comparator A */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_AUX_ADC = 32, /**< 48 AUX ADC IRQ */
|
||||
CC13XX_CC26XX_CM3_EXCEPTION_TRNG = 33, /**< 49 TRNG event */
|
||||
} cc13xx_cc26xx_cm3_irq_t;
|
||||
|
||||
typedef cc13xx_cc26xx_cm3_irq_t IRQn_Type;
|
||||
|
||||
#define SysTick_IRQn CC13XX_CC26XX_CM3_EXCEPTION_SYS_TICK
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name Processor and Core Peripheral Section
|
||||
* @{
|
||||
*/
|
||||
/* Configuration of the Cortex-M3 Processor and Core Peripherals */
|
||||
#define __MPU_PRESENT 1 /**< MPU present or not */
|
||||
#define __NVIC_PRIO_BITS 3 /**< Number of Bits used for Priority Levels */
|
||||
#define __Vendor_SysTickConfig 0 /**< Set to 1 if different SysTick Config is used */
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "core_cm3.h" /* Cortex-M3 processor and core peripherals */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* CC13XX_CC26XX_CM3_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Texas Instruments Incorporated
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of Texas Instruments Incorporated nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
define symbol STACK_SIZE = 0x800; /* 2048 bytes */
|
||||
define symbol HEAP_SIZE = 0x100; /* 256 bytes */
|
||||
|
||||
define symbol __intvec_start__ = 0x00000000;
|
||||
|
||||
/*-Memory Regions-*/
|
||||
define symbol ROM_start__ = 0x00000000;
|
||||
define symbol ROM_end__ = 0x0001FFFF;
|
||||
define symbol RAM_start__ = 0x20000000;
|
||||
define symbol RAM_end__ = 0x20004FFF;
|
||||
|
||||
/* Define a memory region that covers the entire 4 GB addressable space */
|
||||
define memory mem with size = 4G;
|
||||
|
||||
/* Define a region for the on-chip flash */
|
||||
define region FLASH_region = mem:[from ROM_start__ to ROM_end__];
|
||||
|
||||
/* Define a region for the on-chip SRAM */
|
||||
define region RAM_region = mem:[from RAM_start__ to RAM_end__];
|
||||
|
||||
/* Place the interrupt vectors at the start of flash */
|
||||
place at address mem:__intvec_start__ { readonly section .intvec };
|
||||
keep { section .intvec };
|
||||
|
||||
/* Place the CCA area at the end of flash */
|
||||
place at end of FLASH_region { readonly section .ccfg };
|
||||
keep { section .ccfg };
|
||||
|
||||
/* Place remaining 'read only' in Flash */
|
||||
place in FLASH_region { readonly };
|
||||
|
||||
/* Place all read/write items into RAM */
|
||||
place in RAM_region { readwrite };
|
||||
initialize by copy { readwrite };
|
||||
|
||||
/*
|
||||
* Define CSTACK block to contain .stack section. This enables the IAR IDE
|
||||
* to properly show the stack content during debug. Place stack at end of
|
||||
* retention RAM, do not initialize (initializing the stack will destroy the
|
||||
* return address from the initialization code, causing the processor to branch
|
||||
* to zero and fault)
|
||||
*/
|
||||
define block CSTACK with alignment = 8, size = STACK_SIZE { section .stack };
|
||||
place at end of RAM_region { block CSTACK };
|
||||
do not initialize { section .stack, section .noinit };
|
||||
|
||||
/* Export stack top symbol. Used by startup file */
|
||||
define exported symbol STACK_TOP = RAM_end__ + 1;
|
||||
|
||||
/* Primary Heap configuration */
|
||||
define block HEAP with alignment = 8, size = HEAP_SIZE { };
|
||||
|
||||
/* Place heap just before CSTACK */
|
||||
place in RAM_region { block HEAP };
|
|
@ -0,0 +1,232 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, Texas Instruments Incorporated
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of Texas Instruments Incorporated nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
MIN_STACKSIZE = 0x600; /* 1536 bytes */
|
||||
HEAPSIZE = 0x100; /* 256 bytes */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x0001ffa8
|
||||
/*
|
||||
* Customer Configuration Area and Bootloader Backdoor configuration in
|
||||
* flash, 40 bytes
|
||||
*/
|
||||
FLASH_CCFG (RX) : ORIGIN = 0x0001ffa8, LENGTH = 0x00000058
|
||||
SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00005000
|
||||
GPRAM (RWX) : ORIGIN = 0x11000000, LENGTH = 0x00002000
|
||||
}
|
||||
|
||||
REGION_ALIAS("REGION_TEXT", FLASH);
|
||||
REGION_ALIAS("REGION_BSS", SRAM);
|
||||
REGION_ALIAS("REGION_DATA", SRAM);
|
||||
REGION_ALIAS("REGION_STACK", SRAM);
|
||||
REGION_ALIAS("REGION_HEAP", SRAM);
|
||||
REGION_ALIAS("REGION_ARM_EXIDX", FLASH);
|
||||
REGION_ALIAS("REGION_ARM_EXTAB", FLASH);
|
||||
|
||||
SECTIONS {
|
||||
|
||||
PROVIDE (_resetVecs_base_addr = DEFINED(_resetVecs_base_addr)
|
||||
? _resetVecs_base_addr
|
||||
: 0x0);
|
||||
|
||||
.resetVecs (_resetVecs_base_addr) : AT (_resetVecs_base_addr) {
|
||||
KEEP (*(.resetVecs))
|
||||
} > REGION_TEXT
|
||||
|
||||
.ramVecs (NOLOAD) : ALIGN(1024) {
|
||||
KEEP (*(.ramVecs))
|
||||
} > REGION_DATA
|
||||
|
||||
/*
|
||||
* UDMACC26XX_CONFIG_BASE below must match UDMACC26XX_CONFIG_BASE defined
|
||||
* by ti/drivers/dma/UDMACC26XX.h
|
||||
* The user is allowed to change UDMACC26XX_CONFIG_BASE to move it away from
|
||||
* the default address 0x2000_0400, but remember it must be 1024 bytes aligned.
|
||||
*/
|
||||
UDMACC26XX_CONFIG_BASE = 0x20000400;
|
||||
|
||||
/*
|
||||
* Define absolute addresses for the DMA channels.
|
||||
* DMA channels must always be allocated at a fixed offset from the DMA base address.
|
||||
* CTEA := Control Table Entry Address
|
||||
* --------- DO NOT MODIFY -----------
|
||||
*/
|
||||
DMA_SPI0_RX_CTEA = (UDMACC26XX_CONFIG_BASE + 0x30);
|
||||
DMA_SPI0_TX_CTEA = (UDMACC26XX_CONFIG_BASE + 0x40);
|
||||
DMA_ADC_PRI_CTEA = (UDMACC26XX_CONFIG_BASE + 0x70);
|
||||
DMA_GPT0A_PRI_CTEA = (UDMACC26XX_CONFIG_BASE + 0x90);
|
||||
DMA_SPI1_RX_CTEA = (UDMACC26XX_CONFIG_BASE + 0x100);
|
||||
DMA_SPI1_TX_CTEA = (UDMACC26XX_CONFIG_BASE + 0x110);
|
||||
DMA_ADC_ALT_CTEA = (UDMACC26XX_CONFIG_BASE + 0x270);
|
||||
DMA_GPT0A_ALT_CTEA = (UDMACC26XX_CONFIG_BASE + 0x290);
|
||||
|
||||
/*
|
||||
* Allocate SPI0, SPI1, ADC, and GPTimer0 DMA descriptors at absolute addresses.
|
||||
* --------- DO NOT MODIFY -----------
|
||||
*/
|
||||
UDMACC26XX_dmaSpi0RxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi0RxControlTableEntry DMA_SPI0_RX_CTEA : AT (DMA_SPI0_RX_CTEA) {
|
||||
*(.dmaSpi0RxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaSpi0TxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi0TxControlTableEntry DMA_SPI0_TX_CTEA : AT (DMA_SPI0_TX_CTEA) {
|
||||
*(.dmaSpi0TxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaADCPriControlTableEntry_is_placed = 0;
|
||||
.dmaADCPriControlTableEntry DMA_ADC_PRI_CTEA : AT (DMA_ADC_PRI_CTEA) {
|
||||
*(.dmaADCPriControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaGPT0APriControlTableEntry_is_placed = 0;
|
||||
.dmaGPT0APriControlTableEntry DMA_GPT0A_PRI_CTEA : AT (DMA_GPT0A_PRI_CTEA) {
|
||||
*(.dmaGPT0APriControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaSpi1RxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi1RxControlTableEntry DMA_SPI1_RX_CTEA : AT (DMA_SPI1_RX_CTEA) {
|
||||
*(.dmaSpi1RxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaSpi1TxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi1TxControlTableEntry DMA_SPI1_TX_CTEA : AT (DMA_SPI1_TX_CTEA) {
|
||||
*(.dmaSpi1TxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaADCAltControlTableEntry_is_placed = 0;
|
||||
.dmaADCAltControlTableEntry DMA_ADC_ALT_CTEA : AT (DMA_ADC_ALT_CTEA) {
|
||||
*(.dmaADCAltControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaGPT0AAltControlTableEntry_is_placed = 0;
|
||||
.dmaGPT0AAltControlTableEntry DMA_GPT0A_ALT_CTEA : AT (DMA_GPT0A_ALT_CTEA) {
|
||||
*(.dmaGPT0AAltControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
.text : {
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
. = ALIGN(0x4);
|
||||
KEEP (*(.ctors))
|
||||
. = ALIGN(0x4);
|
||||
KEEP (*(.dtors))
|
||||
. = ALIGN(0x4);
|
||||
__init_array_start = .;
|
||||
KEEP (*(.init_array*))
|
||||
__init_array_end = .;
|
||||
*(.init)
|
||||
*(.fini*)
|
||||
} > REGION_TEXT AT> REGION_TEXT
|
||||
|
||||
PROVIDE(__etext = .);
|
||||
PROVIDE(_etext = .);
|
||||
PROVIDE(etext = .);
|
||||
|
||||
.rodata : {
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
} > REGION_TEXT AT> REGION_TEXT
|
||||
|
||||
.data : ALIGN(0x4) {
|
||||
__data_load__ = LOADADDR(.data);
|
||||
__data_start__ = .;
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
. = ALIGN (0x4);
|
||||
__data_end__ = .;
|
||||
} > REGION_DATA AT> REGION_TEXT
|
||||
|
||||
.ARM.exidx : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
__exidx_end = .;
|
||||
} > REGION_ARM_EXIDX AT> REGION_ARM_EXIDX
|
||||
|
||||
.ARM.extab : {
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > REGION_ARM_EXTAB AT> REGION_ARM_EXTAB
|
||||
|
||||
.nvs (NOLOAD) : ALIGN(0x1000) {
|
||||
*(.nvs)
|
||||
} > REGION_TEXT
|
||||
|
||||
.ccfg : {
|
||||
KEEP(*(.ccfg))
|
||||
} > FLASH_CCFG AT> FLASH_CCFG
|
||||
|
||||
.bss : {
|
||||
__bss_start__ = .;
|
||||
*(.shbss)
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(0x4);
|
||||
__bss_end__ = .;
|
||||
} > REGION_BSS AT> REGION_BSS
|
||||
|
||||
/* Start of heap must be 4 byte aligned */
|
||||
.heap (NOLOAD) : ALIGN(0x4) {
|
||||
PROVIDE(__heap_start__ = .);
|
||||
PROVIDE(_heap = __heap_start__);
|
||||
PROVIDE(end = __heap_start__);
|
||||
PROVIDE(_end = __heap_start__);
|
||||
PROVIDE(__end = __heap_start__);
|
||||
|
||||
. += HEAPSIZE;
|
||||
KEEP(*(.heap))
|
||||
|
||||
PROVIDE(__heap_end__ = .);
|
||||
PROVIDE(_eheap = __heap_end__);
|
||||
PROVIDE(__HeapLimit = __heap_end__);
|
||||
} > REGION_HEAP AT> REGION_HEAP
|
||||
|
||||
PROVIDE(__stack_size = ORIGIN(SRAM) + LENGTH(SRAM) - ALIGN(0x8));
|
||||
|
||||
/* Start of stack must be 8 byte aligned */
|
||||
.stack (NOLOAD) : {
|
||||
PROVIDE(_stack = ALIGN(0x8));
|
||||
PROVIDE(__stack = _stack);
|
||||
|
||||
PROVIDE(_stack_end = ORIGIN(SRAM) + LENGTH(SRAM));
|
||||
PROVIDE(__stack_end = _stack_end);
|
||||
PROVIDE(_stack_origin = _stack_end);
|
||||
|
||||
/* Note that the stack check library requires the symbols */
|
||||
/* "_stack" and "_stack_origin" to be defined. */
|
||||
|
||||
/* Assert that we have enough stack */
|
||||
ASSERT(__stack_size >= MIN_STACKSIZE, "Error: No room left for the stack");
|
||||
} > REGION_STACK AT> REGION_STACK
|
||||
}
|
|
@ -0,0 +1,629 @@
|
|||
/******************************************************************************
|
||||
* Filename: rf_ieee_cmd.h
|
||||
* Revised: 2018-01-15 06:15:14 +0100 (Mon, 15 Jan 2018)
|
||||
* Revision: 18170
|
||||
*
|
||||
* Description: CC13x2/CC26x2 API for IEEE 802.15.4 commands
|
||||
*
|
||||
* Copyright (c) 2015 - 2017, Texas Instruments Incorporated
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1) Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2) Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3) Neither the name of the ORGANIZATION nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __IEEE_CMD_H
|
||||
#define __IEEE_CMD_H
|
||||
|
||||
#ifndef __RFC_STRUCT
|
||||
#define __RFC_STRUCT
|
||||
#endif
|
||||
|
||||
#ifndef __RFC_STRUCT_ATTR
|
||||
#if defined(__GNUC__)
|
||||
#define __RFC_STRUCT_ATTR __attribute__ ((aligned (4)))
|
||||
#elif defined(__TI_ARM__)
|
||||
#define __RFC_STRUCT_ATTR __attribute__ ((__packed__,aligned (4)))
|
||||
#else
|
||||
#define __RFC_STRUCT_ATTR
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//! \addtogroup rfc
|
||||
//! @{
|
||||
|
||||
//! \addtogroup ieee_cmd
|
||||
//! @{
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
|
||||
typedef struct __RFC_STRUCT rfc_CMD_IEEE_RX_s rfc_CMD_IEEE_RX_t;
|
||||
typedef struct __RFC_STRUCT rfc_CMD_IEEE_ED_SCAN_s rfc_CMD_IEEE_ED_SCAN_t;
|
||||
typedef struct __RFC_STRUCT rfc_CMD_IEEE_TX_s rfc_CMD_IEEE_TX_t;
|
||||
typedef struct __RFC_STRUCT rfc_CMD_IEEE_CSMA_s rfc_CMD_IEEE_CSMA_t;
|
||||
typedef struct __RFC_STRUCT rfc_CMD_IEEE_RX_ACK_s rfc_CMD_IEEE_RX_ACK_t;
|
||||
typedef struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_BG_s rfc_CMD_IEEE_ABORT_BG_t;
|
||||
typedef struct __RFC_STRUCT rfc_CMD_IEEE_MOD_CCA_s rfc_CMD_IEEE_MOD_CCA_t;
|
||||
typedef struct __RFC_STRUCT rfc_CMD_IEEE_MOD_FILT_s rfc_CMD_IEEE_MOD_FILT_t;
|
||||
typedef struct __RFC_STRUCT rfc_CMD_IEEE_MOD_SRC_MATCH_s rfc_CMD_IEEE_MOD_SRC_MATCH_t;
|
||||
typedef struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_FG_s rfc_CMD_IEEE_ABORT_FG_t;
|
||||
typedef struct __RFC_STRUCT rfc_CMD_IEEE_STOP_FG_s rfc_CMD_IEEE_STOP_FG_t;
|
||||
typedef struct __RFC_STRUCT rfc_CMD_IEEE_CCA_REQ_s rfc_CMD_IEEE_CCA_REQ_t;
|
||||
typedef struct __RFC_STRUCT rfc_ieeeRxOutput_s rfc_ieeeRxOutput_t;
|
||||
typedef struct __RFC_STRUCT rfc_shortAddrEntry_s rfc_shortAddrEntry_t;
|
||||
typedef struct __RFC_STRUCT rfc_ieeeRxCorrCrc_s rfc_ieeeRxCorrCrc_t;
|
||||
|
||||
//! \addtogroup CMD_IEEE_RX
|
||||
//! @{
|
||||
#define CMD_IEEE_RX 0x2801
|
||||
//! IEEE 802.15.4 Receive Command
|
||||
struct __RFC_STRUCT rfc_CMD_IEEE_RX_s {
|
||||
uint16_t commandNo; //!< The command ID number 0x2801
|
||||
uint16_t status; //!< \brief An integer telling the status of the command. This value is
|
||||
//!< updated by the radio CPU during operation and may be read by the
|
||||
//!< system CPU at any time.
|
||||
rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done
|
||||
ratmr_t startTime; //!< Absolute or relative start time (depending on the value of <code>startTrigger</code>)
|
||||
struct {
|
||||
uint8_t triggerType:4; //!< The type of trigger
|
||||
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
|
||||
//!< 1: CMD_TRIGGER can be used as an alternative trigger
|
||||
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
|
||||
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
|
||||
//!< 1: A trigger in the past is triggered as soon as possible
|
||||
} startTrigger; //!< Identification of the trigger that starts the operation
|
||||
struct {
|
||||
uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed
|
||||
uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
|
||||
} condition;
|
||||
uint8_t channel; //!< \brief Channel to tune to in the start of the operation<br>
|
||||
//!< 0: Use existing channel<br>
|
||||
//!< 11--26: Use as IEEE 802.15.4 channel, i.e. frequency is (2405 + 5 × (channel - 11)) MHz<br>
|
||||
//!< 60--207: Frequency is (2300 + channel) MHz<br>
|
||||
//!< Others: <i>Reserved</i>
|
||||
struct {
|
||||
uint8_t bAutoFlushCrc:1; //!< If 1, automatically remove packets with CRC error from Rx queue
|
||||
uint8_t bAutoFlushIgn:1; //!< If 1, automatically remove packets that can be ignored according to frame filtering from Rx queue
|
||||
uint8_t bIncludePhyHdr:1; //!< If 1, include the received PHY header field in the stored packet; otherwise discard it
|
||||
uint8_t bIncludeCrc:1; //!< If 1, include the received CRC field in the stored packet; otherwise discard it
|
||||
uint8_t bAppendRssi:1; //!< If 1, append an RSSI byte to the packet in the Rx queue
|
||||
uint8_t bAppendCorrCrc:1; //!< If 1, append a correlation value and CRC result byte to the packet in the Rx queue
|
||||
uint8_t bAppendSrcInd:1; //!< If 1, append an index from the source matching algorithm
|
||||
uint8_t bAppendTimestamp:1; //!< If 1, append a timestamp to the packet in the Rx queue
|
||||
} rxConfig;
|
||||
dataQueue_t* pRxQ; //!< Pointer to receive queue
|
||||
rfc_ieeeRxOutput_t *pOutput; //!< Pointer to output structure (NULL: Do not store results)
|
||||
struct {
|
||||
uint16_t frameFiltEn:1; //!< \brief 0: Disable frame filtering<br>
|
||||
//!< 1: Enable frame filtering
|
||||
uint16_t frameFiltStop:1; //!< \brief 0: Receive all packets to the end<br>
|
||||
//!< 1: Stop receiving frame once frame filtering has caused the frame to be rejected.
|
||||
uint16_t autoAckEn:1; //!< \brief 0: Disable auto ACK<br>
|
||||
//!< 1: Enable auto ACK.
|
||||
uint16_t slottedAckEn:1; //!< \brief 0: Non-slotted ACK<br>
|
||||
//!< 1: Slotted ACK.
|
||||
uint16_t autoPendEn:1; //!< \brief 0: Auto-pend disabled<br>
|
||||
//!< 1: Auto-pend enabled
|
||||
uint16_t defaultPend:1; //!< The value of the pending data bit in auto ACK packets that are not subject to auto-pend
|
||||
uint16_t bPendDataReqOnly:1; //!< \brief 0: Use auto-pend for any packet<br>
|
||||
//!< 1: Use auto-pend for data request packets only
|
||||
uint16_t bPanCoord:1; //!< \brief 0: Device is not PAN coordinator<br>
|
||||
//!< 1: Device is PAN coordinator
|
||||
uint16_t maxFrameVersion:2; //!< Reject frames where the frame version field in the FCF is greater than this value
|
||||
uint16_t fcfReservedMask:3; //!< Value to be AND-ed with the reserved part of the FCF; frame rejected if result is non-zero
|
||||
uint16_t modifyFtFilter:2; //!< \brief Treatment of MSB of frame type field before frame-type filtering:<br>
|
||||
//!< 0: No modification<br>
|
||||
//!< 1: Invert MSB<br>
|
||||
//!< 2: Set MSB to 0<br>
|
||||
//!< 3: Set MSB to 1
|
||||
uint16_t bStrictLenFilter:1; //!< \brief 0: Accept acknowledgement frames of any length >= 5<br>
|
||||
//!< 1: Accept only acknowledgement frames of length 5
|
||||
} frameFiltOpt; //!< Frame filtering options
|
||||
struct {
|
||||
uint8_t bAcceptFt0Beacon:1; //!< \brief Treatment of frames with frame type 000 (beacon):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
uint8_t bAcceptFt1Data:1; //!< \brief Treatment of frames with frame type 001 (data):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
uint8_t bAcceptFt2Ack:1; //!< \brief Treatment of frames with frame type 010 (ACK):<br>
|
||||
//!< 0: Reject, unless running ACK receive command<br>
|
||||
//!< 1: Always accept
|
||||
uint8_t bAcceptFt3MacCmd:1; //!< \brief Treatment of frames with frame type 011 (MAC command):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
uint8_t bAcceptFt4Reserved:1; //!< \brief Treatment of frames with frame type 100 (reserved):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
uint8_t bAcceptFt5Reserved:1; //!< \brief Treatment of frames with frame type 101 (reserved):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
uint8_t bAcceptFt6Reserved:1; //!< \brief Treatment of frames with frame type 110 (reserved):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
uint8_t bAcceptFt7Reserved:1; //!< \brief Treatment of frames with frame type 111 (reserved):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
} frameTypes; //!< Frame types to receive in frame filtering
|
||||
struct {
|
||||
uint8_t ccaEnEnergy:1; //!< Enable energy scan as CCA source
|
||||
uint8_t ccaEnCorr:1; //!< Enable correlator based carrier sense as CCA source
|
||||
uint8_t ccaEnSync:1; //!< Enable sync found based carrier sense as CCA source
|
||||
uint8_t ccaCorrOp:1; //!< \brief Operator to use between energy based and correlator based CCA<br>
|
||||
//!< 0: Report busy channel if either ccaEnergy or ccaCorr are busy<br>
|
||||
//!< 1: Report busy channel if both ccaEnergy and ccaCorr are busy
|
||||
uint8_t ccaSyncOp:1; //!< \brief Operator to use between sync found based CCA and the others<br>
|
||||
//!< 0: Always report busy channel if ccaSync is busy<br>
|
||||
//!< 1: Always report idle channel if ccaSync is idle
|
||||
uint8_t ccaCorrThr:2; //!< Threshold for number of correlation peaks in correlator based carrier sense
|
||||
} ccaOpt; //!< CCA options
|
||||
int8_t ccaRssiThr; //!< RSSI threshold for CCA
|
||||
uint8_t __dummy0;
|
||||
uint8_t numExtEntries; //!< Number of extended address entries
|
||||
uint8_t numShortEntries; //!< Number of short address entries
|
||||
uint32_t* pExtEntryList; //!< Pointer to list of extended address entries
|
||||
uint32_t* pShortEntryList; //!< Pointer to list of short address entries
|
||||
uint64_t localExtAddr; //!< The extended address of the local device
|
||||
uint16_t localShortAddr; //!< The short address of the local device
|
||||
uint16_t localPanID; //!< The PAN ID of the local device
|
||||
uint16_t __dummy1;
|
||||
uint8_t __dummy2;
|
||||
struct {
|
||||
uint8_t triggerType:4; //!< The type of trigger
|
||||
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
|
||||
//!< 1: CMD_TRIGGER can be used as an alternative trigger
|
||||
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
|
||||
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
|
||||
//!< 1: A trigger in the past is triggered as soon as possible
|
||||
} endTrigger; //!< Trigger that causes the device to end the Rx operation
|
||||
ratmr_t endTime; //!< \brief Time used together with <code>endTrigger</code> that causes the device to end the Rx
|
||||
//!< operation
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup CMD_IEEE_ED_SCAN
|
||||
//! @{
|
||||
#define CMD_IEEE_ED_SCAN 0x2802
|
||||
//! IEEE 802.15.4 Energy Detect Scan Command
|
||||
struct __RFC_STRUCT rfc_CMD_IEEE_ED_SCAN_s {
|
||||
uint16_t commandNo; //!< The command ID number 0x2802
|
||||
uint16_t status; //!< \brief An integer telling the status of the command. This value is
|
||||
//!< updated by the radio CPU during operation and may be read by the
|
||||
//!< system CPU at any time.
|
||||
rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done
|
||||
ratmr_t startTime; //!< Absolute or relative start time (depending on the value of <code>startTrigger</code>)
|
||||
struct {
|
||||
uint8_t triggerType:4; //!< The type of trigger
|
||||
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
|
||||
//!< 1: CMD_TRIGGER can be used as an alternative trigger
|
||||
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
|
||||
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
|
||||
//!< 1: A trigger in the past is triggered as soon as possible
|
||||
} startTrigger; //!< Identification of the trigger that starts the operation
|
||||
struct {
|
||||
uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed
|
||||
uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
|
||||
} condition;
|
||||
uint8_t channel; //!< \brief Channel to tune to in the start of the operation<br>
|
||||
//!< 0: Use existing channel<br>
|
||||
//!< 11--26: Use as IEEE 802.15.4 channel, i.e. frequency is (2405 + 5 × (channel - 11)) MHz<br>
|
||||
//!< 60--207: Frequency is (2300 + channel) MHz<br>
|
||||
//!< Others: <i>Reserved</i>
|
||||
struct {
|
||||
uint8_t ccaEnEnergy:1; //!< Enable energy scan as CCA source
|
||||
uint8_t ccaEnCorr:1; //!< Enable correlator based carrier sense as CCA source
|
||||
uint8_t ccaEnSync:1; //!< Enable sync found based carrier sense as CCA source
|
||||
uint8_t ccaCorrOp:1; //!< \brief Operator to use between energy based and correlator based CCA<br>
|
||||
//!< 0: Report busy channel if either ccaEnergy or ccaCorr are busy<br>
|
||||
//!< 1: Report busy channel if both ccaEnergy and ccaCorr are busy
|
||||
uint8_t ccaSyncOp:1; //!< \brief Operator to use between sync found based CCA and the others<br>
|
||||
//!< 0: Always report busy channel if ccaSync is busy<br>
|
||||
//!< 1: Always report idle channel if ccaSync is idle
|
||||
uint8_t ccaCorrThr:2; //!< Threshold for number of correlation peaks in correlator based carrier sense
|
||||
} ccaOpt; //!< CCA options
|
||||
int8_t ccaRssiThr; //!< RSSI threshold for CCA
|
||||
uint8_t __dummy0;
|
||||
int8_t maxRssi; //!< The maximum RSSI recorded during the ED scan
|
||||
struct {
|
||||
uint8_t triggerType:4; //!< The type of trigger
|
||||
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
|
||||
//!< 1: CMD_TRIGGER can be used as an alternative trigger
|
||||
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
|
||||
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
|
||||
//!< 1: A trigger in the past is triggered as soon as possible
|
||||
} endTrigger; //!< Trigger that causes the device to end the Rx operation
|
||||
ratmr_t endTime; //!< \brief Time used together with <code>endTrigger</code> that causes the device to end the Rx
|
||||
//!< operation
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup CMD_IEEE_TX
|
||||
//! @{
|
||||
#define CMD_IEEE_TX 0x2C01
|
||||
//! IEEE 802.15.4 Transmit Command
|
||||
struct __RFC_STRUCT rfc_CMD_IEEE_TX_s {
|
||||
uint16_t commandNo; //!< The command ID number 0x2C01
|
||||
uint16_t status; //!< \brief An integer telling the status of the command. This value is
|
||||
//!< updated by the radio CPU during operation and may be read by the
|
||||
//!< system CPU at any time.
|
||||
rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done
|
||||
ratmr_t startTime; //!< Absolute or relative start time (depending on the value of <code>startTrigger</code>)
|
||||
struct {
|
||||
uint8_t triggerType:4; //!< The type of trigger
|
||||
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
|
||||
//!< 1: CMD_TRIGGER can be used as an alternative trigger
|
||||
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
|
||||
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
|
||||
//!< 1: A trigger in the past is triggered as soon as possible
|
||||
} startTrigger; //!< Identification of the trigger that starts the operation
|
||||
struct {
|
||||
uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed
|
||||
uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
|
||||
} condition;
|
||||
struct {
|
||||
uint8_t bIncludePhyHdr:1; //!< \brief 0: Find PHY header automatically<br>
|
||||
//!< 1: Insert PHY header from the buffer
|
||||
uint8_t bIncludeCrc:1; //!< \brief 0: Append automatically calculated CRC<br>
|
||||
//!< 1: Insert FCS (CRC) from the buffer
|
||||
uint8_t :1;
|
||||
uint8_t payloadLenMsb:5; //!< \brief Most significant bits of payload length. Should only be non-zero to create long
|
||||
//!< non-standard packets for test purposes
|
||||
} txOpt;
|
||||
uint8_t payloadLen; //!< Number of bytes in the payload
|
||||
uint8_t* pPayload; //!< Pointer to payload buffer of size <code>payloadLen</code>
|
||||
ratmr_t timeStamp; //!< Time stamp of transmitted frame
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup CMD_IEEE_CSMA
|
||||
//! @{
|
||||
#define CMD_IEEE_CSMA 0x2C02
|
||||
//! IEEE 802.15.4 CSMA-CA Command
|
||||
struct __RFC_STRUCT rfc_CMD_IEEE_CSMA_s {
|
||||
uint16_t commandNo; //!< The command ID number 0x2C02
|
||||
uint16_t status; //!< \brief An integer telling the status of the command. This value is
|
||||
//!< updated by the radio CPU during operation and may be read by the
|
||||
//!< system CPU at any time.
|
||||
rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done
|
||||
ratmr_t startTime; //!< Absolute or relative start time (depending on the value of <code>startTrigger</code>)
|
||||
struct {
|
||||
uint8_t triggerType:4; //!< The type of trigger
|
||||
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
|
||||
//!< 1: CMD_TRIGGER can be used as an alternative trigger
|
||||
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
|
||||
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
|
||||
//!< 1: A trigger in the past is triggered as soon as possible
|
||||
} startTrigger; //!< Identification of the trigger that starts the operation
|
||||
struct {
|
||||
uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed
|
||||
uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
|
||||
} condition;
|
||||
uint16_t randomState; //!< The state of the pseudo-random generator
|
||||
uint8_t macMaxBE; //!< The IEEE 802.15.4 MAC parameter <i>macMaxBE</i>
|
||||
uint8_t macMaxCSMABackoffs; //!< The IEEE 802.15.4 MAC parameter <i>macMaxCSMABackoffs</i>
|
||||
struct {
|
||||
uint8_t initCW:5; //!< The initialization value for the CW parameter
|
||||
uint8_t bSlotted:1; //!< \brief 0: non-slotted CSMA<br>
|
||||
//!< 1: slotted CSMA
|
||||
uint8_t rxOffMode:2; //!< \brief 0: RX stays on during CSMA backoffs<br>
|
||||
//!< 1: The CSMA-CA algorithm will suspend the receiver if no frame is being received<br>
|
||||
//!< 2: The CSMA-CA algorithm will suspend the receiver if no frame is being received,
|
||||
//!< or after finishing it (including auto ACK) otherwise<br>
|
||||
//!< 3: The CSMA-CA algorithm will suspend the receiver immediately during back-offs
|
||||
} csmaConfig;
|
||||
uint8_t NB; //!< The NB parameter from the IEEE 802.15.4 CSMA-CA algorithm
|
||||
uint8_t BE; //!< The BE parameter from the IEEE 802.15.4 CSMA-CA algorithm
|
||||
uint8_t remainingPeriods; //!< The number of remaining periods from a paused backoff countdown
|
||||
int8_t lastRssi; //!< RSSI measured at the last CCA operation
|
||||
struct {
|
||||
uint8_t triggerType:4; //!< The type of trigger
|
||||
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
|
||||
//!< 1: CMD_TRIGGER can be used as an alternative trigger
|
||||
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
|
||||
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
|
||||
//!< 1: A trigger in the past is triggered as soon as possible
|
||||
} endTrigger; //!< Trigger that causes the device to end the CSMA-CA operation
|
||||
ratmr_t lastTimeStamp; //!< Time of the last CCA operation
|
||||
ratmr_t endTime; //!< \brief Time used together with <code>endTrigger</code> that causes the device to end the
|
||||
//!< CSMA-CA operation
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup CMD_IEEE_RX_ACK
|
||||
//! @{
|
||||
#define CMD_IEEE_RX_ACK 0x2C03
|
||||
//! IEEE 802.15.4 Receive Acknowledgement Command
|
||||
struct __RFC_STRUCT rfc_CMD_IEEE_RX_ACK_s {
|
||||
uint16_t commandNo; //!< The command ID number 0x2C03
|
||||
uint16_t status; //!< \brief An integer telling the status of the command. This value is
|
||||
//!< updated by the radio CPU during operation and may be read by the
|
||||
//!< system CPU at any time.
|
||||
rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done
|
||||
ratmr_t startTime; //!< Absolute or relative start time (depending on the value of <code>startTrigger</code>)
|
||||
struct {
|
||||
uint8_t triggerType:4; //!< The type of trigger
|
||||
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
|
||||
//!< 1: CMD_TRIGGER can be used as an alternative trigger
|
||||
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
|
||||
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
|
||||
//!< 1: A trigger in the past is triggered as soon as possible
|
||||
} startTrigger; //!< Identification of the trigger that starts the operation
|
||||
struct {
|
||||
uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed
|
||||
uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
|
||||
} condition;
|
||||
uint8_t seqNo; //!< Sequence number to expect
|
||||
struct {
|
||||
uint8_t triggerType:4; //!< The type of trigger
|
||||
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
|
||||
//!< 1: CMD_TRIGGER can be used as an alternative trigger
|
||||
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
|
||||
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
|
||||
//!< 1: A trigger in the past is triggered as soon as possible
|
||||
} endTrigger; //!< Trigger that causes the device to give up acknowledgement reception
|
||||
ratmr_t endTime; //!< \brief Time used together with <code>endTrigger</code> that causes the device to give up
|
||||
//!< acknowledgement reception
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup CMD_IEEE_ABORT_BG
|
||||
//! @{
|
||||
#define CMD_IEEE_ABORT_BG 0x2C04
|
||||
//! IEEE 802.15.4 Abort Background Level Command
|
||||
struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_BG_s {
|
||||
uint16_t commandNo; //!< The command ID number 0x2C04
|
||||
uint16_t status; //!< \brief An integer telling the status of the command. This value is
|
||||
//!< updated by the radio CPU during operation and may be read by the
|
||||
//!< system CPU at any time.
|
||||
rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done
|
||||
ratmr_t startTime; //!< Absolute or relative start time (depending on the value of <code>startTrigger</code>)
|
||||
struct {
|
||||
uint8_t triggerType:4; //!< The type of trigger
|
||||
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
|
||||
//!< 1: CMD_TRIGGER can be used as an alternative trigger
|
||||
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
|
||||
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
|
||||
//!< 1: A trigger in the past is triggered as soon as possible
|
||||
} startTrigger; //!< Identification of the trigger that starts the operation
|
||||
struct {
|
||||
uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed
|
||||
uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
|
||||
} condition;
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup CMD_IEEE_MOD_CCA
|
||||
//! @{
|
||||
#define CMD_IEEE_MOD_CCA 0x2001
|
||||
//! IEEE 802.15.4 Modify CCA Parameter Command
|
||||
struct __RFC_STRUCT rfc_CMD_IEEE_MOD_CCA_s {
|
||||
uint16_t commandNo; //!< The command ID number 0x2001
|
||||
struct {
|
||||
uint8_t ccaEnEnergy:1; //!< Enable energy scan as CCA source
|
||||
uint8_t ccaEnCorr:1; //!< Enable correlator based carrier sense as CCA source
|
||||
uint8_t ccaEnSync:1; //!< Enable sync found based carrier sense as CCA source
|
||||
uint8_t ccaCorrOp:1; //!< \brief Operator to use between energy based and correlator based CCA<br>
|
||||
//!< 0: Report busy channel if either ccaEnergy or ccaCorr are busy<br>
|
||||
//!< 1: Report busy channel if both ccaEnergy and ccaCorr are busy
|
||||
uint8_t ccaSyncOp:1; //!< \brief Operator to use between sync found based CCA and the others<br>
|
||||
//!< 0: Always report busy channel if ccaSync is busy<br>
|
||||
//!< 1: Always report idle channel if ccaSync is idle
|
||||
uint8_t ccaCorrThr:2; //!< Threshold for number of correlation peaks in correlator based carrier sense
|
||||
} newCcaOpt; //!< New value of <code>ccaOpt</code> for the running background level operation
|
||||
int8_t newCcaRssiThr; //!< New value of <code>ccaRssiThr</code> for the running background level operation
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup CMD_IEEE_MOD_FILT
|
||||
//! @{
|
||||
#define CMD_IEEE_MOD_FILT 0x2002
|
||||
//! IEEE 802.15.4 Modify Frame Filtering Parameter Command
|
||||
struct __RFC_STRUCT rfc_CMD_IEEE_MOD_FILT_s {
|
||||
uint16_t commandNo; //!< The command ID number 0x2002
|
||||
struct {
|
||||
uint16_t frameFiltEn:1; //!< \brief 0: Disable frame filtering<br>
|
||||
//!< 1: Enable frame filtering
|
||||
uint16_t frameFiltStop:1; //!< \brief 0: Receive all packets to the end<br>
|
||||
//!< 1: Stop receiving frame once frame filtering has caused the frame to be rejected.
|
||||
uint16_t autoAckEn:1; //!< \brief 0: Disable auto ACK<br>
|
||||
//!< 1: Enable auto ACK.
|
||||
uint16_t slottedAckEn:1; //!< \brief 0: Non-slotted ACK<br>
|
||||
//!< 1: Slotted ACK.
|
||||
uint16_t autoPendEn:1; //!< \brief 0: Auto-pend disabled<br>
|
||||
//!< 1: Auto-pend enabled
|
||||
uint16_t defaultPend:1; //!< The value of the pending data bit in auto ACK packets that are not subject to auto-pend
|
||||
uint16_t bPendDataReqOnly:1; //!< \brief 0: Use auto-pend for any packet<br>
|
||||
//!< 1: Use auto-pend for data request packets only
|
||||
uint16_t bPanCoord:1; //!< \brief 0: Device is not PAN coordinator<br>
|
||||
//!< 1: Device is PAN coordinator
|
||||
uint16_t maxFrameVersion:2; //!< Reject frames where the frame version field in the FCF is greater than this value
|
||||
uint16_t fcfReservedMask:3; //!< Value to be AND-ed with the reserved part of the FCF; frame rejected if result is non-zero
|
||||
uint16_t modifyFtFilter:2; //!< \brief Treatment of MSB of frame type field before frame-type filtering:<br>
|
||||
//!< 0: No modification<br>
|
||||
//!< 1: Invert MSB<br>
|
||||
//!< 2: Set MSB to 0<br>
|
||||
//!< 3: Set MSB to 1
|
||||
uint16_t bStrictLenFilter:1; //!< \brief 0: Accept acknowledgement frames of any length >= 5<br>
|
||||
//!< 1: Accept only acknowledgement frames of length 5
|
||||
} newFrameFiltOpt; //!< New value of <code>frameFiltOpt</code> for the running background level operation
|
||||
struct {
|
||||
uint8_t bAcceptFt0Beacon:1; //!< \brief Treatment of frames with frame type 000 (beacon):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
uint8_t bAcceptFt1Data:1; //!< \brief Treatment of frames with frame type 001 (data):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
uint8_t bAcceptFt2Ack:1; //!< \brief Treatment of frames with frame type 010 (ACK):<br>
|
||||
//!< 0: Reject, unless running ACK receive command<br>
|
||||
//!< 1: Always accept
|
||||
uint8_t bAcceptFt3MacCmd:1; //!< \brief Treatment of frames with frame type 011 (MAC command):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
uint8_t bAcceptFt4Reserved:1; //!< \brief Treatment of frames with frame type 100 (reserved):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
uint8_t bAcceptFt5Reserved:1; //!< \brief Treatment of frames with frame type 101 (reserved):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
uint8_t bAcceptFt6Reserved:1; //!< \brief Treatment of frames with frame type 110 (reserved):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
uint8_t bAcceptFt7Reserved:1; //!< \brief Treatment of frames with frame type 111 (reserved):<br>
|
||||
//!< 0: Reject<br>
|
||||
//!< 1: Accept
|
||||
} newFrameTypes; //!< New value of <code>frameTypes</code> for the running background level operation
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup CMD_IEEE_MOD_SRC_MATCH
|
||||
//! @{
|
||||
#define CMD_IEEE_MOD_SRC_MATCH 0x2003
|
||||
//! IEEE 802.15.4 Enable/Disable Source Matching Entry Command
|
||||
struct __RFC_STRUCT rfc_CMD_IEEE_MOD_SRC_MATCH_s {
|
||||
uint16_t commandNo; //!< The command ID number 0x2003
|
||||
struct {
|
||||
uint8_t bEnable:1; //!< \brief 0: Disable entry<br>
|
||||
//!< 1: Enable entry
|
||||
uint8_t srcPend:1; //!< New value of the pending bit for the entry
|
||||
uint8_t entryType:1; //!< \brief 0: Short address<br>
|
||||
//!< 1: Extended address
|
||||
} options;
|
||||
uint8_t entryNo; //!< Index of entry to enable or disable
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup CMD_IEEE_ABORT_FG
|
||||
//! @{
|
||||
#define CMD_IEEE_ABORT_FG 0x2401
|
||||
//! IEEE 802.15.4 Abort Foreground Level Command
|
||||
struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_FG_s {
|
||||
uint16_t commandNo; //!< The command ID number 0x2401
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup CMD_IEEE_STOP_FG
|
||||
//! @{
|
||||
#define CMD_IEEE_STOP_FG 0x2402
|
||||
//! IEEE 802.15.4 Gracefully Stop Foreground Level Command
|
||||
struct __RFC_STRUCT rfc_CMD_IEEE_STOP_FG_s {
|
||||
uint16_t commandNo; //!< The command ID number 0x2402
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup CMD_IEEE_CCA_REQ
|
||||
//! @{
|
||||
#define CMD_IEEE_CCA_REQ 0x2403
|
||||
//! IEEE 802.15.4 CCA and RSSI Information Request Command
|
||||
struct __RFC_STRUCT rfc_CMD_IEEE_CCA_REQ_s {
|
||||
uint16_t commandNo; //!< The command ID number 0x2403
|
||||
int8_t currentRssi; //!< The RSSI currently observed on the channel
|
||||
int8_t maxRssi; //!< The maximum RSSI observed on the channel since Rx was started
|
||||
struct {
|
||||
uint8_t ccaState:2; //!< \brief Value of the current CCA state<br>
|
||||
//!< 0: Idle<br>
|
||||
//!< 1: Busy<br>
|
||||
//!< 2: Invalid
|
||||
uint8_t ccaEnergy:2; //!< \brief Value of the current energy detect CCA state<br>
|
||||
//!< 0: Idle<br>
|
||||
//!< 1: Busy<br>
|
||||
//!< 2: Invalid
|
||||
uint8_t ccaCorr:2; //!< \brief Value of the current correlator based carrier sense CCA state<br>
|
||||
//!< 0: Idle<br>
|
||||
//!< 1: Busy<br>
|
||||
//!< 2: Invalid
|
||||
uint8_t ccaSync:1; //!< \brief Value of the current sync found based carrier sense CCA state<br>
|
||||
//!< 0: Idle<br>
|
||||
//!< 1: Busy
|
||||
} ccaInfo;
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup ieeeRxOutput
|
||||
//! @{
|
||||
//! Output structure for CMD_IEEE_RX
|
||||
|
||||
struct __RFC_STRUCT rfc_ieeeRxOutput_s {
|
||||
uint8_t nTxAck; //!< Total number of transmitted ACK frames
|
||||
uint8_t nRxBeacon; //!< Number of received beacon frames
|
||||
uint8_t nRxData; //!< Number of received data frames
|
||||
uint8_t nRxAck; //!< Number of received acknowledgement frames
|
||||
uint8_t nRxMacCmd; //!< Number of received MAC command frames
|
||||
uint8_t nRxReserved; //!< Number of received frames with reserved frame type
|
||||
uint8_t nRxNok; //!< Number of received frames with CRC error
|
||||
uint8_t nRxIgnored; //!< Number of frames received that are to be ignored
|
||||
uint8_t nRxBufFull; //!< Number of received frames discarded because the Rx buffer was full
|
||||
int8_t lastRssi; //!< RSSI of last received frame
|
||||
int8_t maxRssi; //!< Highest RSSI observed in the operation
|
||||
uint8_t __dummy0;
|
||||
ratmr_t beaconTimeStamp; //!< Time stamp of last received beacon frame
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup shortAddrEntry
|
||||
//! @{
|
||||
//! Structure for short address entries
|
||||
|
||||
struct __RFC_STRUCT rfc_shortAddrEntry_s {
|
||||
uint16_t shortAddr; //!< Short address
|
||||
uint16_t panId; //!< PAN ID
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! \addtogroup ieeeRxCorrCrc
|
||||
//! @{
|
||||
//! Receive status byte that may be appended to message in receive buffer
|
||||
|
||||
struct __RFC_STRUCT rfc_ieeeRxCorrCrc_s {
|
||||
struct {
|
||||
uint8_t corr:6; //!< The correlation value
|
||||
uint8_t bIgnore:1; //!< 1 if the packet should be rejected by frame filtering, 0 otherwise
|
||||
uint8_t bCrcErr:1; //!< 1 if the packet was received with CRC error, 0 otherwise
|
||||
} status;
|
||||
} __RFC_STRUCT_ATTR;
|
||||
|
||||
//! @}
|
||||
|
||||
//! @}
|
||||
//! @}
|
||||
#endif
|
|
@ -0,0 +1,74 @@
|
|||
/******************************************************************************
|
||||
* Filename: rf_ieee_mailbox.h
|
||||
* Revised: 2018-01-23 19:51:42 +0100 (Tue, 23 Jan 2018)
|
||||
* Revision: 18189
|
||||
*
|
||||
* Description: Definitions for IEEE 802.15.4 interface
|
||||
*
|
||||
* Copyright (c) 2015 - 2017, Texas Instruments Incorporated
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1) Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2) Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3) Neither the name of the ORGANIZATION nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _IEEE_MAILBOX_H
|
||||
#define _IEEE_MAILBOX_H
|
||||
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
|
||||
/// \name Radio operation status
|
||||
///@{
|
||||
/// \name Operation not finished
|
||||
///@{
|
||||
#define IEEE_SUSPENDED 0x2001 ///< Operation suspended
|
||||
///@}
|
||||
/// \name Operation finished normally
|
||||
///@{
|
||||
#define IEEE_DONE_OK 0x2400 ///< Operation ended normally
|
||||
#define IEEE_DONE_BUSY 0x2401 ///< CSMA-CA operation ended with failure
|
||||
#define IEEE_DONE_STOPPED 0x2402 ///< Operation stopped after stop command
|
||||
#define IEEE_DONE_ACK 0x2403 ///< ACK packet received with pending data bit cleared
|
||||
#define IEEE_DONE_ACKPEND 0x2404 ///< ACK packet received with pending data bit set
|
||||
#define IEEE_DONE_TIMEOUT 0x2405 ///< Operation ended due to timeout
|
||||
#define IEEE_DONE_BGEND 0x2406 ///< FG operation ended because necessary background level
|
||||
///< operation ended
|
||||
#define IEEE_DONE_ABORT 0x2407 ///< Operation aborted by command
|
||||
///@}
|
||||
/// \name Operation finished with error
|
||||
///@{
|
||||
#define IEEE_ERROR_PAR 0x2800 ///< Illegal parameter
|
||||
#define IEEE_ERROR_NO_SETUP 0x2801 ///< Operation using Rx or Tx attempted when not in 15.4 mode
|
||||
#define IEEE_ERROR_NO_FS 0x2802 ///< Operation using Rx or Tx attempted without frequency synth configured
|
||||
#define IEEE_ERROR_SYNTH_PROG 0x2803 ///< Synthesizer programming failed to complete on time
|
||||
#define IEEE_ERROR_RXOVF 0x2804 ///< Receiver overflowed during operation
|
||||
#define IEEE_ERROR_TXUNF 0x2805 ///< Transmitter underflowed during operation
|
||||
///@}
|
||||
///@}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,269 @@
|
|||
/******************************************************************************
|
||||
* Filename: rf_patch_cpe_ieee.h
|
||||
* Revised: $Date$
|
||||
* Revision: $Revision$
|
||||
*
|
||||
* Description: RF Core patch file for CC26xx IEEE 802.15.4 PHY
|
||||
*
|
||||
* Copyright (c) 2015, Texas Instruments Incorporated
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1) Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2) Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3) Neither the name of the ORGANIZATION nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _RF_PATCH_CPE_IEEE_H
|
||||
#define _RF_PATCH_CPE_IEEE_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef CPE_PATCH_TYPE
|
||||
#define CPE_PATCH_TYPE static const uint32_t
|
||||
#endif
|
||||
|
||||
#ifndef SYS_PATCH_TYPE
|
||||
#define SYS_PATCH_TYPE static const uint32_t
|
||||
#endif
|
||||
|
||||
#ifndef PATCH_FUN_SPEC
|
||||
#define PATCH_FUN_SPEC static inline
|
||||
#endif
|
||||
|
||||
#ifndef _APPLY_PATCH_TAB
|
||||
#define _APPLY_PATCH_TAB
|
||||
#endif
|
||||
|
||||
|
||||
CPE_PATCH_TYPE patchImageIeee[] = {
|
||||
0x210004ef,
|
||||
0x21000419,
|
||||
0x21000519,
|
||||
0x21000599,
|
||||
0x210004b1,
|
||||
0x22024823,
|
||||
0x421a7dc3,
|
||||
0xd0034472,
|
||||
0x1dc04678,
|
||||
0xb5f84686,
|
||||
0x4c1f4710,
|
||||
0x200834ae,
|
||||
0x490347a0,
|
||||
0x60082008,
|
||||
0x3cec6008,
|
||||
0xbdf847a0,
|
||||
0x40045004,
|
||||
0x4c17b5f0,
|
||||
0x18612140,
|
||||
0x280278c8,
|
||||
0x4809d005,
|
||||
0x60012100,
|
||||
0x47884908,
|
||||
0x6e25bdf0,
|
||||
0x60354e07,
|
||||
0x43280760,
|
||||
0x68276620,
|
||||
0x480e6024,
|
||||
0x60274780,
|
||||
0xbdf06035,
|
||||
0x4004112c,
|
||||
0x000065a5,
|
||||
0x40044028,
|
||||
0x4c07b510,
|
||||
0x29007da1,
|
||||
0x2101d105,
|
||||
0x024875a1,
|
||||
0x393e4904,
|
||||
0x68204788,
|
||||
0xd0002800,
|
||||
0xbd104780,
|
||||
0x21000254,
|
||||
0x0000398b,
|
||||
0x6a034807,
|
||||
0x46784907,
|
||||
0x46861dc0,
|
||||
0x4788b5f8,
|
||||
0x009b089b,
|
||||
0x6a014802,
|
||||
0xd10007c9,
|
||||
0xbdf86203,
|
||||
0x40045040,
|
||||
0x0000f1ab,
|
||||
0x6a00480b,
|
||||
0xd00407c0,
|
||||
0x2201480a,
|
||||
0x43117801,
|
||||
0x48097001,
|
||||
0x72c84700,
|
||||
0xd006280d,
|
||||
0x00802285,
|
||||
0x18800252,
|
||||
0x60486840,
|
||||
0x48044770,
|
||||
0x0000e7fb,
|
||||
0x40045040,
|
||||
0x21000268,
|
||||
0x0000ff39,
|
||||
0x210004d9,
|
||||
0x4e1ab5f8,
|
||||
0x6b314605,
|
||||
0x09cc4819,
|
||||
0x2d0001e4,
|
||||
0x4918d011,
|
||||
0x29027809,
|
||||
0x7b00d00f,
|
||||
0xb6724304,
|
||||
0x4f152001,
|
||||
0x47b80240,
|
||||
0x38204811,
|
||||
0x09c18800,
|
||||
0xd00407c9,
|
||||
0x7ac0e016,
|
||||
0x7b40e7f0,
|
||||
0x490fe7ee,
|
||||
0x61cc6334,
|
||||
0x07c00a40,
|
||||
0x2001d00c,
|
||||
0x6af10380,
|
||||
0xd0012d00,
|
||||
0xe0004301,
|
||||
0x46084381,
|
||||
0x490762f1,
|
||||
0x63483940,
|
||||
0x47b82000,
|
||||
0xbdf8b662,
|
||||
0x21000280,
|
||||
0x21000088,
|
||||
0x21000296,
|
||||
0x00003cdf,
|
||||
0x40044040,
|
||||
0x28004907,
|
||||
0x2004d000,
|
||||
0xb6724a06,
|
||||
0x07c97809,
|
||||
0x5810d001,
|
||||
0x2080e000,
|
||||
0xb240b662,
|
||||
0x00004770,
|
||||
0x2100026b,
|
||||
0x40046058,
|
||||
};
|
||||
#define _NWORD_PATCHIMAGE_IEEE 111
|
||||
|
||||
#define _NWORD_PATCHSYS_IEEE 0
|
||||
|
||||
#define _IRQ_PATCH_0 0x21000449
|
||||
#define _IRQ_PATCH_1 0x21000489
|
||||
|
||||
|
||||
#ifndef _IEEE_SYSRAM_START
|
||||
#define _IEEE_SYSRAM_START 0x20000000
|
||||
#endif
|
||||
|
||||
#ifndef _IEEE_CPERAM_START
|
||||
#define _IEEE_CPERAM_START 0x21000000
|
||||
#endif
|
||||
|
||||
#define _IEEE_SYS_PATCH_FIXED_ADDR 0x20000000
|
||||
|
||||
#define _IEEE_PARSER_PATCH_TAB_OFFSET 0x0334
|
||||
#define _IEEE_PATCH_TAB_OFFSET 0x033C
|
||||
#define _IEEE_IRQPATCH_OFFSET 0x03AC
|
||||
#define _IEEE_PATCH_VEC_OFFSET 0x0404
|
||||
|
||||
PATCH_FUN_SPEC void enterIeeeCpePatch(void)
|
||||
{
|
||||
uint32_t *pPatchVec = (uint32_t *) (_IEEE_CPERAM_START + _IEEE_PATCH_VEC_OFFSET);
|
||||
|
||||
#if (_NWORD_PATCHIMAGE_IEEE > 0)
|
||||
memcpy(pPatchVec, patchImageIeee, sizeof(patchImageIeee));
|
||||
#endif
|
||||
}
|
||||
|
||||
PATCH_FUN_SPEC void enterIeeeSysPatch(void)
|
||||
{
|
||||
}
|
||||
|
||||
PATCH_FUN_SPEC void configureIeeePatch(void)
|
||||
{
|
||||
uint8_t *pPatchTab = (uint8_t *) (_IEEE_CPERAM_START + _IEEE_PATCH_TAB_OFFSET);
|
||||
uint32_t *pIrqPatch = (uint32_t *) (_IEEE_CPERAM_START + _IEEE_IRQPATCH_OFFSET);
|
||||
|
||||
|
||||
pPatchTab[5] = 0;
|
||||
pPatchTab[52] = 1;
|
||||
pPatchTab[103] = 2;
|
||||
pPatchTab[60] = 3;
|
||||
pPatchTab[38] = 4;
|
||||
|
||||
pIrqPatch[1] = _IRQ_PATCH_0;
|
||||
pIrqPatch[9] = _IRQ_PATCH_1;
|
||||
}
|
||||
|
||||
PATCH_FUN_SPEC void applyIeeePatch(void)
|
||||
{
|
||||
enterIeeeSysPatch();
|
||||
enterIeeeCpePatch();
|
||||
configureIeeePatch();
|
||||
}
|
||||
|
||||
PATCH_FUN_SPEC void refreshIeeePatch(void)
|
||||
{
|
||||
enterIeeeCpePatch();
|
||||
configureIeeePatch();
|
||||
}
|
||||
|
||||
PATCH_FUN_SPEC void rf_patch_cpe_ieee(void)
|
||||
{
|
||||
applyIeeePatch();
|
||||
}
|
||||
|
||||
#undef _IRQ_PATCH_0
|
||||
#undef _IRQ_PATCH_1
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _RF_PATCH_CPE_IEEE_H
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
################################################################################
|
||||
### CC13x2/CC26x2 CPU makefile
|
||||
|
||||
# Simplelink SDK pre-compiled libraries
|
||||
TARGET_LIBFILES += $(SDK_NORTOS)/lib/nortos_$(SDK_LIB_NAME).am4fg
|
||||
TARGET_LIBFILES += $(SDK_DRIVERS)/rf/lib/rf_multiMode_$(SDK_LIB_NAME).am4fg
|
||||
TARGET_LIBFILES += $(SDK_DRIVERS)/lib/drivers_$(SDK_LIB_NAME).am4fg
|
||||
TARGET_LIBFILES += $(SDK_DEVICES)/driverlib/bin/gcc/driverlib.lib
|
||||
|
||||
# CC13x2/CC26x2 is a Cortex-M4 architecture
|
||||
include $(CONTIKI)/arch/cpu/arm/cortex-m/cm4/Makefile.cm4
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* Template:
|
||||
* Copyright (c) 2012 ARM LIMITED
|
||||
* All rights reserved.
|
||||
*
|
||||
* CC13xx-CC26xx:
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* 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-cm4 CC13xx/CC26xx CMSIS
|
||||
*
|
||||
* CC13xx/CC26xx Cortex-M4 CMSIS definitions
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* CMSIS Cortex-M4 core peripheral access layer header file for CC13xx/CC26xx
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef CC13XX_CC26XX_CM4_H_
|
||||
#define CC13XX_CC26XX_CM4_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Interrupt Number Definition
|
||||
* @{
|
||||
*/
|
||||
typedef enum cc13xx_cc26xx_cm4_irq_e {
|
||||
/* Cortex-M4 Processor Exceptions */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_RESET = -15, /**< 1 Reset */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_NMI = -14, /**< 2 NMI */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_HARD_FAULT = -13, /**< 3 Hard fault */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_MPU_FAULT = -12, /**< 4 MPU fault */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_BUS_FAULT = -11, /**< 5 Bus fault */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_USAGE_FAULT = -10, /**< 6 Usage fault */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_SV_CALL = -5, /**< 11 SVCall */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_DEBUG_MON = -4, /**< 12 Debug monitor */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_PEND_SV = -2, /**< 14 PendSV */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_SYS_TICK = -1, /**< 15 SysTick */
|
||||
|
||||
/* CC13xx/CC26xx interrupts */
|
||||
CC13XX_CC26XX_CM4_IRQ_EDGE_DETECT = 0, /**< 16 AON edge detect */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_I2C = 1, /**< 17 I2C */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_RF_CPE1 = 2, /**< 18 RF Command and Packet Engine 1 */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_AON_SPI_SLAVE = 3, /**< 19 AON SpiSplave Rx, Tx and CS */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_AON_RTC = 4, /**< 20 AON RTC */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_UART0 = 5, /**< 21 UART0 Rx and Tx */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_AON_AUX_SWEV0 = 6, /**< 22 Sensor Controller software event 0, through AON domain*/
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_SSI0 = 7, /**< 23 SSI0 Rx and Tx */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_SSI1 = 8, /**< 24 SSI1 Rx and Tx */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_RF_CPE0 = 9, /**< 25 RF Command and Packet Engine 0 */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_RF_HW = 10, /**< 26 RF Core Hardware */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_RF_CMD_ACK = 11, /**< 27 RF Core Command Acknowledge */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_I2S = 12, /**< 28 I2S */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_AON_AUX_SWEV1 = 13, /**< 29 Sensor Controller software event 1, through AON domain*/
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_WATCHDOG = 14, /**< 30 Watchdog timer */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_GPTIMER_0A = 15, /**< 31 Timer 0 subtimer A */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_GPTIMER_0B = 16, /**< 32 Timer 0 subtimer B */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_GPTIMER_1A = 17, /**< 33 Timer 1 subtimer A */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_GPTIMER_1B = 18, /**< 34 Timer 1 subtimer B */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_GPTIMER_2A = 19, /**< 35 Timer 2 subtimer A */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_GPTIMER_2B = 20, /**< 36 Timer 2 subtimer B */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_GPTIMER_3A = 21, /**< 37 Timer 3 subtimer A */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_GPTIMER_3B = 22, /**< 38 Timer 3 subtimer B */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_CRYPTO = 23, /**< 39 Crypto Core Result available */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_UDMA = 24, /**< 40 uDMA Software */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_UDMA_ERR = 25, /**< 41 uDMA Error */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_FLASH_CTRL = 26, /**< 42 Flash controller */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_SW0 = 27, /**< 43 Software Event 0 */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_AUX_COM_EVENT = 28, /**< 44 AUX combined event, directly to MCU domain*/
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_AON_PRG0 = 29, /**< 45 AON programmable 0 */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_PROG = 30, /**< 46 Dynamic Programmable interrupt (default source: PRCM)*/
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_AUX_COMPA = 31, /**< 47 AUX Comparator A */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_AUX_ADC = 32, /**< 48 AUX ADC IRQ */
|
||||
CC13XX_CC26XX_CM4_EXCEPTION_TRNG = 33, /**< 49 TRNG event */
|
||||
} cc13xx_cc26xx_cm4_irq_t;
|
||||
|
||||
typedef cc13xx_cc26xx_cm4_irq_t IRQn_Type;
|
||||
|
||||
#define SysTick_IRQn CC13XX_CC26XX_CM4_EXCEPTION_SYS_TICK
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name Processor and Core Peripheral Section
|
||||
* @{
|
||||
*/
|
||||
/* Configuration of the Cortex-M4 Processor and Core Peripherals */
|
||||
#define __MPU_PRESENT 1 /**< MPU present or not */
|
||||
#define __NVIC_PRIO_BITS 3 /**< Number of Bits used for Priority Levels */
|
||||
#define __Vendor_SysTickConfig 0 /**< Set to 1 if different SysTick Config is used */
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "core_cm4.h" /* Cortex-M4 processor and core peripherals */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* CC13XX_CC26XX_CM4_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Texas Instruments Incorporated
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of Texas Instruments Incorporated nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
define symbol STACK_SIZE = 0x800; /* 2048 bytes */
|
||||
define symbol HEAP_SIZE = 0x100; /* 256 bytes */
|
||||
|
||||
define symbol __intvec_start__ = 0x00000000;
|
||||
|
||||
/*-Memory Regions-*/
|
||||
define symbol ROM_start__ = 0x00000000;
|
||||
define symbol ROM_end__ = 0x00057FFF;
|
||||
define symbol RAM_start__ = 0x20000000;
|
||||
define symbol RAM_end__ = 0x20013FFF;
|
||||
define symbol GPRAM_start__ = 0x11000000;
|
||||
define symbol GPRAM_end__ = 0x11001FFF;
|
||||
|
||||
/* Define a memory region that covers the entire 4 GB addressable space */
|
||||
define memory mem with size = 4G;
|
||||
|
||||
/* Define a region for the on-chip flash */
|
||||
define region FLASH_region = mem:[from ROM_start__ to ROM_end__];
|
||||
|
||||
/* Define a region for the on-chip SRAM */
|
||||
define region RAM_region = mem:[from RAM_start__ to RAM_end__];
|
||||
|
||||
/* Define a region for the on-chip GPRAM */
|
||||
define region GPRAM_region = mem:[from GPRAM_start__ to GPRAM_end__];
|
||||
|
||||
/* Place the interrupt vectors at the start of flash */
|
||||
place at address mem:__intvec_start__ { readonly section .intvec };
|
||||
keep { section .intvec };
|
||||
|
||||
/* Place the CCA area at the end of flash */
|
||||
place at end of FLASH_region { readonly section .ccfg };
|
||||
keep { section .ccfg };
|
||||
|
||||
/* Place remaining 'read only' in Flash */
|
||||
place in FLASH_region { readonly };
|
||||
|
||||
/* Place all read/write items into RAM */
|
||||
place in RAM_region { readwrite };
|
||||
initialize by copy { readwrite };
|
||||
|
||||
/*
|
||||
* Define CSTACK block to contain .stack section. This enables the IAR IDE
|
||||
* to properly show the stack content during debug. Place stack at end of
|
||||
* retention RAM, do not initialize (initializing the stack will destroy the
|
||||
* return address from the initialization code, causing the processor to branch
|
||||
* to zero and fault)
|
||||
*/
|
||||
define block CSTACK with alignment = 8, size = STACK_SIZE { section .stack };
|
||||
place at end of RAM_region { block CSTACK };
|
||||
do not initialize { section .stack, section .noinit };
|
||||
|
||||
/* Export stack top symbol. Used by startup file */
|
||||
define exported symbol STACK_TOP = RAM_end__ + 1;
|
||||
|
||||
/* Primary Heap configuration */
|
||||
define block HEAP with alignment = 8, size = HEAP_SIZE { };
|
||||
|
||||
/* Place heap just before CSTACK */
|
||||
place in RAM_region { block HEAP };
|
|
@ -0,0 +1,232 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, Texas Instruments Incorporated
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of Texas Instruments Incorporated nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
MIN_STACKSIZE = 0x600; /* 1536 bytes */
|
||||
HEAPSIZE = 0x100; /* 256 bytes */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x00057fa8
|
||||
/*
|
||||
* Customer Configuration Area and Bootloader Backdoor configuration in
|
||||
* flash, 40 bytes
|
||||
*/
|
||||
FLASH_CCFG (RX) : ORIGIN = 0x00057fa8, LENGTH = 0x00000058
|
||||
SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00014000
|
||||
GPRAM (RWX) : ORIGIN = 0x11000000, LENGTH = 0x00002000
|
||||
}
|
||||
|
||||
REGION_ALIAS("REGION_TEXT", FLASH);
|
||||
REGION_ALIAS("REGION_BSS", SRAM);
|
||||
REGION_ALIAS("REGION_DATA", SRAM);
|
||||
REGION_ALIAS("REGION_STACK", SRAM);
|
||||
REGION_ALIAS("REGION_HEAP", SRAM);
|
||||
REGION_ALIAS("REGION_ARM_EXIDX", FLASH);
|
||||
REGION_ALIAS("REGION_ARM_EXTAB", FLASH);
|
||||
|
||||
SECTIONS {
|
||||
|
||||
PROVIDE (_resetVecs_base_addr = DEFINED(_resetVecs_base_addr)
|
||||
? _resetVecs_base_addr
|
||||
: 0x0);
|
||||
|
||||
.resetVecs (_resetVecs_base_addr) : AT (_resetVecs_base_addr) {
|
||||
KEEP (*(.resetVecs))
|
||||
} > REGION_TEXT
|
||||
|
||||
.ramVecs (NOLOAD) : ALIGN(1024) {
|
||||
KEEP (*(.ramVecs))
|
||||
} > REGION_DATA
|
||||
|
||||
/*
|
||||
* UDMACC26XX_CONFIG_BASE below must match UDMACC26XX_CONFIG_BASE defined
|
||||
* by ti/drivers/dma/UDMACC26XX.h
|
||||
* The user is allowed to change UDMACC26XX_CONFIG_BASE to move it away from
|
||||
* the default address 0x2000_1800, but remember it must be 1024 bytes aligned.
|
||||
*/
|
||||
UDMACC26XX_CONFIG_BASE = 0x20001800;
|
||||
|
||||
/*
|
||||
* Define absolute addresses for the DMA channels.
|
||||
* DMA channels must always be allocated at a fixed offset from the DMA base address.
|
||||
* CTEA := Control Table Entry Address
|
||||
* --------- DO NOT MODIFY -----------
|
||||
*/
|
||||
DMA_SPI0_RX_CTEA = (UDMACC26XX_CONFIG_BASE + 0x30);
|
||||
DMA_SPI0_TX_CTEA = (UDMACC26XX_CONFIG_BASE + 0x40);
|
||||
DMA_ADC_PRI_CTEA = (UDMACC26XX_CONFIG_BASE + 0x70);
|
||||
DMA_GPT0A_PRI_CTEA = (UDMACC26XX_CONFIG_BASE + 0x90);
|
||||
DMA_SPI1_RX_CTEA = (UDMACC26XX_CONFIG_BASE + 0x100);
|
||||
DMA_SPI1_TX_CTEA = (UDMACC26XX_CONFIG_BASE + 0x110);
|
||||
DMA_ADC_ALT_CTEA = (UDMACC26XX_CONFIG_BASE + 0x270);
|
||||
DMA_GPT0A_ALT_CTEA = (UDMACC26XX_CONFIG_BASE + 0x290);
|
||||
|
||||
/*
|
||||
* Allocate SPI0, SPI1, ADC, and GPTimer0 DMA descriptors at absolute addresses.
|
||||
* --------- DO NOT MODIFY -----------
|
||||
*/
|
||||
UDMACC26XX_dmaSpi0RxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi0RxControlTableEntry DMA_SPI0_RX_CTEA : AT (DMA_SPI0_RX_CTEA) {
|
||||
*(.dmaSpi0RxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaSpi0TxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi0TxControlTableEntry DMA_SPI0_TX_CTEA : AT (DMA_SPI0_TX_CTEA) {
|
||||
*(.dmaSpi0TxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaADCPriControlTableEntry_is_placed = 0;
|
||||
.dmaADCPriControlTableEntry DMA_ADC_PRI_CTEA : AT (DMA_ADC_PRI_CTEA) {
|
||||
*(.dmaADCPriControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaGPT0APriControlTableEntry_is_placed = 0;
|
||||
.dmaGPT0APriControlTableEntry DMA_GPT0A_PRI_CTEA : AT (DMA_GPT0A_PRI_CTEA) {
|
||||
*(.dmaGPT0APriControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaSpi1RxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi1RxControlTableEntry DMA_SPI1_RX_CTEA : AT (DMA_SPI1_RX_CTEA) {
|
||||
*(.dmaSpi1RxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaSpi1TxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi1TxControlTableEntry DMA_SPI1_TX_CTEA : AT (DMA_SPI1_TX_CTEA) {
|
||||
*(.dmaSpi1TxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaADCAltControlTableEntry_is_placed = 0;
|
||||
.dmaADCAltControlTableEntry DMA_ADC_ALT_CTEA : AT (DMA_ADC_ALT_CTEA) {
|
||||
*(.dmaADCAltControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaGPT0AAltControlTableEntry_is_placed = 0;
|
||||
.dmaGPT0AAltControlTableEntry DMA_GPT0A_ALT_CTEA : AT (DMA_GPT0A_ALT_CTEA) {
|
||||
*(.dmaGPT0AAltControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
.text : {
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
. = ALIGN(0x4);
|
||||
KEEP (*(.ctors))
|
||||
. = ALIGN(0x4);
|
||||
KEEP (*(.dtors))
|
||||
. = ALIGN(0x4);
|
||||
__init_array_start = .;
|
||||
KEEP (*(.init_array*))
|
||||
__init_array_end = .;
|
||||
*(.init)
|
||||
*(.fini*)
|
||||
} > REGION_TEXT AT> REGION_TEXT
|
||||
|
||||
PROVIDE (__etext = .);
|
||||
PROVIDE (_etext = .);
|
||||
PROVIDE (etext = .);
|
||||
|
||||
.rodata : {
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
} > REGION_TEXT AT> REGION_TEXT
|
||||
|
||||
.data : ALIGN(0x4) {
|
||||
__data_load__ = LOADADDR(.data);
|
||||
__data_start__ = .;
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
. = ALIGN (0x4);
|
||||
__data_end__ = .;
|
||||
} > REGION_DATA AT> REGION_TEXT
|
||||
|
||||
.ARM.exidx : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
__exidx_end = .;
|
||||
} > REGION_ARM_EXIDX AT> REGION_ARM_EXIDX
|
||||
|
||||
.ARM.extab : {
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > REGION_ARM_EXTAB AT> REGION_ARM_EXTAB
|
||||
|
||||
.nvs (NOLOAD) : ALIGN(0x2000) {
|
||||
*(.nvs)
|
||||
} > REGION_TEXT
|
||||
|
||||
.ccfg : {
|
||||
KEEP(*(.ccfg))
|
||||
} > FLASH_CCFG AT> FLASH_CCFG
|
||||
|
||||
.bss : {
|
||||
__bss_start__ = .;
|
||||
*(.shbss)
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(0x4);
|
||||
__bss_end__ = .;
|
||||
} > REGION_BSS AT> REGION_BSS
|
||||
|
||||
/* Start of heap must be 4 byte aligned */
|
||||
.heap (NOLOAD) : ALIGN(0x4) {
|
||||
PROVIDE(__heap_start__ = .);
|
||||
PROVIDE(_heap = __heap_start__);
|
||||
PROVIDE(end = __heap_start__);
|
||||
PROVIDE(_end = __heap_start__);
|
||||
PROVIDE(__end = __heap_start__);
|
||||
|
||||
. += HEAPSIZE;
|
||||
KEEP(*(.heap))
|
||||
|
||||
PROVIDE(__heap_end__ = .);
|
||||
PROVIDE(_eheap = __heap_end__);
|
||||
PROVIDE(__HeapLimit = __heap_end__);
|
||||
} > REGION_HEAP AT> REGION_HEAP
|
||||
|
||||
PROVIDE(__stack_size = ORIGIN(SRAM) + LENGTH(SRAM) - ALIGN(0x8));
|
||||
|
||||
/* Start of stack must be 8 byte aligned */
|
||||
.stack (NOLOAD) : {
|
||||
PROVIDE(_stack = ALIGN(0x8));
|
||||
PROVIDE(__stack = _stack);
|
||||
|
||||
PROVIDE(_stack_end = ORIGIN(SRAM) + LENGTH(SRAM));
|
||||
PROVIDE(__stack_end = _stack_end);
|
||||
PROVIDE(_stack_origin = _stack_end);
|
||||
|
||||
/* Note that the stack check library requires the symbols */
|
||||
/* "_stack" and "_stack_origin" to be defined. */
|
||||
|
||||
/* Assert that we have enough stack */
|
||||
ASSERT(__stack_size >= MIN_STACKSIZE, "Error: No room left for the stack");
|
||||
} > REGION_STACK AT> REGION_STACK
|
||||
}
|
|
@ -0,0 +1,472 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header with configuration defines common to the CC13xx/CC26xx
|
||||
* platform.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef CC13XX_CC26XX_CONF_H_
|
||||
#define CC13XX_CC26XX_CONF_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "cc13xx-cc26xx-def.h"
|
||||
|
||||
#include "rf/rf.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Board Configuration.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Configure that a board has sensors for the dev/sensors.h API. */
|
||||
#ifndef BOARD_CONF_HAS_SENSORS
|
||||
#define BOARD_CONF_HAS_SENSORS 0
|
||||
#endif
|
||||
|
||||
/* Enable/disable the dev/sensors.h API for the given board. */
|
||||
#ifndef BOARD_CONF_SENSORS_DISABLE
|
||||
#define BOARD_CONF_SENSORS_DISABLE 0
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name GPIO HAL configuration.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define GPIO_HAL_CONF_ARCH_SW_TOGGLE 0
|
||||
#define GPIO_HAL_CONF_ARCH_HDR_PATH "dev/gpio-hal-arch.h"
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Watchdog Configuration.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#ifndef WATCHDOG_CONF_DISABLE
|
||||
#define WATCHDOG_CONF_DISABLE 0
|
||||
#endif
|
||||
|
||||
#ifndef WATCHDOG_CONF_TIMER_TOP
|
||||
#define WATCHDOG_CONF_TIMER_TOP 0xFFFFF
|
||||
#endif
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name RF configuration.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* Set the inactivity timeout period for the RF driver. This determines how
|
||||
* long the RF driver will wait when inactive until turning off the RF Core.
|
||||
* Specified in microseconds.
|
||||
*/
|
||||
#ifndef RF_CONF_INACTIVITY_TIMEOUT
|
||||
#define RF_CONF_INACTIVITY_TIMEOUT 2000 /**< 2 ms */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Configure TX power to either default PA or High PA, defaults to
|
||||
* default PA.
|
||||
*/
|
||||
#ifndef RF_CONF_TXPOWER_HIGH_PA
|
||||
#define RF_CONF_TXPOWER_HIGH_PA 0
|
||||
#endif
|
||||
|
||||
#if (RF_CONF_TXPOWER_HIGH_PA) && !(SUPPORTS_HIGH_PA)
|
||||
#error "Device does not support High PA"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CC13xx only: Configure TX power to use boot mode, allowing to gain
|
||||
* up to 14 dBm with the default PA. This will, however, increase power
|
||||
* consumption.
|
||||
*/
|
||||
#ifndef RF_CONF_TXPOWER_BOOST_MODE
|
||||
#define RF_CONF_TXPOWER_BOOST_MODE 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Configure RF mode. That is, whether to run on Sub-1 GHz (Prop-mode) or
|
||||
* 2.4 GHz (IEEE-mode).
|
||||
*/
|
||||
#ifdef RF_CONF_MODE
|
||||
/* Sanity check a valid configuration is provided. */
|
||||
#if !(RF_CONF_MODE & RF_MODE_BM)
|
||||
#error "Invalid RF_CONF_MODE provided"
|
||||
#endif
|
||||
|
||||
#define RF_MODE RF_CONF_MODE
|
||||
#endif /* RF_CONF_MODE */
|
||||
|
||||
/* Number of RX buffers. */
|
||||
#ifndef RF_CONF_RX_BUF_CNT
|
||||
#define RF_CONF_RX_BUF_CNT 4
|
||||
#endif
|
||||
|
||||
/* Size of each RX buffer in bytes. */
|
||||
#ifndef RF_CONF_RX_BUF_SIZE
|
||||
#define RF_CONF_RX_BUF_SIZE 144
|
||||
#endif
|
||||
|
||||
/* Enable/disable BLE beacon. */
|
||||
#ifndef RF_CONF_BLE_BEACON_ENABLE
|
||||
#define RF_CONF_BLE_BEACON_ENABLE 0
|
||||
#endif
|
||||
|
||||
#if (RF_CONF_BLE_BEACON_ENABLE) && !(SUPPORTS_BLE_BEACON)
|
||||
#error "Device does not support BLE for BLE beacon"
|
||||
#endif
|
||||
|
||||
/*----- CC13xx Device Line --------------------------------------------------*/
|
||||
/* CC13xx supports both IEEE and Prop mode, depending on which device. */
|
||||
#if defined(DEVICE_LINE_CC13XX)
|
||||
|
||||
/* Default to Prop-mode for CC13xx devices if not configured. */
|
||||
#ifndef RF_MODE
|
||||
#define RF_MODE RF_MODE_SUB_1_GHZ
|
||||
#endif
|
||||
|
||||
/*----- CC13xx Prop-mode ----------------------------------------------------*/
|
||||
#if (RF_MODE == RF_MODE_SUB_1_GHZ) && (SUPPORTS_PROP_MODE)
|
||||
|
||||
/* Netstack configuration. */
|
||||
#define NETSTACK_CONF_RADIO prop_mode_driver
|
||||
|
||||
/* CSMA configuration. */
|
||||
#define CSMA_CONF_ACK_WAIT_TIME (RTIMER_SECOND / 300)
|
||||
#define CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME (RTIMER_SECOND / 1000)
|
||||
#define CSMA_CONF_SEND_SOFT_ACK 1
|
||||
|
||||
/*----- CC13xx IEEE-mode ----------------------------------------------------*/
|
||||
#elif (RF_MODE == RF_MODE_2_4_GHZ) && (SUPPORTS_IEEE_MODE)
|
||||
|
||||
/* Netstack configuration. */
|
||||
#define NETSTACK_CONF_RADIO ieee_mode_driver
|
||||
|
||||
/* CSMA configuration. */
|
||||
#define CSMA_CONF_SEND_SOFT_ACK 0
|
||||
|
||||
#else
|
||||
/*----- CC13xx Unsupported Mode ---------------------------------------------*/
|
||||
#error "Invalid RF mode configuration of CC13xx device"
|
||||
#endif /* CC13xx RF Mode configuration */
|
||||
|
||||
/*----- CC26xx Device Line --------------------------------------------------*/
|
||||
/* CC26xx only supports IEEE mode */
|
||||
#elif defined(DEVICE_LINE_CC26XX)
|
||||
|
||||
/* Default to IEEE-mode for CC26xx devices if not configured */
|
||||
#ifndef RF_MODE
|
||||
#define RF_MODE RF_MODE_2_4_GHZ
|
||||
#endif
|
||||
|
||||
/*----- CC26xx IEEE-mode ----------------------------------------------------*/
|
||||
#if (RF_MODE == RF_MODE_2_4_GHZ) && (SUPPORTS_IEEE_MODE)
|
||||
|
||||
/* Netstack configuration */
|
||||
#define NETSTACK_CONF_RADIO ieee_mode_driver
|
||||
|
||||
/* CSMA configuration */
|
||||
#define CSMA_CONF_SEND_SOFT_ACK 0
|
||||
|
||||
/* Frequncy band configuration */
|
||||
#undef DOT_15_4G_FREQ_BAND_ID
|
||||
#define DOT_15_4G_CONF_FREQ_BAND_ID DOT_15_4G_FREQ_BAND_2450
|
||||
|
||||
#else
|
||||
/*----- CC26xx Unsupported Mode ---------------------------------------------*/
|
||||
#error "IEEE-mode only supported by CC26xx devices"
|
||||
#endif /* CC26xx RF Mode configuration */
|
||||
|
||||
/*----- Unsupported device line ---------------------------------------------*/
|
||||
#else
|
||||
#error "Unsupported Device Line defined"
|
||||
#endif /* Unsupported device line */
|
||||
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name IEEE address configuration. Used to generate our link-local and
|
||||
* global IPv6 addresses.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Location of the IEEE address.
|
||||
* 0 => Read from InfoPage.
|
||||
* 1 => Use a hardcoded address, configured by IEEE_ADDR_CONF_ADDRESS.
|
||||
*/
|
||||
#ifndef IEEE_ADDR_CONF_HARDCODED
|
||||
#define IEEE_ADDR_CONF_HARDCODED 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief The hardcoded IEEE address to be used when IEEE_ADDR_CONF_HARDCODED
|
||||
* is defined as 1. Must be a byte array of size 8.
|
||||
*/
|
||||
#ifndef IEEE_ADDR_CONF_ADDRESS
|
||||
#define IEEE_ADDR_CONF_ADDRESS { 0x00, 0x12, 0x4B, 0x00, 0x89, 0xAB, 0xCD, 0xEF }
|
||||
#endif
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name IEEE-mode configuration.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Configuration to enable/disable auto ACKs in IEEE-mode.
|
||||
* 0 => ACK generated by software
|
||||
* 1 => ACK generated by the radio.
|
||||
*/
|
||||
#ifndef IEEE_MODE_CONF_AUTOACK
|
||||
#define IEEE_MODE_CONF_AUTOACK 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Configuration to enable/disable frame filtering in IEEE-mode.
|
||||
* 0 => Disable promiscous mode.
|
||||
* 1 => Enable promiscous mode.
|
||||
*/
|
||||
#ifndef IEEE_MODE_CONF_PROMISCOUS
|
||||
#define IEEE_MODE_CONF_PROMISCOUS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Configuration to set the RSSI threshold in dBm in IEEE-mode.
|
||||
* Defaults to -90 dBm.
|
||||
*/
|
||||
#ifndef IEEE_MODE_CONF_CCA_RSSI_THRESHOLD
|
||||
#define IEEE_MODE_CONF_CCA_RSSI_THRESHOLD 0xA6
|
||||
#endif
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Prop-mode configuration.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Configuration to set whitener in Prop-mode.
|
||||
* 0 => No whitener
|
||||
* 1 => Whitener.
|
||||
*/
|
||||
#ifndef PROP_MODE_CONF_DW
|
||||
#define PROP_MODE_CONF_DW 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Use 16-bit or 32-bit CRC in Prop-mode.
|
||||
* 0 => 32-bit CRC.
|
||||
* 1 => 16-bit CRC.
|
||||
*/
|
||||
#ifndef PROP_MODE_CONF_USE_CRC16
|
||||
#define PROP_MODE_CONF_USE_CRC16 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Configuration to set the RSSI threshold in dBm in Prop-mode.
|
||||
* Defaults to -90 dBm.
|
||||
*/
|
||||
#ifndef PROP_MODE_CONF_CCA_RSSI_THRESHOLD
|
||||
#define PROP_MODE_CONF_CCA_RSSI_THRESHOLD 0xA6
|
||||
#endif
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name TI Drivers Configuration.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Enable or disable UART driver.
|
||||
*/
|
||||
#ifndef TI_UART_CONF_ENABLE
|
||||
#define TI_UART_CONF_ENABLE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Enable or disable UART0 peripheral.
|
||||
*/
|
||||
#ifndef TI_UART_CONF_UART0_ENABLE
|
||||
#define TI_UART_CONF_UART0_ENABLE TI_UART_CONF_ENABLE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Enable or disable UART1 peripheral.
|
||||
*/
|
||||
#ifndef TI_UART_CONF_UART1_ENABLE
|
||||
#define TI_UART_CONF_UART1_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief UART driver baud rate configuration.
|
||||
*/
|
||||
#ifndef TI_UART_CONF_BAUD_RATE
|
||||
#define TI_UART_CONF_BAUD_RATE 115200
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Enable or disable SPI driver.
|
||||
*/
|
||||
#ifndef TI_SPI_CONF_ENABLE
|
||||
#define TI_SPI_CONF_ENABLE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Enable or disable SPI0 peripheral.
|
||||
*/
|
||||
#ifndef TI_SPI_CONF_SPI0_ENABLE
|
||||
#define TI_SPI_CONF_SPI0_ENABLE TI_SPI_CONF_ENABLE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Enable or disable SPI1 peripheral.
|
||||
*/
|
||||
#ifndef TI_SPI_CONF_SPI1_ENABLE
|
||||
#define TI_SPI_CONF_SPI1_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Enable or disable I2C driver.
|
||||
*/
|
||||
#ifndef TI_I2C_CONF_ENABLE
|
||||
#define TI_I2C_CONF_ENABLE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Enable or disable I2C0 peripheral.
|
||||
*/
|
||||
#ifndef TI_I2C_CONF_I2C0_ENABLE
|
||||
#define TI_I2C_CONF_I2C0_ENABLE TI_I2C_CONF_ENABLE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Enable or disable Non-Volatile Storage (NVS) driver.
|
||||
*/
|
||||
#ifndef TI_NVS_CONF_ENABLE
|
||||
#define TI_NVS_CONF_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Enable or disable internal flash storage.
|
||||
*/
|
||||
#ifndef TI_NVS_CONF_NVS_INTERNAL_ENABLE
|
||||
#define TI_NVS_CONF_NVS_INTERNAL_ENABLE TI_NVS_CONF_ENABLE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Enable or disable external flash storage.
|
||||
*/
|
||||
#ifndef TI_NVS_CONF_NVS_EXTERNAL_ENABLE
|
||||
#define TI_NVS_CONF_NVS_EXTERNAL_ENABLE TI_NVS_CONF_ENABLE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Enable or disable SD driver.
|
||||
*/
|
||||
#ifndef TI_SD_CONF_ENABLE
|
||||
#define TI_SD_CONF_ENABLE 0
|
||||
#endif
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name SPI HAL configuration.
|
||||
*
|
||||
* CC13x0/CC26x0 has one SPI interface, while CC13x2/CC26x2 has two
|
||||
* SPI interfaces. Some additional checks has to be made for the
|
||||
* SPI_CONF_CONTROLLER_COUNT configuration, as this relies on whether the
|
||||
* available SPI interfaces are enabled or not, as well as if the SPI driver
|
||||
* is enabled at all.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#if TI_SPI_CONF_ENABLE
|
||||
/*
|
||||
* The SPI driver is enabled. Therefore, the number of SPI interfaces depends
|
||||
* on which Device family parent the device falls under and if any of its
|
||||
* corresponding SPI interfaces are enabled or not.
|
||||
*/
|
||||
|
||||
#define SPI0_IS_ENABLED ((TI_SPI_CONF_SPI0_ENABLE) ? 1 : 0)
|
||||
#define SPI1_IS_ENABLED ((TI_SPI_CONF_SPI1_ENABLE) ? 1 : 0)
|
||||
|
||||
#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
|
||||
|
||||
/* CC13x0/CC26x0 only has one SPI interface: SPI0. */
|
||||
#define SPI_CONF_CONTROLLER_COUNT (SPI0_IS_ENABLED)
|
||||
|
||||
#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
|
||||
|
||||
/* CC13x0/CC26x0 only has two SPI interface: SPI0 and SPI1. */
|
||||
#define SPI_CONF_CONTROLLER_COUNT (SPI0_IS_ENABLED + SPI1_IS_ENABLED)
|
||||
|
||||
#endif /* DeviceFamily_PARENT */
|
||||
|
||||
#else /* TI_SPI_CONF_ENABLE */
|
||||
/*
|
||||
* If the SPI driver is disabled then there are 0 available
|
||||
* SPI interfaces. */
|
||||
#define SPI_CONF_CONTROLLER_COUNT 0
|
||||
#endif /* TI_SPI_CONF_ENABLE */
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Slip configuration
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#ifndef SLIP_ARCH_CONF_ENABLED
|
||||
/*
|
||||
* Determine whether we need SLIP
|
||||
* This will keep working while UIP_FALLBACK_INTERFACE and CMD_CONF_OUTPUT
|
||||
* keep using SLIP
|
||||
*/
|
||||
#if defined(UIP_FALLBACK_INTERFACE) || defined(CMD_CONF_OUTPUT)
|
||||
#define SLIP_ARCH_CONF_ENABLED 1
|
||||
#endif
|
||||
|
||||
#endif /* SLIP_ARCH_CONF_ENABLED */
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* CC13XX_CC26XX_CONF_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header with configuration defines for the Contiki system.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef CC13XX_CC26XX_DEF_H_
|
||||
#define CC13XX_CC26XX_DEF_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
|
||||
#include <cm3/cm3-def.h>
|
||||
#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
|
||||
#include <cm4/cm4-def.h>
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define RTIMER_ARCH_SECOND 65536
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define INT_MASTER_CONF_STATUS_DATATYPE uintptr_t
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TSCH related defines */
|
||||
|
||||
/* Delay between GO signal and SFD */
|
||||
#define RADIO_DELAY_BEFORE_TX ((unsigned)US_TO_RTIMERTICKS(81))
|
||||
/* Delay between GO signal and start listening.
|
||||
* This value is so small because the radio is constantly on within each timeslot. */
|
||||
#define RADIO_DELAY_BEFORE_RX ((unsigned)US_TO_RTIMERTICKS(15))
|
||||
/* Delay between the SFD finishes arriving and it is detected in software. */
|
||||
#define RADIO_DELAY_BEFORE_DETECT ((unsigned)US_TO_RTIMERTICKS(352))
|
||||
|
||||
/* Timer conversion; radio is running at 4 MHz */
|
||||
#define RAT_SECOND 4000000u
|
||||
#define RAT_TO_RTIMER(x) ((uint32_t)(((uint64_t)(x)*(RTIMER_SECOND / 256)) / (RAT_SECOND / 256)))
|
||||
#define USEC_TO_RAT(x) ((x) * 4)
|
||||
|
||||
#if (RTIMER_SECOND % 256) || (RAT_SECOND % 256)
|
||||
#error RAT_TO_RTIMER macro must be fixed!
|
||||
#endif
|
||||
|
||||
/* The PHY header (preamble + SFD, 4+1 bytes) duration is equivalent to 10 symbols */
|
||||
#define RADIO_IEEE_802154_PHY_HEADER_DURATION_USEC 160
|
||||
|
||||
/* Do not turn off TSCH within a timeslot: not enough time */
|
||||
#define TSCH_CONF_RADIO_ON_DURING_TIMESLOT 1
|
||||
|
||||
/* Disable TSCH frame filtering */
|
||||
#define TSCH_CONF_HW_FRAME_FILTERING 0
|
||||
|
||||
/* Use hardware timestamps */
|
||||
#ifndef TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS
|
||||
#define TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS 1
|
||||
#define TSCH_CONF_TIMESYNC_REMOVE_JITTER 0
|
||||
#endif
|
||||
|
||||
#ifndef TSCH_CONF_BASE_DRIFT_PPM
|
||||
/*
|
||||
* The drift compared to "true" 10ms slots.
|
||||
* Enable adaptive sync to enable compensation for this.
|
||||
* Slot length 10000 usec
|
||||
* 328 ticks
|
||||
* Tick duration 30.517578125 usec
|
||||
* Real slot duration 10009.765625 usec
|
||||
* Target - real duration = -9.765625 usec
|
||||
* TSCH_CONF_BASE_DRIFT_PPM -977
|
||||
*/
|
||||
#define TSCH_CONF_BASE_DRIFT_PPM -977
|
||||
#endif
|
||||
|
||||
/* 10 times per second */
|
||||
#ifndef TSCH_CONF_CHANNEL_SCAN_DURATION
|
||||
#define TSCH_CONF_CHANNEL_SCAN_DURATION (CLOCK_SECOND / 10)
|
||||
#endif
|
||||
|
||||
/* Slightly reduce the TSCH guard time (from 2200 usec to 1800 usec) to make sure
|
||||
* the CC26xx radio has sufficient time to start up. */
|
||||
#ifndef TSCH_CONF_RX_WAIT
|
||||
#define TSCH_CONF_RX_WAIT 1800
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Path to CMSIS header */
|
||||
#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
|
||||
#define CMSIS_CONF_HEADER_PATH "cc13x0-cc26x0-cm3.h"
|
||||
#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
|
||||
#define CMSIS_CONF_HEADER_PATH "cc13x2-cc26x2-cm4.h"
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Path to headers with implementation of mutexes and memory barriers */
|
||||
#define MUTEX_CONF_ARCH_HEADER_PATH "mutex-cortex.h"
|
||||
#define MEMORY_BARRIER_CONF_ARCH_HEADER_PATH "memory-barrier-cortex.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* CC13XX_CC26XX_DEF_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-ccfg Customer Configuration (CCFG)
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Configuration of CCFG.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki-conf.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name JTAG interface configuration
|
||||
*
|
||||
* Enable/Disable the JTAG DAP and TAP interfaces on the chip.
|
||||
* Setting this to 0 will disable access to the debug interface
|
||||
* to secure deployed images.
|
||||
* @{
|
||||
*/
|
||||
#if CCFG_CONF_JTAG_INTERFACE_DISABLE
|
||||
#define SET_CCFG_CCFG_TI_OPTIONS_TI_FA_ENABLE 0x00
|
||||
#define SET_CCFG_CCFG_TAP_DAP_0_CPU_DAP_ENABLE 0x00
|
||||
#define SET_CCFG_CCFG_TAP_DAP_0_PRCM_TAP_ENABLE 0x00
|
||||
#define SET_CCFG_CCFG_TAP_DAP_0_TEST_TAP_ENABLE 0x00
|
||||
#define SET_CCFG_CCFG_TAP_DAP_1_PBIST2_TAP_ENABLE 0x00
|
||||
#define SET_CCFG_CCFG_TAP_DAP_1_PBIST1_TAP_ENABLE 0x00
|
||||
#define SET_CCFG_CCFG_TAP_DAP_1_WUC_TAP_ENABLE 0x00
|
||||
#endif /* CCFG_CONF_JTAG_INTERFACE_DISABLE */
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name TX Power Boost Mode
|
||||
*
|
||||
* CC13xx only: Enable/Disable boost mode, which enables maximum +14 dBm
|
||||
* output power with the default PA front-end configuration.
|
||||
* @{
|
||||
*/
|
||||
#if defined(DEVICE_LINE_CC13XX) && (RF_CONF_TXPOWER_BOOST_MODE)
|
||||
#define CCFG_FORCE_VDDR_HH 1
|
||||
#endif
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name ROM Bootloader configuration
|
||||
*
|
||||
* Enable/Disable the ROM bootloader in your image, if the board supports it.
|
||||
* Look in Board.h to choose the DIO and corresponding level that will cause
|
||||
* the chip to enter bootloader mode.
|
||||
* @{
|
||||
*/
|
||||
#ifndef CCFG_CONF_ROM_BOOTLOADER_ENABLE
|
||||
#define CCFG_CONF_ROM_BOOTLOADER_ENABLE 0
|
||||
#endif
|
||||
|
||||
#if CCFG_CONF_ROM_BOOTLOADER_ENABLE
|
||||
#define SET_CCFG_BL_CONFIG_BOOTLOADER_ENABLE 0xC5
|
||||
#define SET_CCFG_BL_CONFIG_BL_LEVEL 0x00
|
||||
#if defined(CCFG_CONF_BL_PIN_NUMBER)
|
||||
#define SET_CCFG_BL_CONFIG_BL_PIN_NUMBER CCFG_CONF_BL_PIN_NUMBER
|
||||
#endif
|
||||
#define SET_CCFG_BL_CONFIG_BL_ENABLE 0xC5
|
||||
#endif /* CCFG_CONF_ROM_BOOTLOADER_ENABLE */
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Include the device-specific CCFG file from the SDK.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(startup_files/ccfg.c)
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-clock CC13xx/CC26xx clock library
|
||||
*
|
||||
* @{
|
||||
* \file
|
||||
* Implementation of the clock libary for CC13xx/CC26xx.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "sys/etimer.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/aon_rtc.h)
|
||||
#include DeviceFamily_constructPath(driverlib/cpu.h)
|
||||
#include DeviceFamily_constructPath(driverlib/interrupt.h)
|
||||
#include DeviceFamily_constructPath(driverlib/prcm.h)
|
||||
#include DeviceFamily_constructPath(driverlib/timer.h)
|
||||
|
||||
#include <ti/drivers/dpl/ClockP.h>
|
||||
#include <ti/drivers/dpl/HwiP.h>
|
||||
#include <ti/drivers/power/PowerCC26XX.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static volatile clock_time_t count;
|
||||
static ClockP_Struct etimer_clock;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
clock_update_cb(void)
|
||||
{
|
||||
const uintptr_t key = HwiP_disable();
|
||||
count += 1;
|
||||
HwiP_restore(key);
|
||||
|
||||
/* Notify the etimer system. */
|
||||
if(etimer_pending()) {
|
||||
etimer_request_poll();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static inline clock_time_t
|
||||
get_count(void)
|
||||
{
|
||||
clock_time_t count_read;
|
||||
|
||||
const uintptr_t key = HwiP_disable();
|
||||
count_read = count;
|
||||
HwiP_restore(key);
|
||||
|
||||
return count_read;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
clock_init(void)
|
||||
{
|
||||
/* ClockP_getSystemTickPeriod() returns ticks per us. */
|
||||
const uint32_t clockp_ticks_second =
|
||||
(uint32_t)(1000 * 1000) / (CLOCK_SECOND) / ClockP_getSystemTickPeriod();
|
||||
|
||||
count = 0;
|
||||
|
||||
ClockP_Params params;
|
||||
ClockP_Params_init(¶ms);
|
||||
|
||||
params.period = clockp_ticks_second;
|
||||
params.startFlag = true;
|
||||
|
||||
ClockP_construct(&etimer_clock, (ClockP_Fxn)clock_update_cb,
|
||||
clockp_ticks_second, ¶ms);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
clock_time_t
|
||||
clock_time(void)
|
||||
{
|
||||
return get_count();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned long
|
||||
clock_seconds(void)
|
||||
{
|
||||
return (unsigned long)get_count() / CLOCK_SECOND;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
clock_wait(clock_time_t i)
|
||||
{
|
||||
clock_time_t start;
|
||||
|
||||
start = clock_time();
|
||||
while(clock_time() - start < i);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
clock_delay_usec(uint16_t usec)
|
||||
{
|
||||
ClockP_usleep(usec);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Obsolete delay function but we implement it here since some code
|
||||
* still uses it.
|
||||
*/
|
||||
void
|
||||
clock_delay(unsigned int i)
|
||||
{
|
||||
clock_delay_usec(i);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-platform
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the dbg module for CC13xx/CC26xx, used by stdio.
|
||||
* The dbg module is implemented by writing to UART0.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "sys/cc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "uart0-arch.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
dbg_putchar(int c)
|
||||
{
|
||||
unsigned char ch;
|
||||
int num_bytes;
|
||||
|
||||
ch = (unsigned char)c;
|
||||
|
||||
num_bytes = (int)uart0_write(&ch, 1);
|
||||
return (num_bytes > 0)
|
||||
? num_bytes
|
||||
: 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned int
|
||||
dbg_send_bytes(const unsigned char *seq, unsigned int len)
|
||||
{
|
||||
size_t seq_len;
|
||||
size_t max_len;
|
||||
int num_bytes;
|
||||
|
||||
seq_len = strlen((const char *)seq);
|
||||
max_len = MIN(seq_len, (size_t)len);
|
||||
|
||||
if(max_len == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
num_bytes = (int)uart0_write(seq, max_len);
|
||||
return (num_bytes > 0)
|
||||
? num_bytes
|
||||
: 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,215 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-gpio-hal
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the GPIO HAL module for CC13xx/CC26xx. The GPIO
|
||||
* HAL module is implemented by using the PINCC26XX module, except
|
||||
* for multi-dio functions which use the GPIO driverlib module.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/gpio.h)
|
||||
|
||||
#include <ti/drivers/PIN.h>
|
||||
#include <ti/drivers/pin/PINCC26XX.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static PIN_Config pin_config[] = { PIN_TERMINATE };
|
||||
static PIN_State pin_state;
|
||||
static PIN_Handle pin_handle;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
from_hal_cfg(gpio_hal_pin_cfg_t cfg, PIN_Config *pin_cfg, PIN_Config *pin_mask)
|
||||
{
|
||||
/* Pulling config */
|
||||
*pin_mask |= PIN_BM_PULLING;
|
||||
|
||||
switch(cfg & GPIO_HAL_PIN_CFG_PULL_MASK) {
|
||||
default: /* Default to no pullup/pulldown */
|
||||
case GPIO_HAL_PIN_CFG_PULL_NONE: *pin_cfg |= PIN_NOPULL; break;
|
||||
case GPIO_HAL_PIN_CFG_PULL_UP: *pin_cfg |= PIN_PULLUP; break;
|
||||
case GPIO_HAL_PIN_CFG_PULL_DOWN: *pin_cfg |= PIN_PULLDOWN; break;
|
||||
}
|
||||
|
||||
/* Hysteresis config */
|
||||
*pin_mask |= PIN_BM_HYSTERESIS;
|
||||
|
||||
if(cfg & GPIO_HAL_PIN_CFG_HYSTERESIS) {
|
||||
*pin_cfg |= PIN_HYSTERESIS;
|
||||
}
|
||||
|
||||
/* Interrupt config */
|
||||
*pin_mask |= PIN_BM_IRQ;
|
||||
|
||||
if((cfg & GPIO_HAL_PIN_CFG_INT_MASK) == GPIO_HAL_PIN_CFG_INT_ENABLE) {
|
||||
/* Interrupt edge config */
|
||||
switch(cfg & GPIO_HAL_PIN_CFG_EDGE_BOTH) {
|
||||
case GPIO_HAL_PIN_CFG_EDGE_NONE: *pin_cfg |= PIN_IRQ_DIS; break;
|
||||
case GPIO_HAL_PIN_CFG_EDGE_FALLING: *pin_cfg |= PIN_IRQ_NEGEDGE; break;
|
||||
case GPIO_HAL_PIN_CFG_EDGE_RISING: *pin_cfg |= PIN_IRQ_POSEDGE; break;
|
||||
case GPIO_HAL_PIN_CFG_EDGE_BOTH: *pin_cfg |= PIN_IRQ_BOTHEDGES; break;
|
||||
}
|
||||
} else {
|
||||
*pin_cfg |= PIN_IRQ_DIS;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
to_hal_cfg(PIN_Config pin_cfg, gpio_hal_pin_cfg_t *cfg)
|
||||
{
|
||||
/* Input config */
|
||||
if(pin_cfg & PIN_BM_INPUT_MODE) {
|
||||
/* Hysteresis config */
|
||||
if((pin_cfg & PIN_BM_HYSTERESIS) == PIN_HYSTERESIS) {
|
||||
*cfg |= GPIO_HAL_PIN_CFG_HYSTERESIS;
|
||||
}
|
||||
|
||||
/* Pulling config */
|
||||
switch(pin_cfg & PIN_BM_PULLING) {
|
||||
case PIN_NOPULL: *cfg |= GPIO_HAL_PIN_CFG_PULL_NONE; break;
|
||||
case PIN_PULLUP: *cfg |= GPIO_HAL_PIN_CFG_PULL_UP; break;
|
||||
case PIN_PULLDOWN: *cfg |= GPIO_HAL_PIN_CFG_PULL_DOWN; break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Interrupt config */
|
||||
if(pin_cfg & PIN_BM_IRQ) {
|
||||
/* Interrupt edge config */
|
||||
switch(pin_cfg & PIN_BM_IRQ) {
|
||||
case PIN_IRQ_DIS: *cfg |= GPIO_HAL_PIN_CFG_EDGE_NONE;
|
||||
*cfg |= GPIO_HAL_PIN_CFG_INT_DISABLE;
|
||||
break;
|
||||
case PIN_IRQ_NEGEDGE: *cfg |= GPIO_HAL_PIN_CFG_EDGE_FALLING;
|
||||
*cfg |= GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
break;
|
||||
case PIN_IRQ_POSEDGE: *cfg |= GPIO_HAL_PIN_CFG_EDGE_RISING;
|
||||
*cfg |= GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
break;
|
||||
case PIN_IRQ_BOTHEDGES: *cfg |= GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
*cfg |= GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
gpio_int_cb(PIN_Handle handle, PIN_Id pin_id)
|
||||
{
|
||||
/* Unused args */
|
||||
(void)handle;
|
||||
|
||||
/* Notify the GPIO HAL driver */
|
||||
gpio_hal_event_handler(gpio_hal_pin_to_mask(pin_id));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_init(void)
|
||||
{
|
||||
/* No error checking */
|
||||
pin_handle = PIN_open(&pin_state, pin_config);
|
||||
PIN_registerIntCb(pin_handle, gpio_int_cb);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin)
|
||||
{
|
||||
PIN_Config pin_cfg;
|
||||
PIN_Config irq_cfg;
|
||||
|
||||
pin_cfg = PIN_getConfig(pin);
|
||||
PIN_add(pin_handle, pin_cfg);
|
||||
|
||||
irq_cfg = pin_cfg & PIN_BM_IRQ;
|
||||
PIN_setInterrupt(pin_handle, pin | irq_cfg);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_interrupt_disable(gpio_hal_pin_t pin)
|
||||
{
|
||||
PIN_add(pin_handle, PIN_getConfig(pin));
|
||||
|
||||
PIN_setInterrupt(pin_handle, pin | PIN_IRQ_DIS);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
|
||||
{
|
||||
PIN_add(pin_handle, PIN_getConfig(pin));
|
||||
|
||||
/* Clear settings that we are about to change, keep everything else. */
|
||||
PIN_Config pin_cfg = 0;
|
||||
PIN_Config pin_mask = 0;
|
||||
|
||||
from_hal_cfg(cfg, &pin_cfg, &pin_mask);
|
||||
|
||||
PIN_setConfig(pin_handle, pin_mask, pin | pin_cfg);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_cfg_t
|
||||
gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin)
|
||||
{
|
||||
PIN_Config pin_cfg = PIN_getConfig(pin);
|
||||
gpio_hal_pin_cfg_t cfg = 0;
|
||||
|
||||
to_hal_cfg(pin_cfg, &cfg);
|
||||
|
||||
return cfg;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_mask_t
|
||||
gpio_hal_arch_read_pins(gpio_hal_pin_mask_t pins)
|
||||
{
|
||||
/* For pins configured as output we need to read DOUT31_0 */
|
||||
gpio_hal_pin_mask_t oe_pins = GPIO_getOutputEnableMultiDio(pins);
|
||||
|
||||
pins &= ~oe_pins;
|
||||
|
||||
return (HWREG(GPIO_BASE + GPIO_O_DOUT31_0) & oe_pins) |
|
||||
GPIO_readMultiDio(pins);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint8_t
|
||||
gpio_hal_arch_read_pin(gpio_hal_pin_t pin)
|
||||
{
|
||||
return (GPIO_getOutputEnableDio(pin))
|
||||
? PINCC26XX_getOutputValue(pin)
|
||||
: PINCC26XX_getInputValue(pin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-gpio-hal CC13xx/CC26xx GPIO HAL implementation
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file for the CC13xx/CC26xx GPIO HAL functions.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
* \note
|
||||
* Do not include this header directly.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef GPIO_HAL_ARCH_H_
|
||||
#define GPIO_HAL_ARCH_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/gpio.h)
|
||||
|
||||
#include <ti/drivers/pin/PINCC26XX.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define gpio_hal_arch_pin_set_input(p) PINCC26XX_setOutputEnable(p, false)
|
||||
#define gpio_hal_arch_pin_set_output(p) PINCC26XX_setOutputEnable(p, true)
|
||||
|
||||
#define gpio_hal_arch_set_pin(p) PINCC26XX_setOutputValue(p, 1)
|
||||
#define gpio_hal_arch_clear_pin(p) PINCC26XX_setOutputValue(p, 0)
|
||||
#define gpio_hal_arch_toggle_pin(p) PINCC26XX_setOutputValue(p, \
|
||||
PINCC26XX_getOutputValue(p) \
|
||||
? 0 : 1)
|
||||
#define gpio_hal_arch_write_pin(p, v) PINCC26XX_setOutputValue(p, v)
|
||||
|
||||
#define gpio_hal_arch_set_pins(p) GPIO_setMultiDio(p)
|
||||
#define gpio_hal_arch_clear_pins(p) GPIO_clearMultiDio(p)
|
||||
#define gpio_hal_arch_toggle_pins(p) GPIO_toggleMultiDio(p)
|
||||
#define gpio_hal_arch_write_pins(p, v) GPIO_writeMultiDio(p, v)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* GPIO_HAL_ARCH_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-int-master CC13xx/CC26xx master interrupt manipulation
|
||||
*
|
||||
* Master interrupt manipulation routines for CC13xx/CC26xx.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Master interrupt manipulation implementation for CC13xx/CC26xx.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "sys/int-master.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/cpu.h)
|
||||
|
||||
#include <ti/drivers/dpl/HwiP.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
int_master_enable(void)
|
||||
{
|
||||
HwiP_enable();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int_master_status_t
|
||||
int_master_read_and_disable(void)
|
||||
{
|
||||
return (int_master_status_t)HwiP_disable();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
int_master_status_set(int_master_status_t status)
|
||||
{
|
||||
HwiP_restore((uintptr_t)status);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
bool
|
||||
int_master_is_enabled(void)
|
||||
{
|
||||
return CPUprimask() ? false : true;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-prng Pseudo Random Number Generator (PRNG) for CC13xx/CC26xx.
|
||||
* @{
|
||||
*
|
||||
* Implementation based on Bob Jenkins' small noncryptographic PRNG.
|
||||
* - http://burtleburtle.net/bob/rand/smallprng.html
|
||||
*
|
||||
* This file overrides os/lib/random.c. Note that the file name must
|
||||
* match the original file for the override to work.
|
||||
*
|
||||
* \file
|
||||
* Implementation of Pseudo Random Number Generator for CC13xx/CC26xx.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <contiki.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
uint32_t a;
|
||||
uint32_t b;
|
||||
uint32_t c;
|
||||
uint32_t d;
|
||||
} ranctx_t;
|
||||
|
||||
static ranctx_t ranctx;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define rot32(x, k) (((x) << (k)) | ((x) >> (32 - (k))))
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Generates a new random number using the PRNG.
|
||||
* \return The random number.
|
||||
*/
|
||||
unsigned short
|
||||
random_rand(void)
|
||||
{
|
||||
uint32_t e;
|
||||
|
||||
e = ranctx.a - rot32(ranctx.b, 27);
|
||||
ranctx.a = ranctx.b ^ rot32(ranctx.c, 17);
|
||||
ranctx.b = ranctx.c + ranctx.d;
|
||||
ranctx.c = ranctx.d + e;
|
||||
ranctx.d = e + ranctx.a;
|
||||
|
||||
return (unsigned short)ranctx.d;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Initialize the PRNG.
|
||||
* \param seed Seed for the PRNG.
|
||||
*/
|
||||
void
|
||||
random_init(unsigned short seed)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
ranctx.a = 0xf1ea5eed;
|
||||
ranctx.b = ranctx.c = ranctx.d = (uint32_t)seed;
|
||||
for(i = 0; i < 20; ++i) {
|
||||
(void)random_rand();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,190 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rtimer
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the rtimer driver for CC13xx/CC26xx.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/aon_event.h)
|
||||
#include DeviceFamily_constructPath(driverlib/aon_rtc.h)
|
||||
#include DeviceFamily_constructPath(driverlib/interrupt.h)
|
||||
|
||||
#include <ti/drivers/dpl/ClockP.h>
|
||||
#include <ti/drivers/dpl/HwiP.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define HWIP_RTC_CH AON_RTC_CH0
|
||||
#define RTIMER_RTC_CH AON_RTC_CH1
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef void (*isr_fxn_t)(void);
|
||||
typedef void (*hwi_dispatch_fxn_t)(void);
|
||||
|
||||
static hwi_dispatch_fxn_t hwi_dispatch_fxn;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Stub function used when creating the dummy clock object.
|
||||
*/
|
||||
static void
|
||||
rtimer_clock_stub(uintptr_t unused)
|
||||
{
|
||||
(void)unused;
|
||||
/* do nothing */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief The Man-in-the-Middle ISR hook for the HWI dispatch ISR. This
|
||||
* will be the ISR dispatched when INT_AON_RTC_COMB is triggered,
|
||||
* and will either dispatch the interrupt to the rtimer driver or
|
||||
* the HWI driver, depening on which event triggered the interrupt.
|
||||
*/
|
||||
static void
|
||||
rtimer_isr_hook(void)
|
||||
{
|
||||
if(AONRTCEventGet(RTIMER_RTC_CH)) {
|
||||
AONRTCEventClear(RTIMER_RTC_CH);
|
||||
AONRTCChannelDisable(RTIMER_RTC_CH);
|
||||
|
||||
rtimer_run_next();
|
||||
}
|
||||
/*
|
||||
* HWI Dispatch clears the interrupt. If HWI wasn't triggered, clear
|
||||
* the interrupt manually.
|
||||
*/
|
||||
if(AONRTCEventGet(HWIP_RTC_CH)) {
|
||||
hwi_dispatch_fxn();
|
||||
} else {
|
||||
IntPendClear(INT_AON_RTC_COMB);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief TODO
|
||||
*/
|
||||
void
|
||||
rtimer_arch_init(void)
|
||||
{
|
||||
uintptr_t key;
|
||||
ClockP_Struct clk_object;
|
||||
ClockP_Params clk_params;
|
||||
volatile isr_fxn_t *ramvec_table;
|
||||
|
||||
key = HwiP_disable();
|
||||
|
||||
/*
|
||||
* Create a dummy clock to guarantee the RAM vector table is initialized.
|
||||
*
|
||||
* Creating a dummy clock will trigger initialization of TimerP, which
|
||||
* subsequently initializes the driverlib/interrupt.h module. It is the
|
||||
* interrupt module that initializes the RAM vector table.
|
||||
*
|
||||
* It is safe to destruct the Clock object immediately afterwards.
|
||||
*/
|
||||
ClockP_Params_init(&clk_params);
|
||||
ClockP_construct(&clk_object, rtimer_clock_stub, 0, &clk_params);
|
||||
ClockP_destruct(&clk_object);
|
||||
|
||||
/* Try to access the RAM vector table. */
|
||||
ramvec_table = (isr_fxn_t *)HWREG(NVIC_VTABLE);
|
||||
if(!ramvec_table) {
|
||||
/*
|
||||
* Unable to find the RAM vector table is a serious fault.
|
||||
* Spin-lock forever.
|
||||
*/
|
||||
for(;;) { /* hang */ }
|
||||
}
|
||||
|
||||
/*
|
||||
* The HWI Dispatch ISR is located at interrupt number INT_AON_RTC_COMB
|
||||
* in the RAM vector table. Fetch and store it.
|
||||
*/
|
||||
hwi_dispatch_fxn = (hwi_dispatch_fxn_t)ramvec_table[INT_AON_RTC_COMB];
|
||||
if(!hwi_dispatch_fxn) {
|
||||
/*
|
||||
* Unable to find the HWI dispatch ISR in the RAM vector table is
|
||||
* a serious fault. Spin-lock forever.
|
||||
*/
|
||||
for(;;) { /* hang */ }
|
||||
}
|
||||
|
||||
/*
|
||||
* Override the INT_AON_RTC_COMB interrupt number with our own ISR hook,
|
||||
* which will act as a man-in-the-middle ISR for the HWI dispatch.
|
||||
*/
|
||||
IntRegister(INT_AON_RTC_COMB, rtimer_isr_hook);
|
||||
|
||||
AONEventMcuWakeUpSet(AON_EVENT_MCU_WU1, AON_EVENT_RTC_CH1);
|
||||
AONRTCCombinedEventConfig(HWIP_RTC_CH | RTIMER_RTC_CH);
|
||||
|
||||
HwiP_restore(key);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Schedules an rtimer task to be triggered at time \p t.
|
||||
* \param t The time when the task will need executed.
|
||||
*
|
||||
* \p t is an absolute time, in other words the task will be
|
||||
* executed AT time \p t, not IN \p t rtimer ticks.
|
||||
*
|
||||
* This function schedules a one-shot event with the AON RTC.
|
||||
*
|
||||
* This functions converts \p t to a value suitable for the AON RTC.
|
||||
*/
|
||||
void
|
||||
rtimer_arch_schedule(rtimer_clock_t t)
|
||||
{
|
||||
/* Convert the rtimer tick value to a value suitable for the AON RTC */
|
||||
AONRTCCompareValueSet(RTIMER_RTC_CH, (uint32_t)t);
|
||||
AONRTCChannelEnable(RTIMER_RTC_CH);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Returns the current real-time clock time.
|
||||
* \return The current rtimer time in ticks.
|
||||
*
|
||||
* The value is read from the AON RTC counter and converted to a
|
||||
* number of rtimer ticks.
|
||||
*/
|
||||
rtimer_clock_t
|
||||
rtimer_arch_now()
|
||||
{
|
||||
return (rtimer_clock_t)AONRTCCurrentCompareValueGet();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-rtimer The CC13xx/CC26xx rtimer
|
||||
*
|
||||
* Implementation of the rtimer module for CC13xx/CC26xx. This header
|
||||
* is included by os/sys/rtimer.h.
|
||||
*
|
||||
* RTIMER_ARCH_SECOND is defined in cc13xx-cc26xx-def.h.
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file of the rtimer driver for CC13xx/CC26xx.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef RTIMER_ARCH_H_
|
||||
#define RTIMER_ARCH_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rtimer_clock_t rtimer_arch_now(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* HW oscillator frequency is 32 kHz, not 64 kHz. And, RTIMER_NOW() never
|
||||
* returns an odd value; US_TO_RTIMERTICKS always rounds to the nearest
|
||||
* even number.
|
||||
*/
|
||||
#define US_TO_RTIMERTICKS(us) ( \
|
||||
(((us) >= 0) \
|
||||
? (((int32_t)(us) * (RTIMER_ARCH_SECOND / 2) + 500000) / 1000000L) \
|
||||
: (((int32_t)(us) * (RTIMER_ARCH_SECOND / 2) - 500000) / 1000000L) \
|
||||
) * 2)
|
||||
|
||||
#define RTIMERTICKS_TO_US(rt) ( \
|
||||
((rt) >= 0) \
|
||||
? (((int32_t)(rt) * 1000000L + (RTIMER_ARCH_SECOND / 2)) / RTIMER_ARCH_SECOND) \
|
||||
: (((int32_t)(rt) * 1000000L - (RTIMER_ARCH_SECOND / 2)) / RTIMER_ARCH_SECOND) \
|
||||
)
|
||||
|
||||
/*
|
||||
* A 64-bit version because the 32-bit one cannot handle T >= 4295 ticks.
|
||||
* Intended only for positive values of T.
|
||||
*/
|
||||
#define RTIMERTICKS_TO_US_64(rt) ( \
|
||||
(uint32_t)( \
|
||||
((uint64_t)(rt) * 1000000 + (RTIMER_ARCH_SECOND / 2)) / RTIMER_ARCH_SECOND \
|
||||
))
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RTIMER_ARCH_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-slip-arch SLIP for CC13xx/CC26xx.
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of SLIP driver for CC13xx/CC26xx.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/slip.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "uart0-arch.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Write a single byte over SLIP.
|
||||
* \param c The byte to write.
|
||||
*/
|
||||
void
|
||||
slip_arch_writeb(unsigned char c)
|
||||
{
|
||||
uart0_write(&c, 1);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Initialize the SLIP driver.
|
||||
*/
|
||||
void
|
||||
slip_arch_init(void)
|
||||
{
|
||||
/*
|
||||
* Set an input handler. In doing so, the driver will make sure that UART
|
||||
* RX stays operational during deep sleep.
|
||||
*/
|
||||
uart0_init();
|
||||
uart0_set_callback(slip_input_byte);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,265 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-spi CC13xx/CC26xx SPI HAL
|
||||
*
|
||||
* @{
|
||||
* \file
|
||||
* Implementation of the SPI HAL driver for CC13xx/CC26xx.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "sys/cc.h"
|
||||
#include "dev/spi.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/drivers/SPI.h>
|
||||
#include <ti/drivers/dpl/HwiP.h>
|
||||
#include <ti/drivers/pin/PINCC26XX.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
SPI_Handle handle;
|
||||
spi_device_t *owner;
|
||||
} spi_arch_t;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if (SPI_CONTROLLER_COUNT > 0)
|
||||
static spi_arch_t spi_arches[SPI_CONTROLLER_COUNT];
|
||||
#else
|
||||
static spi_arch_t *spi_arches = NULL;
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static inline spi_arch_t *
|
||||
get_handle(uint8_t spi_controller)
|
||||
{
|
||||
if(spi_controller < SPI_CONTROLLER_COUNT) {
|
||||
return &spi_arches[spi_controller];
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static SPI_FrameFormat
|
||||
convert_frame_format(uint8_t pol, uint8_t pha)
|
||||
{
|
||||
pol = (pol) ? 1 : 0;
|
||||
pha = (pha) ? 1 : 0;
|
||||
/*
|
||||
* Convert pol/pha to a single byte on the following format:
|
||||
* xxxA xxxB
|
||||
* where A is the polarity bit and B is the phase bit.
|
||||
* Note that any other value deviating from this format will
|
||||
* default to the SPI_POL1_PHA1 format.
|
||||
*/
|
||||
uint8_t pol_pha = (pol << 4) | (pha << 0);
|
||||
switch(pol_pha) {
|
||||
case 0x00: return SPI_POL0_PHA0;
|
||||
case 0x01: return SPI_POL0_PHA1;
|
||||
case 0x10: return SPI_POL1_PHA0;
|
||||
default: /* fallthrough */
|
||||
case 0x11: return SPI_POL1_PHA1;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
bool
|
||||
spi_arch_has_lock(spi_device_t *dev)
|
||||
{
|
||||
/*
|
||||
* The SPI device is the owner if the SPI controller returns a valid
|
||||
* SPI arch object and the SPI device is owner of that object.
|
||||
*/
|
||||
spi_arch_t *spi_arch = get_handle(dev->spi_controller);
|
||||
return (spi_arch != NULL) && (spi_arch->owner == dev);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
bool
|
||||
spi_arch_is_bus_locked(spi_device_t *dev)
|
||||
{
|
||||
/*
|
||||
* The SPI controller is locked by any device if the SPI controller returns
|
||||
* a valid SPI arch object and the SPI handle of that object is valid.
|
||||
*/
|
||||
spi_arch_t *spi_arch = get_handle(dev->spi_controller);
|
||||
return (spi_arch != NULL) && (spi_arch->handle != NULL);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
spi_status_t
|
||||
spi_arch_lock_and_open(spi_device_t *dev)
|
||||
{
|
||||
uint_least8_t spi_index;
|
||||
spi_arch_t *spi_arch;
|
||||
SPI_Params spi_params;
|
||||
|
||||
const uintptr_t hwi_key = HwiP_disable();
|
||||
|
||||
spi_index = dev->spi_controller;
|
||||
spi_arch = get_handle(spi_index);
|
||||
|
||||
/* Ensure the provided SPI index is valid. */
|
||||
if(spi_arch == NULL) {
|
||||
HwiP_restore(hwi_key);
|
||||
return SPI_DEV_STATUS_EINVAL;
|
||||
}
|
||||
|
||||
/* Ensure the corresponding SPI interface is not already locked. */
|
||||
if(spi_arch_is_bus_locked(dev)) {
|
||||
HwiP_restore(hwi_key);
|
||||
return SPI_DEV_STATUS_BUS_LOCKED;
|
||||
}
|
||||
|
||||
SPI_Params_init(&spi_params);
|
||||
|
||||
spi_params.transferMode = SPI_MODE_BLOCKING;
|
||||
spi_params.mode = SPI_MASTER;
|
||||
spi_params.bitRate = dev->spi_bit_rate;
|
||||
spi_params.dataSize = 8;
|
||||
spi_params.frameFormat = convert_frame_format(dev->spi_pol, dev->spi_pha);
|
||||
|
||||
/*
|
||||
* Try to open the SPI driver. Accessing the SPI driver also ensures
|
||||
* atomic access to the SPI interface.
|
||||
*/
|
||||
spi_arch->handle = SPI_open(spi_index, &spi_params);
|
||||
|
||||
if(spi_arch->handle == NULL) {
|
||||
HwiP_restore(hwi_key);
|
||||
return SPI_DEV_STATUS_BUS_LOCKED;
|
||||
}
|
||||
|
||||
spi_arch->owner = dev;
|
||||
|
||||
HwiP_restore(hwi_key);
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
spi_status_t
|
||||
spi_arch_close_and_unlock(spi_device_t *dev)
|
||||
{
|
||||
spi_arch_t *spi_arch;
|
||||
|
||||
const uintptr_t hwi_key = HwiP_disable();
|
||||
|
||||
/* Ensure the provided SPI index is valid. */
|
||||
spi_arch = get_handle(dev->spi_controller);
|
||||
if(spi_arch == NULL) {
|
||||
HwiP_restore(hwi_key);
|
||||
return SPI_DEV_STATUS_EINVAL;
|
||||
}
|
||||
|
||||
/* Ensure the corresponding SPI device owns the SPI controller. */
|
||||
if(!spi_arch_has_lock(dev)) {
|
||||
HwiP_restore(hwi_key);
|
||||
return SPI_DEV_STATUS_BUS_NOT_OWNED;
|
||||
}
|
||||
|
||||
SPI_close(spi_arch->handle);
|
||||
|
||||
spi_arch->handle = NULL;
|
||||
spi_arch->owner = NULL;
|
||||
|
||||
HwiP_restore(hwi_key);
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
spi_status_t
|
||||
spi_arch_transfer(spi_device_t *dev,
|
||||
const uint8_t *write_buf, int wlen,
|
||||
uint8_t *inbuf, int rlen, int ignore_len)
|
||||
{
|
||||
spi_arch_t *spi_arch;
|
||||
size_t totlen;
|
||||
SPI_Transaction spi_transaction;
|
||||
bool transfer_ok;
|
||||
|
||||
/* Ensure the provided SPI index is valid. */
|
||||
spi_arch = get_handle(dev->spi_controller);
|
||||
if(spi_arch == NULL) {
|
||||
return SPI_DEV_STATUS_EINVAL;
|
||||
}
|
||||
|
||||
if(!spi_arch_has_lock(dev)) {
|
||||
return SPI_DEV_STATUS_BUS_NOT_OWNED;
|
||||
}
|
||||
|
||||
totlen = MAX((size_t)(rlen + ignore_len), (size_t)wlen);
|
||||
|
||||
if(totlen == 0) {
|
||||
/* Nothing to do */
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
|
||||
spi_transaction.count = totlen;
|
||||
spi_transaction.txBuf = (void *)write_buf;
|
||||
spi_transaction.rxBuf = (void *)inbuf;
|
||||
|
||||
transfer_ok = SPI_transfer(spi_arch->handle, &spi_transaction);
|
||||
|
||||
if(!transfer_ok) {
|
||||
return SPI_DEV_STATUS_TRANSFER_ERR;
|
||||
}
|
||||
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
spi_status_t
|
||||
spi_arch_select(spi_device_t *dev)
|
||||
{
|
||||
if(!spi_arch_has_lock(dev)) {
|
||||
return SPI_DEV_STATUS_BUS_NOT_OWNED;
|
||||
}
|
||||
|
||||
PINCC26XX_setOutputValue(dev->pin_spi_cs, 0);
|
||||
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
spi_status_t
|
||||
spi_arch_deselect(spi_device_t *dev)
|
||||
{
|
||||
if(!spi_arch_has_lock(dev)) {
|
||||
return SPI_DEV_STATUS_BUS_NOT_OWNED;
|
||||
}
|
||||
|
||||
PINCC26XX_setOutputValue(dev->pin_spi_cs, 1);
|
||||
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,311 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Startup file for GCC for CC13xx/CC26xx.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Check if compiler is GNU Compiler. */
|
||||
#if !(defined(__GNUC__))
|
||||
#error "startup_cc13xx_cc26xx_gcc.c: Unsupported compiler!"
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <string.h>
|
||||
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(inc/hw_types.h)
|
||||
#include DeviceFamily_constructPath(driverlib/interrupt.h)
|
||||
#include DeviceFamily_constructPath(driverlib/setup.h)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Forward declaration of the default fault handlers. */
|
||||
void resetISR(void);
|
||||
static void nmiISR(void);
|
||||
static void faultISR(void);
|
||||
static void defaultHandler(void);
|
||||
static void busFaultHandler(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* External declaration for the reset handler that is to be called when the
|
||||
* processor is started.
|
||||
*/
|
||||
extern void _c_int00(void);
|
||||
|
||||
/* The entry point for the application. */
|
||||
extern int main(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Linker variable that marks the top of stack. */
|
||||
extern unsigned long _stack_end;
|
||||
|
||||
/*
|
||||
* The vector table. Note that the proper constructs must be placed on this to
|
||||
* ensure that it ends up at physical address 0x0000.0000.
|
||||
*/
|
||||
__attribute__((section(".resetVecs"))) __attribute__((used))
|
||||
static void(*const resetVectors[16])(void) =
|
||||
{
|
||||
(void(*)(void))((uint32_t)&_stack_end),
|
||||
/* The initial stack pointer */
|
||||
resetISR, /* The reset handler */
|
||||
nmiISR, /* The NMI handler */
|
||||
faultISR, /* The hard fault handler */
|
||||
defaultHandler, /* The MPU fault handler */
|
||||
busFaultHandler, /* The bus fault handler */
|
||||
defaultHandler, /* The usage fault handler */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
defaultHandler, /* SVCall handler */
|
||||
defaultHandler, /* Debug monitor handler */
|
||||
0, /* Reserved */
|
||||
defaultHandler, /* The PendSV handler */
|
||||
defaultHandler /* The SysTick handler */
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* The following are arrays of pointers to constructor functions that need to
|
||||
* be called during startup to initialize global objects.
|
||||
*/
|
||||
extern void (*__init_array_start[])(void);
|
||||
extern void (*__init_array_end[])(void);
|
||||
|
||||
/* The following global variable is required for C++ support. */
|
||||
void *__dso_handle = (void *)&__dso_handle;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* The following are constructs created by the linker, indicating where the
|
||||
* the "data" and "bss" segments reside in memory. The initializers for the
|
||||
* for the "data" segment resides immediately following the "text" segment.
|
||||
*/
|
||||
extern uint32_t __bss_start__;
|
||||
extern uint32_t __bss_end__;
|
||||
extern uint32_t __data_load__;
|
||||
extern uint32_t __data_start__;
|
||||
extern uint32_t __data_end__;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief Entry point of the startup code.
|
||||
*
|
||||
* Initialize the .data and .bss sections, and call main.
|
||||
*/
|
||||
void
|
||||
localProgramStart(void)
|
||||
{
|
||||
uint32_t *bs;
|
||||
uint32_t *be;
|
||||
uint32_t *dl;
|
||||
uint32_t *ds;
|
||||
uint32_t *de;
|
||||
uint32_t count;
|
||||
uint32_t i;
|
||||
|
||||
IntMasterDisable();
|
||||
|
||||
/* Final trim of device */
|
||||
SetupTrimDevice();
|
||||
|
||||
/* initiailize .bss to zero */
|
||||
bs = &__bss_start__;
|
||||
be = &__bss_end__;
|
||||
while(bs < be) {
|
||||
*bs = 0;
|
||||
bs++;
|
||||
}
|
||||
|
||||
/* relocate the .data section */
|
||||
dl = &__data_load__;
|
||||
ds = &__data_start__;
|
||||
de = &__data_end__;
|
||||
if(dl != ds) {
|
||||
while(ds < de) {
|
||||
*ds = *dl;
|
||||
dl++;
|
||||
ds++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Run any constructors */
|
||||
count = (uint32_t)(__init_array_end - __init_array_start);
|
||||
for(i = 0; i < count; i++) {
|
||||
__init_array_start[i]();
|
||||
}
|
||||
|
||||
/* Call the application's entry point. */
|
||||
main();
|
||||
|
||||
/* If we ever return signal Error */
|
||||
faultISR();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief Reset ISR.
|
||||
*
|
||||
* This is the code that gets called when the processor first starts execution
|
||||
* following a reset event. Only the absolutely necessary set is performed,
|
||||
* after which the application supplied entry() routine is called. Any fancy
|
||||
* actions (such as making decisions based on the reset cause register, and
|
||||
* resetting the bits in that register) are left solely in the hands of the
|
||||
* application.
|
||||
*/
|
||||
void __attribute__((naked))
|
||||
resetISR(void)
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"movw r0, #:lower16:resetVectors \n"
|
||||
"movt r0, #:upper16:resetVectors \n"
|
||||
"ldr r0, [r0] \n"
|
||||
"mov sp, r0 \n"
|
||||
"bx %0 \n"
|
||||
: /* output */
|
||||
: /* input */
|
||||
"r"(localProgramStart)
|
||||
);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief Non-Maskable Interrupt (NMI) ISR.
|
||||
*
|
||||
* This is the code that gets called when the processor receives a NMI. This
|
||||
* simply enters an infinite loop, preserving the system state for examination
|
||||
* by a debugger.
|
||||
*/
|
||||
static void
|
||||
nmiISR(void)
|
||||
{
|
||||
/* Enter an infinite loop. */
|
||||
for(;;) { /* hang */ }
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief Debug stack pointer.
|
||||
* \param sp Stack pointer.
|
||||
*
|
||||
* Provide a view into the CPU state from the provided stack pointer.
|
||||
*/
|
||||
static void
|
||||
debugHardfault(uint32_t *sp)
|
||||
{
|
||||
volatile uint32_t r0; /**< R0 register */
|
||||
volatile uint32_t r1; /**< R1 register */
|
||||
volatile uint32_t r2; /**< R2 register */
|
||||
volatile uint32_t r3; /**< R3 register */
|
||||
volatile uint32_t r12; /**< R12 register */
|
||||
volatile uint32_t lr; /**< LR register */
|
||||
volatile uint32_t pc; /**< PC register */
|
||||
volatile uint32_t psr; /**< PSR register */
|
||||
|
||||
(void)(r0 = sp[0]);
|
||||
(void)(r1 = sp[1]);
|
||||
(void)(r2 = sp[2]);
|
||||
(void)(r3 = sp[3]);
|
||||
(void)(r12 = sp[4]);
|
||||
(void)(lr = sp[5]);
|
||||
(void)(pc = sp[6]);
|
||||
(void)(psr = sp[7]);
|
||||
|
||||
/* Enter an infinite loop. */
|
||||
for(;;) { /* hang */ }
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief CPU Fault ISR.
|
||||
*
|
||||
* This is the code that gets called when the processor receives a fault
|
||||
* interrupt. Setup a call to debugStackPointer with the current stack pointer.
|
||||
* The stack pointer in this case would be the CPU state which caused the CPU
|
||||
* fault.
|
||||
*/
|
||||
static void
|
||||
faultISR(void)
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"tst lr, #4 \n"
|
||||
"ite eq \n"
|
||||
"mrseq r0, msp \n"
|
||||
"mrsne r0, psp \n"
|
||||
"bx %0 \n"
|
||||
: /* output */
|
||||
: /* input */
|
||||
"r"(debugHardfault)
|
||||
);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Dummy variable */
|
||||
volatile int x__;
|
||||
|
||||
/*
|
||||
* \brief Bus Fault Handler.
|
||||
*
|
||||
* This is the code that gets called when the processor receives an unexpected
|
||||
* interrupt. This simply enters an infinite loop, preserving the system state
|
||||
* for examination by a debugger.
|
||||
*/
|
||||
static void
|
||||
busFaultHandler(void)
|
||||
{
|
||||
x__ = 0;
|
||||
|
||||
/* Enter an infinite loop. */
|
||||
for(;;) { /* hang */ }
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief Default Handler.
|
||||
*
|
||||
* This is the code that gets called when the processor receives an unexpected
|
||||
* interrupt. This simply enters an infinite loop, preserving the system state
|
||||
* for examination by a debugger.
|
||||
*/
|
||||
static void
|
||||
defaultHandler(void)
|
||||
{
|
||||
/* Enter an infinite loop. */
|
||||
for(;;) { /* hang */ }
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief Finalize object function.
|
||||
*
|
||||
* This function is called by __libc_fini_array which gets called when exit()
|
||||
* is called. In order to support exit(), an empty _fini() stub function is
|
||||
* required.
|
||||
*/
|
||||
void
|
||||
_fini(void)
|
||||
{
|
||||
/* Function body left empty intentionally */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,318 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Startup file for IAR for CC13xx/CC26xx.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Check if compiler is IAR. */
|
||||
#if !(defined(__IAR_SYSTEMS_ICC__))
|
||||
#error "startup_cc13xx_cc26xx_iar.c: Unsupported compiler!"
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* We need intrinsic functions for IAR (if used in source code). */
|
||||
#include <intrinsics.h>
|
||||
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(inc/hw_types.h)
|
||||
#include DeviceFamily_constructPath(driverlib/setup.h)
|
||||
#include DeviceFamily_constructPath(driverlib/interrupt.h)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Forward declaration of the reset ISR and the default fault handlers. */
|
||||
static void nmiISR(void);
|
||||
static void faultISR(void);
|
||||
static void intDefaultHandler(void);
|
||||
extern int main(void);
|
||||
|
||||
extern void MPUFaultIntHandler(void);
|
||||
extern void BusFaultIntHandler(void);
|
||||
extern void UsageFaultIntHandler(void);
|
||||
extern void SVCallIntHandler(void);
|
||||
extern void DebugMonIntHandler(void);
|
||||
extern void PendSVIntHandler(void);
|
||||
extern void SysTickIntHandler(void);
|
||||
extern void GPIOIntHandler(void);
|
||||
extern void I2CIntHandler(void);
|
||||
extern void RFCCPE1IntHandler(void);
|
||||
extern void AONRTCIntHandler(void);
|
||||
extern void UART0IntHandler(void);
|
||||
extern void AUXSWEvent0IntHandler(void);
|
||||
extern void SSI0IntHandler(void);
|
||||
extern void SSI1IntHandler(void);
|
||||
extern void RFCCPE0IntHandler(void);
|
||||
extern void RFCHardwareIntHandler(void);
|
||||
extern void RFCCmdAckIntHandler(void);
|
||||
extern void I2SIntHandler(void);
|
||||
extern void AUXSWEvent1IntHandler(void);
|
||||
extern void WatchdogIntHandler(void);
|
||||
extern void Timer0AIntHandler(void);
|
||||
extern void Timer0BIntHandler(void);
|
||||
extern void Timer1AIntHandler(void);
|
||||
extern void Timer1BIntHandler(void);
|
||||
extern void Timer2AIntHandler(void);
|
||||
extern void Timer2BIntHandler(void);
|
||||
extern void Timer3AIntHandler(void);
|
||||
extern void Timer3BIntHandler(void);
|
||||
extern void CryptoIntHandler(void);
|
||||
extern void uDMAIntHandler(void);
|
||||
extern void uDMAErrIntHandler(void);
|
||||
extern void FlashIntHandler(void);
|
||||
extern void SWEvent0IntHandler(void);
|
||||
extern void AUXCombEventIntHandler(void);
|
||||
extern void AONProgIntHandler(void);
|
||||
extern void DynProgIntHandler(void);
|
||||
extern void AUXCompAIntHandler(void);
|
||||
extern void AUXADCIntHandler(void);
|
||||
extern void TRNGIntHandler(void);
|
||||
|
||||
/* Default interrupt handlers */
|
||||
#pragma weak MPUFaultIntHandler = intDefaultHandler
|
||||
#pragma weak BusFaultIntHandler = intDefaultHandler
|
||||
#pragma weak UsageFaultIntHandler = intDefaultHandler
|
||||
#pragma weak SVCallIntHandler = intDefaultHandler
|
||||
#pragma weak DebugMonIntHandler = intDefaultHandler
|
||||
#pragma weak PendSVIntHandler = intDefaultHandler
|
||||
#pragma weak SysTickIntHandler = intDefaultHandler
|
||||
#pragma weak GPIOIntHandler = intDefaultHandler
|
||||
#pragma weak I2CIntHandler = intDefaultHandler
|
||||
#pragma weak RFCCPE1IntHandler = intDefaultHandler
|
||||
#pragma weak AONRTCIntHandler = intDefaultHandler
|
||||
#pragma weak UART0IntHandler = intDefaultHandler
|
||||
#pragma weak AUXSWEvent0IntHandler = intDefaultHandler
|
||||
#pragma weak SSI0IntHandler = intDefaultHandler
|
||||
#pragma weak SSI1IntHandler = intDefaultHandler
|
||||
#pragma weak RFCCPE0IntHandler = intDefaultHandler
|
||||
#pragma weak RFCHardwareIntHandler = intDefaultHandler
|
||||
#pragma weak RFCCmdAckIntHandler = intDefaultHandler
|
||||
#pragma weak I2SIntHandler = intDefaultHandler
|
||||
#pragma weak AUXSWEvent1IntHandler = intDefaultHandler
|
||||
#pragma weak WatchdogIntHandler = intDefaultHandler
|
||||
#pragma weak Timer0AIntHandler = intDefaultHandler
|
||||
#pragma weak Timer0BIntHandler = intDefaultHandler
|
||||
#pragma weak Timer1AIntHandler = intDefaultHandler
|
||||
#pragma weak Timer1BIntHandler = intDefaultHandler
|
||||
#pragma weak Timer2AIntHandler = intDefaultHandler
|
||||
#pragma weak Timer2BIntHandler = intDefaultHandler
|
||||
#pragma weak Timer3AIntHandler = intDefaultHandler
|
||||
#pragma weak Timer3BIntHandler = intDefaultHandler
|
||||
#pragma weak CryptoIntHandler = intDefaultHandler
|
||||
#pragma weak uDMAIntHandler = intDefaultHandler
|
||||
#pragma weak uDMAErrIntHandler = intDefaultHandler
|
||||
#pragma weak FlashIntHandler = intDefaultHandler
|
||||
#pragma weak SWEvent0IntHandler = intDefaultHandler
|
||||
#pragma weak AUXCombEventIntHandler = intDefaultHandler
|
||||
#pragma weak AONProgIntHandler = intDefaultHandler
|
||||
#pragma weak DynProgIntHandler = intDefaultHandler
|
||||
#pragma weak AUXCompAIntHandler = intDefaultHandler
|
||||
#pragma weak AUXADCIntHandler = intDefaultHandler
|
||||
#pragma weak TRNGIntHandler = intDefaultHandler
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* The entry point for the application startup code. */
|
||||
extern void __iar_program_start(void);
|
||||
|
||||
/* Get stack start (highest address) symbol from linker file. */
|
||||
extern const void *STACK_TOP;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* It is required to place something in the CSTACK segment to get the stack
|
||||
* check feature in IAR to work as expected
|
||||
*/
|
||||
__root static void *dummy_stack @ ".stack";
|
||||
|
||||
/*
|
||||
* The vector table. Note that the proper constructs must be placed on this to
|
||||
* ensure that it ends up at physical address 0x0000.0000 or at the start of
|
||||
* the program if located at a start address other than 0.
|
||||
*/
|
||||
__root void(*const __vector_table[])(void) @ ".intvec" =
|
||||
{
|
||||
(void (*)(void)) & STACK_TOP, /* 0 The initial stack pointer */
|
||||
__iar_program_start, /* 1 The reset handler */
|
||||
nmiISR, /* 2 The NMI handler */
|
||||
faultISR, /* 3 The hard fault handler */
|
||||
MPUFaultIntHandler, /* 4 The MPU fault handler */
|
||||
BusFaultIntHandler, /* 5 The bus fault handler */
|
||||
UsageFaultIntHandler, /* 6 The usage fault handler */
|
||||
0, /* 7 Reserved */
|
||||
0, /* 8 Reserved */
|
||||
0, /* 9 Reserved */
|
||||
0, /* 10 Reserved */
|
||||
SVCallIntHandler, /* 11 SVCall handler */
|
||||
DebugMonIntHandler, /* 12 Debug monitor handler */
|
||||
0, /* 13 Reserved */
|
||||
PendSVIntHandler, /* 14 The PendSV handler */
|
||||
SysTickIntHandler, /* 15 The SysTick handler */
|
||||
/* --- External interrupts --- */
|
||||
GPIOIntHandler, /* 16 AON edge detect */
|
||||
I2CIntHandler, /* 17 I2C */
|
||||
RFCCPE1IntHandler, /* 18 RF Core Command & Packet Engine 1 */
|
||||
intDefaultHandler, /* 19 Reserved */
|
||||
AONRTCIntHandler, /* 20 AON RTC */
|
||||
UART0IntHandler, /* 21 UART0 Rx and Tx */
|
||||
AUXSWEvent0IntHandler, /* 22 AUX software event 0 */
|
||||
SSI0IntHandler, /* 23 SSI0 Rx and Tx */
|
||||
SSI1IntHandler, /* 24 SSI1 Rx and Tx */
|
||||
RFCCPE0IntHandler, /* 25 RF Core Command & Packet Engine 0 */
|
||||
RFCHardwareIntHandler, /* 26 RF Core Hardware */
|
||||
RFCCmdAckIntHandler, /* 27 RF Core Command Acknowledge */
|
||||
I2SIntHandler, /* 28 I2S */
|
||||
AUXSWEvent1IntHandler, /* 29 AUX software event 1 */
|
||||
WatchdogIntHandler, /* 30 Watchdog timer */
|
||||
Timer0AIntHandler, /* 31 Timer 0 subtimer A */
|
||||
Timer0BIntHandler, /* 32 Timer 0 subtimer B */
|
||||
Timer1AIntHandler, /* 33 Timer 1 subtimer A */
|
||||
Timer1BIntHandler, /* 34 Timer 1 subtimer B */
|
||||
Timer2AIntHandler, /* 35 Timer 2 subtimer A */
|
||||
Timer2BIntHandler, /* 36 Timer 2 subtimer B */
|
||||
Timer3AIntHandler, /* 37 Timer 3 subtimer A */
|
||||
Timer3BIntHandler, /* 38 Timer 3 subtimer B */
|
||||
CryptoIntHandler, /* 39 Crypto Core Result available */
|
||||
uDMAIntHandler, /* 40 uDMA Software */
|
||||
uDMAErrIntHandler, /* 41 uDMA Error */
|
||||
FlashIntHandler, /* 42 Flash controller */
|
||||
SWEvent0IntHandler, /* 43 Software Event 0 */
|
||||
AUXCombEventIntHandler, /* 44 AUX combined event */
|
||||
AONProgIntHandler, /* 45 AON programmable 0 */
|
||||
DynProgIntHandler, /* 46 Dynamic Programmable interrupt */
|
||||
/* source (Default: PRCM) */
|
||||
AUXCompAIntHandler, /* 47 AUX Comparator A */
|
||||
AUXADCIntHandler, /* 48 AUX ADC new sample or ADC DMA */
|
||||
/* done, ADC underflow, ADC overflow */
|
||||
TRNGIntHandler /* 49 TRNG event */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief Setup trim device.
|
||||
* \return Return value determines whether to omit seg_init or not.
|
||||
* 0 => omit seg_init
|
||||
* 1 => run seg_init
|
||||
*
|
||||
* This function is called by __iar_program_start() early in the boot sequence.
|
||||
* Copy the first 16 vectors from the read-only/reset table to the runtime
|
||||
* RAM table. Fill the remaining vectors with a stub. This vector table will
|
||||
* be updated at runtime.
|
||||
*/
|
||||
int
|
||||
__low_level_init(void)
|
||||
{
|
||||
IntMasterDisable();
|
||||
|
||||
/* Final trim of device */
|
||||
SetupTrimDevice();
|
||||
|
||||
/* Run seg_init */
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief Non-Maskable Interrupt (NMI) ISR.
|
||||
*
|
||||
* This is the code that gets called when the processor receives a NMI. This
|
||||
* simply enters an infinite loop, preserving the system state for examination
|
||||
* by a debugger.
|
||||
*/
|
||||
static void
|
||||
nmiISR(void)
|
||||
{
|
||||
/* Enter an infinite loop. */
|
||||
for(;;) { /* hang */ }
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief Debug stack pointer.
|
||||
* \param sp Stack pointer.
|
||||
*
|
||||
* Provide a view into the CPU state from the provided stack pointer.
|
||||
*/
|
||||
void
|
||||
debugStackPointer(uint32_t *sp)
|
||||
{
|
||||
volatile uint32_t r0; /**< R0 register */
|
||||
volatile uint32_t r1; /**< R1 register */
|
||||
volatile uint32_t r2; /**< R2 register */
|
||||
volatile uint32_t r3; /**< R3 register */
|
||||
volatile uint32_t r12; /**< R12 register */
|
||||
volatile uint32_t lr; /**< LR register */
|
||||
volatile uint32_t pc; /**< PC register */
|
||||
volatile uint32_t psr; /**< PSR register */
|
||||
|
||||
/* Cast to void to disable warnings of unused variables */
|
||||
(void)(r0 = sp[0]);
|
||||
(void)(r1 = sp[1]);
|
||||
(void)(r2 = sp[2]);
|
||||
(void)(r3 = sp[3]);
|
||||
(void)(r12 = sp[4]);
|
||||
(void)(lr = sp[5]);
|
||||
(void)(pc = sp[6]);
|
||||
(void)(psr = sp[7]);
|
||||
|
||||
/* Enter an infinite loop. */
|
||||
for(;;) { /* hang */ }
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief CPU Fault ISR.
|
||||
*
|
||||
* This is the code that gets called when the processor receives a fault
|
||||
* interrupt. Setup a call to debugStackPointer with the current stack pointer.
|
||||
* The stack pointer in this case would be the CPU state which caused the CPU
|
||||
* fault.
|
||||
*/
|
||||
static void
|
||||
faultISR(void)
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"tst lr, #4 \n"
|
||||
"ite eq \n"
|
||||
"mrseq r0, msp \n"
|
||||
"mrsne r0, psp \n"
|
||||
"b debugStackPointer \n"
|
||||
);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief Interrupt Default Handler.
|
||||
*
|
||||
* This is the code that gets called when the processor receives an unexpected
|
||||
* interrupt. This simply enters an infinite loop, preserving the system state
|
||||
* for examination by a debugger.
|
||||
*/
|
||||
static void
|
||||
intDefaultHandler(void)
|
||||
{
|
||||
/* Enter an infinite loop. */
|
||||
for(;;) { /* hang */ }
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-trng
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of True Random Number Generator for CC13xx/CC26xx.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
|
||||
#include "trng-arch.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/drivers/TRNG.h>
|
||||
#include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Very dirty workaround because the pre-compiled TI drivers library for
|
||||
* CC13x0/CC26x0 is missing the CryptoKey object file. This can be removed
|
||||
* when the pre-compiled library includes the missing object file.
|
||||
*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
|
||||
#include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintextCC26XX.c>
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
bool
|
||||
trng_rand(uint8_t *entropy_buf, size_t entropy_len, uint32_t timeout_us)
|
||||
{
|
||||
TRNG_Params trng_params;
|
||||
TRNG_Handle trng_handle;
|
||||
CryptoKey entropy_key;
|
||||
int_fast16_t result;
|
||||
|
||||
TRNG_Params_init(&trng_params);
|
||||
trng_params.returnBehavior = TRNG_RETURN_BEHAVIOR_BLOCKING;
|
||||
if(timeout_us != TRNG_WAIT_FOREVER) {
|
||||
trng_params.timeout = timeout_us;
|
||||
}
|
||||
|
||||
trng_handle = TRNG_open(0, &trng_params);
|
||||
if(!trng_handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CryptoKeyPlaintext_initBlankKey(&entropy_key, entropy_buf, entropy_len);
|
||||
|
||||
result = TRNG_generateEntropy(trng_handle, &entropy_key);
|
||||
|
||||
TRNG_close(trng_handle);
|
||||
|
||||
return result == TRNG_STATUS_SUCCESS;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-trng True Random Number Generator for CC13xx/CC26xx.
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file of True Random Number Generator for CC13xx/CC26xx.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef TRNG_ARCH_H_
|
||||
#define TRNG_ARCH_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <contiki.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define TRNG_WAIT_FOREVER (~(uint32_t)0)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Generates a stream of entropy from which you can create
|
||||
* a true random number from. This is a blocking function
|
||||
* call with a specified timeout.
|
||||
* \param entropy_buf Buffer to store a stream of entropy.
|
||||
* \param entropy_len Length of the entropy buffer.
|
||||
* \param timeout_us How long to wait until timing out the operation. A
|
||||
* timeout of TRNG_WAIT_FOREVER blocks forever.
|
||||
* \return true if successful; else, false.
|
||||
*/
|
||||
bool trng_rand(uint8_t *entropy_buf, size_t entropy_len, uint32_t timeout_us);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* TRNG_ARCH_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-uart
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of UART driver for CC13xx/CC26xx.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "uart0-arch.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <Board.h>
|
||||
|
||||
#include <ti/drivers/UART.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static UART_Handle uart_handle;
|
||||
|
||||
static volatile uart0_input_fxn_t curr_input_cb;
|
||||
static unsigned char char_buf;
|
||||
|
||||
static bool initialized;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
uart0_cb(UART_Handle handle, void *buf, size_t count)
|
||||
{
|
||||
/* Simply return if the current callback is NULL. */
|
||||
if(!curr_input_cb) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save the current callback function locally, as it might be overwritten
|
||||
* after calling the callback.
|
||||
*/
|
||||
const uart0_input_fxn_t curr_cb = curr_input_cb;
|
||||
curr_cb(char_buf);
|
||||
/*
|
||||
* If curr_input_cb didn't change after the call, do another read.
|
||||
* Else, the uart0_set_callback was called with a different callback pointer
|
||||
* and triggered an another read.
|
||||
*/
|
||||
if(curr_cb == curr_input_cb) {
|
||||
UART_read(uart_handle, &char_buf, 1);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
uart0_init(void)
|
||||
{
|
||||
if(initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
UART_Params uart_params;
|
||||
UART_Params_init(&uart_params);
|
||||
|
||||
uart_params.baudRate = TI_UART_CONF_BAUD_RATE;
|
||||
uart_params.readMode = UART_MODE_CALLBACK;
|
||||
uart_params.writeMode = UART_MODE_BLOCKING;
|
||||
uart_params.readCallback = uart0_cb;
|
||||
uart_params.readDataMode = UART_DATA_TEXT;
|
||||
uart_params.readReturnMode = UART_RETURN_NEWLINE;
|
||||
|
||||
/* No error handling. */
|
||||
uart_handle = UART_open(Board_UART0, &uart_params);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int_fast32_t
|
||||
uart0_write(const void *buf, size_t buf_size)
|
||||
{
|
||||
if(!initialized) {
|
||||
return UART_STATUS_ERROR;
|
||||
}
|
||||
return UART_write(uart_handle, buf, buf_size);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int_fast32_t
|
||||
uart0_write_byte(uint8_t byte)
|
||||
{
|
||||
if(!initialized) {
|
||||
return UART_STATUS_ERROR;
|
||||
}
|
||||
return UART_write(uart_handle, &byte, 1);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int_fast32_t
|
||||
uart0_set_callback(uart0_input_fxn_t input_cb)
|
||||
{
|
||||
if(!initialized) {
|
||||
return UART_STATUS_ERROR;
|
||||
}
|
||||
|
||||
if(curr_input_cb == input_cb) {
|
||||
return UART_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
curr_input_cb = input_cb;
|
||||
if(input_cb) {
|
||||
return UART_read(uart_handle, &char_buf, 1);
|
||||
} else {
|
||||
UART_readCancel(uart_handle);
|
||||
return UART_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-uart UART for CC13xx/CC26xx.
|
||||
*
|
||||
* This particular driver utilizes the UART0 peripheral specifically.
|
||||
*
|
||||
* Driver for the CC13xx/CC26xx UART controller.
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file of UART driver for CC13xx/CC26xx.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
#ifndef UART0_ARCH_H_
|
||||
#define UART0_ARCH_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef int (*uart0_input_fxn_t)(unsigned char);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Initializes the UART driver.
|
||||
*/
|
||||
void uart0_init(void);
|
||||
|
||||
/**
|
||||
* \brief Writes data from a memory buffer to the UART interface.
|
||||
* \param buf A pointer to the data buffer.
|
||||
* \param buf_size Size of the data buffer.
|
||||
* \return Number of bytes that has been written to the UART. If an
|
||||
* error occurs, a negative value is returned.
|
||||
*/
|
||||
int_fast32_t uart0_write(const void *buf, size_t buf_size);
|
||||
|
||||
/**
|
||||
* \brief Writes a single byte to the UART interface.
|
||||
* \param byte Byte to write.
|
||||
* \return Number of bytes that has been written to the UART. If an
|
||||
* error occurs, a negative value is returned.
|
||||
*/
|
||||
int_fast32_t uart0_write_byte(uint8_t byte);
|
||||
|
||||
/**
|
||||
* \brief Set the callback function for when bytes are received
|
||||
* on UART0.
|
||||
* \param input_cb Pointer to the callback function. A valid pointer
|
||||
* subscribes for UART0 callbacks when bytes are received,
|
||||
* while a NULL pointer unsubscribes.
|
||||
* \return 0 for success, negative value for errors.
|
||||
*/
|
||||
int_fast32_t uart0_set_callback(uart0_input_fxn_t input_cb);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* UART0_ARCH_H_ */
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-watchdog CC13xx/CC26xx watchdog timer driver
|
||||
*
|
||||
* Driver for the CC13xx/CC26xx Watchdog Timer
|
||||
*
|
||||
* This file is not called watchdog.c because the filename is in use by
|
||||
* TI CC26xxware/CC13xxware
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the CC13xx/CC26xx watchdog driver.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/watchdog.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <Board.h>
|
||||
|
||||
#include <ti/drivers/Watchdog.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define WATCHDOG_DISABLE WATCHDOG_CONF_DISABLE
|
||||
#define WATCHDOG_TIMER_TOP WATCHDOG_CONF_TIMER_TOP
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static Watchdog_Handle wdt_handle;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Initialises the Watchdog module.
|
||||
*
|
||||
* Simply sets the reload counter to a default value. The WDT is not
|
||||
* started yet. To start it, watchdog_start() must be called.
|
||||
*/
|
||||
void
|
||||
watchdog_init(void)
|
||||
{
|
||||
if(WATCHDOG_DISABLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
Watchdog_init();
|
||||
|
||||
Watchdog_Params wdt_params;
|
||||
Watchdog_Params_init(&wdt_params);
|
||||
|
||||
wdt_params.resetMode = Watchdog_RESET_ON;
|
||||
wdt_params.debugStallMode = Watchdog_DEBUG_STALL_ON;
|
||||
|
||||
wdt_handle = Watchdog_open(Board_WATCHDOG0, &wdt_params);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Start the Watchdog.
|
||||
*/
|
||||
void
|
||||
watchdog_start(void)
|
||||
{
|
||||
if(WATCHDOG_DISABLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
watchdog_periodic();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Refresh (feed) the Watchdog.
|
||||
*/
|
||||
void
|
||||
watchdog_periodic(void)
|
||||
{
|
||||
if(WATCHDOG_DISABLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
Watchdog_setReload(wdt_handle, WATCHDOG_TIMER_TOP);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Stop the Watchdog such that it won't timeout and cause a
|
||||
* system reset.
|
||||
*/
|
||||
void
|
||||
watchdog_stop(void)
|
||||
{
|
||||
if(WATCHDOG_DISABLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
Watchdog_clear(wdt_handle);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Manually trigger a Watchdog timeout.
|
||||
*/
|
||||
void
|
||||
watchdog_reboot(void)
|
||||
{
|
||||
if(WATCHDOG_DISABLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
watchdog_start();
|
||||
|
||||
/* Busy loop until watchdog times out */
|
||||
for (;;) { /* hang */ }
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* \defgroup cc13xx-cc26xx-cpu The TI SimpleLink CC13xx and CC26xx SoC
|
||||
*
|
||||
* This group documents the TI CC13xx and CC26xx CPUs. The two CPU families are
|
||||
* very similar, with the main difference being related to radio capability.
|
||||
*
|
||||
* Documentation in this group should be considered to be applicable to both
|
||||
* families, unless explicitly stated otherwise.
|
||||
*
|
||||
* \ingroup cpu
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup cc13xx-cc26xx-platform TI SimpleLink CC13xx/CC26xx platform
|
||||
* \ingroup platform
|
||||
*/
|
|
@ -0,0 +1 @@
|
|||
Subproject commit b83faf3be2cb7468dc836a6fbd9d804638263252
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Parameter summary
|
||||
* Adv. Address: 010203040506
|
||||
* Adv. Data: 255
|
||||
* BLE Channel: 17
|
||||
* Frequency: 2440 MHz
|
||||
* PDU Payload length: 30
|
||||
* TX Power: 9 dBm (requires define CCFG_FORCE_VDDR_HH = 1 in ccfg.c,
|
||||
* see CC13xx/CC26xx Technical Reference Manual)
|
||||
* Whitening: true
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "sys/cc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_ble.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_ble.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "ble-settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
RF_Mode rf_ble_mode =
|
||||
{
|
||||
.rfMode = RF_MODE_BLE,
|
||||
.cpePatchFxn = &rf_patch_cpe_ble,
|
||||
.mcePatchFxn = 0,
|
||||
.rfePatchFxn = &rf_patch_rfe_ble,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_RADIO_SETUP */
|
||||
uint32_t rf_ble_overrides[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_use_patch_ble_1mbps.xml */
|
||||
MCE_RFE_OVERRIDE(0,0,0,1,0,0), /* PHY: Use MCE ROM, RFE RAM patch */
|
||||
/* override_synth_ble_1mbps.xml */
|
||||
HW_REG_OVERRIDE(0x4038,0x0034), /* Synth: Set recommended RTRIM to 4 */
|
||||
(uint32_t)0x000784A3, /* Synth: Set Fref to 3.43 MHz */
|
||||
HW_REG_OVERRIDE(0x4020,0x7F00), /* Synth: Configure fine calibration setting */
|
||||
HW_REG_OVERRIDE(0x4064,0x0040), /* Synth: Configure fine calibration setting */
|
||||
(uint32_t)0xB1070503, /* Synth: Configure fine calibration setting */
|
||||
(uint32_t)0x05330523, /* Synth: Configure fine calibration setting */
|
||||
(uint32_t)0xA47E0583, /* Synth: Set loop bandwidth after lock to 80 kHz */
|
||||
(uint32_t)0xEAE00603, /* Synth: Set loop bandwidth after lock to 80 kHz */
|
||||
(uint32_t)0x00010623, /* Synth: Set loop bandwidth after lock to 80 kHz */
|
||||
HW32_ARRAY_OVERRIDE(0x405C,1), /* Synth: Configure PLL bias */
|
||||
(uint32_t)0x18000000, /* Synth: Configure PLL bias */
|
||||
/* Synth: Configure VCO LDO */
|
||||
ADI_REG_OVERRIDE(1,4,0x9F), /* (in ADI1, set VCOLDOCFG=0x9F to use voltage input reference) */
|
||||
ADI_HALFREG_OVERRIDE(1,7,0x4,0x4), /* Synth: Configure synth LDO (in ADI1, set SLDOCTL0.COMP_CAP=1) */
|
||||
/* override_phy_ble_1mbps.xml */
|
||||
(uint32_t)0x013800C3, /* Tx: Configure symbol shape for BLE frequency deviation requirements */
|
||||
HW_REG_OVERRIDE(0x6088, 0x0045), /* Rx: Configure AGC reference level */
|
||||
HW_REG_OVERRIDE(0x6084, 0x05FD), /* Rx: Configure AGC gain level */
|
||||
(uint32_t)0x00038883, /* Rx: Configure LNA bias current trim offset */
|
||||
/* override_frontend_xd.xml */
|
||||
(uint32_t)0x00F388A3, /* Rx: Set RSSI offset to adjust reported RSSI by +13 dB */
|
||||
/* TX power override */
|
||||
ADI_REG_OVERRIDE(0,12,0xF8), /* Tx: Set PA trim to max (in ADI0, set PACTL0=0xF8) */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_RADIO_SETUP: Radio Setup Command for Pre-Defined Schemes */
|
||||
rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup =
|
||||
{
|
||||
.commandNo = CMD_RADIO_SETUP,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.mode = 0x00,
|
||||
.loDivider = 0x00,
|
||||
.config.frontEndMode = 0x0,
|
||||
.config.biasMode = 0x0,
|
||||
.config.analogCfgMode = 0x0,
|
||||
.config.bNoFsPowerUp = 0x0,
|
||||
.txPower = 0x3D3F,
|
||||
.pRegOverride = rf_ble_overrides,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Structure for CMD_BLE_ADV_NC.pParams */
|
||||
rfc_bleAdvPar_t rf_ble_adv_par =
|
||||
{
|
||||
.pRxQ = 0,
|
||||
.rxConfig.bAutoFlushIgnored = 0x0,
|
||||
.rxConfig.bAutoFlushCrcErr = 0x0,
|
||||
.rxConfig.bAutoFlushEmpty = 0x0,
|
||||
.rxConfig.bIncludeLenByte = 0x0,
|
||||
.rxConfig.bIncludeCrc = 0x0,
|
||||
.rxConfig.bAppendRssi = 0x0,
|
||||
.rxConfig.bAppendStatus = 0x0,
|
||||
.rxConfig.bAppendTimestamp = 0x0,
|
||||
.advConfig.advFilterPolicy = 0x0,
|
||||
.advConfig.deviceAddrType = 0x0,
|
||||
.advConfig.peerAddrType = 0x0,
|
||||
.advConfig.bStrictLenFilter = 0x0,
|
||||
.advConfig.rpaMode = 0x0,
|
||||
.advLen = 0x18,
|
||||
.scanRspLen = 0x00,
|
||||
.pAdvData = 0,
|
||||
.pScanRspData = 0,
|
||||
.pDeviceAddress = 0,
|
||||
.pWhiteList = 0,
|
||||
.__dummy0 = 0x0000,
|
||||
.__dummy1 = 0x00,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_BLE_ADV_NC: BLE Non-Connectable Advertiser Command */
|
||||
rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
||||
{
|
||||
.commandNo = CMD_BLE_ADV_NC,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.channel = 0x8C,
|
||||
.whitening.init = 0x51,
|
||||
.whitening.bOverride = 0x1,
|
||||
.pParams = &rf_ble_adv_par,
|
||||
.pOutput = 0,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef BLE_SETTINGS_H_
|
||||
#define BLE_SETTINGS_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
extern RF_Mode rf_ble_mode;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API commands */
|
||||
extern rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup;
|
||||
extern rfc_bleAdvPar_t rf_ble_adv_par;
|
||||
extern rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API Overrides */
|
||||
extern uint32_t rf_ble_overrides[];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* BLE_SETTINGS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-tx-power
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Source file for BLE Beacon TX power tables for CC13x0.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/tx-power.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1350
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ble_tx_power_table_cc1350[] =
|
||||
{
|
||||
{ -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 3, 1, 6) },
|
||||
{ -18, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 1, 6) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 1, 10) },
|
||||
{ -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 3, 1, 12) },
|
||||
{ -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 3, 1, 14) },
|
||||
{ -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(35, 3, 1, 18) },
|
||||
{ -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(47, 3, 1, 22) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(29, 0, 1, 45) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 0, 1, 49) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(38, 0, 1, 55) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(44, 0, 1, 63) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(52, 0, 1, 59) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(60, 0, 1, 47) },
|
||||
#if RF_TXPOWER_BOOST_MODE
|
||||
/* This setting requires CCFG_FORCE_VDDR_HH = 1. */
|
||||
{ 6, RF_TxPowerTable_DEFAULT_PA_ENTRY(38, 0, 1, 49) },
|
||||
/* This setting requires CCFG_FORCE_VDDR_HH = 1. */
|
||||
{ 7, RF_TxPowerTable_DEFAULT_PA_ENTRY(46, 0, 1, 59) },
|
||||
/* This setting requires CCFG_FORCE_VDDR_HH = 1. */
|
||||
{ 8, RF_TxPowerTable_DEFAULT_PA_ENTRY(55, 0, 1, 51) },
|
||||
/* This setting requires CCFG_FORCE_VDDR_HH = 1. */
|
||||
{ 9, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 30) },
|
||||
#endif
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
tx_power_table_t rf_ble_tx_power_table_empty[] =
|
||||
{
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TX power table, based on which board is used. */
|
||||
#if defined(DEVICE_CC1350) || defined(DEVICE_CC1350_4)
|
||||
#define TX_POWER_TABLE rf_ble_tx_power_table_cc1350
|
||||
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_ble_tx_power_table_empty
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define symbols for both the TX power table and its size. The TX power
|
||||
* table size is with one less entry by excluding the termination entry.
|
||||
*/
|
||||
tx_power_table_t *const ble_tx_power_table = TX_POWER_TABLE;
|
||||
const size_t ble_tx_power_table_size = (sizeof(TX_POWER_TABLE) / sizeof(TX_POWER_TABLE[0])) - 1;
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,252 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Parameter summary
|
||||
* IEEE Channel: 11
|
||||
* Frequency: 2405 MHz
|
||||
* SFD: 0
|
||||
* Packet Data: 255
|
||||
* Preamble (32 bit): 01010101...
|
||||
* TX Power: 5 dBm (requires define CCFG_FORCE_VDDR_HH = 0 in ccfg.c,
|
||||
* see CC13xx/CC26xx Technical Reference Manual)
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "sys/cc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
/*
|
||||
* rf_ieee_cmd.h must be included "locally" from the arch/cpu directory,
|
||||
* as it isn't defined in CC13x0 driverlib.
|
||||
*/
|
||||
#include "driverlib/rf_ieee_cmd.h"
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "ieee-settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
RF_Mode rf_ieee_mode =
|
||||
{
|
||||
.rfMode = RF_MODE_IEEE_15_4,
|
||||
.cpePatchFxn = 0,
|
||||
.mcePatchFxn = 0,
|
||||
.rfePatchFxn = 0,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* CMD_RADIO_SETUP must be configured with default TX power value
|
||||
* in the .txPower field.
|
||||
*/
|
||||
#define DEFAULT_TX_POWER 0x9330 /* 5 dBm */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_RADIO_SETUP */
|
||||
uint32_t rf_ieee_overrides[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_synth_ieee_15_4.xml */
|
||||
HW_REG_OVERRIDE(0x4038,0x0035), /* Synth: Set recommended RTRIM to 5 */
|
||||
(uint32_t)0x000784A3, /* Synth: Set Fref to 3.43 MHz */
|
||||
(uint32_t)0xA47E0583, /* Synth: Set loop bandwidth after lock to 80 kHz */
|
||||
(uint32_t)0xEAE00603, /* Synth: Set loop bandwidth after lock to 80 kHz */
|
||||
(uint32_t)0x00010623, /* Synth: Set loop bandwidth after lock to 80 kHz */
|
||||
HW32_ARRAY_OVERRIDE(0x405C,1), /* Synth: Configure PLL bias */
|
||||
(uint32_t)0x1801F800, /* Synth: Configure PLL bias */
|
||||
HW32_ARRAY_OVERRIDE(0x402C,1), /* Synth: Configure PLL latency */
|
||||
(uint32_t)0x00608402, /* Synth: Configure PLL latency */
|
||||
(uint32_t)0x02010403, /* Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering */
|
||||
HW32_ARRAY_OVERRIDE(0x4034,1), /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x177F0408, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x38000463, /* Synth: Configure extra PLL filtering */
|
||||
/* override_phy_ieee_15_4.xml */
|
||||
(uint32_t)0x05000243, /* Synth: Increase synth programming timeout */
|
||||
(uint32_t)0x002082C3, /* Rx: Adjust Rx FIFO threshold to avoid overflow */
|
||||
/* override_frontend_id.xml */
|
||||
(uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB */
|
||||
(uint32_t)0x000F8883, /* Rx: Configure LNA bias current trim offset */
|
||||
HW_REG_OVERRIDE(0x50DC,0x002B), /* Rx: Adjust AGC DC filter */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_RADIO_SETUP: Radio Setup Command for Pre-Defined Schemes */
|
||||
rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup =
|
||||
{
|
||||
.commandNo = CMD_RADIO_SETUP,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.mode = 0x01,
|
||||
.config.frontEndMode = 0x0,
|
||||
.config.biasMode = 0x0,
|
||||
.config.analogCfgMode = 0x0,
|
||||
.config.bNoFsPowerUp = 0x0,
|
||||
.txPower = DEFAULT_TX_POWER, /* 5 dBm default */
|
||||
.pRegOverride = rf_ieee_overrides,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_FS: Frequency Synthesizer Programming Command */
|
||||
rfc_CMD_FS_t rf_cmd_ieee_fs =
|
||||
{
|
||||
.commandNo = CMD_FS,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.frequency = 0x0965, /* set by driver */
|
||||
.fractFreq = 0x0000, /* set by driver */
|
||||
.synthConf.bTxMode = 0x1,
|
||||
.synthConf.refFreq = 0x0,
|
||||
.__dummy0 = 0x00,
|
||||
.__dummy1 = 0x00,
|
||||
.__dummy2 = 0x00,
|
||||
.__dummy3 = 0x0000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_IEEE_TX: IEEE 802.15.4 Transmit Command */
|
||||
rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx =
|
||||
{
|
||||
.commandNo = CMD_IEEE_TX,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.txOpt.bIncludePhyHdr = 0x0,
|
||||
.txOpt.bIncludeCrc = 0x0,
|
||||
.txOpt.payloadLenMsb = 0x0,
|
||||
.payloadLen = 0x0, /* set by driver */
|
||||
.pPayload = 0, /* set by driver */
|
||||
.timeStamp = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_IEEE_RX: IEEE 802.15.4 Receive Command */
|
||||
rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx =
|
||||
{
|
||||
.commandNo = CMD_IEEE_RX,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.channel = 0x00, /* set by driver */
|
||||
.rxConfig.bAutoFlushCrc = 0x1,
|
||||
.rxConfig.bAutoFlushIgn = 0x1,
|
||||
.rxConfig.bIncludePhyHdr = 0x0,
|
||||
.rxConfig.bIncludeCrc = 0x1,
|
||||
.rxConfig.bAppendRssi = 0x1,
|
||||
.rxConfig.bAppendCorrCrc = 0x1,
|
||||
.rxConfig.bAppendSrcInd = 0x0,
|
||||
.rxConfig.bAppendTimestamp = 0x1,
|
||||
.pRxQ = 0, /* set by driver */
|
||||
.pOutput = 0, /* set by driver */
|
||||
.frameFiltOpt.frameFiltEn = 0x0, /* set by driver */
|
||||
.frameFiltOpt.frameFiltStop = 0x1,
|
||||
.frameFiltOpt.autoAckEn = 0x0, /* set by driver */
|
||||
.frameFiltOpt.slottedAckEn = 0x0,
|
||||
.frameFiltOpt.autoPendEn = 0x0,
|
||||
.frameFiltOpt.defaultPend = 0x0,
|
||||
.frameFiltOpt.bPendDataReqOnly = 0x0,
|
||||
.frameFiltOpt.bPanCoord = 0x0,
|
||||
.frameFiltOpt.maxFrameVersion = 0x2,
|
||||
.frameFiltOpt.fcfReservedMask = 0x0,
|
||||
.frameFiltOpt.modifyFtFilter = 0x0,
|
||||
.frameFiltOpt.bStrictLenFilter = 0x0,
|
||||
.frameTypes.bAcceptFt0Beacon = 0x1,
|
||||
.frameTypes.bAcceptFt1Data = 0x1,
|
||||
.frameTypes.bAcceptFt2Ack = 0x1,
|
||||
.frameTypes.bAcceptFt3MacCmd = 0x1,
|
||||
.frameTypes.bAcceptFt4Reserved = 0x1,
|
||||
.frameTypes.bAcceptFt5Reserved = 0x1,
|
||||
.frameTypes.bAcceptFt6Reserved = 0x1,
|
||||
.frameTypes.bAcceptFt7Reserved = 0x1,
|
||||
.ccaOpt.ccaEnEnergy = 0x1,
|
||||
.ccaOpt.ccaEnCorr = 0x1,
|
||||
.ccaOpt.ccaEnSync = 0x1,
|
||||
.ccaOpt.ccaCorrOp = 0x1,
|
||||
.ccaOpt.ccaSyncOp = 0x0,
|
||||
.ccaOpt.ccaCorrThr = 0x3,
|
||||
.ccaRssiThr = 0x0, /* set by driver */
|
||||
.__dummy0 = 0x00,
|
||||
.numExtEntries = 0x00,
|
||||
.numShortEntries = 0x00,
|
||||
.pExtEntryList = 0,
|
||||
.pShortEntryList = 0,
|
||||
.localExtAddr = 0x0, /* set by driver */
|
||||
.localShortAddr = 0x0, /* set by driver */
|
||||
.localPanID = 0x0000,
|
||||
.__dummy1 = 0x000000,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_IEEE_RX_ACK: IEEE 802.15.4 Receive ACK Command */
|
||||
rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack =
|
||||
{
|
||||
.commandNo = CMD_IEEE_RX_ACK,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.seqNo = 0x0,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef IEEE_SETTINGS_H_
|
||||
#define IEEE_SETTINGS_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki-conf.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
/*
|
||||
* These two headers must be included "locally" from the arch/cpu directory,
|
||||
* as they aren't defined in CC13x0 driverlib.
|
||||
*/
|
||||
#include "driverlib/rf_ieee_cmd.h"
|
||||
#include "driverlib/rf_ieee_mailbox.h"
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
extern RF_Mode rf_ieee_mode;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API commands */
|
||||
extern rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup;
|
||||
extern rfc_CMD_FS_t rf_cmd_ieee_fs;
|
||||
extern rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx;
|
||||
extern rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx;
|
||||
extern rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API Overrides */
|
||||
extern uint32_t rf_ieee_overrides[];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* IEEE_SETTINGS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-tx-power
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Source file for IEEE-mode TX power tables for CC13x0.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/tx-power.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1350
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ieee_tx_power_table_cc1350[] =
|
||||
{
|
||||
{ -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 6) },
|
||||
{ -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 6) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 6) },
|
||||
{ -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 1, 0, 10) },
|
||||
{ -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 1, 12) },
|
||||
{ -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 1, 1, 14) },
|
||||
{ -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 1, 1, 18) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 1, 1, 24) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 0, 0, 33) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 0, 0, 39) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 0, 0, 45) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(36, 0, 1, 73) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(48, 0, 1, 73) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
tx_power_table_t rf_ieee_tx_power_table_empty[] =
|
||||
{
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Only define the symbols if Prop-mode is selected */
|
||||
#if (RF_MODE == RF_MODE_2_4_GHZ)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TX power table, based on which board is used. */
|
||||
#if defined(DEVICE_CC1350) || defined(DEVICE_CC1350_4)
|
||||
#define TX_POWER_TABLE rf_ieee_tx_power_table_cc1350
|
||||
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_ieee_tx_power_table_empty
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define symbols for both the TX power table and its size. The TX power
|
||||
* table size is with one less entry by excluding the termination entry.
|
||||
*/
|
||||
tx_power_table_t *const rf_tx_power_table = TX_POWER_TABLE;
|
||||
const size_t rf_tx_power_table_size = (sizeof(TX_POWER_TABLE) / sizeof(TX_POWER_TABLE[0])) - 1;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_MODE */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,310 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Parameter summary
|
||||
* Address: 0
|
||||
* Address0: 0xAA
|
||||
* Address1: 0xBB
|
||||
* Frequency: 868.00000 MHz
|
||||
* Data Format: Serial mode disable
|
||||
* Deviation: 25.000 kHz
|
||||
* pktLen: 30
|
||||
* 802.15.4g Mode: 0
|
||||
* Select bit order to transmit PSDU octets:: 1
|
||||
* Packet Length Config: Variable
|
||||
* Max Packet Length: 255
|
||||
* Packet Length: 0
|
||||
* Packet Data: 255
|
||||
* RX Filter BW: 98 kHz
|
||||
* Symbol Rate: 50.00000 kBaud
|
||||
* Sync Word Length: 24 Bits
|
||||
* TX Power: 14 dBm (requires define CCFG_FORCE_VDDR_HH = 1 in ccfg.c,
|
||||
* see CC13xx/CC26xx Technical Reference Manual)
|
||||
* Whitening: Dynamically IEEE 802.15.4g compatible whitener and 16/32-bit CRC
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki-conf.h"
|
||||
#include "sys/cc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_genfsk.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_genfsk.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "prop-settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
RF_Mode rf_prop_mode =
|
||||
{
|
||||
.rfMode = RF_MODE_PROPRIETARY_SUB_1,
|
||||
.cpePatchFxn = &rf_patch_cpe_genfsk,
|
||||
.mcePatchFxn = 0,
|
||||
.rfePatchFxn = &rf_patch_rfe_genfsk,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if defined(DEVICE_CC1310)
|
||||
/*
|
||||
* CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value
|
||||
* in the .txPower field. This depends on whether RF_CONF_TXPOWER_BOOST_MODE
|
||||
* is configured or not.
|
||||
*/
|
||||
#if RF_CONF_TXPOWER_BOOST_MODE
|
||||
#define DEFAULT_TX_POWER 0xA73F /* 14 dBm */
|
||||
#else
|
||||
#define DEFAULT_TX_POWER 0xA63F /* 12.5 dBm (rounded up to 13 dBm) */
|
||||
#endif
|
||||
|
||||
#endif /* defined(DEVICE_CC1310) */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if defined(DEVICE_CC1350)
|
||||
/*
|
||||
* CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value
|
||||
* in the .txPower field. This depends on whether RF_CONF_TXPOWER_BOOST_MODE
|
||||
* is configured or not.
|
||||
*/
|
||||
#if RF_CONF_TXPOWER_BOOST_MODE
|
||||
#define DEFAULT_TX_POWER 0xAB3F /* 14 dBm */
|
||||
#else
|
||||
#define DEFAULT_TX_POWER 0xBC2B /* 12 dBm */
|
||||
#endif
|
||||
|
||||
#endif /* defined(DEVICE_CC1350) */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if defined(DEVICE_CC1350_4)
|
||||
/*
|
||||
* CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value
|
||||
* in the .txPower field. This depends on whether RF_CONF_TXPOWER_BOOST_MODE
|
||||
* is configured or not.
|
||||
*/
|
||||
#if RF_CONF_TXPOWER_BOOST_MODE
|
||||
#define DEFAULT_TX_POWER 0x913F /* 15 dBm */
|
||||
#else
|
||||
#define DEFAULT_TX_POWER 0xB83F /* 13.7 dBm (rounded up to 14 dBm) */
|
||||
#endif
|
||||
|
||||
#endif /* defined(DEVICE_CC1350_4) */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_PROP_RADIO_DIV_SETUP */
|
||||
uint32_t rf_prop_overrides[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_use_patch_prop_genfsk.xml */
|
||||
MCE_RFE_OVERRIDE(0,4,0,1,0,0), /* PHY: Use MCE ROM bank 4, RFE RAM patch */
|
||||
/* override_synth_prop_863_930_div5.xml */
|
||||
HW_REG_OVERRIDE(0x4038,0x0037), /* Synth: Set recommended RTRIM to 7 */
|
||||
(uint32_t)0x000684A3, /* Synth: Set Fref to 4 MHz */
|
||||
HW_REG_OVERRIDE(0x4020,0x7F00), /* Synth: Configure fine calibration setting */
|
||||
HW_REG_OVERRIDE(0x4064,0x0040), /* Synth: Configure fine calibration setting */
|
||||
(uint32_t)0xB1070503, /* Synth: Configure fine calibration setting */
|
||||
(uint32_t)0x05330523, /* Synth: Configure fine calibration setting */
|
||||
(uint32_t)0x0A480583, /* Synth: Set loop bandwidth after lock to 20 kHz */
|
||||
(uint32_t)0x7AB80603, /* Synth: Set loop bandwidth after lock to 20 kHz */
|
||||
/* Synth: Configure VCO LDO */
|
||||
ADI_REG_OVERRIDE(1,4,0x9F), /* (in ADI1, set VCOLDOCFG=0x9F to use voltage input reference) */
|
||||
ADI_HALFREG_OVERRIDE(1,7,0x4,0x4), /* Synth: Configure synth LDO (in ADI1, set SLDOCTL0.COMP_CAP=1) */
|
||||
(uint32_t)0x02010403, /* Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering */
|
||||
(uint32_t)0x00108463, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x04B00243, /* Synth: Increase synth programming timeout (0x04B0 RAT ticks = 300 us) */
|
||||
/* override_phy_rx_aaf_bw_0xd.xml */
|
||||
/* Rx: Set anti-aliasing filter bandwidth to 0xD */
|
||||
ADI_HALFREG_OVERRIDE(0,61,0xF,0xD), /* (in ADI0, set IFAMPCTL3[7:4]=0xD) */
|
||||
/* override_phy_gfsk_rx.xml */
|
||||
(uint32_t)0x00038883, /* Rx: Set LNA bias current trim offset to 3 */
|
||||
HW_REG_OVERRIDE(0x6084,0x35F1), /* Rx: Freeze RSSI on sync found event */
|
||||
/* override_phy_gfsk_pa_ramp_agc_reflevel_0x1a.xml */
|
||||
/* Tx: Configure PA ramping setting (0x41). */
|
||||
HW_REG_OVERRIDE(0x6088,0x411A), /* Rx: Set AGC reference level to 0x1A. */
|
||||
HW_REG_OVERRIDE(0x608C,0x8213), /* Tx: Configure PA ramping setting */
|
||||
/* override_crc_ieee_802_15_4.xml */
|
||||
/* IEEE 802.15.4g: Fix incorrect initialization value for */
|
||||
(uint32_t)0x00000943, /* CRC-16 calculation (see TRM section 23.7.5.2.1) */
|
||||
/* IEEE 802.15.4g: Fix incorrect initialization value for */
|
||||
(uint32_t)0x00000963, /* CRC-16 calculation (see TRM section 23.7.5.2.1) */
|
||||
#if defined(DEVICE_CC1350_4)
|
||||
/* override_phy_rx_rssi_offset_neg2db.xml */
|
||||
(uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB */
|
||||
#else
|
||||
/* override_phy_rx_rssi_offset_5db.xml */
|
||||
(uint32_t)0x00FB88A3, /* Rx: Set RSSI offset to adjust reported RSSI by +5 dB */
|
||||
#endif
|
||||
/* TX power override */
|
||||
#if RF_CONF_TXPOWER_BOOST_MODE
|
||||
ADI_REG_OVERRIDE(0,12,0xF8), /* Tx: Set PA trim to max (in ADI0, set PACTL0=0xF8) */
|
||||
#endif
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_PROP_RADIO_DIV_SETUP */
|
||||
/* Proprietary Mode Radio Setup Command for All Frequency Bands */
|
||||
rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup =
|
||||
{
|
||||
.commandNo = CMD_PROP_RADIO_DIV_SETUP,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.modulation.modType = 0x1,
|
||||
.modulation.deviation = 0x64,
|
||||
.symbolRate.preScale = 0xF,
|
||||
.symbolRate.rateWord = 0x8000,
|
||||
.rxBw = 0x24,
|
||||
.preamConf.nPreamBytes = 0x7,
|
||||
.preamConf.preamMode = 0x0,
|
||||
.formatConf.nSwBits = 0x18,
|
||||
.formatConf.bBitReversal = 0x0,
|
||||
.formatConf.bMsbFirst = 0x1,
|
||||
.formatConf.fecMode = 0x0,
|
||||
.formatConf.whitenMode = 0x7,
|
||||
.config.frontEndMode = 0x0, /* set by driver */
|
||||
.config.biasMode = 0x0, /* set by driver */
|
||||
.config.analogCfgMode = 0x0,
|
||||
.config.bNoFsPowerUp = 0x0,
|
||||
.txPower = DEFAULT_TX_POWER,
|
||||
.pRegOverride = rf_prop_overrides,
|
||||
.centerFreq = 0x0364, /* set by driver */
|
||||
.intFreq = 0x8000, /* set by driver */
|
||||
.loDivider = 0x05, /* set by driver */
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_FS */
|
||||
/* Frequency Synthesizer Programming Command */
|
||||
rfc_CMD_FS_t rf_cmd_prop_fs =
|
||||
{
|
||||
.commandNo = CMD_FS,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.frequency = 0x0364, /* set by driver */
|
||||
.fractFreq = 0x0000, /* set by driver */
|
||||
.synthConf.bTxMode = 0x0,
|
||||
.synthConf.refFreq = 0x0,
|
||||
.__dummy0 = 0x00,
|
||||
.__dummy1 = 0x00,
|
||||
.__dummy2 = 0x00,
|
||||
.__dummy3 = 0x0000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_PROP_TX_ADV */
|
||||
/* Proprietary Mode Advanced Transmit Command */
|
||||
rfc_CMD_PROP_TX_ADV_t rf_cmd_prop_tx_adv =
|
||||
{
|
||||
.commandNo = CMD_PROP_TX_ADV,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.pktConf.bFsOff = 0x0,
|
||||
.pktConf.bUseCrc = 0x1,
|
||||
.pktConf.bCrcIncSw = 0x0,
|
||||
.pktConf.bCrcIncHdr = 0x0,
|
||||
.numHdrBits = 0x10,
|
||||
.pktLen = 0x0, /* set by driver */
|
||||
.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, /* set by driver */
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_PROP_RX_ADV */
|
||||
/* Proprietary Mode Advanced Receive Command */
|
||||
rfc_CMD_PROP_RX_ADV_t rf_cmd_prop_rx_adv =
|
||||
{
|
||||
.commandNo = CMD_PROP_RX_ADV,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.pktConf.bFsOff = 0x0,
|
||||
.pktConf.bRepeatOk = 0x1,
|
||||
.pktConf.bRepeatNok = 0x1,
|
||||
.pktConf.bUseCrc = 0x1,
|
||||
.pktConf.bCrcIncSw = 0x0,
|
||||
.pktConf.bCrcIncHdr = 0x0,
|
||||
.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 = 0x0, /* set by driver */
|
||||
.hdrConf.numHdrBits = 0x10,
|
||||
.hdrConf.lenPos = 0x0,
|
||||
.hdrConf.numLenBits = 0x0B,
|
||||
.addrConf.addrType = 0x0,
|
||||
.addrConf.addrSize = 0x0,
|
||||
.addrConf.addrPos = 0x0,
|
||||
.addrConf.numAddr = 0x0,
|
||||
.lenOffset = 0xFC,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
.pAddr = 0, /* set by driver */
|
||||
.pQueue = 0, /* set by driver */
|
||||
.pOutput = 0, /* set by driver */
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef PROP_SETTINGS_H_
|
||||
#define PROP_SETTINGS_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki-conf.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
extern RF_Mode rf_prop_mode;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TX Power Table */
|
||||
extern RF_TxPowerTable_Entry rf_prop_tx_power_table[];
|
||||
extern const size_t rf_prop_tx_power_table_size;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API commands */
|
||||
extern rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup;
|
||||
extern rfc_CMD_FS_t rf_cmd_prop_fs;
|
||||
extern rfc_CMD_PROP_TX_ADV_t rf_cmd_prop_tx_adv;
|
||||
extern rfc_CMD_PROP_RX_ADV_t rf_cmd_prop_rx_adv;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API Overrides */
|
||||
extern uint32_t rf_prop_overrides[];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* PROP_SETTINGS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-tx-power
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Source file for Prop-mode TX power tables for CC13x0.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/tx-power.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1310
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_prop_tx_power_table_cc1310[] =
|
||||
{
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY( 0, 3, 0, 4) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY( 1, 1, 0, 0) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY( 3, 3, 0, 8) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY( 2, 1, 0, 8) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY( 4, 3, 0, 10) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY( 5, 3, 0, 12) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY( 6, 3, 0, 12) },
|
||||
{ 6, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 14) },
|
||||
{ 7, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 16) },
|
||||
{ 8, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 18) },
|
||||
{ 9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 3, 0, 22) },
|
||||
{ 10, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 3, 0, 28) },
|
||||
{ 11, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 3, 0, 40) },
|
||||
{ 12, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 0, 0, 92) },
|
||||
/* The original PA value (12.5 dBm) have been rounded to an integer value. */
|
||||
{ 13, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 0, 83) },
|
||||
#if RF_CONF_TXPOWER_BOOST_MODE
|
||||
/* This setting requires RF_CONF_TXPOWER_BOOST_MODE = 1. */
|
||||
{ 14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 83) },
|
||||
#endif
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1350
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_prop_tx_power_table_cc1350[] =
|
||||
{
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY( 0, 3, 0, 2) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY( 3, 3, 0, 9) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY( 4, 3, 0, 11) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY( 5, 3, 0, 12) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY( 6, 3, 0, 14) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY( 4, 1, 0, 12) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 3, 0, 16) },
|
||||
{ 6, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 18) },
|
||||
{ 7, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 21) },
|
||||
{ 8, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 25) },
|
||||
{ 9, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 3, 0, 32) },
|
||||
{ 10, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 3, 0, 44) },
|
||||
{ 11, RF_TxPowerTable_DEFAULT_PA_ENTRY(37, 3, 0, 72) },
|
||||
{ 12, RF_TxPowerTable_DEFAULT_PA_ENTRY(43, 0, 0, 94) },
|
||||
#if RF_CONF_TXPOWER_BOOST_MODE
|
||||
/* This setting requires RF_CONF_TXPOWER_BOOST_MODE = 1. */
|
||||
{ 14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 85) },
|
||||
#endif
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1350_433
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_prop_tx_power_table_cc1350_4[] =
|
||||
{
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY( 0, 3, 0, 2) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY( 1, 3, 0, 7) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY( 1, 3, 0, 9) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY( 2, 3, 0, 11) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY( 2, 3, 0, 12) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY( 3, 3, 0, 16) },
|
||||
{ 6, RF_TxPowerTable_DEFAULT_PA_ENTRY( 4, 3, 0, 18) },
|
||||
{ 7, RF_TxPowerTable_DEFAULT_PA_ENTRY( 5, 3, 0, 21) },
|
||||
{ 8, RF_TxPowerTable_DEFAULT_PA_ENTRY( 6, 3, 0, 23) },
|
||||
{ 9, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 3, 0, 28) },
|
||||
{ 10, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 35) },
|
||||
{ 11, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 1, 0, 39) },
|
||||
{ 12, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 60) },
|
||||
{ 13, RF_TxPowerTable_DEFAULT_PA_ENTRY(15, 0, 0, 108) },
|
||||
/* The original PA value (13.7 dBm) have been rounded to an integer value. */
|
||||
{ 14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 0, 92) },
|
||||
#if RF_CONF_TXPOWER_BOOST_MODE
|
||||
/* This setting requires RF_CONF_TXPOWER_BOOST_MODE = 1. */
|
||||
{ 15, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 72) },
|
||||
#endif
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
tx_power_table_t rf_prop_tx_power_table_empty[] =
|
||||
{
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Only define the symbols if Prop-mode is selected */
|
||||
#if (RF_MODE == RF_MODE_SUB_1_GHZ)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TX power table, based on which board is used. */
|
||||
#if defined(DEVICE_CC1310)
|
||||
#define TX_POWER_TABLE rf_prop_tx_power_table_cc1310
|
||||
|
||||
#elif defined(DEVICE_CC1350)
|
||||
#define TX_POWER_TABLE rf_prop_tx_power_table_cc1350
|
||||
|
||||
#elif defined(DEVICE_CC1350_4)
|
||||
#define TX_POWER_TABLE rf_prop_tx_power_table_cc1350_4
|
||||
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_prop_tx_power_table_empty
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define symbols for both the TX power table and its size. The TX power
|
||||
* table size is with one less entry by excluding the termination entry.
|
||||
*/
|
||||
tx_power_table_t *const rf_tx_power_table = TX_POWER_TABLE;
|
||||
const size_t rf_tx_power_table_size = (sizeof(TX_POWER_TABLE) / sizeof(TX_POWER_TABLE[0])) - 1;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_MODE */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Parameter summary
|
||||
* Adv. Address: 010203040506
|
||||
* Adv. Data: dummy
|
||||
* BLE Channel: 17
|
||||
* Extended Header: 09 09 010203040506 babe
|
||||
* Frequency: 2440 MHz
|
||||
* PDU Payload length:: 30
|
||||
* TX Power: 5 dBm (requires define CCFG_FORCE_VDDR_HH = 0 in ccfg
|
||||
* see CC13xx/CC26xx Technical Reference Manual)
|
||||
* Whitening: true
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "sys/cc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_bt5.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_bt5.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_bt5.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "ble-settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
RF_Mode rf_ble_mode =
|
||||
{
|
||||
.rfMode = RF_MODE_AUTO,
|
||||
.cpePatchFxn = &rf_patch_cpe_bt5,
|
||||
.mcePatchFxn = &rf_patch_mce_bt5,
|
||||
.rfePatchFxn = &rf_patch_rfe_bt5,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_BLE5_RADIO_SETUP */
|
||||
uint32_t rf_ble_overrides_common[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_ble5_setup_override_common.xml */
|
||||
(uint32_t)0x02400403, /* Synth: Use 48 MHz crystal, enable extra PLL filtering */
|
||||
(uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x00088433, /* Synth: Configure synth hardware */
|
||||
(uint32_t)0x00038793, /* Synth: Set minimum RTRIM to 3 */
|
||||
HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x1C0C0618, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC00401A1, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00010101, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC0040141, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00214AD3, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x02980243, /* Synth: Decrease synth programming time-out (0x0298 RAT ticks = 166 us) */
|
||||
/* DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0x00038883, /* Rx: Set LNA bias current offset to adjust +3 (default: 0) */
|
||||
(uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB (default: 0) */
|
||||
(uint32_t)0x01080263, /* Bluetooth 5: Compensate for reduced pilot tone length */
|
||||
(uint32_t)0x08E90AA3, /* Bluetooth 5: Compensate for reduced pilot tone length */
|
||||
(uint32_t)0x00068BA3, /* Bluetooth 5: Compensate for reduced pilot tone length */
|
||||
/* Bluetooth 5: Set correct total clock accuracy for received AuxPtr */
|
||||
(uint32_t)0x0E490C83, /* assuming local sleep clock of 50 ppm */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_BLE5_RADIO_SETUP */
|
||||
uint32_t rf_ble_overrides_1mbps[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_ble5_setup_override_1mbps.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,0,1,0,0), /* PHY: Use MCE RAM patch (mode 0), RFE RAM patch (mode 0) */
|
||||
HW_REG_OVERRIDE(0x5320,0x0240), /* Bluetooth 5: Reduce pilot tone length */
|
||||
(uint32_t)0x013302A3, /* Bluetooth 5: Compensate for reduced pilot tone length */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_BLE5_RADIO_SETUP */
|
||||
uint32_t rf_ble_overrides_2mbps[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_ble5_setup_override_2mbps.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,2,1,0,2), /* PHY: Use MCE RAM patch (mode 2), RFE RAM patch (mode 2) */
|
||||
HW_REG_OVERRIDE(0x5320,0x0240), /* Bluetooth 5: Reduce pilot tone length */
|
||||
(uint32_t)0x00D102A3, /* Bluetooth 5: Compensate for reduced pilot tone length */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_BLE5_RADIO_SETUP */
|
||||
uint32_t rf_ble_overrides_coded[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_ble5_setup_override_coded.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,1,1,0,1), /* PHY: Use MCE RAM patch (mode 1), RFE RAM patch (mode 1) */
|
||||
HW_REG_OVERRIDE(0x5320,0x0240), /* Bluetooth 5: Reduce pilot tone length */
|
||||
(uint32_t)0x078902A3, /* Bluetooth 5: Compensate for reduced pilot tone length */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_BLE5_RADIO_SETUP: Bluetooth 5 Radio Setup Command for all PHYs */
|
||||
rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup =
|
||||
{
|
||||
.commandNo = CMD_BLE5_RADIO_SETUP,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.defaultPhy.mainMode = 0x0,
|
||||
.defaultPhy.coding = 0x0,
|
||||
.loDivider = 0x00,
|
||||
.config.frontEndMode = 0x0,
|
||||
.config.biasMode = 0x0,
|
||||
.config.analogCfgMode = 0x0,
|
||||
.config.bNoFsPowerUp = 0x0,
|
||||
.txPower = 0x941E,
|
||||
.pRegOverrideCommon = rf_ble_overrides_common,
|
||||
.pRegOverride1Mbps = rf_ble_overrides_1mbps,
|
||||
.pRegOverride2Mbps = rf_ble_overrides_2mbps,
|
||||
.pRegOverrideCoded = rf_ble_overrides_coded,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Structure for CMD_BLE5_ADV_NC.pParams */
|
||||
rfc_bleAdvPar_t rf_ble_adv_par =
|
||||
{
|
||||
.pRxQ = 0,
|
||||
.rxConfig.bAutoFlushIgnored = 0x0,
|
||||
.rxConfig.bAutoFlushCrcErr = 0x0,
|
||||
.rxConfig.bAutoFlushEmpty = 0x0,
|
||||
.rxConfig.bIncludeLenByte = 0x0,
|
||||
.rxConfig.bIncludeCrc = 0x0,
|
||||
.rxConfig.bAppendRssi = 0x0,
|
||||
.rxConfig.bAppendStatus = 0x0,
|
||||
.rxConfig.bAppendTimestamp = 0x0,
|
||||
.advConfig.advFilterPolicy = 0x0,
|
||||
.advConfig.deviceAddrType = 0x0,
|
||||
.advConfig.peerAddrType = 0x0,
|
||||
.advConfig.bStrictLenFilter = 0x0,
|
||||
.advConfig.rpaMode = 0x0,
|
||||
.advLen = 0x18,
|
||||
.scanRspLen = 0x00,
|
||||
.pAdvData = 0,
|
||||
.pScanRspData = 0,
|
||||
.pDeviceAddress = 0,
|
||||
.pWhiteList = 0,
|
||||
.__dummy0 = 0x0000,
|
||||
.__dummy1 = 0x00,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_BLE5_ADV_NC: Bluetooth 5 Non-Connectable Advertiser Command */
|
||||
rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
||||
{
|
||||
.commandNo = 0x182D,
|
||||
.status = 0x0000,
|
||||
.pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = 0x0,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = 0x1,
|
||||
.condition.nSkip = 0x0,
|
||||
.channel = 0x8C,
|
||||
.whitening.init = 0x51,
|
||||
.whitening.bOverride = 0x1,
|
||||
.phyMode.mainMode = 0x0,
|
||||
.phyMode.coding = 0x0,
|
||||
.rangeDelay = 0x00,
|
||||
.txPower = 0x0000,
|
||||
.pParams = &rf_ble_adv_par,
|
||||
.pOutput = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
|
||||
.tx20Power = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef BLE_SETTINGS_H_
|
||||
#define BLE_SETTINGS_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
extern RF_Mode rf_ble_mode;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API commands */
|
||||
extern rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup;
|
||||
extern rfc_bleAdvPar_t rf_ble_adv_par;
|
||||
extern rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API Overrides */
|
||||
extern uint32_t rf_ble_overrides_common[];
|
||||
extern uint32_t rf_ble_overrides_1mbps[];
|
||||
extern uint32_t rf_ble_overrides_2mbps[];
|
||||
extern uint32_t rf_ble_overrides_coded[];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* BLE_SETTINGS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-tx-power
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Source file for ble-mode TX power tables for CC13x2.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/tx-power.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1352R
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ble_tx_power_table_cc1352r[] =
|
||||
{
|
||||
{ -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 3) },
|
||||
{ -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 3) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 2, 0, 6) },
|
||||
{ -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 2, 0, 8) },
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) },
|
||||
{ -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) },
|
||||
{ -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) },
|
||||
{ -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) },
|
||||
{ -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1352P with default PA
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ble_tx_power_table_cc1352p_dpa[] =
|
||||
{
|
||||
{ -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 3) },
|
||||
{ -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 3) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 2, 0, 6) },
|
||||
{ -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 2, 0, 8) },
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) },
|
||||
{ -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) },
|
||||
{ -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) },
|
||||
{ -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) },
|
||||
{ -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1352P with high PA
|
||||
* The RF_TxPowerTable_HIGH_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_HIGH_PA_ENTRY(bias, ibboost, boost, coefficient, ldoTrim)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ble_tx_power_table_cc1352p_hpa[] =
|
||||
{
|
||||
{ 0, RF_TxPowerTable_HIGH_PA_ENTRY(29, 0, 1, 17, 1) },
|
||||
{ 3, RF_TxPowerTable_HIGH_PA_ENTRY(39, 0, 1, 20, 1) },
|
||||
{ 6, RF_TxPowerTable_HIGH_PA_ENTRY(46, 0, 1, 26, 7) },
|
||||
{ 9, RF_TxPowerTable_HIGH_PA_ENTRY(40, 0, 1, 39, 41) },
|
||||
{ 10, RF_TxPowerTable_HIGH_PA_ENTRY(23, 2, 1, 65, 5) },
|
||||
{ 11, RF_TxPowerTable_HIGH_PA_ENTRY(24, 2, 1, 29, 7) },
|
||||
{ 12, RF_TxPowerTable_HIGH_PA_ENTRY(19, 2, 1, 16, 25) },
|
||||
{ 13, RF_TxPowerTable_HIGH_PA_ENTRY(27, 2, 1, 19, 13) },
|
||||
{ 14, RF_TxPowerTable_HIGH_PA_ENTRY(24, 2, 1, 19, 27) },
|
||||
{ 15, RF_TxPowerTable_HIGH_PA_ENTRY(23, 2, 1, 20, 39) },
|
||||
{ 16, RF_TxPowerTable_HIGH_PA_ENTRY(34, 2, 1, 26, 23) },
|
||||
{ 17, RF_TxPowerTable_HIGH_PA_ENTRY(38, 2, 1, 33, 25) },
|
||||
{ 18, RF_TxPowerTable_HIGH_PA_ENTRY(30, 2, 1, 37, 53) },
|
||||
{ 19, RF_TxPowerTable_HIGH_PA_ENTRY(36, 2, 1, 57, 59) },
|
||||
{ 20, RF_TxPowerTable_HIGH_PA_ENTRY(56, 2, 1, 45, 63) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
tx_power_table_t rf_ble_tx_power_table_empty[] =
|
||||
{
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TX power table, based on which board is used. */
|
||||
#if defined(DEVICE_CC1352R)
|
||||
#define TX_POWER_TABLE rf_ble_tx_power_table_cc1352r
|
||||
|
||||
#elif defined(DEVICE_CC1352P)
|
||||
#if RF_TXPOWER_HIGH_PA
|
||||
#define TX_POWER_TABLE rf_ble_tx_power_table_cc1352p_hpa
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_ble_tx_power_table_cc1352p_dpa
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_ble_tx_power_table_empty
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define symbols for both the TX power table and its size. The TX power
|
||||
* table size is with one less entry by excluding the termination entry.
|
||||
*/
|
||||
tx_power_table_t *const ble_tx_power_table = TX_POWER_TABLE;
|
||||
const size_t ble_tx_power_table_size = (sizeof(TX_POWER_TABLE) / sizeof(TX_POWER_TABLE[0])) - 1;
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,322 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Parameter summary
|
||||
* IEEE Channel: 11
|
||||
* Frequency: 2405 MHz
|
||||
* SFD: 0
|
||||
* Packet Data: 255
|
||||
* Preamble (32 bit): 01010101...
|
||||
* For Default PA:
|
||||
* Enable high output power PA: false
|
||||
* TX Power: 5 dBm (requires define CCFG_FORCE_VDDR_HH = 0 in ccfg.c,
|
||||
* see CC13xx/CC26xx Technical Reference Manual)
|
||||
* For High PA:
|
||||
* Enable high output power PA: true
|
||||
* TX Power: 20 dBm (requires define CCFG_FORCE_VDDR_HH = 0 in ccfg.c,
|
||||
* see CC13xx/CC26xx Technical Reference Manual)
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "sys/cc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_ieee_802_15_4.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_ieee_802_15_4.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "ieee-settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
RF_Mode rf_ieee_mode =
|
||||
{
|
||||
.rfMode = RF_MODE_AUTO,
|
||||
.cpePatchFxn = &rf_patch_cpe_ieee_802_15_4,
|
||||
.mcePatchFxn = &rf_patch_mce_ieee_802_15_4,
|
||||
.rfePatchFxn = 0,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if defined(DEVICE_CC1352R)
|
||||
/*
|
||||
* CMD_RADIO_SETUP must be configured with default TX power value
|
||||
* in the .txPower field.
|
||||
*/
|
||||
#define DEFAULT_TX_POWER 0x941E /* 5 dBm */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_RADIO_SETUP */
|
||||
uint32_t rf_ieee_overrides[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_ieee_802_15_4.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,0,0,1,0), /* PHY: Use MCE RAM patch, RFE ROM bank 1 */
|
||||
(uint32_t)0x02400403, /* Synth: Use 48 MHz crystal, enable extra PLL filtering */
|
||||
(uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x00088433, /* Synth: Configure synth hardware */
|
||||
(uint32_t)0x00038793, /* Synth: Set minimum RTRIM to 3 */
|
||||
HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x1C0C0618, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC00401A1, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00010101, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC0040141, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00214AD3, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x02980243, /* Synth: Decrease synth programming time-out (0x0298 RAT ticks = 166 us) */
|
||||
/* DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0x000F8883, /* Rx: Set LNA bias current offset to +15 to saturate trim to max (default: 0) */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
|
||||
#endif /* defined(DEVICE_CC1352R) */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if defined(DEVICE_CC1352P)
|
||||
|
||||
#if RF_CONF_TXPOWER_HIGH_PA
|
||||
/*
|
||||
* CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value
|
||||
* in the .txPower field. For High PA, this must be 0xFFFF.
|
||||
*/
|
||||
#define DEFAULT_TX_POWER 0xFFFF /* High PA */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_RADIO_SETUP with high PA */
|
||||
uint32_t rf_ieee_overrides[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_ieee_802_15_4.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,0,0,1,0), /* PHY: Use MCE RAM patch, RFE ROM bank 1 */
|
||||
(uint32_t)0x02400403, /* Synth: Use 48 MHz crystal, enable extra PLL filtering */
|
||||
(uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x00088433, /* Synth: Configure synth hardware */
|
||||
(uint32_t)0x00038793, /* Synth: Set minimum RTRIM to 3 */
|
||||
HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x1C0C0618, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC00401A1, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00010101, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC0040141, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00214AD3, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x02980243, /* Synth: Decrease synth programming time-out (0x0298 RAT ticks = 166 us) */
|
||||
/* DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0x000F8883, /* Rx: Set LNA bias current offset to +15 to saturate trim to max (default: 0) */
|
||||
/* override_frontend_xd.xml */
|
||||
/* TX power override */
|
||||
(uint32_t)0xFD6EE02B, /* txHighPA=0x3F5BB8 */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#else
|
||||
/*
|
||||
* CMD_RADIO_SETUP must be configured with default TX power value
|
||||
* in the .txPower field.
|
||||
*/
|
||||
#define DEFAULT_TX_POWER 0x941E /* 5 dBm */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_RADIO_SETUP with default PA */
|
||||
uint32_t rf_ieee_overrides[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_ieee_802_15_4.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,0,0,1,0), /* PHY: Use MCE RAM patch, RFE ROM bank 1 */
|
||||
(uint32_t)0x02400403, /* Synth: Use 48 MHz crystal, enable extra PLL filtering */
|
||||
(uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x00088433, /* Synth: Configure synth hardware */
|
||||
(uint32_t)0x00038793, /* Synth: Set minimum RTRIM to 3 */
|
||||
HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x1C0C0618, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC00401A1, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00010101, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC0040141, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00214AD3, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x02980243, /* Synth: Decrease synth programming time-out (0x0298 RAT ticks = 166 us) */
|
||||
/* DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0x000F8883, /* Rx: Set LNA bias current offset to +15 to saturate trim to max (default: 0) */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
|
||||
#endif /* RF_CONF_TXPOWER_HIGH_PA */
|
||||
|
||||
#endif /* defined(DEVICE_CC1352P) */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_RADIO_SETUP: Radio Setup Command for Pre-Defined Schemes */
|
||||
rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup =
|
||||
{
|
||||
.commandNo = CMD_RADIO_SETUP,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.mode = 0x01,
|
||||
.loDivider = 0x00,
|
||||
.config.frontEndMode = 0x0,
|
||||
.config.biasMode = 0x0,
|
||||
.config.analogCfgMode = 0x0,
|
||||
.config.bNoFsPowerUp = 0x0,
|
||||
.txPower = DEFAULT_TX_POWER, /* 5 dBm default */
|
||||
.pRegOverride = rf_ieee_overrides,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_FS: Frequency Synthesizer Programming Command */
|
||||
rfc_CMD_FS_t rf_cmd_ieee_fs =
|
||||
{
|
||||
.commandNo = CMD_FS,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.frequency = 0x0965, /* set by driver */
|
||||
.fractFreq = 0x0000, /* set by driver */
|
||||
.synthConf.bTxMode = 0x1,
|
||||
.synthConf.refFreq = 0x0,
|
||||
.__dummy0 = 0x00,
|
||||
.__dummy1 = 0x00,
|
||||
.__dummy2 = 0x00,
|
||||
.__dummy3 = 0x0000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_IEEE_TX: IEEE 802.15.4 Transmit Command */
|
||||
rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx =
|
||||
{
|
||||
.commandNo = CMD_IEEE_TX,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.txOpt.bIncludePhyHdr = 0x0,
|
||||
.txOpt.bIncludeCrc = 0x0,
|
||||
.txOpt.payloadLenMsb = 0x0,
|
||||
.payloadLen = 0x0, /* set by driver */
|
||||
.pPayload = 0, /* set by driver */
|
||||
.timeStamp = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_IEEE_RX: IEEE 802.15.4 Receive Command */
|
||||
rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx =
|
||||
{
|
||||
.commandNo = CMD_IEEE_RX,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.channel = 0x00, /* set by driver */
|
||||
.rxConfig.bAutoFlushCrc = 0x1,
|
||||
.rxConfig.bAutoFlushIgn = 0x1,
|
||||
.rxConfig.bIncludePhyHdr = 0x0,
|
||||
.rxConfig.bIncludeCrc = 0x1,
|
||||
.rxConfig.bAppendRssi = 0x1,
|
||||
.rxConfig.bAppendCorrCrc = 0x1,
|
||||
.rxConfig.bAppendSrcInd = 0x0,
|
||||
.rxConfig.bAppendTimestamp = 0x1,
|
||||
.pRxQ = 0, /* set by driver */
|
||||
.pOutput = 0, /* set by driver */
|
||||
.frameFiltOpt.frameFiltEn = 0x0, /* set by driver */
|
||||
.frameFiltOpt.frameFiltStop = 0x1,
|
||||
.frameFiltOpt.autoAckEn = 0x0, /* set by driver */
|
||||
.frameFiltOpt.slottedAckEn = 0x0,
|
||||
.frameFiltOpt.autoPendEn = 0x0,
|
||||
.frameFiltOpt.defaultPend = 0x0,
|
||||
.frameFiltOpt.bPendDataReqOnly = 0x0,
|
||||
.frameFiltOpt.bPanCoord = 0x0,
|
||||
.frameFiltOpt.maxFrameVersion = 0x2,
|
||||
.frameFiltOpt.fcfReservedMask = 0x0,
|
||||
.frameFiltOpt.modifyFtFilter = 0x0,
|
||||
.frameFiltOpt.bStrictLenFilter = 0x0,
|
||||
.frameTypes.bAcceptFt0Beacon = 0x1,
|
||||
.frameTypes.bAcceptFt1Data = 0x1,
|
||||
.frameTypes.bAcceptFt2Ack = 0x1,
|
||||
.frameTypes.bAcceptFt3MacCmd = 0x1,
|
||||
.frameTypes.bAcceptFt4Reserved = 0x1,
|
||||
.frameTypes.bAcceptFt5Reserved = 0x1,
|
||||
.frameTypes.bAcceptFt6Reserved = 0x1,
|
||||
.frameTypes.bAcceptFt7Reserved = 0x1,
|
||||
.ccaOpt.ccaEnEnergy = 0x1,
|
||||
.ccaOpt.ccaEnCorr = 0x1,
|
||||
.ccaOpt.ccaEnSync = 0x1,
|
||||
.ccaOpt.ccaCorrOp = 0x1,
|
||||
.ccaOpt.ccaSyncOp = 0x0,
|
||||
.ccaOpt.ccaCorrThr = 0x3,
|
||||
.ccaRssiThr = 0x0, /* set by driver */
|
||||
.__dummy0 = 0x00,
|
||||
.numExtEntries = 0x00,
|
||||
.numShortEntries = 0x00,
|
||||
.pExtEntryList = 0,
|
||||
.pShortEntryList = 0,
|
||||
.localExtAddr = 0x0, /* set by driver */
|
||||
.localShortAddr = 0x0, /* set by driver */
|
||||
.localPanID = 0x0000,
|
||||
.__dummy1 = 0x000000,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_IEEE_RX_ACK: IEEE 802.15.4 Receive ACK Command */
|
||||
rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack =
|
||||
{
|
||||
.commandNo = CMD_IEEE_RX_ACK,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.seqNo = 0x0,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef IEEE_SETTINGS_H_
|
||||
#define IEEE_SETTINGS_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki-conf.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ieee_mailbox.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
extern RF_Mode rf_ieee_mode;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API commands */
|
||||
extern rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup;
|
||||
extern rfc_CMD_FS_t rf_cmd_ieee_fs;
|
||||
extern rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx;
|
||||
extern rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx;
|
||||
extern rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API Overrides */
|
||||
extern uint32_t rf_ieee_overrides[];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* IEEE_SETTINGS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-tx-power
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Source file for IEEE-mode TX power tables for CC13x2.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/tx-power.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1312R
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ieee_tx_power_table_cc1312r[] =
|
||||
{
|
||||
{ -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 3) },
|
||||
{ -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 3) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 2, 0, 6) },
|
||||
{ -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 2, 0, 8) },
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) },
|
||||
{ -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) },
|
||||
{ -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) },
|
||||
{ -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) },
|
||||
{ -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1352R
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ieee_tx_power_table_cc1352r[] =
|
||||
{
|
||||
{ -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 3) },
|
||||
{ -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 3) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 2, 0, 6) },
|
||||
{ -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 2, 0, 8) },
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) },
|
||||
{ -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) },
|
||||
{ -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) },
|
||||
{ -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) },
|
||||
{ -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1352P with default PA
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ieee_tx_power_table_cc1352p_dpa[] =
|
||||
{
|
||||
{ -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 3) },
|
||||
{ -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 3) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 2, 0, 6) },
|
||||
{ -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 2, 0, 8) },
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) },
|
||||
{ -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) },
|
||||
{ -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) },
|
||||
{ -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) },
|
||||
{ -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1352P with high PA
|
||||
* The RF_TxPowerTable_HIGH_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_HIGH_PA_ENTRY(bias, ibboost, boost, coefficient, ldoTrim)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ieee_tx_power_table_cc1352p_hpa[] =
|
||||
{
|
||||
{ 0, RF_TxPowerTable_HIGH_PA_ENTRY(29, 0, 1, 17, 1) },
|
||||
{ 3, RF_TxPowerTable_HIGH_PA_ENTRY(39, 0, 1, 20, 1) },
|
||||
{ 6, RF_TxPowerTable_HIGH_PA_ENTRY(46, 0, 1, 26, 7) },
|
||||
{ 9, RF_TxPowerTable_HIGH_PA_ENTRY(40, 0, 1, 39, 41) },
|
||||
{ 10, RF_TxPowerTable_HIGH_PA_ENTRY(23, 2, 1, 65, 5) },
|
||||
{ 11, RF_TxPowerTable_HIGH_PA_ENTRY(24, 2, 1, 29, 7) },
|
||||
{ 12, RF_TxPowerTable_HIGH_PA_ENTRY(19, 2, 1, 16, 25) },
|
||||
{ 13, RF_TxPowerTable_HIGH_PA_ENTRY(27, 2, 1, 19, 13) },
|
||||
{ 14, RF_TxPowerTable_HIGH_PA_ENTRY(24, 2, 1, 19, 27) },
|
||||
{ 15, RF_TxPowerTable_HIGH_PA_ENTRY(23, 2, 1, 20, 39) },
|
||||
{ 16, RF_TxPowerTable_HIGH_PA_ENTRY(34, 2, 1, 26, 23) },
|
||||
{ 17, RF_TxPowerTable_HIGH_PA_ENTRY(38, 2, 1, 33, 25) },
|
||||
{ 18, RF_TxPowerTable_HIGH_PA_ENTRY(30, 2, 1, 37, 53) },
|
||||
{ 19, RF_TxPowerTable_HIGH_PA_ENTRY(36, 2, 1, 57, 59) },
|
||||
{ 20, RF_TxPowerTable_HIGH_PA_ENTRY(56, 2, 1, 45, 63) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
tx_power_table_t rf_ieee_ztx_power_table_empty[] =
|
||||
{
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Only define the symbols if Prop-mode is selected */
|
||||
#if (RF_MODE == RF_MODE_2_4_GHZ)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TX power table, based on which board is used. */
|
||||
#if defined(DEVICE_CC1312R)
|
||||
#define TX_POWER_TABLE rf_ieee_tx_power_table_cc1312r
|
||||
|
||||
#elif defined(DEVICE_CC1352R)
|
||||
#define TX_POWER_TABLE rf_ieee_tx_power_table_cc1352r
|
||||
|
||||
#elif defined(DEVICE_CC1352P)
|
||||
#if RF_TXPOWER_HIGH_PA
|
||||
#define TX_POWER_TABLE rf_ieee_tx_power_table_cc1352p_hpa
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_ieee_tx_power_table_cc1352p_dpa
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_ieee_tx_power_table_empty
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define symbols for both the TX power table and its size. The TX power
|
||||
* table size is with one less entry by excluding the termination entry.
|
||||
*/
|
||||
tx_power_table_t *const rf_tx_power_table = TX_POWER_TABLE;
|
||||
const size_t rf_tx_power_table_size = (sizeof(TX_POWER_TABLE) / sizeof(TX_POWER_TABLE[0])) - 1;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_MODE */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,406 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Parameter summary
|
||||
* Address: 0
|
||||
* Address0: 0xAA
|
||||
* Address1: 0xBB
|
||||
* Frequency: 915.00000 MHz
|
||||
* Data Format: Serial mode disable
|
||||
* Deviation: 25.000 kHz
|
||||
* pktLen: 30
|
||||
* 802.15.4g Mode: 0
|
||||
* Select bit order to transmit PSDU octets:: 1
|
||||
* Packet Length Config: Variable
|
||||
* Max Packet Length: 255
|
||||
* Packet Length: 20
|
||||
* Packet Data: 255
|
||||
* RX Filter BW: 98.0 kHz
|
||||
* Symbol Rate: 50.00000 kBaud
|
||||
* Sync Word Length: 24 Bits
|
||||
* For Default PA:
|
||||
* Enable high output power PA: false
|
||||
* TX Power: 13.5 dBm (requires define CCFG_FORCE_VDDR_HH = 1 in ccfg.c,
|
||||
* see CC13xx/CC26xx Technical Reference Manual)
|
||||
* For High PA:
|
||||
* Enable high output power PA: true
|
||||
* TX Power: 20 dBm (requires define CCFG_FORCE_VDDR_HH = 0 in ccfg.c,
|
||||
* see CC13xx/CC26xx Technical Reference Manual)
|
||||
* Whitening: Dynamically IEEE 802.15.4g compatible whitener and 16/32-bit CRC
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "sys/cc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_prop.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_genfsk.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_genfsk.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "prop-settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
RF_Mode rf_prop_mode =
|
||||
{
|
||||
.rfMode = RF_MODE_AUTO,
|
||||
.cpePatchFxn = &rf_patch_cpe_prop,
|
||||
.mcePatchFxn = &rf_patch_mce_genfsk,
|
||||
.rfePatchFxn = &rf_patch_rfe_genfsk,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if defined(DEVICE_CC1312R) || defined(DEVICE_CC1352R)
|
||||
/*
|
||||
* CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value
|
||||
* in the .txPower field. This depends on whether RF_CONF_TXPOWER_BOOST_MODE
|
||||
* is configured or not.
|
||||
*/
|
||||
#if RF_CONF_TXPOWER_BOOST_MODE
|
||||
#define DEFAULT_TX_POWER 0x9F3F /* 14 dBm */
|
||||
#else
|
||||
#define DEFAULT_TX_POWER 0xCC14 /* 12.5 dBm (rounded up to 13 dBm) */
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_PROP_RADIO_DIV_SETUP */
|
||||
uint32_t rf_prop_overrides[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_use_patch_prop_genfsk.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,0,1,0,0), /* PHY: Use MCE RAM patch, RFE RAM patch */
|
||||
/* override_synth_prop_863_930_div5.xml */
|
||||
(uint32_t)0x02400403, /* Synth: Use 48 MHz crystal as synth clock, enable extra PLL filtering */
|
||||
(uint32_t)0x00068793, /* Synth: Set minimum RTRIM to 6 */
|
||||
(uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x00088433, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x000684A3, /* Synth: Set Fref to 4 MHz */
|
||||
HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x180C0618, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC00401A1, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00010101, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC0040141, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00214AD3, /* Synth: Configure faster calibration */
|
||||
/* Synth: Decrease synth programming time-out by 90 us from default */
|
||||
(uint32_t)0x02980243, /* (0x0298 RAT ticks = 166 us) */
|
||||
(uint32_t)0x0A480583, /* Synth: Set loop bandwidth after lock to 20 kHz */
|
||||
(uint32_t)0x7AB80603, /* Synth: Set loop bandwidth after lock to 20 kHz */
|
||||
(uint32_t)0x00000623, /* Synth: Set loop bandwidth after lock to 20 kHz */
|
||||
/* override_phy_tx_pa_ramp_genfsk_hpa.xml */
|
||||
ADI_HALFREG_OVERRIDE(0,16,0x8,0x8), /* Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[3]=1) */
|
||||
ADI_HALFREG_OVERRIDE(0,17,0x1,0x1), /* Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[4]=1) */
|
||||
/* override_phy_rx_frontend_genfsk.xml */
|
||||
HW_REG_OVERRIDE(0x609C,0x001A), /* Rx: Set AGC reference level to 0x1A (default: 0x2E) */
|
||||
(uint32_t)0x00018883, /* Rx: Set LNA bias current offset to adjust +1 (default: 0) */
|
||||
(uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB (default: 0) */
|
||||
/* override_phy_rx_aaf_bw_0xd.xml */
|
||||
/* Rx: Set anti-aliasing filter bandwidth to 0xD */
|
||||
ADI_HALFREG_OVERRIDE(0,61,0xF,0xD), /* (in ADI0, set IFAMPCTL3[7:4]=0xD) */
|
||||
#if RF_CONF_TXPOWER_BOOST_MODE
|
||||
/* TX power override */
|
||||
/* DC/DC regulator: In Tx with 14 dBm PA setting, */
|
||||
/* use DCDCCTL5[3:0]=0xF (DITHER_EN=1 and IPEAK=7). */
|
||||
(uint32_t)0xFFFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
/* Tx: Set PA trim to max to maximize its output power */
|
||||
ADI_REG_OVERRIDE(0,12,0xF8), /* (in ADI0, set PACTL0=0xF8) */
|
||||
#else
|
||||
/* TX power override */
|
||||
/* DC/DC regulator: */
|
||||
/* In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
#endif
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
|
||||
#endif /* defined(DEVICE_CC1312R) || defined(DEVICE_CC1352R) */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if defined(DEVICE_CC1352P)
|
||||
|
||||
#if RF_CONF_TXPOWER_HIGH_PA
|
||||
/*
|
||||
* CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value
|
||||
* in the .txPower field. For High PA, this must be 0xFFFF.
|
||||
*/
|
||||
#define DEFAULT_TX_POWER 0xFFFF /* High PA */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_PROP_RADIO_DIV_SETUP with high PA */
|
||||
uint32_t rf_prop_overrides[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_use_patch_prop_genfsk.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,0,1,0,0), /* PHY: Use MCE RAM patch, RFE RAM patch */
|
||||
/* override_synth_prop_863_930_div5.xml */
|
||||
(uint32_t)0x02400403, /* Synth: Use 48 MHz crystal as synth clock, enable extra PLL filtering */
|
||||
(uint32_t)0x00068793, /* Synth: Set minimum RTRIM to 6 */
|
||||
(uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x00088433, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x000684A3, /* Synth: Set Fref to 4 MHz */
|
||||
HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x180C0618, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC00401A1, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00010101, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC0040141, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00214AD3, /* Synth: Configure faster calibration */
|
||||
/* Synth: Decrease synth programming time-out by 90 us */
|
||||
(uint32_t)0x02980243, /* from default (0x0298 RAT ticks = 166 us) */
|
||||
(uint32_t)0x0A480583, /* Synth: Set loop bandwidth after lock to 20 kHz */
|
||||
(uint32_t)0x7AB80603, /* Synth: Set loop bandwidth after lock to 20 kHz */
|
||||
(uint32_t)0x00000623, /* Synth: Set loop bandwidth after lock to 20 kHz */
|
||||
/* override_phy_tx_pa_ramp_genfsk_hpa.xml */
|
||||
/* Tx: Configure PA ramping, set wait time before turning off */
|
||||
HW_REG_OVERRIDE(0x6028,0x002F), /* (0x2F ticks of 16/24 us = 31.3 us). */
|
||||
ADI_HALFREG_OVERRIDE(0,16,0x8,0x8), /* Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[3]=1) */
|
||||
ADI_HALFREG_OVERRIDE(0,17,0x1,0x1), /* Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[4]=1) */
|
||||
/* override_phy_rx_frontend_genfsk.xml */
|
||||
HW_REG_OVERRIDE(0x609C,0x001A), /* Rx: Set AGC reference level to 0x1A (default: 0x2E) */
|
||||
(uint32_t)0x00018883, /* Rx: Set LNA bias current offset to adjust +1 (default: 0) */
|
||||
(uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB (default: 0) */
|
||||
/* override_phy_rx_aaf_bw_0xd.xml */
|
||||
/* Rx: Set anti-aliasing filter bandwidth to 0xD */
|
||||
ADI_HALFREG_OVERRIDE(0,61,0xF,0xD), /* (in ADI0, set IFAMPCTL3[7:4]=0xD) */
|
||||
/* TX power override */
|
||||
/* DC/DC regulator: */
|
||||
/* In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0x82A86C2B, /* txHighPA=0x20AA1B */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
|
||||
#else
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value
|
||||
* in the .txPower field. This depends on whether RF_CONF_TXPOWER_BOOST_MODE
|
||||
* is configured or not.
|
||||
*/
|
||||
#if RF_CONF_TXPOWER_BOOST_MODE
|
||||
#define DEFAULT_TX_POWER 0x013F /* 13.5 dBm (rounded up to 14 dBm) */
|
||||
#else
|
||||
#define DEFAULT_TX_POWER 0x803F /* 12 dBm */
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_PROP_RADIO_DIV_SETUP with defualt PA */
|
||||
uint32_t rf_prop_overrides[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_use_patch_prop_genfsk.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,0,1,0,0), /* PHY: Use MCE RAM patch, RFE RAM patch */
|
||||
/* override_synth_prop_863_930_div5.xml */
|
||||
(uint32_t)0x02400403, /* Synth: Use 48 MHz crystal as synth clock, enable extra PLL filtering */
|
||||
(uint32_t)0x00068793, /* Synth: Set minimum RTRIM to 6 */
|
||||
(uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x00088433, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x000684A3, /* Synth: Set Fref to 4 MHz */
|
||||
HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x180C0618, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC00401A1, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00010101, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC0040141, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00214AD3, /* Synth: Configure faster calibration */
|
||||
/* Synth: Decrease synth programming time-out by 90 us from default */
|
||||
(uint32_t)0x02980243, /* (0x0298 RAT ticks = 166 us) */
|
||||
(uint32_t)0x0A480583, /* Synth: Set loop bandwidth after lock to 20 kHz */
|
||||
(uint32_t)0x7AB80603, /* Synth: Set loop bandwidth after lock to 20 kHz */
|
||||
(uint32_t)0x00000623, /* Synth: Set loop bandwidth after lock to 20 kHz */
|
||||
/* override_phy_tx_pa_ramp_genfsk_hpa.xml */
|
||||
/* Tx: Configure PA ramping, set wait time before turning off */
|
||||
HW_REG_OVERRIDE(0x6028,0x002F), /* (0x2F ticks of 16/24 us = 31.3 us). */
|
||||
ADI_HALFREG_OVERRIDE(0,16,0x8,0x8), /* Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[3]=1) */
|
||||
ADI_HALFREG_OVERRIDE(0,17,0x1,0x1), /* Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[4]=1) */
|
||||
/* override_phy_rx_frontend_genfsk.xml */
|
||||
HW_REG_OVERRIDE(0x609C,0x001A), /* Rx: Set AGC reference level to 0x1A (default: 0x2E) */
|
||||
(uint32_t)0x00018883, /* Rx: Set LNA bias current offset to adjust +1 (default: 0) */
|
||||
(uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB (default: 0) */
|
||||
/* override_phy_rx_aaf_bw_0xd.xml */
|
||||
/* Rx: Set anti-aliasing filter bandwidth to 0xD */
|
||||
ADI_HALFREG_OVERRIDE(0,61,0xF,0xD), /* (in ADI0, set IFAMPCTL3[7:4]=0xD) */
|
||||
#if RF_CONF_TXPOWER_BOOST_MODE
|
||||
/* TX power override */
|
||||
/* DC/DC regulator: In Tx with 14 dBm PA setting, */
|
||||
/* use DCDCCTL5[3:0]=0xF (DITHER_EN=1 and IPEAK=7). */
|
||||
(uint32_t)0xFFFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
/* Tx: Set PA trim to max to maximize its output power */
|
||||
ADI_REG_OVERRIDE(0,12,0xF8), /* (in ADI0, set PACTL0=0xF8) */
|
||||
#else
|
||||
/* TX power override */
|
||||
/* DC/DC regulator: */
|
||||
/* In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
#endif
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
|
||||
#endif /* RF_CONF_TXPOWER_HIGH_PA */
|
||||
|
||||
#endif /* defined(DEVICE_CC1352P) */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_PROP_RADIO_DIV_SETUP: Proprietary Mode Radio Setup Command for All Frequency Bands */
|
||||
rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup =
|
||||
{
|
||||
.commandNo = CMD_PROP_RADIO_DIV_SETUP,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.modulation.modType = 0x1,
|
||||
.modulation.deviation = 0x64,
|
||||
.modulation.deviationStepSz = 0x0,
|
||||
.symbolRate.preScale = 0xF,
|
||||
.symbolRate.rateWord = 0x8000,
|
||||
.symbolRate.decimMode = 0x0,
|
||||
.rxBw = 0x52,
|
||||
.preamConf.nPreamBytes = 0x7,
|
||||
.preamConf.preamMode = 0x0,
|
||||
.formatConf.nSwBits = 0x18,
|
||||
.formatConf.bBitReversal = 0x0,
|
||||
.formatConf.bMsbFirst = 0x1,
|
||||
.formatConf.fecMode = 0x0,
|
||||
.formatConf.whitenMode = 0x7,
|
||||
.config.frontEndMode = 0x0, /* set by driver */
|
||||
.config.biasMode = 0x0, /* set by driver */
|
||||
.config.analogCfgMode = 0x0,
|
||||
.config.bNoFsPowerUp = 0x0,
|
||||
.txPower = DEFAULT_TX_POWER,
|
||||
.pRegOverride = rf_prop_overrides,
|
||||
.centerFreq = 0x0393, /* set by driver */
|
||||
.intFreq = 0x8000, /* set by driver */
|
||||
.loDivider = 0x05, /* set by driver */
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_FS: Frequency Synthesizer Programming Command */
|
||||
rfc_CMD_FS_t rf_cmd_prop_fs =
|
||||
{
|
||||
.commandNo = CMD_FS,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.frequency = 0x0393, /* set by driver */
|
||||
.fractFreq = 0x0000, /* set by driver */
|
||||
.synthConf.bTxMode = 0x0,
|
||||
.synthConf.refFreq = 0x0,
|
||||
.__dummy0 = 0x00,
|
||||
.__dummy1 = 0x00,
|
||||
.__dummy2 = 0x00,
|
||||
.__dummy3 = 0x0000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_PROP_TX_ADV: Proprietary Mode Advanced Transmit Command */
|
||||
rfc_CMD_PROP_TX_ADV_t rf_cmd_prop_tx_adv =
|
||||
{
|
||||
.commandNo = CMD_PROP_TX_ADV,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.pktConf.bFsOff = 0x0,
|
||||
.pktConf.bUseCrc = 0x1,
|
||||
.pktConf.bCrcIncSw = 0x0,
|
||||
.pktConf.bCrcIncHdr = 0x0,
|
||||
.numHdrBits = 0x10,
|
||||
.pktLen = 0x0, /* set by driver */
|
||||
.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, /* set by driver */
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_PROP_RX_ADV: Proprietary Mode Advanced Receive Command */
|
||||
rfc_CMD_PROP_RX_ADV_t rf_cmd_prop_rx_adv =
|
||||
{
|
||||
.commandNo = CMD_PROP_RX_ADV,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.pktConf.bFsOff = 0x0,
|
||||
.pktConf.bRepeatOk = 0x1,
|
||||
.pktConf.bRepeatNok = 0x1,
|
||||
.pktConf.bUseCrc = 0x1,
|
||||
.pktConf.bCrcIncSw = 0x0,
|
||||
.pktConf.bCrcIncHdr = 0x0,
|
||||
.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 = 0x0, /* set by driver */
|
||||
.hdrConf.numHdrBits = 0x10,
|
||||
.hdrConf.lenPos = 0x0,
|
||||
.hdrConf.numLenBits = 0x0B,
|
||||
.addrConf.addrType = 0x0,
|
||||
.addrConf.addrSize = 0x0,
|
||||
.addrConf.addrPos = 0x0,
|
||||
.addrConf.numAddr = 0x0,
|
||||
.lenOffset = 0xFC,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
.pAddr = 0, /* set by driver */
|
||||
.pQueue = 0, /* set by driver */
|
||||
.pOutput = 0, /* set by driver */
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef PROP_SETTINGS_H_
|
||||
#define PROP_SETTINGS_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki-conf.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
extern RF_Mode rf_prop_mode;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API commands */
|
||||
extern rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup;
|
||||
extern rfc_CMD_FS_t rf_cmd_prop_fs;
|
||||
extern rfc_CMD_PROP_TX_ADV_t rf_cmd_prop_tx_adv;
|
||||
extern rfc_CMD_PROP_RX_ADV_t rf_cmd_prop_rx_adv;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API Overrides */
|
||||
extern uint32_t rf_prop_overrides[];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* PROP_SETTINGS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,203 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-tx-power
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Source file for TX power tables for CC13x2.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/tx-power.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1312R
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_prop_tx_power_table_cc1312r[] =
|
||||
{
|
||||
{ -20, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 2) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 3, 0, 2) },
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 3, 0, 4) },
|
||||
{ -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 5) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 0, 7) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 7) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 9) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 9) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 3, 0, 11) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 12) },
|
||||
{ 6, RF_TxPowerTable_DEFAULT_PA_ENTRY(16, 3, 0, 14) },
|
||||
{ 7, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 2, 0, 16) },
|
||||
{ 8, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 3, 0, 32) },
|
||||
{ 9, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 3, 0, 28) },
|
||||
{ 10, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 3, 0, 55) },
|
||||
{ 11, RF_TxPowerTable_DEFAULT_PA_ENTRY(23, 2, 0, 42) },
|
||||
{ 12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 0, 0, 58) },
|
||||
/* The original PA value (12.5 dBm) have been rounded to an integer value. */
|
||||
{ 13, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 0, 0, 102) },
|
||||
#if RF_TXPOWER_BOOST_MODE
|
||||
/* This setting requires RF_TXPOWER_BOOST_MODE = 1. */
|
||||
{ 14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 79) },
|
||||
#endif
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1352R
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_prop_tx_power_table_cc1352r[] =
|
||||
{
|
||||
{ -20, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 2) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 3, 0, 2) },
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 3, 0, 4) },
|
||||
{ -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 5) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 0, 7) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 7) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 9) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 9) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 3, 0, 11) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 12) },
|
||||
{ 6, RF_TxPowerTable_DEFAULT_PA_ENTRY(16, 3, 0, 14) },
|
||||
{ 7, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 2, 0, 16) },
|
||||
{ 8, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 3, 0, 32) },
|
||||
{ 9, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 3, 0, 28) },
|
||||
{ 10, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 3, 0, 55) },
|
||||
{ 11, RF_TxPowerTable_DEFAULT_PA_ENTRY(23, 2, 0, 42) },
|
||||
{ 12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 0, 0, 58) },
|
||||
/* The original PA value (12.5 dBm) have been rounded to an integer value. */
|
||||
{ 13, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 0, 0, 102) },
|
||||
#if RF_TXPOWER_BOOST_MODE
|
||||
/* This setting requires RF_TXPOWER_BOOST_MODE = 1. */
|
||||
{ 14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 79) },
|
||||
#endif
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1352P with default PA
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_prop_tx_power_table_cc1352p_dpa[] =
|
||||
{
|
||||
{ -20, RF_TxPowerTable_DEFAULT_PA_ENTRY( 0, 3, 0, 2) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 1, 3, 0, 3) },
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY( 2, 3, 0, 3) },
|
||||
{ -5, RF_TxPowerTable_DEFAULT_PA_ENTRY( 4, 3, 0, 6) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 8) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 3, 0, 9) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 9) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 11) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 3, 0, 12) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 14) },
|
||||
{ 6, RF_TxPowerTable_DEFAULT_PA_ENTRY( 6, 2, 0, 14) },
|
||||
{ 7, RF_TxPowerTable_DEFAULT_PA_ENTRY( 4, 1, 0, 16) },
|
||||
{ 8, RF_TxPowerTable_DEFAULT_PA_ENTRY( 6, 1, 0, 19) },
|
||||
{ 9, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 1, 0, 25) },
|
||||
{ 10, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 40) },
|
||||
{ 11, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 0, 0, 71) },
|
||||
{ 12, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 0, 64) },
|
||||
#if RF_TXPOWER_BOOST_MODE
|
||||
/*
|
||||
* This setting requires RF_TXPOWER_BOOST_MODE = 1.
|
||||
* The original PA value (13.5 dBm) have been rounded to an integer value.
|
||||
*/
|
||||
{ 14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 0) },
|
||||
#endif
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC1352P with high PA
|
||||
* The RF_TxPowerTable_HIGH_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_HIGH_PA_ENTRY(bias, ibboost, boost, coefficient, ldoTrim)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_prop_tx_power_table_cc1352p_hpa[] =
|
||||
{
|
||||
{ 14, RF_TxPowerTable_HIGH_PA_ENTRY( 7, 0, 0, 23, 4) },
|
||||
{ 15, RF_TxPowerTable_HIGH_PA_ENTRY(10, 0, 0, 26, 4) },
|
||||
{ 16, RF_TxPowerTable_HIGH_PA_ENTRY(14, 0, 0, 33, 4) },
|
||||
{ 17, RF_TxPowerTable_HIGH_PA_ENTRY(18, 0, 0, 40, 6) },
|
||||
{ 18, RF_TxPowerTable_HIGH_PA_ENTRY(24, 0, 0, 51, 8) },
|
||||
{ 19, RF_TxPowerTable_HIGH_PA_ENTRY(32, 0, 0, 73, 12) },
|
||||
{ 20, RF_TxPowerTable_HIGH_PA_ENTRY(27, 0, 0, 85, 32) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
tx_power_table_t rf_prop_tx_power_table_empty[] =
|
||||
{
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Only define the symbols if Prop-mode is selected */
|
||||
#if (RF_MODE == RF_MODE_SUB_1_GHZ)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TX power table, based on which board is used. */
|
||||
#if defined(DEVICE_CC1312R)
|
||||
#define TX_POWER_TABLE rf_prop_tx_power_table_cc1312r
|
||||
|
||||
#elif defined(DEVICE_CC1352R)
|
||||
#define TX_POWER_TABLE rf_prop_tx_power_table_cc1352r
|
||||
|
||||
#elif defined(DEVICE_CC1352P)
|
||||
#if RF_TXPOWER_HIGH_PA
|
||||
#define TX_POWER_TABLE rf_prop_tx_power_table_cc1352p_hpa
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_prop_tx_power_table_cc1352p_dpa
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_prop_tx_power_table_empty
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define symbols for both the TX power table and its size. The TX power
|
||||
* table size is with one less entry by excluding the termination entry.
|
||||
*/
|
||||
tx_power_table_t *const rf_tx_power_table = TX_POWER_TABLE;
|
||||
const size_t rf_tx_power_table_size = (sizeof(TX_POWER_TABLE) / sizeof(TX_POWER_TABLE[0])) - 1;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_MODE */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Parameter summary
|
||||
* Adv. Address: 010203040506
|
||||
* Adv. Data: 255
|
||||
* BLE Channel: 17
|
||||
* Frequency: 2440 MHz
|
||||
* PDU Payload length:: 30
|
||||
* TX Power: 5 dBm
|
||||
* Whitening: true
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "sys/cc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_ble.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_ble.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "ble-settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
RF_Mode rf_ble_mode =
|
||||
{
|
||||
.rfMode = RF_MODE_BLE,
|
||||
.cpePatchFxn = &rf_patch_cpe_ble,
|
||||
.mcePatchFxn = 0,
|
||||
.rfePatchFxn = &rf_patch_rfe_ble,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_RADIO_SETUP */
|
||||
uint32_t rf_ble_overrides[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_use_patch_ble_1mbps.xml */
|
||||
MCE_RFE_OVERRIDE(0,0,0,1,0,0), /* PHY: Use MCE ROM, RFE RAM patch */
|
||||
/* override_synth_ble_1mbps.xml */
|
||||
HW_REG_OVERRIDE(0x4038,0x0035), /* Synth: Set recommended RTRIM to 5 */
|
||||
(uint32_t)0x000784A3, /* Synth: Set Fref to 3.43 MHz */
|
||||
(uint32_t)0xA47E0583, /* Synth: Set loop bandwidth after lock to 80 kHz */
|
||||
(uint32_t)0xEAE00603, /* Synth: Set loop bandwidth after lock to 80 kHz */
|
||||
(uint32_t)0x00010623, /* Synth: Set loop bandwidth after lock to 80 kHz */
|
||||
HW32_ARRAY_OVERRIDE(0x405C,1), /* Synth: Configure PLL bias */
|
||||
(uint32_t)0x1801F800, /* Synth: Configure PLL bias */
|
||||
HW32_ARRAY_OVERRIDE(0x402C,1), /* Synth: Configure PLL latency */
|
||||
(uint32_t)0x00608402, /* Synth: Configure PLL latency */
|
||||
(uint32_t)0x02010403, /* Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering */
|
||||
HW32_ARRAY_OVERRIDE(0x4034,1), /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x177F0408, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x38000463, /* Synth: Configure extra PLL filtering */
|
||||
/* override_phy_ble_1mbps.xml */
|
||||
(uint32_t)0x013800C3, /* Tx: Configure symbol shape for BLE frequency deviation requirements */
|
||||
HW_REG_OVERRIDE(0x6088, 0x0045), /* Rx: Configure AGC reference level */
|
||||
/* Tx: Configure pilot tone length to ensure stable frequency */
|
||||
HW_REG_OVERRIDE(0x52AC, 0x0360), /* before start of packet */
|
||||
(uint32_t)0x01AD02A3, /* Tx: Compensate timing offset to match new pilot tone setting */
|
||||
(uint32_t)0x01680263, /* Tx: Compensate timing offset to match new pilot tone setting */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_RADIO_SETUP: Radio Setup Command for Pre-Defined Schemes */
|
||||
rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup =
|
||||
{
|
||||
.commandNo = CMD_RADIO_SETUP,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.mode = 0x00,
|
||||
.__dummy0 = 0x00,
|
||||
.config.frontEndMode = 0x0,
|
||||
.config.biasMode = 0x0,
|
||||
.config.analogCfgMode = 0x0,
|
||||
.config.bNoFsPowerUp = 0x0,
|
||||
.txPower = 0x9330,
|
||||
.pRegOverride = rf_ble_overrides,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Structure for CMD_BLE_ADV_NC.pParams */
|
||||
rfc_bleAdvPar_t rf_ble_adv_par =
|
||||
{
|
||||
.pRxQ = 0,
|
||||
.rxConfig.bAutoFlushIgnored = 0x0,
|
||||
.rxConfig.bAutoFlushCrcErr = 0x0,
|
||||
.rxConfig.bAutoFlushEmpty = 0x0,
|
||||
.rxConfig.bIncludeLenByte = 0x0,
|
||||
.rxConfig.bIncludeCrc = 0x0,
|
||||
.rxConfig.bAppendRssi = 0x0,
|
||||
.rxConfig.bAppendStatus = 0x0,
|
||||
.rxConfig.bAppendTimestamp = 0x0,
|
||||
.advConfig.advFilterPolicy = 0x0,
|
||||
.advConfig.deviceAddrType = 0x0,
|
||||
.advConfig.peerAddrType = 0x0,
|
||||
.advConfig.bStrictLenFilter = 0x0,
|
||||
.advConfig.rpaMode = 0x0,
|
||||
.advLen = 0x18,
|
||||
.scanRspLen = 0x00,
|
||||
.pAdvData = 0,
|
||||
.pScanRspData = 0,
|
||||
.pDeviceAddress = 0,
|
||||
.pWhiteList = 0,
|
||||
.__dummy0 = 0x0000,
|
||||
.__dummy1 = 0x00,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_BLE_ADV_NC: BLE Non-Connectable Advertiser Command */
|
||||
rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
||||
{
|
||||
.commandNo = CMD_BLE_ADV_NC,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.channel = 0x8C,
|
||||
.whitening.init = 0x51,
|
||||
.whitening.bOverride = 0x1,
|
||||
.pParams = &rf_ble_adv_par,
|
||||
.pOutput = 0,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef BLE_SETTINGS_H_
|
||||
#define BLE_SETTINGS_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
extern RF_Mode rf_ble_mode;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API commands */
|
||||
extern rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup;
|
||||
extern rfc_bleAdvPar_t rf_ble_adv_par;
|
||||
extern rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API Overrides */
|
||||
extern uint32_t rf_ble_overrides[];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* BLE_SETTINGS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-tx-power
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Source file for BLE Beacon TX power tables for CC26x0.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/tx-power.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC2650
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ble_tx_power_table_cc2650[] =
|
||||
{
|
||||
{ -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 6) },
|
||||
{ -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 6) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 6) },
|
||||
{ -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 1, 0, 10) },
|
||||
{ -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 1, 12) },
|
||||
{ -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 1, 1, 14) },
|
||||
{ -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 1, 1, 18) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 1, 1, 24) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 0, 0, 33) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 0, 0, 39) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 0, 0, 45) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(36, 0, 1, 73) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(48, 0, 1, 73) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
tx_power_table_t rf_ble_tx_power_table_empty[] =
|
||||
{
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TX power table, based on which board is used. */
|
||||
#if defined(DEVICE_CC2650)
|
||||
#define TX_POWER_TABLE rf_ble_tx_power_table_cc2650
|
||||
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_ble_tx_power_table_empty
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define symbols for both the TX power table and its size. The TX power
|
||||
* table size is with one less entry by excluding the termination entry.
|
||||
*/
|
||||
tx_power_table_t *const ble_tx_power_table = TX_POWER_TABLE;
|
||||
const size_t ble_tx_power_table_size = (sizeof(TX_POWER_TABLE) / sizeof(TX_POWER_TABLE[0])) - 1;
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,249 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Parameter summary
|
||||
* IEEE Channel: 11
|
||||
* Frequency: 2405 MHz
|
||||
* SFD: 0
|
||||
* Packet Data: 255
|
||||
* Preamble (32 bit): 01010101...
|
||||
* TX Power: 5 dBm
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "sys/cc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_ieee.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "ieee-settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
RF_Mode rf_ieee_mode =
|
||||
{
|
||||
.rfMode = RF_MODE_IEEE_15_4,
|
||||
.cpePatchFxn = &rf_patch_cpe_ieee,
|
||||
.mcePatchFxn = 0,
|
||||
.rfePatchFxn = 0,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* CMD_RADIO_SETUP must be configured with default TX power value
|
||||
* in the .txPower field.
|
||||
*/
|
||||
#define DEFAULT_TX_POWER 0x9330 /* 5 dBm */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_RADIO_SETUP */
|
||||
uint32_t rf_ieee_overrides[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_synth_ieee_15_4.xml */
|
||||
HW_REG_OVERRIDE(0x4038,0x0035), /* Synth: Set recommended RTRIM to 5 */
|
||||
(uint32_t)0x000784A3, /* Synth: Set Fref to 3.43 MHz */
|
||||
(uint32_t)0xA47E0583, /* Synth: Set loop bandwidth after lock to 80 kHz */
|
||||
(uint32_t)0xEAE00603, /* Synth: Set loop bandwidth after lock to 80 kHz */
|
||||
(uint32_t)0x00010623, /* Synth: Set loop bandwidth after lock to 80 kHz */
|
||||
HW32_ARRAY_OVERRIDE(0x405C,1), /* Synth: Configure PLL bias */
|
||||
(uint32_t)0x1801F800, /* Synth: Configure PLL bias */
|
||||
HW32_ARRAY_OVERRIDE(0x402C,1), /* Synth: Configure PLL latency */
|
||||
(uint32_t)0x00608402, /* Synth: Configure PLL latency */
|
||||
(uint32_t)0x02010403, /* Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering */
|
||||
HW32_ARRAY_OVERRIDE(0x4034,1), /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x177F0408, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x38000463, /* Synth: Configure extra PLL filtering */
|
||||
/* override_phy_ieee_15_4.xml */
|
||||
(uint32_t)0x05000243, /* Synth: Increase synth programming timeout */
|
||||
(uint32_t)0x002082C3, /* Rx: Adjust Rx FIFO threshold to avoid overflow */
|
||||
/* override_frontend_id.xml */
|
||||
(uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB */
|
||||
(uint32_t)0x000F8883, /* Rx: Configure LNA bias current trim offset */
|
||||
HW_REG_OVERRIDE(0x50DC,0x002B), /* Rx: Adjust AGC DC filter */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_RADIO_SETUP: Radio Setup Command for Pre-Defined Schemes */
|
||||
rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup =
|
||||
{
|
||||
.commandNo = CMD_RADIO_SETUP,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.mode = 0x01,
|
||||
.__dummy0 = 0x00,
|
||||
.config.frontEndMode = 0x0,
|
||||
.config.biasMode = 0x0,
|
||||
.config.analogCfgMode = 0x0,
|
||||
.config.bNoFsPowerUp = 0x0,
|
||||
.txPower = DEFAULT_TX_POWER, /* 5 dBm default */
|
||||
.pRegOverride = rf_ieee_overrides,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_FS: Frequency Synthesizer Programming Command */
|
||||
rfc_CMD_FS_t rf_cmd_ieee_fs =
|
||||
{
|
||||
.commandNo = CMD_FS,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.frequency = 0x0965, /* set by driver */
|
||||
.fractFreq = 0x0000, /* set by driver */
|
||||
.synthConf.bTxMode = 0x1,
|
||||
.synthConf.refFreq = 0x0,
|
||||
.__dummy0 = 0x00,
|
||||
.__dummy1 = 0x00,
|
||||
.__dummy2 = 0x00,
|
||||
.__dummy3 = 0x0000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_IEEE_TX: IEEE 802.15.4 Transmit Command */
|
||||
rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx =
|
||||
{
|
||||
.commandNo = CMD_IEEE_TX,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.txOpt.bIncludePhyHdr = 0x0,
|
||||
.txOpt.bIncludeCrc = 0x0,
|
||||
.txOpt.payloadLenMsb = 0x0,
|
||||
.payloadLen = 0x0, /* set by driver */
|
||||
.pPayload = 0, /* set by driver */
|
||||
.timeStamp = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_IEEE_RX: IEEE 802.15.4 Receive Command */
|
||||
rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx =
|
||||
{
|
||||
.commandNo = CMD_IEEE_RX,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.channel = 0x00, /* set by driver */
|
||||
.rxConfig.bAutoFlushCrc = 0x1,
|
||||
.rxConfig.bAutoFlushIgn = 0x1,
|
||||
.rxConfig.bIncludePhyHdr = 0x0,
|
||||
.rxConfig.bIncludeCrc = 0x1,
|
||||
.rxConfig.bAppendRssi = 0x1,
|
||||
.rxConfig.bAppendCorrCrc = 0x1,
|
||||
.rxConfig.bAppendSrcInd = 0x0,
|
||||
.rxConfig.bAppendTimestamp = 0x1,
|
||||
.pRxQ = 0, /* set by driver */
|
||||
.pOutput = 0, /* set by driver */
|
||||
.frameFiltOpt.frameFiltEn = 0x0, /* set by driver */
|
||||
.frameFiltOpt.frameFiltStop = 0x1,
|
||||
.frameFiltOpt.autoAckEn = 0x0, /* set by driver */
|
||||
.frameFiltOpt.slottedAckEn = 0x0,
|
||||
.frameFiltOpt.autoPendEn = 0x0,
|
||||
.frameFiltOpt.defaultPend = 0x0,
|
||||
.frameFiltOpt.bPendDataReqOnly = 0x0,
|
||||
.frameFiltOpt.bPanCoord = 0x0,
|
||||
.frameFiltOpt.maxFrameVersion = 0x2,
|
||||
.frameFiltOpt.fcfReservedMask = 0x0,
|
||||
.frameFiltOpt.modifyFtFilter = 0x0,
|
||||
.frameFiltOpt.bStrictLenFilter = 0x0,
|
||||
.frameTypes.bAcceptFt0Beacon = 0x1,
|
||||
.frameTypes.bAcceptFt1Data = 0x1,
|
||||
.frameTypes.bAcceptFt2Ack = 0x1,
|
||||
.frameTypes.bAcceptFt3MacCmd = 0x1,
|
||||
.frameTypes.bAcceptFt4Reserved = 0x1,
|
||||
.frameTypes.bAcceptFt5Reserved = 0x1,
|
||||
.frameTypes.bAcceptFt6Reserved = 0x1,
|
||||
.frameTypes.bAcceptFt7Reserved = 0x1,
|
||||
.ccaOpt.ccaEnEnergy = 0x1,
|
||||
.ccaOpt.ccaEnCorr = 0x1,
|
||||
.ccaOpt.ccaEnSync = 0x1,
|
||||
.ccaOpt.ccaCorrOp = 0x1,
|
||||
.ccaOpt.ccaSyncOp = 0x0,
|
||||
.ccaOpt.ccaCorrThr = 0x3,
|
||||
.ccaRssiThr = 0x0, /* set by driver */
|
||||
.__dummy0 = 0x00,
|
||||
.numExtEntries = 0x00,
|
||||
.numShortEntries = 0x00,
|
||||
.pExtEntryList = 0,
|
||||
.pShortEntryList = 0,
|
||||
.localExtAddr = 0x0, /* set by driver */
|
||||
.localShortAddr = 0x0, /* set by driver */
|
||||
.localPanID = 0x0000,
|
||||
.__dummy1 = 0x000000,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_IEEE_RX_ACK: IEEE 802.15.4 Receive ACK Command */
|
||||
rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack =
|
||||
{
|
||||
.commandNo = CMD_IEEE_RX_ACK,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.seqNo = 0x0,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef IEEE_SETTINGS_H_
|
||||
#define IEEE_SETTINGS_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki-conf.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ieee_mailbox.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
extern RF_Mode rf_ieee_mode;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API commands */
|
||||
extern rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup;
|
||||
extern rfc_CMD_FS_t rf_cmd_ieee_fs;
|
||||
extern rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx;
|
||||
extern rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx;
|
||||
extern rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API Overrides */
|
||||
extern uint32_t rf_ieee_overrides[];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* IEEE_SETTINGS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-tx-power
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Source file for IEEE-mode TX power tables for CC26x0.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/tx-power.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC2650
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ieee_tx_power_table_cc2650[] =
|
||||
{
|
||||
{ -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 6) },
|
||||
{ -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 6) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 6) },
|
||||
{ -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 1, 0, 10) },
|
||||
{ -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 1, 12) },
|
||||
{ -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 1, 1, 14) },
|
||||
{ -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 1, 1, 18) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 1, 1, 24) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 0, 0, 33) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 0, 0, 39) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 0, 0, 45) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(36, 0, 1, 73) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(48, 0, 1, 73) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
tx_power_table_t rf_ieee_tx_power_table_empty[] =
|
||||
{
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Only define the symbols if Prop-mode is selected */
|
||||
#if (RF_MODE == RF_MODE_2_4_GHZ)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TX power table, based on which board is used. */
|
||||
#if defined(DEVICE_CC2650)
|
||||
#define TX_POWER_TABLE rf_ieee_tx_power_table_cc2650
|
||||
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_ieee_tx_power_table_empty
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define symbols for both the TX power table and its size. The TX power
|
||||
* table size is with one less entry by excluding the termination entry.
|
||||
*/
|
||||
tx_power_table_t *const rf_tx_power_table = TX_POWER_TABLE;
|
||||
const size_t rf_tx_power_table_size = (sizeof(TX_POWER_TABLE) / sizeof(TX_POWER_TABLE[0])) - 1;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_MODE */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Parameter summary
|
||||
* Adv. Address: 010203040506
|
||||
* Adv. Data: dummy
|
||||
* BLE Channel: 17
|
||||
* Extended Header: 09 09 010203040506 babe
|
||||
* Frequency: 2440 MHz
|
||||
* PDU Payload length:: 30
|
||||
* TX Power: 5 dBm
|
||||
* Whitening: true
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "sys/cc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_bt5.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_bt5.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_bt5.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "ble-settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
RF_Mode rf_ble_mode =
|
||||
{
|
||||
.rfMode = RF_MODE_AUTO,
|
||||
.cpePatchFxn = &rf_patch_cpe_bt5,
|
||||
.mcePatchFxn = &rf_patch_mce_bt5,
|
||||
.rfePatchFxn = &rf_patch_rfe_bt5,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_BLE5_RADIO_SETUP */
|
||||
uint32_t rf_ble_overrides_common[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_ble5_setup_override_common.xml */
|
||||
(uint32_t)0x02400403, /* Synth: Use 48 MHz crystal, enable extra PLL filtering */
|
||||
(uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x00088433, /* Synth: Configure synth hardware */
|
||||
(uint32_t)0x00038793, /* Synth: Set minimum RTRIM to 3 */
|
||||
HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x1C0C0618, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC00401A1, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00010101, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC0040141, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00214AD3, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x02980243, /* Synth: Decrease synth programming time-out (0x0298 RAT ticks = 166 us) */
|
||||
/* DC/DC regulator: */
|
||||
/* In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0x00038883, /* Rx: Set LNA bias current offset to adjust +3 (default: 0) */
|
||||
(uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB (default: 0) */
|
||||
(uint32_t)0x01080263, /* Bluetooth 5: Compensate for reduced pilot tone length */
|
||||
(uint32_t)0x08E90AA3, /* Bluetooth 5: Compensate for reduced pilot tone length */
|
||||
(uint32_t)0x00068BA3, /* Bluetooth 5: Compensate for reduced pilot tone length */
|
||||
/* Bluetooth 5: Set correct total clock accuracy for received AuxPtr */
|
||||
(uint32_t)0x0E490C83, /* assuming local sleep clock of 50 ppm */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_BLE5_RADIO_SETUP */
|
||||
uint32_t rf_ble_overrides_1mbps[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_ble5_setup_override_1mbps.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,0,1,0,0), /* PHY: Use MCE RAM patch (mode 0), RFE RAM patch (mode 0) */
|
||||
HW_REG_OVERRIDE(0x5320,0x0240), /* Bluetooth 5: Reduce pilot tone length */
|
||||
(uint32_t)0x013302A3, /* Bluetooth 5: Compensate for reduced pilot tone length */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_BLE5_RADIO_SETUP */
|
||||
uint32_t rf_ble_overrides_2mbps[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_ble5_setup_override_2mbps.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,2,1,0,2), /* PHY: Use MCE RAM patch (mode 2), RFE RAM patch (mode 2) */
|
||||
HW_REG_OVERRIDE(0x5320,0x0240), /* Bluetooth 5: Reduce pilot tone length */
|
||||
(uint32_t)0x00D102A3, /* Bluetooth 5: Compensate for reduced pilot tone length */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_BLE5_RADIO_SETUP */
|
||||
uint32_t rf_ble_overrides_coded[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_ble5_setup_override_coded.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,1,1,0,1), /* PHY: Use MCE RAM patch (mode 1), RFE RAM patch (mode 1) */
|
||||
HW_REG_OVERRIDE(0x5320,0x0240), /* Bluetooth 5: Reduce pilot tone length */
|
||||
(uint32_t)0x078902A3, /* Bluetooth 5: Compensate for reduced pilot tone length */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_BLE5_RADIO_SETUP: Bluetooth 5 Radio Setup Command for all PHYs */
|
||||
rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup =
|
||||
{
|
||||
.commandNo = CMD_BLE5_RADIO_SETUP,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.defaultPhy.mainMode = 0x0,
|
||||
.defaultPhy.coding = 0x0,
|
||||
.loDivider = 0x00,
|
||||
.config.frontEndMode = 0x0,
|
||||
.config.biasMode = 0x0,
|
||||
.config.analogCfgMode = 0x0,
|
||||
.config.bNoFsPowerUp = 0x0,
|
||||
.txPower = 0x941E,
|
||||
.pRegOverrideCommon = rf_ble_overrides_common,
|
||||
.pRegOverride1Mbps = rf_ble_overrides_1mbps,
|
||||
.pRegOverride2Mbps = rf_ble_overrides_2mbps,
|
||||
.pRegOverrideCoded = rf_ble_overrides_coded,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Structure for CMD_BLE5_ADV_NC.pParams */
|
||||
rfc_bleAdvPar_t rf_ble_adv_par =
|
||||
{
|
||||
.pRxQ = 0,
|
||||
.rxConfig.bAutoFlushIgnored = 0x0,
|
||||
.rxConfig.bAutoFlushCrcErr = 0x0,
|
||||
.rxConfig.bAutoFlushEmpty = 0x0,
|
||||
.rxConfig.bIncludeLenByte = 0x0,
|
||||
.rxConfig.bIncludeCrc = 0x0,
|
||||
.rxConfig.bAppendRssi = 0x0,
|
||||
.rxConfig.bAppendStatus = 0x0,
|
||||
.rxConfig.bAppendTimestamp = 0x0,
|
||||
.advConfig.advFilterPolicy = 0x0,
|
||||
.advConfig.deviceAddrType = 0x0,
|
||||
.advConfig.peerAddrType = 0x0,
|
||||
.advConfig.bStrictLenFilter = 0x0,
|
||||
.advConfig.rpaMode = 0x0,
|
||||
.advLen = 0x18,
|
||||
.scanRspLen = 0x00,
|
||||
.pAdvData = 0,
|
||||
.pScanRspData = 0,
|
||||
.pDeviceAddress = 0,
|
||||
.pWhiteList = 0,
|
||||
.__dummy0 = 0x0000,
|
||||
.__dummy1 = 0x00,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_BLE5_ADV_NC: Bluetooth 5 Non-Connectable Advertiser Command */
|
||||
rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
||||
{
|
||||
.commandNo = 0x182D,
|
||||
.status = 0x0000,
|
||||
.pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = 0x0,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = 0x1,
|
||||
.condition.nSkip = 0x0,
|
||||
.channel = 0x8C,
|
||||
.whitening.init = 0x51,
|
||||
.whitening.bOverride = 0x1,
|
||||
.phyMode.mainMode = 0x0,
|
||||
.phyMode.coding = 0x0,
|
||||
.rangeDelay = 0x00,
|
||||
.txPower = 0x0000,
|
||||
.pParams = &rf_ble_adv_par,
|
||||
.pOutput = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
|
||||
.tx20Power = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef BLE_SETTINGS_H_
|
||||
#define BLE_SETTINGS_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
extern RF_Mode rf_ble_mode;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API commands */
|
||||
extern rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup;
|
||||
extern rfc_bleAdvPar_t rf_ble_adv_par;
|
||||
extern rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API Overrides */
|
||||
extern uint32_t rf_ble_overrides_common[];
|
||||
extern uint32_t rf_ble_overrides_1mbps[];
|
||||
extern uint32_t rf_ble_overrides_2mbps[];
|
||||
extern uint32_t rf_ble_overrides_coded[];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* BLE_SETTINGS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-tx-power
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Source file for BLE Beacon TX power tables for CC26x2.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/tx-power.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC2652R
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ble_tx_power_table_cc2652r[] =
|
||||
{
|
||||
{ -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 3) },
|
||||
{ -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 3) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 2, 0, 6) },
|
||||
{ -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 2, 0, 8) },
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) },
|
||||
{ -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) },
|
||||
{ -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) },
|
||||
{ -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) },
|
||||
{ -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
tx_power_table_t rf_ble_tx_power_table_empty[] =
|
||||
{
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TX power table, based on which board is used. */
|
||||
#if defined(DEVICE_CC2652R)
|
||||
#define TX_POWER_TABLE rf_ble_tx_power_table_cc2652r
|
||||
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_ble_tx_power_table_empty
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define symbols for both the TX power table and its size. The TX power
|
||||
* table size is with one less entry by excluding the termination entry.
|
||||
*/
|
||||
tx_power_table_t *const ble_tx_power_table = TX_POWER_TABLE;
|
||||
const size_t ble_tx_power_table_size = (sizeof(TX_POWER_TABLE) / sizeof(TX_POWER_TABLE[0])) - 1;
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Parameter summary
|
||||
* IEEE Channel: 11
|
||||
* Frequency: 2405 MHz
|
||||
* SFD: 0
|
||||
* Packet Data: 255
|
||||
* Preamble (32 bit): 01010101...
|
||||
* TX Power: 5 dBm
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "sys/cc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_ieee_802_15_4.h)
|
||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_ieee_802_15_4.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "ieee-settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
RF_Mode rf_ieee_mode =
|
||||
{
|
||||
.rfMode = RF_MODE_AUTO,
|
||||
.cpePatchFxn = &rf_patch_cpe_ieee_802_15_4,
|
||||
.mcePatchFxn = &rf_patch_mce_ieee_802_15_4,
|
||||
.rfePatchFxn = 0,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* CMD_RADIO_SETUP must be configured with default TX power value
|
||||
* in the .txPower field.
|
||||
*/
|
||||
#define DEFAULT_TX_POWER 0x941E /* 5 dBm */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Overrides for CMD_RADIO_SETUP */
|
||||
uint32_t rf_ieee_overrides[] CC_ALIGN(4) =
|
||||
{
|
||||
/* override_ieee_802_15_4.xml */
|
||||
MCE_RFE_OVERRIDE(1,0,0,0,1,0), /* PHY: Use MCE RAM patch, RFE ROM bank 1 */
|
||||
(uint32_t)0x02400403, /* Synth: Use 48 MHz crystal, enable extra PLL filtering */
|
||||
(uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */
|
||||
(uint32_t)0x00088433, /* Synth: Configure synth hardware */
|
||||
(uint32_t)0x00038793, /* Synth: Set minimum RTRIM to 3 */
|
||||
HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x1C0C0618, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC00401A1, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00010101, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0xC0040141, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x00214AD3, /* Synth: Configure faster calibration */
|
||||
(uint32_t)0x02980243, /* Synth: Decrease synth programming time-out (0x0298 RAT ticks = 166 us) */
|
||||
/* DC/DC regulator: */
|
||||
/* In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */
|
||||
(uint32_t)0x000F8883, /* Rx: Set LNA bias current offset to +15 to saturate trim to max (default: 0) */
|
||||
(uint32_t)0xFFFFFFFF,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_RADIO_SETUP: Radio Setup Command for Pre-Defined Schemes */
|
||||
rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup =
|
||||
{
|
||||
.commandNo = CMD_RADIO_SETUP,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.mode = 0x01,
|
||||
.loDivider = 0x00,
|
||||
.config.frontEndMode = 0x0,
|
||||
.config.biasMode = 0x0,
|
||||
.config.analogCfgMode = 0x0,
|
||||
.config.bNoFsPowerUp = 0x0,
|
||||
.txPower = DEFAULT_TX_POWER,
|
||||
.pRegOverride = rf_ieee_overrides,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_FS: Frequency Synthesizer Programming Command */
|
||||
rfc_CMD_FS_t rf_cmd_ieee_fs =
|
||||
{
|
||||
.commandNo = CMD_FS,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.frequency = 0x0965, /* set by driver */
|
||||
.fractFreq = 0x0000, /* set by driver */
|
||||
.synthConf.bTxMode = 0x1,
|
||||
.synthConf.refFreq = 0x0,
|
||||
.__dummy0 = 0x00,
|
||||
.__dummy1 = 0x00,
|
||||
.__dummy2 = 0x00,
|
||||
.__dummy3 = 0x0000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_IEEE_TX: IEEE 802.15.4 Transmit Command */
|
||||
rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx =
|
||||
{
|
||||
.commandNo = CMD_IEEE_TX,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.txOpt.bIncludePhyHdr = 0x0,
|
||||
.txOpt.bIncludeCrc = 0x0,
|
||||
.txOpt.payloadLenMsb = 0x0,
|
||||
.payloadLen = 0x0, /* set by driver */
|
||||
.pPayload = 0, /* set by driver */
|
||||
.timeStamp = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_IEEE_RX: IEEE 802.15.4 Receive Command */
|
||||
rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx =
|
||||
{
|
||||
.commandNo = CMD_IEEE_RX,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.channel = 0x00, /* set by driver */
|
||||
.rxConfig.bAutoFlushCrc = 0x1,
|
||||
.rxConfig.bAutoFlushIgn = 0x1,
|
||||
.rxConfig.bIncludePhyHdr = 0x0,
|
||||
.rxConfig.bIncludeCrc = 0x1,
|
||||
.rxConfig.bAppendRssi = 0x1,
|
||||
.rxConfig.bAppendCorrCrc = 0x1,
|
||||
.rxConfig.bAppendSrcInd = 0x0,
|
||||
.rxConfig.bAppendTimestamp = 0x1,
|
||||
.pRxQ = 0, /* set by driver */
|
||||
.pOutput = 0, /* set by driver */
|
||||
.frameFiltOpt.frameFiltEn = 0x0, /* set by driver */
|
||||
.frameFiltOpt.frameFiltStop = 0x1,
|
||||
.frameFiltOpt.autoAckEn = 0x0, /* set by driver */
|
||||
.frameFiltOpt.slottedAckEn = 0x0,
|
||||
.frameFiltOpt.autoPendEn = 0x0,
|
||||
.frameFiltOpt.defaultPend = 0x0,
|
||||
.frameFiltOpt.bPendDataReqOnly = 0x0,
|
||||
.frameFiltOpt.bPanCoord = 0x0,
|
||||
.frameFiltOpt.maxFrameVersion = 0x2,
|
||||
.frameFiltOpt.fcfReservedMask = 0x0,
|
||||
.frameFiltOpt.modifyFtFilter = 0x0,
|
||||
.frameFiltOpt.bStrictLenFilter = 0x0,
|
||||
.frameTypes.bAcceptFt0Beacon = 0x1,
|
||||
.frameTypes.bAcceptFt1Data = 0x1,
|
||||
.frameTypes.bAcceptFt2Ack = 0x1,
|
||||
.frameTypes.bAcceptFt3MacCmd = 0x1,
|
||||
.frameTypes.bAcceptFt4Reserved = 0x1,
|
||||
.frameTypes.bAcceptFt5Reserved = 0x1,
|
||||
.frameTypes.bAcceptFt6Reserved = 0x1,
|
||||
.frameTypes.bAcceptFt7Reserved = 0x1,
|
||||
.ccaOpt.ccaEnEnergy = 0x1,
|
||||
.ccaOpt.ccaEnCorr = 0x1,
|
||||
.ccaOpt.ccaEnSync = 0x1,
|
||||
.ccaOpt.ccaCorrOp = 0x1,
|
||||
.ccaOpt.ccaSyncOp = 0x0,
|
||||
.ccaOpt.ccaCorrThr = 0x3,
|
||||
.ccaRssiThr = 0x0, /* set by driver */
|
||||
.__dummy0 = 0x00,
|
||||
.numExtEntries = 0x00,
|
||||
.numShortEntries = 0x00,
|
||||
.pExtEntryList = 0,
|
||||
.pShortEntryList = 0,
|
||||
.localExtAddr = 0x0, /* set by driver */
|
||||
.localShortAddr = 0x0, /* set by driver */
|
||||
.localPanID = 0x0000,
|
||||
.__dummy1 = 0x000000,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CMD_IEEE_RX_ACK: IEEE 802.15.4 Receive ACK Command */
|
||||
rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack =
|
||||
{
|
||||
.commandNo = CMD_IEEE_RX_ACK,
|
||||
.status = IDLE,
|
||||
.pNextOp = 0,
|
||||
.startTime = 0x00000000,
|
||||
.startTrigger.triggerType = TRIG_NOW,
|
||||
.startTrigger.bEnaCmd = 0x0,
|
||||
.startTrigger.triggerNo = 0x0,
|
||||
.startTrigger.pastTrig = 0x0,
|
||||
.condition.rule = COND_NEVER,
|
||||
.condition.nSkip = 0x0,
|
||||
.seqNo = 0x0,
|
||||
.endTrigger.triggerType = TRIG_NEVER,
|
||||
.endTrigger.bEnaCmd = 0x0,
|
||||
.endTrigger.triggerNo = 0x0,
|
||||
.endTrigger.pastTrig = 0x0,
|
||||
.endTime = 0x00000000,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef IEEE_SETTINGS_H_
|
||||
#define IEEE_SETTINGS_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki-conf.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ieee_mailbox.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TI-RTOS RF Mode Object */
|
||||
extern RF_Mode rf_ieee_mode;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API commands */
|
||||
extern rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup;
|
||||
extern rfc_CMD_FS_t rf_cmd_ieee_fs;
|
||||
extern rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx;
|
||||
extern rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx;
|
||||
extern rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core API Overrides */
|
||||
extern uint32_t rf_ieee_overrides[];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* IEEE_SETTINGS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-tx-power
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Source file for IEEE-mode TX power tables for CC26x2.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/tx-power.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* TX Power table for CC2652R
|
||||
* The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments:
|
||||
* RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient)
|
||||
* See the Technical Reference Manual for further details about the "txPower" Command field.
|
||||
* The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise.
|
||||
*/
|
||||
tx_power_table_t rf_ieee_tx_power_table_cc2652r[] =
|
||||
{
|
||||
{ -21, RF_TxPowerTable_DEFAULT_PA_ENTRY(7, 3, 0, 3) },
|
||||
{ -18, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 3) },
|
||||
{ -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 100) },
|
||||
{ -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(40, 2, 0, 8) },
|
||||
{ -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) },
|
||||
{ -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) },
|
||||
{ -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) },
|
||||
{ -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) },
|
||||
{ -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) },
|
||||
{ 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) },
|
||||
{ 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) },
|
||||
{ 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) },
|
||||
{ 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) },
|
||||
{ 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) },
|
||||
{ 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) },
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
tx_power_table_t rf_ieee_tx_power_table_empty[] =
|
||||
{
|
||||
RF_TxPowerTable_TERMINATION_ENTRY
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Only define the symbols if Prop-mode is selected */
|
||||
#if (RF_MODE == RF_MODE_2_4_GHZ)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TX power table, based on which board is used. */
|
||||
#if defined(DEVICE_CC2652R)
|
||||
#define TX_POWER_TABLE rf_ieee_tx_power_table_cc2652r
|
||||
|
||||
#else
|
||||
#define TX_POWER_TABLE rf_ieee_tx_power_table_empty
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define symbols for both the TX power table and its size. The TX power
|
||||
* table size is with one less entry by excluding the termination entry.
|
||||
*/
|
||||
tx_power_table_t *const rf_tx_power_table = TX_POWER_TABLE;
|
||||
const size_t rf_tx_power_table_size = (sizeof(TX_POWER_TABLE) / sizeof(TX_POWER_TABLE[0])) - 1;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_MODE */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Michael Spoerk
|
||||
* 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 cc13xx-cc26xx-rf-ble-addr
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the CC13xx/CC26xx IEEE addresses driver.
|
||||
* \author
|
||||
* Michael Spoerk <mi.spoerk@gmail.com>
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/ble-hal.h"
|
||||
#include "net/linkaddr.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)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint8_t *
|
||||
ble_addr_ptr(void)
|
||||
{
|
||||
volatile const uint8_t *const primary = (uint8_t *)BLE_MAC_PRIMARY_ADDRESS;
|
||||
volatile const uint8_t *const secondary = (uint8_t *)BLE_MAC_SECONDARY_ADDRESS;
|
||||
|
||||
/*
|
||||
* Reading from primary location...
|
||||
* ...unless we can find a byte != 0xFF in secondary
|
||||
*
|
||||
* Intentionally checking all bytes here instead of len, because we
|
||||
* are checking validity of the entire address irrespective of the
|
||||
* actual number of bytes the caller wants to copy over.
|
||||
*/
|
||||
size_t i;
|
||||
for(i = 0; i < BLE_ADDR_SIZE; i++) {
|
||||
if(secondary[i] != 0xFF) {
|
||||
/* A byte in secondary is not 0xFF. Use secondary address. */
|
||||
return (uint8_t *)secondary;
|
||||
}
|
||||
}
|
||||
|
||||
/* All bytes in secondary is 0xFF. Use primary address. */
|
||||
return (uint8_t *)primary;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
ble_addr_cpy(uint8_t *dst)
|
||||
{
|
||||
if(!dst) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
volatile const uint8_t *const ble_addr = ble_addr_ptr();
|
||||
|
||||
/*
|
||||
* We have chosen what address to read the BLE address from. Do so,
|
||||
* inverting byte order
|
||||
*/
|
||||
size_t i;
|
||||
for(i = 0; i < BLE_ADDR_SIZE; i++) {
|
||||
dst[i] = ble_addr[BLE_ADDR_SIZE - 1 - i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
ble_addr_to_eui64(uint8_t *dst, uint8_t *src)
|
||||
{
|
||||
if(!dst || !src) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(dst, src, 3);
|
||||
dst[3] = 0xFF;
|
||||
dst[4] = 0xFE;
|
||||
memcpy(&dst[5], &src[3], 3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
ble_addr_to_eui64_cpy(uint8_t *dst)
|
||||
{
|
||||
if(!dst) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int res;
|
||||
uint8_t ble_addr[BLE_ADDR_SIZE];
|
||||
|
||||
res = ble_addr_cpy(ble_addr);
|
||||
if(res) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ble_addr_to_eui64(dst, ble_addr);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Michael Spoerk
|
||||
* 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 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>
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef BLE_ADDR_H_
|
||||
#define BLE_ADDR_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
|
||||
#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);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Copy the node's factory BLE address to a destination memory area
|
||||
* \param dst A pointer to the destination area where the BLE address is to be
|
||||
* written
|
||||
* \return 0 : Returned successfully
|
||||
* -1 : Returned with error
|
||||
*
|
||||
* This function will copy 6 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.
|
||||
*/
|
||||
int ble_addr_cpy(uint8_t *dst);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Copy the node's BLE address to a destination memory area and converts
|
||||
* it into a EUI64 address in the process
|
||||
* \param dst A pointer to the destination area where the EUI64 address is to be
|
||||
* written
|
||||
* \param src A pointer to the BLE address that is to be copied
|
||||
* \return 0 : Returned successfully
|
||||
* -1 : Returned with error
|
||||
*/
|
||||
int ble_addr_to_eui64(uint8_t *dst, uint8_t *src);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Copy the node's EUI64 address that is based on its factory BLE address
|
||||
* to a destination memory area
|
||||
* \param dst A pointer to the destination area where the EUI64 address is to be
|
||||
* written
|
||||
* \return 0 : Returned successfully
|
||||
* -1 : Returned with error
|
||||
*/
|
||||
int ble_addr_to_eui64_cpy(uint8_t *dst);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* BLE_ADDR_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,359 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-ble
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation for the CC13xx/CC26xx BLE Beacon Daemon.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "sys/cc.h"
|
||||
#include "sys/clock.h"
|
||||
#include "sys/etimer.h"
|
||||
#include "sys/process.h"
|
||||
#include "net/linkaddr.h"
|
||||
#include "net/netstack.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/chipinfo.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/sched.h"
|
||||
#include "rf/ble-addr.h"
|
||||
#include "rf/ble-beacond.h"
|
||||
#include "rf/tx-power.h"
|
||||
#include "rf/settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "Radio"
|
||||
#define LOG_LEVEL LOG_LEVEL_NONE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* BLE Advertisement channels. Not to be changed by the user. */
|
||||
typedef enum {
|
||||
BLE_ADV_CHANNEL_37 = (1 << 0),
|
||||
BLE_ADV_CHANNEL_38 = (1 << 1),
|
||||
BLE_ADV_CHANNEL_39 = (1 << 2),
|
||||
|
||||
BLE_ADV_CHANNEL_ALL = (BLE_ADV_CHANNEL_37 |
|
||||
BLE_ADV_CHANNEL_38 |
|
||||
BLE_ADV_CHANNEL_39),
|
||||
} ble_adv_channel_t;
|
||||
|
||||
#define BLE_ADV_CHANNEL_MIN 37
|
||||
#define BLE_ADV_CHANNEL_MAX 39
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Maximum BLE advertisement size. Not to be changed by the user. */
|
||||
#define BLE_ADV_MAX_SIZE 31
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* BLE Intervals: Send a burst of advertisements every BLE_ADV_INTERVAL secs */
|
||||
#define BLE_ADV_INTERVAL (CLOCK_SECOND * 5)
|
||||
#define BLE_ADV_DUTY_CYCLE (CLOCK_SECOND / 10)
|
||||
#define BLE_ADV_MESSAGES 10
|
||||
|
||||
/* BLE Advertisement-related macros */
|
||||
#define BLE_ADV_TYPE_DEVINFO 0x01
|
||||
#define BLE_ADV_TYPE_NAME 0x09
|
||||
#define BLE_ADV_TYPE_MANUFACTURER 0xFF
|
||||
#define BLE_ADV_NAME_BUF_LEN BLE_ADV_MAX_SIZE
|
||||
#define BLE_ADV_PAYLOAD_BUF_LEN 64
|
||||
#define BLE_UUID_SIZE 16
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
/* Outgoing frame buffer */
|
||||
uint8_t tx_buf[BLE_ADV_PAYLOAD_BUF_LEN] CC_ALIGN(4);
|
||||
|
||||
/* Config data */
|
||||
size_t adv_name_len;
|
||||
char adv_name[BLE_ADV_NAME_BUF_LEN];
|
||||
|
||||
/* Indicates whether deamon is active or not */
|
||||
bool is_active;
|
||||
|
||||
/* Periodic timer for sending out BLE advertisements */
|
||||
clock_time_t ble_adv_interval;
|
||||
struct etimer ble_adv_et;
|
||||
|
||||
/* RF driver */
|
||||
RF_Handle rf_handle;
|
||||
} ble_beacond_t;
|
||||
|
||||
static ble_beacond_t ble_beacond;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(ble_beacond_process, "RF BLE Beacon Daemon Process");
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_beacond_init(void)
|
||||
{
|
||||
ble_adv_par.pDeviceAddress = (uint16_t *)ble_addr_ptr();
|
||||
|
||||
RF_Params rf_params;
|
||||
RF_Params_init(&rf_params);
|
||||
|
||||
/* Should immediately turn off radio if possible */
|
||||
rf_params.nInactivityTimeout = 0;
|
||||
|
||||
ble_beacond.rf_handle = ble_open(&rf_params);
|
||||
|
||||
if(ble_beacond.rf_handle == NULL) {
|
||||
return RF_BLE_BEACOND_ERROR;
|
||||
}
|
||||
|
||||
return RF_BLE_BEACOND_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_beacond_config(clock_time_t interval, const char *name)
|
||||
{
|
||||
rf_ble_beacond_result_t res;
|
||||
|
||||
res = RF_BLE_BEACOND_ERROR;
|
||||
|
||||
if(interval > 0) {
|
||||
ble_beacond.ble_adv_interval = interval;
|
||||
|
||||
res = RF_BLE_BEACOND_OK;
|
||||
}
|
||||
|
||||
if(name != NULL) {
|
||||
const size_t name_len = strlen(name);
|
||||
|
||||
if((name_len == 0) || (name_len >= BLE_ADV_NAME_BUF_LEN)) {
|
||||
ble_beacond.adv_name_len = name_len;
|
||||
memcpy(ble_beacond.adv_name, name, name_len);
|
||||
|
||||
res = RF_BLE_BEACOND_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_beacond_start(void)
|
||||
{
|
||||
if(ble_beacond.is_active) {
|
||||
return RF_BLE_BEACOND_OK;
|
||||
}
|
||||
|
||||
ble_beacond.is_active = true;
|
||||
|
||||
process_start(&ble_beacond_process, NULL);
|
||||
|
||||
return RF_BLE_BEACOND_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_beacond_stop(void)
|
||||
{
|
||||
if(!ble_beacond.is_active) {
|
||||
return RF_BLE_BEACOND_OK;
|
||||
}
|
||||
|
||||
ble_beacond.is_active = false;
|
||||
|
||||
process_exit(&ble_beacond_process);
|
||||
|
||||
return RF_BLE_BEACOND_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int8_t
|
||||
rf_ble_is_active(void)
|
||||
{
|
||||
return (int8_t)ble_beacond.is_active;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_set_tx_power(int8_t dbm)
|
||||
{
|
||||
rf_result_t res;
|
||||
|
||||
if(!tx_power_in_range(dbm, ble_tx_power_table, ble_tx_power_table_size)) {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
|
||||
res = rf_set_tx_power(ble_beacond.rf_handle, ble_tx_power_table, dbm);
|
||||
|
||||
return (res == RF_RESULT_OK)
|
||||
? RF_BLE_BEACOND_OK
|
||||
: RF_BLE_BEACOND_ERROR;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int8_t
|
||||
rf_ble_get_tx_power(void)
|
||||
{
|
||||
rf_result_t res;
|
||||
|
||||
int8_t dbm;
|
||||
res = rf_get_tx_power(ble_beacond.rf_handle, ble_tx_power_table, &dbm);
|
||||
|
||||
if(res != RF_RESULT_OK) {
|
||||
return RF_TxPowerTable_INVALID_DBM;
|
||||
}
|
||||
|
||||
return dbm;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static rf_ble_beacond_result_t
|
||||
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) {
|
||||
const uint8_t channel_bv = (1 << (channel - BLE_ADV_CHANNEL_MIN));
|
||||
if((channel_bv & channels_bm) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ble_adv_par.advLen = len;
|
||||
ble_adv_par.pAdvData = data;
|
||||
|
||||
ble_cmd_beacon.channel = channel;
|
||||
|
||||
res = ble_sched_beacon(NULL, 0);
|
||||
|
||||
if(res != RF_RESULT_OK) {
|
||||
return RF_BLE_BEACOND_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return RF_BLE_BEACOND_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(ble_beacond_process, ev, data)
|
||||
{
|
||||
static size_t i;
|
||||
static size_t len;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
while(1) {
|
||||
etimer_set(&ble_beacond.ble_adv_et, ble_beacond.ble_adv_interval);
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&ble_beacond.ble_adv_et) ||
|
||||
(ev == PROCESS_EVENT_EXIT));
|
||||
|
||||
if(ev == PROCESS_EVENT_EXIT) {
|
||||
PROCESS_EXIT();
|
||||
}
|
||||
|
||||
/* Set the adv payload each pass: The device name may have changed */
|
||||
len = 0;
|
||||
|
||||
/* Device info */
|
||||
ble_beacond.tx_buf[len++] = (uint8_t)0x02; /* 2 bytes */
|
||||
ble_beacond.tx_buf[len++] = (uint8_t)BLE_ADV_TYPE_DEVINFO;
|
||||
ble_beacond.tx_buf[len++] = (uint8_t)0x1A; /* LE general discoverable + BR/EDR */
|
||||
ble_beacond.tx_buf[len++] = (uint8_t)ble_beacond.adv_name_len;
|
||||
ble_beacond.tx_buf[len++] = (uint8_t)BLE_ADV_TYPE_NAME;
|
||||
|
||||
memcpy(ble_beacond.tx_buf + len, ble_beacond.adv_name, ble_beacond.adv_name_len);
|
||||
len += ble_beacond.adv_name_len;
|
||||
|
||||
/*
|
||||
* Send BLE_ADV_MESSAGES beacon bursts. Each burst on all three
|
||||
* channels, with a BLE_ADV_DUTY_CYCLE interval between bursts
|
||||
*/
|
||||
ble_beacon_burst(BLE_ADV_CHANNEL_ALL, ble_beacond.tx_buf, len);
|
||||
for(i = 1; i < BLE_ADV_MESSAGES; ++i) {
|
||||
etimer_set(&ble_beacond.ble_adv_et, BLE_ADV_DUTY_CYCLE);
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&ble_beacond.ble_adv_et));
|
||||
|
||||
ble_beacon_burst(BLE_ADV_CHANNEL_ALL, ble_beacond.tx_buf, len);
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#else /* RF_CONF_BLE_BEACON_ENABLE */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_beacond_init(void)
|
||||
{
|
||||
return RF_BLE_BEACOND_DISABLED;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_beacond_config(clock_time_t interval, const char *name)
|
||||
{
|
||||
(void)interval;
|
||||
(void)name;
|
||||
return RF_BLE_BEACOND_DISABLED;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_beacond_start(void)
|
||||
{
|
||||
return RF_BLE_BEACOND_DISABLED;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_beacond_stop(void)
|
||||
{
|
||||
return RF_BLE_BEACOND_DISABLED;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int8_t
|
||||
rf_ble_is_active(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_set_tx_power(int8_t power)
|
||||
{
|
||||
(void)power;
|
||||
return RF_BLE_BEACOND_DISABLED;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int8_t
|
||||
rf_ble_get_tx_power(void)
|
||||
{
|
||||
return ~(int8_t)(0);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_CONF_BLE_BEACON_ENABLE */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-rf-ble CC13xx/CC26xx BLE Beacon Daemon
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* 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 {
|
||||
RF_BLE_BEACOND_OK,
|
||||
RF_BLE_BEACOND_ERROR,
|
||||
RF_BLE_BEACOND_DISABLED,
|
||||
} rf_ble_beacond_result_t;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Initialize the BLE advertisement/beacon daemon
|
||||
*/
|
||||
rf_ble_beacond_result_t rf_ble_beacond_init(void);
|
||||
|
||||
/**
|
||||
* \brief Set the device name to use with the BLE advertisement/beacon daemon
|
||||
* \param interval The interval (ticks) between two consecutive beacon bursts
|
||||
* \param name The device name to advertise
|
||||
*
|
||||
* If name is NULL it will be ignored. If interval==0 it will be ignored. Thus,
|
||||
* this function can be used to configure a single parameter at a time if so
|
||||
* desired.
|
||||
*/
|
||||
rf_ble_beacond_result_t rf_ble_beacond_config(clock_time_t interval, const char *name);
|
||||
|
||||
/**
|
||||
* \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
|
||||
* calling rf_ble_beacond_config(). Otherwise, this function will return an
|
||||
* error.
|
||||
*/
|
||||
rf_ble_beacond_result_t rf_ble_beacond_start(void);
|
||||
|
||||
/**
|
||||
* \brief Stop the BLE advertisement/beacon daemon
|
||||
*/
|
||||
rf_ble_beacond_result_t rf_ble_beacond_stop(void);
|
||||
|
||||
/**
|
||||
* \brief Check whether the BLE beacond is currently active
|
||||
* \retval 1 BLE daemon is active
|
||||
* \retval 0 BLE daemon is inactive
|
||||
* \retval -1 BLE daemon is disabled
|
||||
*/
|
||||
int8_t rf_ble_is_active(void);
|
||||
|
||||
/**
|
||||
* \brief Set TX power for BLE advertisements
|
||||
* \param dbm The 'at least' TX power in dBm, values avove 5 dBm will be ignored
|
||||
*
|
||||
* Set TX power to 'at least' power dBm.
|
||||
* This works with a lookup table. If the value of 'power' does not exist in
|
||||
* the lookup table, TXPOWER will be set to the immediately higher available
|
||||
* value
|
||||
*/
|
||||
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
|
||||
*/
|
||||
int8_t rf_ble_get_tx_power(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_BLE_BEACOND_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-data-queue
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the CC13xx/CC26xx RF data queue.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "sys/cc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_data_entry.h)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/data-queue.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RX buf configuration */
|
||||
#define RX_BUF_CNT RF_CONF_RX_BUF_CNT
|
||||
#define RX_BUF_SIZE RF_CONF_RX_BUF_SIZE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Receive buffer entries with room for 1 IEEE 802.15.4 frame in each */
|
||||
typedef union {
|
||||
data_entry_t data_entry;
|
||||
uint8_t buf[RX_BUF_SIZE];
|
||||
} rx_buf_t CC_ALIGN (4);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
/* RX bufs */
|
||||
rx_buf_t bufs[RX_BUF_CNT];
|
||||
/* RFC data queue object */
|
||||
data_queue_t data_queue;
|
||||
/* Current data entry in use by RF */
|
||||
data_entry_t *curr_entry;
|
||||
/* Size in bytes of length field in data entry */
|
||||
size_t lensz;
|
||||
} rx_data_queue_t;
|
||||
|
||||
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 = &(rx_data_queue.bufs[i].data_entry);
|
||||
|
||||
data_entry->status = DATA_ENTRY_PENDING;
|
||||
data_entry->config.type = DATA_ENTRY_TYPE_GEN;
|
||||
data_entry->config.lenSz = rx_data_queue.lensz;
|
||||
data_entry->length = RX_BUF_SIZE - sizeof(data_entry_t);
|
||||
/* Point to fist entry if this is last entry, else point to next entry */
|
||||
data_entry->pNextEntry = ((i + 1) == RX_BUF_CNT)
|
||||
? rx_data_queue.bufs[0].buf
|
||||
: rx_data_queue.bufs[i + 1].buf;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
rx_bufs_reset(void)
|
||||
{
|
||||
size_t 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 */
|
||||
memset(&(data_entry->data), 0x0, rx_data_queue.lensz);
|
||||
/* Set status to Pending */
|
||||
data_entry->status = DATA_ENTRY_PENDING;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
data_queue_t *
|
||||
data_queue_init(size_t lensz)
|
||||
{
|
||||
rx_data_queue.lensz = lensz;
|
||||
|
||||
/* Initialize RX buffers */
|
||||
rx_bufs_init();
|
||||
|
||||
/* Configure data queue as circular buffer */
|
||||
rx_data_queue.data_queue.pCurrEntry = rx_data_queue.bufs[0].buf;
|
||||
rx_data_queue.data_queue.pLastEntry = NULL;
|
||||
|
||||
/* Set current read pointer to first element */
|
||||
rx_data_queue.curr_entry = &(rx_data_queue.bufs[0].data_entry);
|
||||
|
||||
return &rx_data_queue.data_queue;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
data_queue_reset(void)
|
||||
{
|
||||
rx_bufs_reset();
|
||||
|
||||
/* Only need to reconfigure pCurrEntry */
|
||||
rx_data_queue.data_queue.pCurrEntry = rx_data_queue.bufs[0].buf;
|
||||
|
||||
/* Set current read pointer to first element */
|
||||
rx_data_queue.curr_entry = &(rx_data_queue.bufs[0].data_entry);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
data_entry_t *
|
||||
data_queue_current_entry(void)
|
||||
{
|
||||
return rx_data_queue.curr_entry;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
data_queue_release_entry(void)
|
||||
{
|
||||
data_entry_t *const curr_entry = rx_data_queue.curr_entry;
|
||||
uint8_t *const frame_ptr = (uint8_t *)&(curr_entry->data);
|
||||
|
||||
/* Clear length bytes */
|
||||
memset(frame_ptr, 0x0, rx_data_queue.lensz);
|
||||
/* Set status to Pending */
|
||||
curr_entry->status = DATA_ENTRY_PENDING;
|
||||
|
||||
/* Move current entry to the next entry */
|
||||
rx_data_queue.curr_entry = (data_entry_t *)(curr_entry->pNextEntry);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* 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 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_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_data_entry.h)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stddef.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
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);
|
||||
data_entry_t *data_queue_current_entry(void);
|
||||
void data_queue_release_entry(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_DATA_QUEUE_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf
|
||||
* @{
|
||||
*
|
||||
* \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.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef DOT_15_4G_H_
|
||||
#define DOT_15_4G_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* IEEE 802.15.4g frequency band identifiers (Table 68f) */
|
||||
#define DOT_15_4G_FREQ_BAND_169 0 /* 169.400–169.475 (Europe) - 169 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_450 1 /* 450–470 (US FCC Part 22/90) - 450 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_470 2 /* 470–510 (China) - 470 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_780 3 /* 779–787 (China) - 780 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_863 4 /* 863–870 (Europe) - 863 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_896 5 /* 896–901 (US FCC Part 90) - 896 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_901 6 /* 901–902 (US FCC Part 24) - 901 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_915 7 /* 902–928 (US) - 915 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_917 8 /* 917–923.5 (Korea) - 917 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_920 9 /* 920–928 (Japan) - 920 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_928 10 /* 928–960 (US, non-contiguous) - 928 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_950 11 /* 950–958 (Japan) - 950 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_1427 12 /* 1427–1518 (US and Canada, non-contiguous) - 1427 MHz band */
|
||||
#define DOT_15_4G_FREQ_BAND_2450 13 /* 2400–2483.5 2450 MHz band */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Default band selection to band 4 - 863MHz */
|
||||
#ifdef DOT_15_4G_CONF_FREQ_BAND_ID
|
||||
#define DOT_15_4G_FREQ_BAND_ID DOT_15_4G_CONF_FREQ_BAND_ID
|
||||
#else
|
||||
#define DOT_15_4G_FREQ_BAND_ID DOT_15_4G_FREQ_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_FREQ is specified here in KHz
|
||||
*/
|
||||
#if (DOT_15_4G_FREQ_BAND_ID == DOT_15_4G_FREQ_BAND_470)
|
||||
#define DOT_15_4G_CHAN_MIN 0
|
||||
#define DOT_15_4G_CHAN_MAX 198
|
||||
#define DOT_15_4G_FREQ_SPACING 200
|
||||
#define DOT_15_4G_CHAN0_FREQ 470200
|
||||
|
||||
#define PROP_MODE_CONF_CENTER_FREQ 0x01EA
|
||||
#define PROP_MODE_CONF_LO_DIVIDER 0x0A
|
||||
|
||||
#elif (DOT_15_4G_FREQ_BAND_ID == DOT_15_4G_FREQ_BAND_780)
|
||||
#define DOT_15_4G_CHAN_MIN 0
|
||||
#define DOT_15_4G_CHAN_MAX 38
|
||||
#define DOT_15_4G_FREQ_SPACING 200
|
||||
#define DOT_15_4G_CHAN0_FREQ 779200
|
||||
|
||||
#define PROP_MODE_CONF_CENTER_FREQ 0x030F
|
||||
#define PROP_MODE_CONF_LO_DIVIDER 0x06
|
||||
|
||||
#elif (DOT_15_4G_FREQ_BAND_ID == DOT_15_4G_FREQ_BAND_863)
|
||||
#define DOT_15_4G_CHAN_MIN 0
|
||||
#define DOT_15_4G_CHAN_MAX 33
|
||||
#define DOT_15_4G_FREQ_SPACING 200
|
||||
#define DOT_15_4G_CHAN0_FREQ 863125
|
||||
|
||||
#define PROP_MODE_CONF_CENTER_FREQ 0x0362
|
||||
#define PROP_MODE_CONF_LO_DIVIDER 0x05
|
||||
|
||||
#elif (DOT_15_4G_FREQ_BAND_ID == DOT_15_4G_FREQ_BAND_915)
|
||||
#define DOT_15_4G_CHAN_MIN 0
|
||||
#define DOT_15_4G_CHAN_MAX 128
|
||||
#define DOT_15_4G_FREQ_SPACING 200
|
||||
#define DOT_15_4G_CHAN0_FREQ 902200
|
||||
|
||||
#define PROP_MODE_CONF_CENTER_FREQ 0x0393
|
||||
#define PROP_MODE_CONF_LO_DIVIDER 0x05
|
||||
|
||||
#elif (DOT_15_4G_FREQ_BAND_ID == DOT_15_4G_FREQ_BAND_920)
|
||||
#define DOT_15_4G_CHAN_MIN 0
|
||||
#define DOT_15_4G_CHAN_MAX 37
|
||||
#define DOT_15_4G_FREQ_SPACING 200
|
||||
#define DOT_15_4G_CHAN0_FREQ 920600
|
||||
|
||||
#define PROP_MODE_CONF_CENTER_FREQ 0x039C
|
||||
#define PROP_MODE_CONF_LO_DIVIDER 0x05
|
||||
|
||||
#elif (DOT_15_4G_FREQ_BAND_ID == DOT_15_4G_FREQ_BAND_950)
|
||||
#define DOT_15_4G_CHAN_MIN 0
|
||||
#define DOT_15_4G_CHAN_MAX 32
|
||||
#define DOT_15_4G_FREQ_SPACING 200
|
||||
#define DOT_15_4G_CHAN0_FREQ 951000
|
||||
|
||||
#define PROP_MODE_CONF_CENTER_FREQ 0x03BA
|
||||
#define PROP_MODE_CONF_LO_DIVIDER 0x05
|
||||
|
||||
#elif (DOT_15_4G_FREQ_BAND_ID == DOT_15_4G_FREQ_BAND_2450)
|
||||
#define DOT_15_4G_CHAN_MIN 11
|
||||
#define DOT_15_4G_CHAN_MAX 26
|
||||
#define DOT_15_4G_FREQ_SPACING 5000
|
||||
#define DOT_15_4G_CHAN0_FREQ 2405000
|
||||
|
||||
#else
|
||||
#error "The selected IEEE 802.15.4g frequency band is not supported"
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
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);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
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);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define DOT_15_4G_DEFAULT_CHAN IEEE802154_DEFAULT_CHANNEL
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* DOT_15_4G_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-ieee-addr
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the CC13xx/CC26xx IEEE addresses driver.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "net/linkaddr.h"
|
||||
|
||||
#include "rf/ieee-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 <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)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
ieee_addr_cpy_to(uint8_t *dst, uint8_t len)
|
||||
{
|
||||
if(len > LINKADDR_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(IEEE_ADDR_HARDCODED) {
|
||||
const uint8_t ieee_addr_hc[LINKADDR_SIZE] = IEEE_ADDR_ADDRESS;
|
||||
|
||||
memcpy(dst, &ieee_addr_hc[LINKADDR_SIZE - len], len);
|
||||
} else {
|
||||
int i;
|
||||
|
||||
volatile const uint8_t *const primary = (uint8_t *)IEEE_MAC_PRIMARY_ADDRESS;
|
||||
volatile const uint8_t *const secondary = (uint8_t *)IEEE_MAC_SECONDARY_ADDRESS;
|
||||
|
||||
/* Reading from primary location... */
|
||||
volatile const uint8_t *ieee_addr = 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 address respective of the
|
||||
* actual number of bytes the caller wants to copy over.
|
||||
*/
|
||||
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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We have chosen what address to read the address from. Do so,
|
||||
* in inverted byte order.
|
||||
*/
|
||||
for(i = 0; i < len; i++) {
|
||||
dst[i] = ieee_addr[len - 1 - i];
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IEEE_ADDR_NODE_ID
|
||||
dst[len - 1] = (IEEE_ADDR_NODE_ID >> 0) & 0xFF;
|
||||
dst[len - 2] = (IEEE_ADDR_NODE_ID >> 8) & 0xFF;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-rf-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 for the CC13xx/CC26xx IEEE address driver.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef IEEE_ADDR_H_
|
||||
#define IEEE_ADDR_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \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 \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);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* IEEE_ADDR_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,713 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-rf-prop Prop-mode driver for CC13xx/CC26xx
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the CC13xx/CC26xx prop-mode NETSTACK_RADIO driver.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "net/packetbuf.h"
|
||||
#include "net/netstack.h"
|
||||
#include "sys/energest.h"
|
||||
#include "sys/clock.h"
|
||||
#include "sys/rtimer.h"
|
||||
#include "sys/cc.h"
|
||||
#include "dev/watchdog.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core Mailbox API */
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_data_entry.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Platform RF dev */
|
||||
#include "rf/dot-15-4g.h"
|
||||
#include "rf/sched.h"
|
||||
#include "rf/data-queue.h"
|
||||
#include "rf/tx-power.h"
|
||||
#include "rf/settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "Radio"
|
||||
#define LOG_LEVEL LOG_LEVEL_NONE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#undef CLAMP
|
||||
#define CLAMP(v, vmin, vmax) (MAX(MIN(v, vmax), vmin))
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Configuration parameters */
|
||||
#define PROP_MODE_DYN_WHITENER PROP_MODE_CONF_DW
|
||||
#define PROP_MODE_USE_CRC16 PROP_MODE_CONF_USE_CRC16
|
||||
#define PROP_MODE_CENTER_FREQ PROP_MODE_CONF_CENTER_FREQ
|
||||
#define PROP_MODE_LO_DIVIDER PROP_MODE_CONF_LO_DIVIDER
|
||||
#define PROP_MODE_CCA_RSSI_THRESHOLD PROP_MODE_CONF_CCA_RSSI_THRESHOLD
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Used for checking result of CCA_REQ command */
|
||||
typedef enum {
|
||||
CCA_STATE_IDLE = 0,
|
||||
CCA_STATE_BUSY = 1,
|
||||
CCA_STATE_INVALID = 2
|
||||
} cca_state_t;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Defines and variables related to the .15.4g PHY HDR */
|
||||
#define DOT_4G_MAX_FRAME_LEN 2047
|
||||
#define DOT_4G_PHR_LEN 2
|
||||
|
||||
/* PHY HDR bits */
|
||||
#define DOT_4G_PHR_CRC16 0x10
|
||||
#define DOT_4G_PHR_DW 0x08
|
||||
|
||||
#if PROP_MODE_USE_CRC16
|
||||
/* CRC16 */
|
||||
#define DOT_4G_PHR_CRC_BIT DOT_4G_PHR_CRC16
|
||||
#define CRC_LEN 2
|
||||
#else
|
||||
/* CRC32 */
|
||||
#define DOT_4G_PHR_CRC_BIT 0
|
||||
#define CRC_LEN 4
|
||||
#endif /* PROP_MODE_USE_CRC16 */
|
||||
|
||||
#if PROP_MODE_DYN_WHITENER
|
||||
#define DOT_4G_PHR_DW_BIT DOT_4G_PHR_DW
|
||||
#else
|
||||
#define DOT_4G_PHR_DW_BIT 0
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* How long to wait for the RF to enter RX in rf_cmd_ieee_rx */
|
||||
#define TIMEOUT_ENTER_RX_WAIT (RTIMER_SECOND >> 10)
|
||||
|
||||
/* How long to wait for the rx read entry to become ready */
|
||||
#define TIMEOUT_DATA_ENTRY_BUSY (RTIMER_SECOND / 250)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TX buf configuration */
|
||||
#define TX_BUF_HDR_LEN 2
|
||||
#define TX_BUF_PAYLOAD_LEN 180
|
||||
|
||||
#define TX_BUF_SIZE (TX_BUF_HDR_LEN + TX_BUF_PAYLOAD_LEN)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Size of the Length field in Data Entry, two bytes in this case */
|
||||
typedef uint16_t lensz_t;
|
||||
|
||||
#define FRAME_OFFSET sizeof(lensz_t)
|
||||
#define FRAME_SHAVE 2 /**< RSSI (1) + Status (1) */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Constants used when calculating the LQI from the RSSI */
|
||||
#define RX_SENSITIVITY_DBM -110
|
||||
#define RX_SATURATION_DBM 10
|
||||
#define ED_MIN_DBM_ABOVE_RX_SENSITIVITY 10
|
||||
#define ED_MAX 0xFF
|
||||
|
||||
#define ED_RF_POWER_MIN_DBM (RX_SENSITIVITY_DBM + ED_MIN_DBM_ABOVE_RX_SENSITIVITY)
|
||||
#define ED_RF_POWER_MAX_DBM RX_SATURATION_DBM
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Core typedefs */
|
||||
typedef rfc_propRxOutput_t rx_output_t;
|
||||
|
||||
typedef struct {
|
||||
/* Outgoing frame buffer */
|
||||
uint8_t tx_buf[TX_BUF_SIZE] CC_ALIGN(4);
|
||||
|
||||
/* RX Statistics struct */
|
||||
rx_output_t rx_stats;
|
||||
|
||||
/* RSSI Threshold */
|
||||
int8_t rssi_threshold;
|
||||
uint16_t channel;
|
||||
|
||||
/* Indicates RF is supposed to be on or off */
|
||||
uint8_t rf_is_on;
|
||||
|
||||
/* RF driver */
|
||||
RF_Handle rf_handle;
|
||||
} prop_radio_t;
|
||||
|
||||
static prop_radio_t prop_radio;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Convenience macros for volatile access with the RF commands */
|
||||
#define cmd_radio_setup (*(volatile rfc_CMD_PROP_RADIO_DIV_SETUP_t *)&rf_cmd_prop_radio_div_setup)
|
||||
#define cmd_fs (*(volatile rfc_CMD_FS_t *) &rf_cmd_prop_fs)
|
||||
#define cmd_tx (*(volatile rfc_CMD_PROP_TX_ADV_t *) &rf_cmd_prop_tx_adv)
|
||||
#define cmd_rx (*(volatile rfc_CMD_PROP_RX_ADV_t *) &rf_cmd_prop_rx_adv)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static inline bool
|
||||
tx_is_active(void)
|
||||
{
|
||||
return cmd_tx.status == ACTIVE;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static inline bool
|
||||
rx_is_active(void)
|
||||
{
|
||||
return cmd_rx.status == ACTIVE;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int on(void);
|
||||
static int off(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
init_rf_params(void)
|
||||
{
|
||||
cmd_radio_setup.centerFreq = PROP_MODE_CENTER_FREQ;
|
||||
cmd_radio_setup.loDivider = PROP_MODE_LO_DIVIDER;
|
||||
|
||||
data_queue_t *data_queue = data_queue_init(sizeof(lensz_t));
|
||||
|
||||
cmd_rx.maxPktLen = DOT_4G_MAX_FRAME_LEN - cmd_rx.lenOffset;
|
||||
cmd_rx.pQueue = data_queue;
|
||||
cmd_rx.pOutput = (uint8_t *)&prop_radio.rx_stats;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int8_t
|
||||
get_rssi(void)
|
||||
{
|
||||
rf_result_t res;
|
||||
|
||||
const bool rx_is_idle = !rx_is_active();
|
||||
|
||||
if(rx_is_idle) {
|
||||
res = netstack_sched_rx(false);
|
||||
if(res != RF_RESULT_OK) {
|
||||
return RF_GET_RSSI_ERROR_VAL;
|
||||
}
|
||||
}
|
||||
|
||||
const rtimer_clock_t t0 = RTIMER_NOW();
|
||||
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()) {
|
||||
rssi = RF_getRssi(prop_radio.rf_handle);
|
||||
}
|
||||
|
||||
if(rx_is_idle) {
|
||||
netstack_stop_rx();
|
||||
}
|
||||
|
||||
return rssi;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint8_t
|
||||
get_channel(void)
|
||||
{
|
||||
uint32_t freq_khz = cmd_fs.frequency * 1000;
|
||||
|
||||
/*
|
||||
* For some channels, fractFreq * 1000 / 65536 will return 324.99xx.
|
||||
* Casting the result to uint32_t will truncate decimals resulting in the
|
||||
* function returning channel - 1 instead of channel. Thus, we do a quick
|
||||
* positive integer round up.
|
||||
*/
|
||||
freq_khz += (((cmd_fs.fractFreq * 1000) + 65535) / 65536);
|
||||
|
||||
return (uint8_t)((freq_khz - DOT_15_4G_CHAN0_FREQ) / DOT_15_4G_FREQ_SPACING);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static rf_result_t
|
||||
set_channel(uint16_t channel)
|
||||
{
|
||||
rf_result_t res;
|
||||
|
||||
if(!dot_15_4g_chan_in_range(channel)) {
|
||||
LOG_WARN("Supplied hannel %d is illegal, defaults to %d\n",
|
||||
(int)channel, DOT_15_4G_DEFAULT_CHAN);
|
||||
channel = DOT_15_4G_DEFAULT_CHAN;
|
||||
}
|
||||
|
||||
if(channel == prop_radio.channel) {
|
||||
/* We are already calibrated to this channel */
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
|
||||
const uint32_t new_freq = dot_15_4g_freq(channel);
|
||||
const uint16_t freq = (uint16_t)(new_freq / 1000);
|
||||
const uint16_t frac = (uint16_t)(((new_freq - (freq * 1000)) * 0x10000) / 1000);
|
||||
|
||||
LOG_DBG("Set channel to %d, frequency 0x%04X.0x%04X (%lu)\n",
|
||||
(int)channel, freq, frac, new_freq);
|
||||
|
||||
cmd_fs.frequency = freq;
|
||||
cmd_fs.fractFreq = frac;
|
||||
|
||||
res = netstack_sched_fs();
|
||||
|
||||
if(res != RF_RESULT_OK) {
|
||||
return res;
|
||||
}
|
||||
|
||||
prop_radio.channel = channel;
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint8_t
|
||||
calculate_lqi(int8_t rssi)
|
||||
{
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
rssi = CLAMP(rssi, ED_RF_POWER_MIN_DBM, ED_RF_POWER_MAX_DBM);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
return (ED_MAX * (rssi - ED_RF_POWER_MIN_DBM)) / (ED_RF_POWER_MAX_DBM - ED_RF_POWER_MIN_DBM);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
prepare(const void *payload, unsigned short payload_len)
|
||||
{
|
||||
const size_t len = MIN((size_t)payload_len,
|
||||
(size_t)TX_BUF_PAYLOAD_LEN);
|
||||
|
||||
memcpy(prop_radio.tx_buf + TX_BUF_HDR_LEN, payload, len);
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
transmit(unsigned short transmit_len)
|
||||
{
|
||||
rf_result_t res;
|
||||
|
||||
if(tx_is_active()) {
|
||||
LOG_ERR("A transmission is already active\n");
|
||||
return RADIO_TX_ERR;
|
||||
}
|
||||
|
||||
/* Length in .15.4g PHY HDR. Includes the CRC but not the HDR itself */
|
||||
const uint16_t total_length = transmit_len + CRC_LEN;
|
||||
/*
|
||||
* Prepare the .15.4g PHY header
|
||||
* MS=0, Length MSBits=0, DW and CRC configurable
|
||||
* Total length = transmit_len (payload) + CRC length
|
||||
*
|
||||
* The Radio will flip the bits around, so tx_buf[0] must have the length
|
||||
* LSBs (PHR[15:8] and tx_buf[1] will have PHR[7:0]
|
||||
*/
|
||||
prop_radio.tx_buf[0] = ((total_length >> 0) & 0xFF);
|
||||
prop_radio.tx_buf[1] = ((total_length >> 8) & 0xFF) + DOT_4G_PHR_DW_BIT + DOT_4G_PHR_CRC_BIT;
|
||||
|
||||
/* pktLen: Total number of bytes in the TX buffer, including the header if
|
||||
* one exists, but not including the CRC (which is not present in the buffer) */
|
||||
cmd_tx.pktLen = transmit_len + DOT_4G_PHR_LEN;
|
||||
cmd_tx.pPkt = prop_radio.tx_buf;
|
||||
|
||||
res = netstack_sched_prop_tx();
|
||||
|
||||
return (res == RF_RESULT_OK)
|
||||
? RADIO_TX_OK
|
||||
: RADIO_TX_ERR;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
send(const void *payload, unsigned short payload_len)
|
||||
{
|
||||
prepare(payload, payload_len);
|
||||
return transmit(payload_len);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
read(void *buf, unsigned short buf_len)
|
||||
{
|
||||
volatile data_entry_t *data_entry = data_queue_current_entry();
|
||||
|
||||
const rtimer_clock_t t0 = RTIMER_NOW();
|
||||
/* Only wait if the Radio is accessing the entry */
|
||||
while((data_entry->status == DATA_ENTRY_BUSY) &&
|
||||
RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + TIMEOUT_DATA_ENTRY_BUSY)) ;
|
||||
|
||||
if(data_entry->status != DATA_ENTRY_FINISHED) {
|
||||
/* No available data */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* lensz bytes (2) in the data entry are the length of the received frame.
|
||||
* Data frame is on the following format:
|
||||
* Length (2) + Payload (N) + RSSI (1) + Status (1)
|
||||
* Data frame DOES NOT contain the following:
|
||||
* no Header/PHY bytes
|
||||
* no appended Received CRC bytes
|
||||
* no Timestamp bytes
|
||||
* Visual representation of frame format:
|
||||
*
|
||||
* +---------+---------+--------+--------+
|
||||
* | 2 bytes | N bytes | 1 byte | 1 byte |
|
||||
* +---------+---------+--------+--------+
|
||||
* | Length | Payload | RSSI | Status |
|
||||
* +---------+---------+--------+--------+
|
||||
*
|
||||
* Length bytes equal total length of entire frame excluding itself,
|
||||
* Length = N + RSSI (1) + Status (1)
|
||||
* = N + 2
|
||||
* N = Length - 2
|
||||
*/
|
||||
uint8_t *const frame_ptr = (uint8_t *)&data_entry->data;
|
||||
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) {
|
||||
LOG_ERR("Received rame is too short, len=%d\n", frame_len);
|
||||
|
||||
data_queue_release_entry();
|
||||
return 0;
|
||||
}
|
||||
|
||||
const uint8_t *payload_ptr = frame_ptr + sizeof(lensz_t);
|
||||
const unsigned short payload_len = (unsigned short)(frame_len - FRAME_SHAVE);
|
||||
|
||||
/* Sanity check that Payload fits in Buffer */
|
||||
if(payload_len > buf_len) {
|
||||
LOG_ERR("Payload of received frame is too large for local buffer, len=%d buf_len=%d\n",
|
||||
payload_len, buf_len);
|
||||
|
||||
data_queue_release_entry();
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(buf, payload_ptr, payload_len);
|
||||
|
||||
/* RSSI stored after payload */
|
||||
const int8_t rssi = (int8_t)payload_ptr[payload_len];
|
||||
/* LQI calculated from RSSI */
|
||||
const uint8_t lqi = calculate_lqi(rssi);
|
||||
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, (packetbuf_attr_t)rssi);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, (packetbuf_attr_t)lqi);
|
||||
|
||||
data_queue_release_entry();
|
||||
return (int)payload_len;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint8_t
|
||||
cca_request(void)
|
||||
{
|
||||
const int8_t rssi = get_rssi();
|
||||
|
||||
if(rssi == RF_GET_RSSI_ERROR_VAL) {
|
||||
return CCA_STATE_INVALID;
|
||||
}
|
||||
|
||||
return (rssi < prop_radio.rssi_threshold)
|
||||
? CCA_STATE_IDLE
|
||||
: CCA_STATE_BUSY;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
channel_clear(void)
|
||||
{
|
||||
if(tx_is_active()) {
|
||||
LOG_ERR("Channel clear called while in TX\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
const uint8_t cca_state = cca_request();
|
||||
|
||||
/* Channel is clear if CCA state is IDLE */
|
||||
return cca_state == CCA_STATE_IDLE;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
receiving_packet(void)
|
||||
{
|
||||
if(!rx_is_active()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const uint8_t cca_state = cca_request();
|
||||
|
||||
return cca_state == CCA_STATE_BUSY;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
pending_packet(void)
|
||||
{
|
||||
const data_entry_t *const read_entry = data_queue_current_entry();
|
||||
volatile const data_entry_t *curr_entry = read_entry;
|
||||
|
||||
int num_pending = 0;
|
||||
|
||||
/* Go through RX Circular buffer and check their status */
|
||||
do {
|
||||
const uint8_t status = curr_entry->status;
|
||||
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);
|
||||
|
||||
if(num_pending > 0) {
|
||||
process_poll(&rf_sched_process);
|
||||
}
|
||||
|
||||
/* If we didn't find an entry at status finished, no frames are pending */
|
||||
return num_pending;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
on(void)
|
||||
{
|
||||
rf_result_t res;
|
||||
|
||||
if(prop_radio.rf_is_on) {
|
||||
LOG_WARN("Radio is already on\n");
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
|
||||
data_queue_reset();
|
||||
|
||||
res = netstack_sched_rx(true);
|
||||
|
||||
if(res != RF_RESULT_OK) {
|
||||
return RF_RESULT_ERROR;
|
||||
}
|
||||
|
||||
prop_radio.rf_is_on = true;
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
off(void)
|
||||
{
|
||||
if(!prop_radio.rf_is_on) {
|
||||
LOG_WARN("Radio is already off\n");
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
|
||||
rf_yield();
|
||||
|
||||
prop_radio.rf_is_on = false;
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static radio_result_t
|
||||
get_value(radio_param_t param, radio_value_t *value)
|
||||
{
|
||||
rf_result_t res;
|
||||
|
||||
if(!value) {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
|
||||
switch(param) {
|
||||
case RADIO_PARAM_POWER_MODE:
|
||||
/* On / off */
|
||||
*value = (prop_radio.rf_is_on)
|
||||
? RADIO_POWER_MODE_ON
|
||||
: RADIO_POWER_MODE_OFF;
|
||||
|
||||
return RADIO_RESULT_OK;
|
||||
|
||||
case RADIO_PARAM_CHANNEL:
|
||||
*value = (radio_value_t)get_channel();
|
||||
return RADIO_RESULT_OK;
|
||||
|
||||
case RADIO_PARAM_TXPOWER:
|
||||
res = rf_get_tx_power(prop_radio.rf_handle, rf_tx_power_table, (int8_t *)&value);
|
||||
return ((res == RF_RESULT_OK) &&
|
||||
(*value != RF_TxPowerTable_INVALID_DBM))
|
||||
? RADIO_RESULT_OK
|
||||
: RADIO_RESULT_ERROR;
|
||||
|
||||
case RADIO_PARAM_CCA_THRESHOLD:
|
||||
*value = prop_radio.rssi_threshold;
|
||||
return RADIO_RESULT_OK;
|
||||
|
||||
case RADIO_PARAM_RSSI:
|
||||
*value = get_rssi();
|
||||
return (*value == RF_GET_RSSI_ERROR_VAL)
|
||||
? RADIO_RESULT_ERROR
|
||||
: RADIO_RESULT_OK;
|
||||
|
||||
case RADIO_CONST_CHANNEL_MIN:
|
||||
*value = DOT_15_4G_CHAN_MIN;
|
||||
return RADIO_RESULT_OK;
|
||||
|
||||
case RADIO_CONST_CHANNEL_MAX:
|
||||
*value = DOT_15_4G_CHAN_MAX;
|
||||
return RADIO_RESULT_OK;
|
||||
|
||||
case RADIO_CONST_TXPOWER_MIN:
|
||||
*value = (radio_value_t)tx_power_min(rf_tx_power_table);
|
||||
return RADIO_RESULT_OK;
|
||||
|
||||
case RADIO_CONST_TXPOWER_MAX:
|
||||
*value = (radio_value_t)tx_power_max(rf_tx_power_table, rf_tx_power_table_size);
|
||||
return RADIO_RESULT_OK;
|
||||
|
||||
default:
|
||||
return RADIO_RESULT_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static radio_result_t
|
||||
set_value(radio_param_t param, radio_value_t value)
|
||||
{
|
||||
rf_result_t res;
|
||||
|
||||
switch(param) {
|
||||
case RADIO_PARAM_POWER_MODE:
|
||||
|
||||
if(value == RADIO_POWER_MODE_ON) {
|
||||
return (on() == RF_RESULT_OK)
|
||||
? RADIO_RESULT_OK
|
||||
: RADIO_RESULT_ERROR;
|
||||
} else if(value == RADIO_POWER_MODE_OFF) {
|
||||
off();
|
||||
return RADIO_RESULT_OK;
|
||||
}
|
||||
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
|
||||
case RADIO_PARAM_CHANNEL:
|
||||
res = set_channel((uint16_t)value);
|
||||
return (res == RF_RESULT_OK)
|
||||
? RADIO_RESULT_OK
|
||||
: RADIO_RESULT_ERROR;
|
||||
|
||||
case RADIO_PARAM_TXPOWER:
|
||||
if(!tx_power_in_range((int8_t)value, rf_tx_power_table, rf_tx_power_table_size)) {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
res = rf_set_tx_power(prop_radio.rf_handle, rf_tx_power_table, (int8_t)value);
|
||||
return (res == RF_RESULT_OK)
|
||||
? RADIO_RESULT_OK
|
||||
: RADIO_RESULT_ERROR;
|
||||
|
||||
case RADIO_PARAM_RX_MODE:
|
||||
return RADIO_RESULT_OK;
|
||||
|
||||
case RADIO_PARAM_CCA_THRESHOLD:
|
||||
prop_radio.rssi_threshold = (int8_t)value;
|
||||
return RADIO_RESULT_OK;
|
||||
|
||||
default:
|
||||
return RADIO_RESULT_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static radio_result_t
|
||||
get_object(radio_param_t param, void *dest, size_t size)
|
||||
{
|
||||
return RADIO_RESULT_NOT_SUPPORTED;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static radio_result_t
|
||||
set_object(radio_param_t param, const void *src, size_t size)
|
||||
{
|
||||
return RADIO_RESULT_NOT_SUPPORTED;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
init(void)
|
||||
{
|
||||
if(prop_radio.rf_handle) {
|
||||
LOG_WARN("Radio is already initialized\n");
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
|
||||
/* RX is off */
|
||||
prop_radio.rf_is_on = false;
|
||||
|
||||
/* Set configured RSSI threshold */
|
||||
prop_radio.rssi_threshold = PROP_MODE_CCA_RSSI_THRESHOLD;
|
||||
|
||||
init_rf_params();
|
||||
|
||||
/* Init RF params and specify non-default params */
|
||||
RF_Params rf_params;
|
||||
RF_Params_init(&rf_params);
|
||||
rf_params.nInactivityTimeout = RF_CONF_INACTIVITY_TIMEOUT;
|
||||
|
||||
/* Open RF Driver */
|
||||
prop_radio.rf_handle = netstack_open(&rf_params);
|
||||
|
||||
if(prop_radio.rf_handle == NULL) {
|
||||
LOG_ERR("Unable to open RF driver during initialization\n");
|
||||
return RF_RESULT_ERROR;
|
||||
}
|
||||
|
||||
set_channel(IEEE802154_DEFAULT_CHANNEL);
|
||||
|
||||
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
||||
|
||||
/* Start RF process */
|
||||
process_start(&rf_sched_process, NULL);
|
||||
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const struct radio_driver prop_mode_driver = {
|
||||
init,
|
||||
prepare,
|
||||
transmit,
|
||||
send,
|
||||
read,
|
||||
channel_clear,
|
||||
receiving_packet,
|
||||
pending_packet,
|
||||
on,
|
||||
off,
|
||||
get_value,
|
||||
set_value,
|
||||
get_object,
|
||||
set_object,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-rf RF specific files for CC13xx/CC26xx
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file of common CC13xx/CC26xx RF functionality.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef RF_CORE_H_
|
||||
#define RF_CORE_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)
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_CORE_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,590 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-rf-sched
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the CC13xx/CC26xx RF scheduler.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/watchdog.h"
|
||||
#include "sys/cc.h"
|
||||
#include "sys/etimer.h"
|
||||
#include "sys/process.h"
|
||||
#include "sys/energest.h"
|
||||
#include "net/netstack.h"
|
||||
#include "net/packetbuf.h"
|
||||
#include "net/mac/mac.h"
|
||||
#include "lib/random.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
|
||||
#include <ti/drivers/rf/RF.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/rf.h"
|
||||
#include "rf/sched.h"
|
||||
#include "rf/data-queue.h"
|
||||
#include "rf/settings.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "Radio"
|
||||
#define LOG_LEVEL LOG_LEVEL_NONE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Configuration parameters */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define CMD_FS_RETRIES 3
|
||||
|
||||
#define RF_EVENTS_CMD_DONE (RF_EventCmdDone | RF_EventLastCmdDone | \
|
||||
RF_EventFGCmdDone | RF_EventLastFGCmdDone)
|
||||
|
||||
#define CMD_STATUS(cmd) (CC_ACCESS_NOW(RF_Op, cmd).status)
|
||||
|
||||
#define CMD_HANDLE_OK(handle) (((handle) != RF_ALLOC_ERROR) && \
|
||||
((handle) != RF_SCHEDULE_CMD_ERROR))
|
||||
|
||||
#define EVENTS_CMD_DONE(events) (((events) & RF_EVENTS_CMD_DONE) != 0)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Synth re-calibration every 3 minutes */
|
||||
#define SYNTH_RECAL_INTERVAL (CLOCK_SECOND * 60 * 3)
|
||||
/* Set re-calibration interval with a jitter of 10 seconds */
|
||||
#define SYNTH_RECAL_JITTER (CLOCK_SECOND * 10)
|
||||
|
||||
static struct etimer synth_recal_timer;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static RF_Object rf_netstack;
|
||||
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
static RF_Object rf_ble;
|
||||
#endif
|
||||
|
||||
static RF_CmdHandle cmd_rx_handle;
|
||||
|
||||
static bool rf_is_on;
|
||||
static volatile bool rx_buf_full;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
cmd_rx_cb(RF_Handle client, RF_CmdHandle command, RF_EventMask events)
|
||||
{
|
||||
/* Unused arguments */
|
||||
(void)client;
|
||||
(void)command;
|
||||
|
||||
if(events & RF_EventRxEntryDone) {
|
||||
process_poll(&rf_sched_process);
|
||||
}
|
||||
|
||||
if(events & RF_EventRxBufFull) {
|
||||
rx_buf_full = true;
|
||||
process_poll(&rf_sched_process);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static inline clock_time_t
|
||||
synth_recal_interval(void)
|
||||
{
|
||||
/*
|
||||
* Add jitter centered around SYNTH_RECAL_INTERVAL, giving a plus/minus
|
||||
* jitter seconds halved.
|
||||
*/
|
||||
return SYNTH_RECAL_INTERVAL + (random_rand() % SYNTH_RECAL_JITTER) - (SYNTH_RECAL_JITTER / 2);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static inline bool
|
||||
cmd_rx_is_active(void)
|
||||
{
|
||||
/*
|
||||
* Active in this case means RX command is either running to be running,
|
||||
* that is ACTIVE for running or PENDING for to be running.
|
||||
*/
|
||||
const uint16_t status = CMD_STATUS(netstack_cmd_rx);
|
||||
return (status == ACTIVE) ||
|
||||
(status == PENDING);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint_fast8_t
|
||||
cmd_rx_disable(void)
|
||||
{
|
||||
const bool is_active = cmd_rx_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;
|
||||
}
|
||||
|
||||
return (uint_fast8_t)is_active;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static rf_result_t
|
||||
cmd_rx_restore(uint_fast8_t rx_key)
|
||||
{
|
||||
const bool was_active = (rx_key != 0) ? true : false;
|
||||
|
||||
if(!was_active) {
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
|
||||
RF_ScheduleCmdParams sched_params;
|
||||
RF_ScheduleCmdParams_init(&sched_params);
|
||||
|
||||
sched_params.priority = RF_PriorityNormal;
|
||||
sched_params.endTime = 0;
|
||||
sched_params.allowDelay = RF_AllowDelayAny;
|
||||
|
||||
CMD_STATUS(netstack_cmd_rx) = PENDING;
|
||||
|
||||
cmd_rx_handle = RF_scheduleCmd(
|
||||
&rf_netstack,
|
||||
(RF_Op *)&netstack_cmd_rx,
|
||||
&sched_params,
|
||||
cmd_rx_cb,
|
||||
RF_EventRxEntryDone | RF_EventRxBufFull);
|
||||
|
||||
if(!CMD_HANDLE_OK(cmd_rx_handle)) {
|
||||
LOG_ERR("Unable to restore RX command, handle=%d status=0x%04x",
|
||||
cmd_rx_handle, CMD_STATUS(netstack_cmd_rx));
|
||||
return RF_RESULT_ERROR;
|
||||
}
|
||||
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_result_t
|
||||
rf_yield(void)
|
||||
{
|
||||
/* Force abort of any ongoing RF operation */
|
||||
RF_flushCmd(&rf_netstack, RF_CMDHANDLE_FLUSH_ALL, RF_ABORT_GRACEFULLY);
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
RF_flushCmd(&rf_ble, RF_CMDHANDLE_FLUSH_ALL, RF_ABORT_GRACEFULLY);
|
||||
#endif
|
||||
|
||||
/* Trigger a manual power-down */
|
||||
RF_yield(&rf_netstack);
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
RF_yield(&rf_ble);
|
||||
#endif
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
|
||||
|
||||
etimer_stop(&synth_recal_timer);
|
||||
rf_is_on = false;
|
||||
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_result_t
|
||||
rf_set_tx_power(RF_Handle handle, RF_TxPowerTable_Entry *table, int8_t dbm)
|
||||
{
|
||||
const RF_Stat stat = RF_setTxPower(handle, RF_TxPowerTable_findValue(table, dbm));
|
||||
|
||||
return (stat == RF_StatSuccess)
|
||||
? RF_RESULT_OK
|
||||
: RF_RESULT_ERROR;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_result_t
|
||||
rf_get_tx_power(RF_Handle handle, RF_TxPowerTable_Entry *table, int8_t *dbm)
|
||||
{
|
||||
*dbm = RF_TxPowerTable_findPowerLevel(table, RF_getTxPower(handle));
|
||||
|
||||
return (*dbm != RF_TxPowerTable_INVALID_DBM)
|
||||
? RF_RESULT_OK
|
||||
: RF_RESULT_ERROR;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
RF_Handle
|
||||
netstack_open(RF_Params *params)
|
||||
{
|
||||
return RF_open(&rf_netstack, &netstack_mode, (RF_RadioSetup *)&netstack_cmd_radio_setup, params);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_result_t
|
||||
netstack_sched_fs(void)
|
||||
{
|
||||
const uint_fast8_t rx_key = cmd_rx_disable();
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* For Prop-mode, the synth is always manually calibrated with CMD_FS.
|
||||
*/
|
||||
#if (RF_MODE == RF_CORE_MODE_2_4_GHZ)
|
||||
if(rx_key) {
|
||||
cmd_rx_restore(rx_key);
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
#endif /* RF_MODE == RF_CORE_MODE_2_4_GHZ */
|
||||
|
||||
RF_EventMask events;
|
||||
bool synth_error = false;
|
||||
uint8_t num_tries = 0;
|
||||
|
||||
do {
|
||||
CMD_STATUS(netstack_cmd_fs) = PENDING;
|
||||
|
||||
events = RF_runCmd(
|
||||
&rf_netstack,
|
||||
(RF_Op *)&netstack_cmd_fs,
|
||||
RF_PriorityNormal,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
synth_error = (EVENTS_CMD_DONE(events)) && (CMD_STATUS(netstack_cmd_fs) == ERROR_SYNTH_PROG);
|
||||
|
||||
} while(synth_error && (num_tries++ < CMD_FS_RETRIES));
|
||||
|
||||
cmd_rx_restore(rx_key);
|
||||
|
||||
return (CMD_STATUS(netstack_cmd_fs) == DONE_OK)
|
||||
? RF_RESULT_OK
|
||||
: RF_RESULT_ERROR;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_result_t
|
||||
netstack_sched_ieee_tx(bool ack_request)
|
||||
{
|
||||
rf_result_t res;
|
||||
|
||||
RF_ScheduleCmdParams sched_params;
|
||||
RF_ScheduleCmdParams_init(&sched_params);
|
||||
|
||||
sched_params.priority = RF_PriorityNormal;
|
||||
sched_params.endTime = 0;
|
||||
sched_params.allowDelay = RF_AllowDelayAny;
|
||||
|
||||
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_needed) {
|
||||
res = netstack_sched_rx(false);
|
||||
if(res != RF_RESULT_OK) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
CMD_STATUS(netstack_cmd_tx) = PENDING;
|
||||
|
||||
RF_CmdHandle tx_handle = RF_scheduleCmd(
|
||||
&rf_netstack,
|
||||
(RF_Op *)&netstack_cmd_tx,
|
||||
&sched_params,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
if(!CMD_HANDLE_OK(tx_handle)) {
|
||||
LOG_ERR("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) {
|
||||
ENERGEST_SWITCH(ENERGEST_TYPE_LISTEN, ENERGEST_TYPE_TRANSMIT);
|
||||
} else {
|
||||
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
|
||||
}
|
||||
|
||||
/* Wait until TX operation finishes */
|
||||
RF_EventMask tx_events = RF_pendCmd(&rf_netstack, tx_handle, 0);
|
||||
|
||||
/* Stop RX if it was turned on only for ACK */
|
||||
if(rx_needed) {
|
||||
netstack_stop_rx();
|
||||
}
|
||||
|
||||
if(rx_is_active) {
|
||||
ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN);
|
||||
} else {
|
||||
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
|
||||
}
|
||||
|
||||
if(!EVENTS_CMD_DONE(tx_events)) {
|
||||
LOG_ERR("Pending on TX comand generated error, events=0x%08llx status=0x%04x\n",
|
||||
tx_events, CMD_STATUS(netstack_cmd_tx));
|
||||
return RF_RESULT_ERROR;
|
||||
}
|
||||
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_result_t
|
||||
netstack_sched_prop_tx(void)
|
||||
{
|
||||
RF_ScheduleCmdParams sched_params;
|
||||
RF_ScheduleCmdParams_init(&sched_params);
|
||||
|
||||
sched_params.priority = RF_PriorityNormal;
|
||||
sched_params.endTime = 0;
|
||||
sched_params.allowDelay = RF_AllowDelayAny;
|
||||
|
||||
CMD_STATUS(netstack_cmd_tx) = PENDING;
|
||||
|
||||
RF_CmdHandle tx_handle = RF_scheduleCmd(
|
||||
&rf_netstack,
|
||||
(RF_Op *)&netstack_cmd_tx,
|
||||
&sched_params,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
if(!CMD_HANDLE_OK(tx_handle)) {
|
||||
LOG_ERR("Unable to schedule TX command, handle=%d status=0x%04x\n",
|
||||
tx_handle, CMD_STATUS(netstack_cmd_tx));
|
||||
return RF_RESULT_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prop TX requires any on-going RX operation to be stopped to be
|
||||
* able to transmit. Therefore, disable RX if running.
|
||||
*/
|
||||
const bool rx_key = cmd_rx_disable();
|
||||
|
||||
if(rx_key) {
|
||||
ENERGEST_SWITCH(ENERGEST_TYPE_LISTEN, ENERGEST_TYPE_TRANSMIT);
|
||||
} else {
|
||||
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
|
||||
}
|
||||
|
||||
/* Wait until TX operation finishes */
|
||||
RF_EventMask tx_events = RF_pendCmd(&rf_netstack, tx_handle, 0);
|
||||
|
||||
cmd_rx_restore(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)) {
|
||||
LOG_ERR("Pending on scheduled TX command generated error, events=0x%08llx status=0x%04x\n",
|
||||
tx_events, CMD_STATUS(netstack_cmd_tx));
|
||||
return RF_RESULT_ERROR;
|
||||
}
|
||||
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_result_t
|
||||
netstack_sched_rx(bool start)
|
||||
{
|
||||
if(cmd_rx_is_active()) {
|
||||
LOG_WARN("Already in RX when scheduling RX\n");
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
|
||||
RF_ScheduleCmdParams sched_params;
|
||||
RF_ScheduleCmdParams_init(&sched_params);
|
||||
|
||||
sched_params.priority = RF_PriorityNormal;
|
||||
sched_params.endTime = 0;
|
||||
sched_params.allowDelay = RF_AllowDelayAny;
|
||||
|
||||
CMD_STATUS(netstack_cmd_rx) = PENDING;
|
||||
|
||||
cmd_rx_handle = RF_scheduleCmd(
|
||||
&rf_netstack,
|
||||
(RF_Op *)&netstack_cmd_rx,
|
||||
&sched_params,
|
||||
cmd_rx_cb,
|
||||
RF_EventRxEntryDone | RF_EventRxBufFull);
|
||||
|
||||
if(!CMD_HANDLE_OK(cmd_rx_handle)) {
|
||||
LOG_ERR("Unable to schedule RX command, handle=%d status=0x%04x\n",
|
||||
cmd_rx_handle, CMD_STATUS(netstack_cmd_rx));
|
||||
return RF_RESULT_ERROR;
|
||||
}
|
||||
|
||||
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
||||
|
||||
if(start) {
|
||||
rf_is_on = true;
|
||||
process_poll(&rf_sched_process);
|
||||
}
|
||||
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_result_t
|
||||
netstack_stop_rx(void)
|
||||
{
|
||||
if(!cmd_rx_is_active()) {
|
||||
LOG_WARN("RX not active when stopping RX\n");
|
||||
return RF_RESULT_OK;
|
||||
}
|
||||
|
||||
CMD_STATUS(netstack_cmd_rx) = DONE_STOPPED;
|
||||
const RF_Stat stat = RF_cancelCmd(&rf_netstack, cmd_rx_handle, RF_ABORT_GRACEFULLY);
|
||||
cmd_rx_handle = 0;
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
|
||||
|
||||
return (stat == RF_StatSuccess)
|
||||
? RF_RESULT_OK
|
||||
: RF_RESULT_ERROR;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
RF_Handle
|
||||
ble_open(RF_Params *params)
|
||||
{
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
return RF_open(&rf_ble, &ble_mode, (RF_RadioSetup *)&ble_cmd_radio_setup, params);
|
||||
|
||||
#else
|
||||
return (RF_Handle)NULL;
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_result_t
|
||||
ble_sched_beacon(RF_Callback cb, RF_EventMask bm_event)
|
||||
{
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
RF_ScheduleCmdParams sched_params;
|
||||
RF_ScheduleCmdParams_init(&sched_params);
|
||||
|
||||
sched_params.priority = RF_PriorityNormal;
|
||||
sched_params.endTime = 0;
|
||||
sched_params.allowDelay = RF_AllowDelayAny;
|
||||
|
||||
CMD_STATUS(ble_cmd_beacon) = PENDING;
|
||||
|
||||
RF_CmdHandle beacon_handle = RF_scheduleCmd(
|
||||
&rf_ble,
|
||||
(RF_Op *)&ble_cmd_beacon,
|
||||
&sched_params,
|
||||
cb,
|
||||
bm_event);
|
||||
|
||||
if(!CMD_HANDLE_OK(beacon_handle)) {
|
||||
LOG_ERR("Unable to schedule BLE Beacon command, handle=%d status=0x%04x\n",
|
||||
beacon_handle, CMD_STATUS(ble_cmd_beacon));
|
||||
return RF_RESULT_ERROR;
|
||||
}
|
||||
|
||||
const uint_fast8_t rx_key = cmd_rx_disable();
|
||||
|
||||
/* Wait until Beacon operation finishes */
|
||||
RF_EventMask beacon_events = RF_pendCmd(&rf_ble, beacon_handle, 0);
|
||||
if(!EVENTS_CMD_DONE(beacon_events)) {
|
||||
LOG_ERR("Pending on scheduled BLE Beacon command generated error, events=0x%08llx status=0x%04x\n",
|
||||
beacon_events, CMD_STATUS(ble_cmd_beacon));
|
||||
|
||||
cmd_rx_restore(rx_key);
|
||||
return RF_RESULT_ERROR;
|
||||
}
|
||||
|
||||
cmd_rx_restore(rx_key);
|
||||
return RF_RESULT_OK;
|
||||
|
||||
#else
|
||||
return RF_RESULT_ERROR;
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(rf_sched_process, "RF Scheduler Process");
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(rf_sched_process, ev, data)
|
||||
{
|
||||
int len;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
while(1) {
|
||||
PROCESS_YIELD_UNTIL((ev == PROCESS_EVENT_POLL) ||
|
||||
(ev == PROCESS_EVENT_TIMER));
|
||||
|
||||
/* start the synth re-calibration timer once. */
|
||||
if(rf_is_on) {
|
||||
rf_is_on = false;
|
||||
clock_time_t interval = synth_recal_interval();
|
||||
LOG_INFO("Starting synth re-calibration timer, next timeout %lu\n", interval);
|
||||
etimer_set(&synth_recal_timer, interval);
|
||||
}
|
||||
|
||||
if(ev == PROCESS_EVENT_POLL) {
|
||||
do {
|
||||
watchdog_periodic();
|
||||
|
||||
packetbuf_clear();
|
||||
len = NETSTACK_RADIO.read(packetbuf_dataptr(), PACKETBUF_SIZE);
|
||||
|
||||
/*
|
||||
* 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) {
|
||||
LOG_ERR("RX buffer full, restart RX status=0x%04x\n", CMD_STATUS(netstack_cmd_rx));
|
||||
rx_buf_full = false;
|
||||
|
||||
/* Restart RX. */
|
||||
netstack_stop_rx();
|
||||
netstack_sched_rx(false);
|
||||
}
|
||||
|
||||
if(len > 0) {
|
||||
packetbuf_set_datalen(len);
|
||||
|
||||
NETSTACK_MAC.input();
|
||||
}
|
||||
/* Only break when we receive -1 => No available data */
|
||||
} while(len >= 0);
|
||||
}
|
||||
|
||||
/* Scheduling CMD_FS will re-calibrate the synth. */
|
||||
if((ev == PROCESS_EVENT_TIMER) &&
|
||||
etimer_expired(&synth_recal_timer)) {
|
||||
clock_time_t interval = synth_recal_interval();
|
||||
LOG_DBG("Re-calibrate synth, next interval %lu\n", interval);
|
||||
|
||||
netstack_sched_fs();
|
||||
etimer_set(&synth_recal_timer, interval);
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* 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 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_
|
||||
#define RF_SCHED_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "sys/process.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;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \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);
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \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);
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \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_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* 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 cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc13xx-cc26xx-rf-settings RF settings for CC13xx/CC26xx
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file of RF settings for CC13xx/CC26xx.
|
||||
* \author
|
||||
* Edvard Pettersen <e.pettersen@ti.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef NETSTACK_SETTINGS_H_
|
||||
#define NETSTACK_SETTINGS_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Netstack RF command configuration */
|
||||
|
||||
#if SUPPORTS_PROP_MODE
|
||||
#include "prop-settings.h"
|
||||
#endif
|
||||
|
||||
#if SUPPORTS_IEEE_MODE
|
||||
#include "ieee-settings.h"
|
||||
#endif
|
||||
|
||||
/* Prop-mode RF settings */
|
||||
#if (RF_MODE == RF_MODE_SUB_1_GHZ)
|
||||
|
||||
#define netstack_mode rf_prop_mode
|
||||
#define netstack_cmd_radio_setup rf_cmd_prop_radio_div_setup
|
||||
#define netstack_cmd_fs rf_cmd_prop_fs
|
||||
#define netstack_cmd_tx rf_cmd_prop_tx_adv
|
||||
#define netstack_cmd_rx rf_cmd_prop_rx_adv
|
||||
|
||||
/* IEEE-mode RF settings */
|
||||
#elif (RF_MODE == RF_MODE_2_4_GHZ)
|
||||
|
||||
#define netstack_mode rf_ieee_mode
|
||||
#define netstack_cmd_radio_setup rf_cmd_ieee_radio_setup
|
||||
#define netstack_cmd_fs rf_cmd_ieee_fs
|
||||
#define netstack_cmd_tx rf_cmd_ieee_tx
|
||||
#define netstack_cmd_rx rf_cmd_ieee_rx
|
||||
|
||||
#endif /* RF_MODE */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* BLE Beacon RF command configuration */
|
||||
#if SUPPORTS_BLE_BEACON
|
||||
|
||||
#include "ble-settings.h"
|
||||
|
||||
/* CC13x0/CC26x0 devices */
|
||||
#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
|
||||
|
||||
#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
|
||||
|
||||
/* CC13x2/CC26x2 devices */
|
||||
#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
|
||||
|
||||
#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
|
||||
|
||||
#endif /* DeviceFamily_PARENT */
|
||||
|
||||
#endif /* SUPPORTS_BLE_BEACON */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* NETSTACK_SETTINGS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue