From 5c058b9c528d70d0bb6f3037ad3788a40a482928 Mon Sep 17 00:00:00 2001 From: Edvard Pettersen Date: Thu, 15 Feb 2018 12:48:02 +0100 Subject: [PATCH] Refactored after PR review --- arch/cpu/simplelink/Makefile.simplelink | 2 +- .../simplelink/dev/{rf-core.c => rf-common.c} | 36 ++++----- arch/cpu/simplelink/dev/rf-common.h | 80 +++++++++++++++++++ arch/cpu/simplelink/dev/rf-core.h | 37 --------- arch/cpu/simplelink/dev/rf-ieee-mode.c | 51 +++++++----- arch/cpu/simplelink/dev/rf-prop-mode.c | 42 ++++++---- arch/cpu/simplelink/dev/watchdog-arch.c | 5 -- .../simplelink/rf-settings/rf-ieee-settings.c | 5 +- .../simplelink/rf-settings/rf-ieee-settings.h | 2 +- .../simplelink/rf-settings/rf-prop-settings.c | 5 +- .../simplelink/rf-settings/rf-prop-settings.h | 2 +- arch/platform/simplelink/platform.c | 65 +++++++-------- 12 files changed, 187 insertions(+), 145 deletions(-) rename arch/cpu/simplelink/dev/{rf-core.c => rf-common.c} (81%) create mode 100644 arch/cpu/simplelink/dev/rf-common.h delete mode 100644 arch/cpu/simplelink/dev/rf-core.h diff --git a/arch/cpu/simplelink/Makefile.simplelink b/arch/cpu/simplelink/Makefile.simplelink index 266565bdb..0f8765d44 100644 --- a/arch/cpu/simplelink/Makefile.simplelink +++ b/arch/cpu/simplelink/Makefile.simplelink @@ -65,7 +65,7 @@ CONTIKI_CPU_DIRS += dev rf-settings CONTIKI_CPU_SOURCEFILES += rtimer-arch.c clock-arch.c CONTIKI_CPU_SOURCEFILES += watchdog-arch.c putchar-arch.c CONTIKI_CPU_SOURCEFILES += uart0-arch.c -CONTIKI_CPU_SOURCEFILES += rf-core.c +CONTIKI_CPU_SOURCEFILES += rf-common.c CONTIKI_CPU_SOURCEFILES += rf-prop-mode.c rf-prop-settings.c CONTIKI_CPU_SOURCEFILES += rf-ieee-mode.c rf-ieee-settings.c CONTIKI_CPU_SOURCEFILES += ieee-addr.c diff --git a/arch/cpu/simplelink/dev/rf-core.c b/arch/cpu/simplelink/dev/rf-common.c similarity index 81% rename from arch/cpu/simplelink/dev/rf-core.c rename to arch/cpu/simplelink/dev/rf-common.c index 232cffb86..e4538e53b 100644 --- a/arch/cpu/simplelink/dev/rf-core.c +++ b/arch/cpu/simplelink/dev/rf-common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,24 +29,20 @@ */ /*---------------------------------------------------------------------------*/ /** - * \addtogroup rf-core + * \addtogroup simplelink * @{ * * \file - * Implementation of the CC13xx/CC26xx RF core driver + * Implementation of common CC13xx/CC26xx RF functionality */ /*---------------------------------------------------------------------------*/ -#include "contiki.h" -#include "dev/watchdog.h" -#include "sys/process.h" -#include "sys/clock.h" -#include "sys/ctimer.h" -#include "sys/energest.h" -#include "sys/cc.h" -#include "net/netstack.h" -#include "net/packetbuf.h" -/*---------------------------------------------------------------------------*/ -#include +#include +#include +#include +#include +#include +#include +#include /*---------------------------------------------------------------------------*/ #include #include @@ -54,14 +50,12 @@ #include #include /*---------------------------------------------------------------------------*/ -#define DEBUG 0 -#if DEBUG -#define PRINTF(...) printf(__VA_ARGS__) -#else -#define PRINTF(...) -#endif +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "RF common" +#define LOG_LEVEL LOG_LEVEL_DBG /*---------------------------------------------------------------------------*/ -PROCESS(RF_coreProcess, "SimpleLink RF driver"); +PROCESS(RF_coreProcess, "SimpleLink RF process"); /*---------------------------------------------------------------------------*/ PROCESS_THREAD(RF_coreProcess, ev, data) { diff --git a/arch/cpu/simplelink/dev/rf-common.h b/arch/cpu/simplelink/dev/rf-common.h new file mode 100644 index 000000000..cd646064f --- /dev/null +++ b/arch/cpu/simplelink/dev/rf-common.h @@ -0,0 +1,80 @@ +/* + * 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 simplelink + * @{ + * + * \defgroup rf-common Common functionality fpr the CC13xx/CC26xx RF + * + * @{ + * + * \file + * Header file of common CC13xx/CC26xx RF functionality + */ +/*---------------------------------------------------------------------------*/ +#ifndef RF_COMMON_H_ +#define RF_COMMON_H_ +/*---------------------------------------------------------------------------*/ +/* Contiki API */ +#include +#include +/*---------------------------------------------------------------------------*/ +/* Standard library */ +#include +/*---------------------------------------------------------------------------*/ +#ifdef RF_CORE_CONF_CHANNEL +# define RF_CORE_CHANNEL RF_CORE_CONF_CHANNEL +#else +# define RF_CORE_CHANNEL 25 +#endif +/*---------------------------------------------------------------------------*/ +typedef enum { + CMD_RESULT_ERROR = 0, + CMD_RESULT_OK = 1, +} CmdResult; +/*---------------------------------------------------------------------------*/ +typedef struct { + radio_value_t dbm; + uint16_t power; ///< Value for the .txPower field +} RF_TxPower; + +#define TX_POWER_UNKNOWN 0xFFFF +/*---------------------------------------------------------------------------*/ +#define RSSI_UNKNOWN -128 +/*---------------------------------------------------------------------------*/ +PROCESS_NAME(RF_coreProcess); +/*---------------------------------------------------------------------------*/ +#endif /* RF_COMMON_H_ */ +/*---------------------------------------------------------------------------*/ +/** + * @} + * @} + */ diff --git a/arch/cpu/simplelink/dev/rf-core.h b/arch/cpu/simplelink/dev/rf-core.h deleted file mode 100644 index 02e882f66..000000000 --- a/arch/cpu/simplelink/dev/rf-core.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef CONTIKI_NG_ARCH_CPU_SIMPLELINK_DEV_RF_CORE_H_ -#define CONTIKI_NG_ARCH_CPU_SIMPLELINK_DEV_RF_CORE_H_ - -/*---------------------------------------------------------------------------*/ -/* Contiki API */ -#include -#include -/*---------------------------------------------------------------------------*/ -#include -/*---------------------------------------------------------------------------*/ -/* Standard library */ -#include -/*---------------------------------------------------------------------------*/ -#ifdef RF_CORE_CONF_CHANNEL -# define RF_CORE_CHANNEL RF_CORE_CONF_CHANNEL -#else -# define RF_CORE_CHANNEL 25 -#endif -/*---------------------------------------------------------------------------*/ -typedef enum { - CMD_ERROR = 0, - CMD_OK = 1, -} CmdResult; -/*---------------------------------------------------------------------------*/ -typedef struct { - radio_value_t dbm; - uint16_t power; /* Value for the PROP_DIV_RADIO_SETUP.txPower field */ -} RF_TxPower; - -#define TX_POWER_UNKNOWN 0xFFFF -/*---------------------------------------------------------------------------*/ -#define RSSI_UNKNOWN -128 -/*---------------------------------------------------------------------------*/ -PROCESS_NAME(RF_coreProcess); -/*---------------------------------------------------------------------------*/ - -#endif /* CONTIKI_NG_ARCH_CPU_SIMPLELINK_DEV_RF_CORE_H_ */ diff --git a/arch/cpu/simplelink/dev/rf-ieee-mode.c b/arch/cpu/simplelink/dev/rf-ieee-mode.c index f3686505c..d80af6d1e 100644 --- a/arch/cpu/simplelink/dev/rf-ieee-mode.c +++ b/arch/cpu/simplelink/dev/rf-ieee-mode.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,10 +57,19 @@ #include #include #include -#include +/*---------------------------------------------------------------------------*/ +/* RF settings */ +#ifdef IEEE_MODE_CONF_RF_SETTINGS +# define IEEE_MODE_RF_SETTINGS IEEE_MODE_CONF_RF_SETTINGS +# undef IEEE_MODE_CONF_RF_SETTINGS +#else +# define IEEE_MODE_RF_SETTINGS "rf-settings/rf-ieee-settings.h" +#endif + +#include IEEE_MODE_RF_SETTINGS /*---------------------------------------------------------------------------*/ /* Simplelink Platform RF dev */ -#include "rf-core.h" +#include "rf-common.h" #include "dot-15-4g.h" /*---------------------------------------------------------------------------*/ #include @@ -389,7 +398,7 @@ set_tx_power(const radio_value_t dbm) } if (!g_pCurrTxPower) { - return CMD_ERROR; + return CMD_RESULT_ERROR; } rfc_CMD_SET_TX_POWER_t cmdSetTxPower = { @@ -400,9 +409,9 @@ set_tx_power(const radio_value_t dbm) const RF_Stat stat = RF_runImmediateCmd(g_rfHandle, (uint32_t*)&cmdSetTxPower); if (stat != RF_StatCmdDoneSuccess) { PRINTF("set_tx_power: stat=0x%02X\n", stat); - return CMD_ERROR; + return CMD_RESULT_ERROR; } - return CMD_OK; + return CMD_RESULT_OK; } /*---------------------------------------------------------------------------*/ static radio_value_t @@ -497,7 +506,7 @@ init(void) process_start(&RF_coreProcess, NULL); - return CMD_OK; + return CMD_RESULT_OK; } /*---------------------------------------------------------------------------*/ static int @@ -530,14 +539,14 @@ set_rx(const PowerState state) if (stat != RF_StatSuccess) { PRINTF("set_rx(off): unable to cancel RX\n"); - return CMD_ERROR; + return CMD_RESULT_ERROR; } } if (state == POWER_STATE_ON || state == POWER_STATE_RESTART) { if (g_vpCmdRx->status == ACTIVE) { PRINTF("set_rx(on): already in RX\n"); - return CMD_OK; + return CMD_RESULT_OK; } RF_ScheduleCmdParams schedParams = { @@ -550,11 +559,11 @@ set_rx(const PowerState state) g_cmdRxHandle = RF_scheduleCmd(g_rfHandle, (RF_Op*)g_vpCmdRx, &schedParams, NULL, 0); if ((g_cmdTxHandle == RF_ALLOC_ERROR) || (g_cmdTxHandle == RF_SCHEDULE_CMD_ERROR)) { PRINTF("transmit: unable to allocate RX command\n"); - return CMD_ERROR; + return CMD_RESULT_ERROR; } } - return CMD_OK; + return CMD_RESULT_OK; } /*---------------------------------------------------------------------------*/ static int @@ -698,7 +707,7 @@ channel_clear_aux(void) const RF_Stat stat = RF_runImmediateCmd(g_rfHandle, (uint32_t*)&RF_cmdIeeeCaaReq); if (stat != RF_StatCmdDoneSuccess) { PRINTF("channel_clear: CCA request failed stat=0x%02X\n", stat); - return CMD_ERROR; + return CMD_RESULT_ERROR; } // Channel is clear if CCA state is idle (0) or invalid (2), i.e. not busy (1) @@ -709,7 +718,7 @@ static int channel_clear(void) { const bool was_rx = (g_vpCmdRx->status == ACTIVE); - if (!was_rx && set_rx(POWER_STATE_ON) != CMD_OK) { + if (!was_rx && set_rx(POWER_STATE_ON) != CMD_RESULT_OK) { PRINTF("channel_clear: unable to start RX\n"); return CHANNEL_CLEAR_ERROR; } @@ -809,7 +818,7 @@ off(void) } } - return CMD_OK; + return CMD_RESULT_OK; } /*---------------------------------------------------------------------------*/ static radio_result_t @@ -905,7 +914,7 @@ set_value(radio_param_t param, radio_value_t value) case RADIO_PARAM_POWER_MODE: switch (value) { case RADIO_POWER_MODE_ON: - if (on() != CMD_OK) { + if (on() != CMD_RESULT_OK) { PRINTF("set_value: on() failed (1)\n"); return RADIO_RESULT_ERROR; } @@ -928,7 +937,7 @@ set_value(radio_param_t param, radio_value_t value) case RADIO_PARAM_PAN_ID: g_vpCmdRx->localPanID = (uint16_t)value; - if (rf_is_on() && set_rx(POWER_STATE_RESTART) != CMD_OK) { + if (rf_is_on() && set_rx(POWER_STATE_RESTART) != CMD_RESULT_OK) { PRINTF("failed to restart RX"); return RADIO_RESULT_ERROR; } @@ -936,7 +945,7 @@ set_value(radio_param_t param, radio_value_t value) case RADIO_PARAM_16BIT_ADDR: g_vpCmdRx->localShortAddr = (uint16_t)value; - if (rf_is_on() && set_rx(POWER_STATE_RESTART) != CMD_OK) { + if (rf_is_on() && set_rx(POWER_STATE_RESTART) != CMD_RESULT_OK) { PRINTF("failed to restart RX"); return RADIO_RESULT_ERROR; } @@ -970,7 +979,7 @@ set_value(radio_param_t param, radio_value_t value) } return RADIO_RESULT_OK; } - if (rf_is_on() && set_rx(POWER_STATE_RESTART) != CMD_OK) { + if (rf_is_on() && set_rx(POWER_STATE_RESTART) != CMD_RESULT_OK) { PRINTF("failed to restart RX"); return RADIO_RESULT_ERROR; } @@ -988,13 +997,13 @@ set_value(radio_param_t param, radio_value_t value) if(value < TX_POWER_MIN.dbm || value > TX_POWER_MAX.dbm) { return RADIO_RESULT_INVALID_VALUE; } - return (set_tx_power(value) != CMD_OK) + return (set_tx_power(value) != CMD_RESULT_OK) ? RADIO_RESULT_ERROR : RADIO_RESULT_OK; case RADIO_PARAM_CCA_THRESHOLD: g_vpCmdRx->ccaRssiThr = (int8_t)value; - if (rf_is_on() && set_rx(POWER_STATE_RESTART) != CMD_OK) { + if (rf_is_on() && set_rx(POWER_STATE_RESTART) != CMD_RESULT_OK) { PRINTF("failed to restart RX"); return RADIO_RESULT_ERROR; } @@ -1062,7 +1071,7 @@ set_object(radio_param_t param, const void *src, size_t size) } const bool is_rx = (g_vpCmdRx->status == ACTIVE); - if (is_rx && set_rx(POWER_STATE_RESTART) != CMD_OK) { + if (is_rx && set_rx(POWER_STATE_RESTART) != CMD_RESULT_OK) { return RADIO_RESULT_ERROR; } return RADIO_RESULT_OK; diff --git a/arch/cpu/simplelink/dev/rf-prop-mode.c b/arch/cpu/simplelink/dev/rf-prop-mode.c index 375b79554..f1cc3c2e9 100644 --- a/arch/cpu/simplelink/dev/rf-prop-mode.c +++ b/arch/cpu/simplelink/dev/rf-prop-mode.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,10 +52,20 @@ #include #include #include -#include +/*---------------------------------------------------------------------------*/ +/* RF settings */ +/* RF settings */ +#ifdef PROP_MODE_CONF_RF_SETTINGS +# define PROP_MODE_RF_SETTINGS PROP_MODE_CONF_RF_SETTINGS +# undef PROP_MODE_CONF_RF_SETTINGS +#else +# define PROP_MODE_RF_SETTINGS "rf-settings/rf-prop-settings.h" +#endif + +#include PROP_MODE_RF_SETTINGS /*---------------------------------------------------------------------------*/ /* Platform RF dev */ -#include "rf-core.h" +#include "rf-common.h" #include "dot-15-4g.h" /*---------------------------------------------------------------------------*/ #include @@ -246,7 +256,7 @@ rf_start_rx() RF_CmdHandle rxCmdHandle = RF_postCmd(rfHandle, (RF_Op*)gvp_cmd_rx_adv, RF_PriorityNormal, &rf_rx_callback, RF_EventRxEntryDone); if (rxCmdHandle == RF_ALLOC_ERROR) { - return CMD_ERROR; + return CMD_RESULT_ERROR; } /* Wait to enter RX */ @@ -258,10 +268,10 @@ rf_start_rx() PRINTF("RF_cmdPropRxAdv: handle=0x%08lx, status=0x%04x\n", (unsigned long)rxCmdHandle, gvp_cmd_rx_adv->status); rf_switch_off(); - return CMD_ERROR; + return CMD_RESULT_ERROR; } - return CMD_OK; + return CMD_RESULT_OK; } /*---------------------------------------------------------------------------*/ static CmdResult @@ -269,7 +279,7 @@ rf_stop_rx(void) { /* If we are off, do nothing */ if (!rf_is_receiving()) { - return CMD_OK; + return CMD_RESULT_OK; } /* Abort any ongoing operation. Don't care about the result. */ @@ -281,12 +291,12 @@ rf_stop_rx(void) gvp_cmd_rx_adv->status != PROP_DONE_ABORT) { PRINTF("RF_cmdPropRxAdv cancel: status=0x%04x\n", gvp_cmd_rx_adv->status); - return CMD_ERROR; + return CMD_RESULT_ERROR; } /* Stopped gracefully */ ENERGEST_OFF(ENERGEST_TYPE_LISTEN); - return CMD_OK; + return CMD_RESULT_OK; } /*---------------------------------------------------------------------------*/ static CmdResult @@ -294,10 +304,10 @@ rf_run_setup() { RF_runCmd(rfHandle, (RF_Op*)gvp_cmd_radio_div_setup, RF_PriorityNormal, NULL, 0); if (gvp_cmd_radio_div_setup->status != PROP_DONE_OK) { - return CMD_ERROR; + return CMD_RESULT_ERROR; } - return CMD_OK; + return CMD_RESULT_OK; } /*---------------------------------------------------------------------------*/ static radio_value_t @@ -309,7 +319,7 @@ get_rssi(void) } const bool was_off = !rf_is_receiving(); - if (was_off && rf_start_rx() == CMD_ERROR) { + if (was_off && rf_start_rx() == CMD_RESULT_ERROR) { PRINTF("get_rssi: unable to start RX\n"); return RF_GET_RSSI_ERROR_VAL; } @@ -658,7 +668,7 @@ rf_switch_off(void) // * from within an interrupt context. Abort, but pretend everything is OK. // */ // if(rf_ble_is_active() == RF_BLE_ACTIVE) { -// return CMD_OK; +// return CMD_RESULT_OK; // } // Force abort of any ongoing RF operation. @@ -670,7 +680,7 @@ rf_switch_off(void) /* We pulled the plug, so we need to restore the status manually */ gvp_cmd_rx_adv->status = IDLE; - return CMD_OK; + return CMD_RESULT_OK; } /*---------------------------------------------------------------------------*/ static radio_result_t @@ -767,7 +777,7 @@ set_value(radio_param_t param, radio_value_t value) /* If we reach here we had no errors. Apply new settings */ if (rf_is_receiving()) { rf_stop_rx(); - if (rf_run_setup() != CMD_OK) { + if (rf_run_setup() != CMD_RESULT_OK) { return RADIO_RESULT_ERROR; } rf_start_rx(); @@ -826,7 +836,7 @@ rf_init(void) process_start(&RF_coreProcess, NULL); - return CMD_OK; + return CMD_RESULT_OK; } /*---------------------------------------------------------------------------*/ const struct radio_driver prop_mode_driver = { diff --git a/arch/cpu/simplelink/dev/watchdog-arch.c b/arch/cpu/simplelink/dev/watchdog-arch.c index 505570ccd..ac137e577 100644 --- a/arch/cpu/simplelink/dev/watchdog-arch.c +++ b/arch/cpu/simplelink/dev/watchdog-arch.c @@ -109,7 +109,6 @@ lock_config(uint32_t status) void watchdog_init(void) { - return; WatchdogReloadSet(CONTIKI_WATCHDOG_TIMER_TOP); lock_config(LOCK_REGISTERS_UNLOCKED); } @@ -120,7 +119,6 @@ watchdog_init(void) void watchdog_start(void) { - return; uint32_t lock_status = unlock_config(); watchdog_periodic(); @@ -135,7 +133,6 @@ watchdog_start(void) void watchdog_periodic(void) { - return; WatchdogReloadSet(CONTIKI_WATCHDOG_TIMER_TOP); WatchdogIntClear(); } @@ -146,7 +143,6 @@ watchdog_periodic(void) void watchdog_stop(void) { - return; uint32_t lock_status = unlock_config(); WatchdogResetDisable(); @@ -160,7 +156,6 @@ watchdog_stop(void) void watchdog_reboot(void) { - return; watchdog_start(); while(1); } diff --git a/arch/cpu/simplelink/rf-settings/rf-ieee-settings.c b/arch/cpu/simplelink/rf-settings/rf-ieee-settings.c index 85dda307d..1f7fea3d9 100644 --- a/arch/cpu/simplelink/rf-settings/rf-ieee-settings.c +++ b/arch/cpu/simplelink/rf-settings/rf-ieee-settings.c @@ -22,10 +22,7 @@ #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 -#include - -#include "rf-core.h" +#include "rf-common.h" /*---------------------------------------------------------------------------*/ /* Default TX power settings for the 2.4 GHz band */ diff --git a/arch/cpu/simplelink/rf-settings/rf-ieee-settings.h b/arch/cpu/simplelink/rf-settings/rf-ieee-settings.h index 898c830cf..d3c973b48 100644 --- a/arch/cpu/simplelink/rf-settings/rf-ieee-settings.h +++ b/arch/cpu/simplelink/rf-settings/rf-ieee-settings.h @@ -8,7 +8,7 @@ #include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h) #include -#include +#include // RF TX power table extern RF_TxPower RF_ieeeTxPower[]; diff --git a/arch/cpu/simplelink/rf-settings/rf-prop-settings.c b/arch/cpu/simplelink/rf-settings/rf-prop-settings.c index 2307acffb..4deeca8d3 100644 --- a/arch/cpu/simplelink/rf-settings/rf-prop-settings.c +++ b/arch/cpu/simplelink/rf-settings/rf-prop-settings.c @@ -35,10 +35,7 @@ #include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_genfsk.h) #include DeviceFamily_constructPath(rf_patches/rf_patch_mce_genfsk.h) -#include -#include - -#include "rf-core.h" +#include "rf-common.h" /*---------------------------------------------------------------------------*/ /** diff --git a/arch/cpu/simplelink/rf-settings/rf-prop-settings.h b/arch/cpu/simplelink/rf-settings/rf-prop-settings.h index d0ac01ff3..d897449ce 100644 --- a/arch/cpu/simplelink/rf-settings/rf-prop-settings.h +++ b/arch/cpu/simplelink/rf-settings/rf-prop-settings.h @@ -13,7 +13,7 @@ #include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h) #include -#include +#include // RF TX power table extern RF_TxPower RF_propTxPower779_930[]; diff --git a/arch/platform/simplelink/platform.c b/arch/platform/simplelink/platform.c index 53cfcefb9..e46077d42 100644 --- a/arch/platform/simplelink/platform.c +++ b/arch/platform/simplelink/platform.c @@ -45,35 +45,36 @@ * - The TI CC26X2R1 LaunchPad * @{ */ +/*---------------------------------------------------------------------------*/ +/* Simplelink SDK includes */ #include #include #include #include #include #include - +/*---------------------------------------------------------------------------*/ +/* Contiki API */ #include "contiki.h" #include "contiki-net.h" - -#include "uart0-arch.h" - -#include "leds.h" -//#include "gpio-interrupt.h" -#include "ieee-addr.h" -#include "dev/rf-core.h" -#include "uart0-arch.h" #include "sys/clock.h" #include "sys/rtimer.h" #include "sys/node-id.h" #include "sys/platform.h" +#include "dev/serial-line.h" +#include "net/mac/framer/frame802154.h" +/*---------------------------------------------------------------------------*/ +/* Arch driver implementations */ +#include "uart0-arch.h" +/*---------------------------------------------------------------------------*/ +#include "leds.h" +//#include "gpio-interrupt.h" +#include "ieee-addr.h" +#include "dev/rf-common.h" #include "lib/random.h" #include "lib/sensors.h" #include "button-sensor.h" -#include "dev/serial-line.h" -#include "net/mac/framer/frame802154.h" - -//#include "driverlib/driverlib_release.h" - +/*---------------------------------------------------------------------------*/ #include /*---------------------------------------------------------------------------*/ /* Log configuration */ @@ -81,7 +82,7 @@ #define LOG_MODULE "CC26xx/CC13xx" #define LOG_LEVEL LOG_LEVEL_MAIN /*---------------------------------------------------------------------------*/ -unsigned short node_id = 0; +unsigned short g_nodeId = 0; /*---------------------------------------------------------------------------*/ /** \brief Board specific initialization */ void board_init(void); @@ -90,9 +91,8 @@ static void fade(unsigned char l) { volatile int i; - int k, j; - for(k = 0; k < 800; ++k) { - j = k > 400 ? 800 - k : k; + for(int k = 0; k < 800; ++k) { + int j = k > 400 ? 800 - k : k; GPIO_write(l, Board_GPIO_LED_ON); for(i = 0; i < j; ++i) { @@ -111,7 +111,7 @@ set_rf_params(void) uint16_t short_addr; uint8_t ext_addr[8]; - ieee_addr_cpy_to(ext_addr, 8); + ieee_addr_cpy_to(ext_addr, sizeof(ext_addr)); short_addr = ext_addr[7]; short_addr |= ext_addr[6] << 8; @@ -119,20 +119,20 @@ set_rf_params(void) NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID); NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr); NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, RF_CORE_CHANNEL); - NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8); + NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, sizeof(ext_addr)); /* also set the global node id */ - node_id = short_addr; + g_nodeId = short_addr; } /*---------------------------------------------------------------------------*/ void platform_init_stage_one() { - Board_initGeneral(); - GPIO_init(); + Board_initGeneral(); + GPIO_init(); // Only enables interrupts - NoRTOS_start(); + NoRTOS_start(); // /* Enable flash cache and prefetch. */ // ti_lib_vims_mode_set(VIMS_BASE, VIMS_MODE_ENABLED); @@ -169,15 +169,14 @@ platform_init_stage_one() void platform_init_stage_two() { - uart0_init(); + uart0_init(); + serial_line_init(); // random_init(0x1234); -// -// serial_line_init(); -// + /* Populate linkaddr_node_addr */ ieee_addr_cpy_to(linkaddr_node_addr.u8, LINKADDR_SIZE); -// + fade(Board_GPIO_LED0); } /*---------------------------------------------------------------------------*/ @@ -200,7 +199,7 @@ platform_init_stage_three() ChipInfo_SupportsBLE() ? "Yes" : "No", ChipInfo_SupportsPROPRIETARY() ? "Yes" : "No"); LOG_INFO(" RF: Channel %d, PANID 0x%04X\n", chan, pan); - LOG_INFO(" Node ID: %d\n", node_id); + LOG_INFO(" Node ID: %d\n", g_nodeId); // // process_start(&sensors_process, NULL); fade(Board_GPIO_LED1); @@ -209,10 +208,8 @@ platform_init_stage_three() void platform_idle() { - /* Drop to some low power mode */ -// lpm_drop(); - - Power_idleFunc(); + // Drop to some low power mode + Power_idleFunc(); } /*---------------------------------------------------------------------------*/ /**