From 6b7681c516389318fb3f64b46db03b876e7dfa98 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 6 Nov 2016 18:42:20 +0000 Subject: [PATCH] Extend the RF core to support RF switches --- cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 3 + cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 3 + cpu/cc26xx-cc13xx/rf-core/rf-ble.c | 3 + cpu/cc26xx-cc13xx/rf-core/rf-core.c | 5 ++ cpu/cc26xx-cc13xx/rf-core/rf-switch.h | 104 ++++++++++++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 cpu/cc26xx-cc13xx/rf-core/rf-switch.h diff --git a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index 67dc0f4ba..db3b670ae 100644 --- a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -56,6 +56,7 @@ #include "lpm.h" #include "ti-lib.h" #include "rf-core/rf-core.h" +#include "rf-core/rf-switch.h" #include "rf-core/rf-ble.h" /*---------------------------------------------------------------------------*/ /* RF core and RF HAL API */ @@ -473,6 +474,8 @@ rf_radio_setup() uint32_t cmd_status; rfc_CMD_RADIO_SETUP_t cmd; + rf_switch_select_path(RF_SWITCH_PATH_2_4GHZ); + /* Create radio setup command */ rf_core_init_radio_op((rfc_radioOp_t *)&cmd, sizeof(cmd), CMD_RADIO_SETUP); diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index ad1e36c2b..f3685eb74 100644 --- a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -56,6 +56,7 @@ #include "lpm.h" #include "ti-lib.h" #include "rf-core/rf-core.h" +#include "rf-core/rf-switch.h" #include "rf-core/rf-ble.h" #include "rf-core/dot-15-4g.h" /*---------------------------------------------------------------------------*/ @@ -365,6 +366,8 @@ prop_div_radio_setup(void) uint32_t cmd_status; rfc_radioOp_t *cmd = (rfc_radioOp_t *)&smartrf_settings_cmd_prop_radio_div_setup; + rf_switch_select_path(RF_SWITCH_PATH_SUBGHZ); + /* Adjust loDivider depending on the selected band */ smartrf_settings_cmd_prop_radio_div_setup.loDivider = PROP_MODE_LO_DIVIDER; diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-ble.c b/cpu/cc26xx-cc13xx/rf-core/rf-ble.c index f41011f5f..bceb9c138 100644 --- a/cpu/cc26xx-cc13xx/rf-core/rf-ble.c +++ b/cpu/cc26xx-cc13xx/rf-core/rf-ble.c @@ -45,6 +45,7 @@ #include "net/linkaddr.h" #include "dev/oscillators.h" #include "rf-core/rf-core.h" +#include "rf-core/rf-switch.h" #include "rf-core/rf-ble.h" #include "driverlib/rf_ble_cmd.h" #include "driverlib/rf_common_cmd.h" @@ -217,6 +218,8 @@ rf_radio_setup() uint32_t cmd_status; rfc_CMD_RADIO_SETUP_t cmd; + rf_switch_select_path(RF_SWITCH_PATH_2_4GHZ); + /* Create radio setup command */ rf_core_init_radio_op((rfc_radioOp_t *)&cmd, sizeof(cmd), CMD_RADIO_SETUP); diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-core.c b/cpu/cc26xx-cc13xx/rf-core/rf-core.c index 81070bdc6..c67f32604 100644 --- a/cpu/cc26xx-cc13xx/rf-core/rf-core.c +++ b/cpu/cc26xx-cc13xx/rf-core/rf-core.c @@ -45,6 +45,7 @@ #include "net/packetbuf.h" #include "net/rime/rimestats.h" #include "rf-core/rf-core.h" +#include "rf-core/rf-switch.h" #include "ti-lib.h" /*---------------------------------------------------------------------------*/ /* RF core and RF HAL API */ @@ -260,6 +261,8 @@ rf_core_power_up() ti_lib_int_master_enable(); } + rf_switch_power_up(); + /* Let CPE boot */ HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = RF_CORE_CLOCKS_MASK; @@ -365,6 +368,8 @@ rf_core_power_down() while(ti_lib_prcm_power_domain_status(PRCM_DOMAIN_RFCORE) != PRCM_DOMAIN_POWER_OFF); + rf_switch_power_down(); + ti_lib_int_pend_clear(INT_RFC_CPE_0); ti_lib_int_pend_clear(INT_RFC_CPE_1); ti_lib_int_enable(INT_RFC_CPE_0); diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-switch.h b/cpu/cc26xx-cc13xx/rf-core/rf-switch.h new file mode 100644 index 000000000..e50b9ff1f --- /dev/null +++ b/cpu/cc26xx-cc13xx/rf-core/rf-switch.h @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/*---------------------------------------------------------------------------*/ +/** \addtogroup rf-core + * @{ + * + * \defgroup rf-switch RF Switch + * + * Header file for RF switch support + * + * @{ + * + * \file + * Header file with definitions related to RF switch support + */ +/*---------------------------------------------------------------------------*/ +#ifndef RF_SWITCH_H_ +#define RF_SWITCH_H_ +/*---------------------------------------------------------------------------*/ +#include "contiki-conf.h" + +#include +/*---------------------------------------------------------------------------*/ +#ifdef RF_SWITCH_CONF_PATH_2_4GHZ +#define RF_SWITCH_PATH_2_4GHZ RF_SWITCH_CONF_PATH_2_4GHZ +#else +#define RF_SWITCH_PATH_2_4GHZ 0 +#endif + +#ifdef RF_SWITCH_CONF_PATH_SUBGHZ +#define RF_SWITCH_PATH_SUBGHZ RF_SWITCH_CONF_PATH_SUBGHZ +#else +#define RF_SWITCH_PATH_SUBGHZ 1 +#endif +/*---------------------------------------------------------------------------*/ +#ifdef RF_SWITCH_CONF_ENABLE +#define RF_SWITCH_ENABLE RF_SWITCH_CONF_ENABLE +#else +#define RF_SWITCH_ENABLE 0 +#endif +/*---------------------------------------------------------------------------*/ +#if RF_SWITCH_ENABLE +/** + * \brief Initialise RF switch pin states. + */ +void rf_switch_init(void); + +/** + * \brief Power up the RF switch. + */ +void rf_switch_power_up(void); + +/** + * \brief Power down the RF switch. + */ +void rf_switch_power_down(void); + +/** + * \brief Select RF path + * \param path The RF path to select on the switch. + * + * The path argument can take values RF_SWITCH_PATH_xyz + */ +void rf_switch_select_path(uint8_t path); +#else +#define rf_switch_init() +#define rf_switch_power_up() +#define rf_switch_power_down() +#define rf_switch_select_path(p) +#endif /* RF_SWITCH_ENABLE */ +/*---------------------------------------------------------------------------*/ +#endif /* RF_SWITCH_H_ */ +/*---------------------------------------------------------------------------*/ +/** + * @} + * @} + */