From 16f56abfad9b69fdd3869dc65167f3e35be581b6 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 1 Nov 2015 17:45:29 +0000 Subject: [PATCH 001/129] Wait for a valid RSSI reading in CC13xx/CC26xx RF drivers As discussed in #1341, the current CC13xx/CC26xx IEEE mode driver sends `CMD_GET_RSSI` once and returns the RSSI reading uncondtionally. This happens within the `get_rssi()` function. This logic is broken if `get_rssi()` is called with the radio off. The function will make sure to turn on the radio first, but it does not make sure the RSSI reading is valid, which only happens a number of symbol periods after the radio enters RX. The outcome is that `NETSTACK_RADIO.get_value(RADIO_PARAM_RSSI, ...)` will always return -128 (meaning that RSSI is unavailable) if the radio was off at the time of calling the function. The same condition affects the prop mode driver. This commit changes the logic of `get_rssi()`: * For PROP mode, if `CMD_GET_RSSI` returns an invalid RSSI, we send it again. For unknown reasons, `CMD_GET_RSSI` on occasion returns 0, so we ignore that value too. * For IEEE mode, we use `CMD_IEEE_CCA_REQ` and we inspect the value of `ccaInfo.ccaEnergy` of the return structure. If the value is 0x02 (Invalid), we send the command again. Fixes #1341 --- cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 21 +++++++++++++-------- cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 18 ++++++++++++------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index f76fe2beb..3480ba86d 100644 --- a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -384,9 +384,8 @@ static radio_value_t get_rssi(void) { uint32_t cmd_status; - int8_t rssi; uint8_t was_off = 0; - rfc_CMD_GET_RSSI_t cmd; + rfc_CMD_IEEE_CCA_REQ_t cmd; /* If we are off, turn on first */ if(!rf_is_on()) { @@ -398,13 +397,19 @@ get_rssi(void) } memset(&cmd, 0x00, sizeof(cmd)); - cmd.commandNo = CMD_GET_RSSI; + cmd.ccaInfo.ccaEnergy = RF_CMD_CCA_REQ_CCA_STATE_INVALID; - rssi = RF_CMD_CCA_REQ_RSSI_UNKNOWN; + while(cmd.ccaInfo.ccaEnergy == RF_CMD_CCA_REQ_CCA_STATE_INVALID) { + memset(&cmd, 0x00, sizeof(cmd)); + cmd.commandNo = CMD_IEEE_CCA_REQ; - if(rf_core_send_cmd((uint32_t)&cmd, &cmd_status) == RF_CORE_CMD_OK) { - /* Current RSSI in bits 23:16 of cmd_status */ - rssi = (cmd_status >> 16) & 0xFF; + if(rf_core_send_cmd((uint32_t)&cmd, &cmd_status) == RF_CORE_CMD_ERROR) { + PRINTF("get_rssi: CMDSTA=0x%08lx\n", cmd_status); + + /* Make sure to return RSSI unknown */ + cmd.currentRssi = RF_CMD_CCA_REQ_RSSI_UNKNOWN; + break; + } } /* If we were off, turn back off */ @@ -412,7 +417,7 @@ get_rssi(void) off(); } - return rssi; + return cmd.currentRssi; } /*---------------------------------------------------------------------------*/ /* Returns the current TX power in dBm */ diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index 94aef33b9..902eb04ea 100644 --- a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -271,6 +271,7 @@ get_rssi(void) { uint32_t cmd_status; int8_t rssi; + uint8_t attempts = 0; uint8_t was_off = 0; rfc_CMD_GET_RSSI_t cmd; @@ -283,14 +284,19 @@ get_rssi(void) } } - memset(&cmd, 0x00, sizeof(cmd)); - cmd.commandNo = CMD_GET_RSSI; - rssi = RF_CMD_CCA_REQ_RSSI_UNKNOWN; - if(rf_core_send_cmd((uint32_t)&cmd, &cmd_status) == RF_CORE_CMD_OK) { - /* Current RSSI in bits 23:16 of cmd_status */ - rssi = (cmd_status >> 16) & 0xFF; + while((rssi == RF_CMD_CCA_REQ_RSSI_UNKNOWN || rssi == 0) && ++attempts < 10) { + memset(&cmd, 0x00, sizeof(cmd)); + cmd.commandNo = CMD_GET_RSSI; + + if(rf_core_send_cmd((uint32_t)&cmd, &cmd_status) == RF_CORE_CMD_ERROR) { + PRINTF("get_rssi: CMDSTA=0x%08lx\n", cmd_status); + break; + } else { + /* Current RSSI in bits 23:16 of cmd_status */ + rssi = (cmd_status >> 16) & 0xFF; + } } /* If we were off, turn back off */ From 2039b3a55277bc5e3cbb06c80fa8ecfb45a27766 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 17 Jul 2016 17:09:09 +0100 Subject: [PATCH 002/129] Use `ccaInfo.ccaState` to decide whether CCA is complete This commit changes the logic of `get_cca_info()` in the CC26xx IEEE mode driver. We now use the command's return status bits to determine whether the radio's CCA monitoring function has concluded, instead of drawing conclusions based on RSSI readings. --- cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index f76fe2beb..88dd234cd 100644 --- a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -340,13 +340,12 @@ transmitting(void) * It is the caller's responsibility to make sure the RF is on. This function * will return RF_GET_CCA_INFO_ERROR if the RF is off * - * This function will in fact wait for a valid RSSI signal + * This function will in fact wait for a valid CCA state */ static uint8_t get_cca_info(void) { uint32_t cmd_status; - int8_t rssi; rfc_CMD_IEEE_CCA_REQ_t cmd; if(!rf_is_on()) { @@ -354,9 +353,10 @@ get_cca_info(void) return RF_GET_CCA_INFO_ERROR; } - rssi = RF_CMD_CCA_REQ_RSSI_UNKNOWN; + memset(&cmd, 0x00, sizeof(cmd)); + cmd.ccaInfo.ccaState = RF_CMD_CCA_REQ_CCA_STATE_INVALID; - while(rssi == RF_CMD_CCA_REQ_RSSI_UNKNOWN || rssi == 0) { + while(cmd.ccaInfo.ccaState == RF_CMD_CCA_REQ_CCA_STATE_INVALID) { memset(&cmd, 0x00, sizeof(cmd)); cmd.commandNo = CMD_IEEE_CCA_REQ; @@ -365,11 +365,9 @@ get_cca_info(void) return RF_GET_CCA_INFO_ERROR; } - - rssi = cmd.currentRssi; } - /* We have a valid RSSI signal. Return the CCA Info */ + /* We have a valid CCA state. Return the CCA Info */ return *((uint8_t *)&cmd.ccaInfo); } /*---------------------------------------------------------------------------*/ From 88fdc46e03da1a7ed462dfc4e399a8e0ca3998a6 Mon Sep 17 00:00:00 2001 From: Mohamed Seliem Date: Sun, 4 Dec 2016 19:03:15 +0200 Subject: [PATCH 003/129] update httpd_cgi to enable the compilation of webserver-ipv6 example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this simple change fixes the bug reported in @#1541. ../../apps/webserver/httpd.h:63:9: note: expected ‘uip_ip6addr_t’ but argument is of type ‘union uip_ipaddr_t *’ --- apps/webserver/httpd-cgi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/webserver/httpd-cgi.c b/apps/webserver/httpd-cgi.c index 506d024d2..0cd474f9b 100644 --- a/apps/webserver/httpd-cgi.c +++ b/apps/webserver/httpd-cgi.c @@ -252,7 +252,7 @@ extern uip_ds6_netif_t uip_ds6_if; static unsigned short make_addresses(void *p) { -uint8_t i,j=0; +uint8_t j=0; uint16_t numprinted; numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh); for (i=0; iipaddr, uip_appdata + numprinted); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, r->length); - numprinted += httpd_cgi_sprint_ip6(uip_ds6_route_nexthop(r), uip_appdata + numprinted); + numprinted += httpd_cgi_sprint_ip6(*(uip_ds6_route_nexthop(r)), uip_appdata + numprinted); if(r->state.lifetime < 3600) { numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, r->state.lifetime); } else { From b67d3cc6ea19b854326bf099b8ae7342318c5239 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 13 Nov 2016 14:13:14 +0000 Subject: [PATCH 004/129] Remove RF API header files xxwares ship these headers now, so we will switch to using those versions. The exceptions are IEEE API headers, which are for not part of xxwares, so we have to keep them locally for now. --- cpu/cc26xx-cc13xx/rf-core/api/ble_cmd.h | 1081 ------------------ cpu/cc26xx-cc13xx/rf-core/api/ble_mailbox.h | 69 -- cpu/cc26xx-cc13xx/rf-core/api/common_cmd.h | 1031 ----------------- cpu/cc26xx-cc13xx/rf-core/api/data_entry.h | 213 ---- cpu/cc26xx-cc13xx/rf-core/api/mailbox.h | 328 ------ cpu/cc26xx-cc13xx/rf-core/api/prop_cmd.h | 596 ---------- cpu/cc26xx-cc13xx/rf-core/api/prop_mailbox.h | 71 -- 7 files changed, 3389 deletions(-) delete mode 100644 cpu/cc26xx-cc13xx/rf-core/api/ble_cmd.h delete mode 100644 cpu/cc26xx-cc13xx/rf-core/api/ble_mailbox.h delete mode 100644 cpu/cc26xx-cc13xx/rf-core/api/common_cmd.h delete mode 100644 cpu/cc26xx-cc13xx/rf-core/api/data_entry.h delete mode 100644 cpu/cc26xx-cc13xx/rf-core/api/mailbox.h delete mode 100644 cpu/cc26xx-cc13xx/rf-core/api/prop_cmd.h delete mode 100644 cpu/cc26xx-cc13xx/rf-core/api/prop_mailbox.h diff --git a/cpu/cc26xx-cc13xx/rf-core/api/ble_cmd.h b/cpu/cc26xx-cc13xx/rf-core/api/ble_cmd.h deleted file mode 100644 index 01324401f..000000000 --- a/cpu/cc26xx-cc13xx/rf-core/api/ble_cmd.h +++ /dev/null @@ -1,1081 +0,0 @@ -/****************************************************************************** -* Filename: ble_cmd.h -* Revised: $ $ -* Revision: $ $ -* -* Description: CC26xx/CC13xx API for Bluetooth Low Energy commands -* -* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ -* -* -* 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. -* -******************************************************************************/ - -#ifndef BLE_CMD_H_ -#define BLE_CMD_H_ - -#ifndef __RFC_STRUCT -#ifdef __GNUC__ -#define __RFC_STRUCT __attribute__ ((aligned (4))) -#else -#define __RFC_STRUCT -#endif -#endif - -//! \addtogroup rfc -//! @{ - -//! \addtogroup ble_cmd -//! @{ - -#include -#include "mailbox.h" -#include "common_cmd.h" - -typedef struct __RFC_STRUCT rfc_bleRadioOp_s rfc_bleRadioOp_t; -typedef struct __RFC_STRUCT rfc_CMD_BLE_SLAVE_s rfc_CMD_BLE_SLAVE_t; -typedef struct __RFC_STRUCT rfc_CMD_BLE_MASTER_s rfc_CMD_BLE_MASTER_t; -typedef struct __RFC_STRUCT rfc_CMD_BLE_ADV_s rfc_CMD_BLE_ADV_t; -typedef struct __RFC_STRUCT rfc_CMD_BLE_ADV_DIR_s rfc_CMD_BLE_ADV_DIR_t; -typedef struct __RFC_STRUCT rfc_CMD_BLE_ADV_NC_s rfc_CMD_BLE_ADV_NC_t; -typedef struct __RFC_STRUCT rfc_CMD_BLE_ADV_SCAN_s rfc_CMD_BLE_ADV_SCAN_t; -typedef struct __RFC_STRUCT rfc_CMD_BLE_SCANNER_s rfc_CMD_BLE_SCANNER_t; -typedef struct __RFC_STRUCT rfc_CMD_BLE_INITIATOR_s rfc_CMD_BLE_INITIATOR_t; -typedef struct __RFC_STRUCT rfc_CMD_BLE_GENERIC_RX_s rfc_CMD_BLE_GENERIC_RX_t; -typedef struct __RFC_STRUCT rfc_CMD_BLE_TX_TEST_s rfc_CMD_BLE_TX_TEST_t; -typedef struct __RFC_STRUCT rfc_CMD_BLE_ADV_PAYLOAD_s rfc_CMD_BLE_ADV_PAYLOAD_t; -typedef struct __RFC_STRUCT rfc_bleMasterSlavePar_s rfc_bleMasterSlavePar_t; -typedef struct __RFC_STRUCT rfc_bleMasterPar_s rfc_bleMasterPar_t; -typedef struct __RFC_STRUCT rfc_bleSlavePar_s rfc_bleSlavePar_t; -typedef struct __RFC_STRUCT rfc_bleAdvPar_s rfc_bleAdvPar_t; -typedef struct __RFC_STRUCT rfc_bleScannerPar_s rfc_bleScannerPar_t; -typedef struct __RFC_STRUCT rfc_bleInitiatorPar_s rfc_bleInitiatorPar_t; -typedef struct __RFC_STRUCT rfc_bleGenericRxPar_s rfc_bleGenericRxPar_t; -typedef struct __RFC_STRUCT rfc_bleTxTestPar_s rfc_bleTxTestPar_t; -typedef struct __RFC_STRUCT rfc_bleMasterSlaveOutput_s rfc_bleMasterSlaveOutput_t; -typedef struct __RFC_STRUCT rfc_bleAdvOutput_s rfc_bleAdvOutput_t; -typedef struct __RFC_STRUCT rfc_bleScannerOutput_s rfc_bleScannerOutput_t; -typedef struct __RFC_STRUCT rfc_bleInitiatorOutput_s rfc_bleInitiatorOutput_t; -typedef struct __RFC_STRUCT rfc_bleGenericRxOutput_s rfc_bleGenericRxOutput_t; -typedef struct __RFC_STRUCT rfc_bleTxTestOutput_s rfc_bleTxTestOutput_t; -typedef struct __RFC_STRUCT rfc_bleWhiteListEntry_s rfc_bleWhiteListEntry_t; -typedef struct __RFC_STRUCT rfc_bleRxStatus_s rfc_bleRxStatus_t; - -//! \addtogroup bleRadioOp -//! @{ -struct __RFC_STRUCT rfc_bleRadioOp_s { - uint16_t commandNo; //!< The command ID number - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t channel; //!< \brief Channel to use
- //!< 0–39: BLE advertising/data channel number - //!< 60–207: Custom frequency; (2300 + channel) MHz - //!< 255: Use existing frequency - //!< Others: Reserved - struct { - uint8_t init:7; //!< \brief If bOverride = 1 or custom frequency is used:
- //!< 0: Do not use whitening
- //!< Other value: Initialization for 7-bit LFSR whitener - uint8_t bOverride:1; //!< \brief 0: Use default whitening for BLE advertising/data channels
- //!< 1: Override whitening initialization with value of init - } whitening; - uint8_t* pParams; //!< Pointer to command specific parameter structure - uint8_t* pOutput; //!< Pointer to command specific output structure -}; - -//! @} - -//! \addtogroup CMD_BLE_SLAVE -//! @{ -#define CMD_BLE_SLAVE 0x1801 -struct __RFC_STRUCT rfc_CMD_BLE_SLAVE_s { - uint16_t commandNo; //!< The command ID number 0x1801 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t channel; //!< \brief Channel to use
- //!< 0–39: BLE advertising/data channel number - //!< 60–207: Custom frequency; (2300 + channel) MHz - //!< 255: Use existing frequency - //!< Others: Reserved - struct { - uint8_t init:7; //!< \brief If bOverride = 1 or custom frequency is used:
- //!< 0: Do not use whitening
- //!< Other value: Initialization for 7-bit LFSR whitener - uint8_t bOverride:1; //!< \brief 0: Use default whitening for BLE advertising/data channels
- //!< 1: Override whitening initialization with value of init - } whitening; - rfc_bleSlavePar_t *pParams; //!< Pointer to command specific parameter structure - rfc_bleMasterSlaveOutput_t *pOutput; //!< Pointer to command specific output structure -}; - -//! @} - -//! \addtogroup CMD_BLE_MASTER -//! @{ -#define CMD_BLE_MASTER 0x1802 -struct __RFC_STRUCT rfc_CMD_BLE_MASTER_s { - uint16_t commandNo; //!< The command ID number 0x1802 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t channel; //!< \brief Channel to use
- //!< 0–39: BLE advertising/data channel number - //!< 60–207: Custom frequency; (2300 + channel) MHz - //!< 255: Use existing frequency - //!< Others: Reserved - struct { - uint8_t init:7; //!< \brief If bOverride = 1 or custom frequency is used:
- //!< 0: Do not use whitening
- //!< Other value: Initialization for 7-bit LFSR whitener - uint8_t bOverride:1; //!< \brief 0: Use default whitening for BLE advertising/data channels
- //!< 1: Override whitening initialization with value of init - } whitening; - rfc_bleMasterPar_t *pParams; //!< Pointer to command specific parameter structure - rfc_bleMasterSlaveOutput_t *pOutput; //!< Pointer to command specific output structure -}; - -//! @} - -//! \addtogroup CMD_BLE_ADV -//! @{ -#define CMD_BLE_ADV 0x1803 -struct __RFC_STRUCT rfc_CMD_BLE_ADV_s { - uint16_t commandNo; //!< The command ID number 0x1803 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t channel; //!< \brief Channel to use
- //!< 0–39: BLE advertising/data channel number - //!< 60–207: Custom frequency; (2300 + channel) MHz - //!< 255: Use existing frequency - //!< Others: Reserved - struct { - uint8_t init:7; //!< \brief If bOverride = 1 or custom frequency is used:
- //!< 0: Do not use whitening
- //!< Other value: Initialization for 7-bit LFSR whitener - uint8_t bOverride:1; //!< \brief 0: Use default whitening for BLE advertising/data channels
- //!< 1: Override whitening initialization with value of init - } whitening; - rfc_bleAdvPar_t *pParams; //!< Pointer to command specific parameter structure - rfc_bleAdvOutput_t *pOutput; //!< Pointer to command specific output structure -}; - -//! @} - -//! \addtogroup CMD_BLE_ADV_DIR -//! @{ -#define CMD_BLE_ADV_DIR 0x1804 -struct __RFC_STRUCT rfc_CMD_BLE_ADV_DIR_s { - uint16_t commandNo; //!< The command ID number 0x1804 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t channel; //!< \brief Channel to use
- //!< 0–39: BLE advertising/data channel number - //!< 60–207: Custom frequency; (2300 + channel) MHz - //!< 255: Use existing frequency - //!< Others: Reserved - struct { - uint8_t init:7; //!< \brief If bOverride = 1 or custom frequency is used:
- //!< 0: Do not use whitening
- //!< Other value: Initialization for 7-bit LFSR whitener - uint8_t bOverride:1; //!< \brief 0: Use default whitening for BLE advertising/data channels
- //!< 1: Override whitening initialization with value of init - } whitening; - rfc_bleAdvPar_t *pParams; //!< Pointer to command specific parameter structure - rfc_bleAdvOutput_t *pOutput; //!< Pointer to command specific output structure -}; - -//! @} - -//! \addtogroup CMD_BLE_ADV_NC -//! @{ -#define CMD_BLE_ADV_NC 0x1805 -struct __RFC_STRUCT rfc_CMD_BLE_ADV_NC_s { - uint16_t commandNo; //!< The command ID number 0x1805 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t channel; //!< \brief Channel to use
- //!< 0–39: BLE advertising/data channel number - //!< 60–207: Custom frequency; (2300 + channel) MHz - //!< 255: Use existing frequency - //!< Others: Reserved - struct { - uint8_t init:7; //!< \brief If bOverride = 1 or custom frequency is used:
- //!< 0: Do not use whitening
- //!< Other value: Initialization for 7-bit LFSR whitener - uint8_t bOverride:1; //!< \brief 0: Use default whitening for BLE advertising/data channels
- //!< 1: Override whitening initialization with value of init - } whitening; - rfc_bleAdvPar_t *pParams; //!< Pointer to command specific parameter structure - rfc_bleAdvOutput_t *pOutput; //!< Pointer to command specific output structure -}; - -//! @} - -//! \addtogroup CMD_BLE_ADV_SCAN -//! @{ -#define CMD_BLE_ADV_SCAN 0x1806 -struct __RFC_STRUCT rfc_CMD_BLE_ADV_SCAN_s { - uint16_t commandNo; //!< The command ID number 0x1806 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t channel; //!< \brief Channel to use
- //!< 0–39: BLE advertising/data channel number - //!< 60–207: Custom frequency; (2300 + channel) MHz - //!< 255: Use existing frequency - //!< Others: Reserved - struct { - uint8_t init:7; //!< \brief If bOverride = 1 or custom frequency is used:
- //!< 0: Do not use whitening
- //!< Other value: Initialization for 7-bit LFSR whitener - uint8_t bOverride:1; //!< \brief 0: Use default whitening for BLE advertising/data channels
- //!< 1: Override whitening initialization with value of init - } whitening; - rfc_bleAdvPar_t *pParams; //!< Pointer to command specific parameter structure - rfc_bleAdvOutput_t *pOutput; //!< Pointer to command specific output structure -}; - -//! @} - -//! \addtogroup CMD_BLE_SCANNER -//! @{ -#define CMD_BLE_SCANNER 0x1807 -struct __RFC_STRUCT rfc_CMD_BLE_SCANNER_s { - uint16_t commandNo; //!< The command ID number 0x1807 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t channel; //!< \brief Channel to use
- //!< 0–39: BLE advertising/data channel number - //!< 60–207: Custom frequency; (2300 + channel) MHz - //!< 255: Use existing frequency - //!< Others: Reserved - struct { - uint8_t init:7; //!< \brief If bOverride = 1 or custom frequency is used:
- //!< 0: Do not use whitening
- //!< Other value: Initialization for 7-bit LFSR whitener - uint8_t bOverride:1; //!< \brief 0: Use default whitening for BLE advertising/data channels
- //!< 1: Override whitening initialization with value of init - } whitening; - rfc_bleScannerPar_t *pParams; //!< Pointer to command specific parameter structure - rfc_bleScannerOutput_t *pOutput; //!< Pointer to command specific output structure -}; - -//! @} - -//! \addtogroup CMD_BLE_INITIATOR -//! @{ -#define CMD_BLE_INITIATOR 0x1808 -struct __RFC_STRUCT rfc_CMD_BLE_INITIATOR_s { - uint16_t commandNo; //!< The command ID number 0x1808 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t channel; //!< \brief Channel to use
- //!< 0–39: BLE advertising/data channel number - //!< 60–207: Custom frequency; (2300 + channel) MHz - //!< 255: Use existing frequency - //!< Others: Reserved - struct { - uint8_t init:7; //!< \brief If bOverride = 1 or custom frequency is used:
- //!< 0: Do not use whitening
- //!< Other value: Initialization for 7-bit LFSR whitener - uint8_t bOverride:1; //!< \brief 0: Use default whitening for BLE advertising/data channels
- //!< 1: Override whitening initialization with value of init - } whitening; - rfc_bleInitiatorPar_t *pParams; //!< Pointer to command specific parameter structure - rfc_bleInitiatorOutput_t *pOutput; //!< Pointer to command specific output structure -}; - -//! @} - -//! \addtogroup CMD_BLE_GENERIC_RX -//! @{ -#define CMD_BLE_GENERIC_RX 0x1809 -struct __RFC_STRUCT rfc_CMD_BLE_GENERIC_RX_s { - uint16_t commandNo; //!< The command ID number 0x1809 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t channel; //!< \brief Channel to use
- //!< 0–39: BLE advertising/data channel number - //!< 60–207: Custom frequency; (2300 + channel) MHz - //!< 255: Use existing frequency - //!< Others: Reserved - struct { - uint8_t init:7; //!< \brief If bOverride = 1 or custom frequency is used:
- //!< 0: Do not use whitening
- //!< Other value: Initialization for 7-bit LFSR whitener - uint8_t bOverride:1; //!< \brief 0: Use default whitening for BLE advertising/data channels
- //!< 1: Override whitening initialization with value of init - } whitening; - rfc_bleGenericRxPar_t *pParams; //!< Pointer to command specific parameter structure - rfc_bleGenericRxOutput_t *pOutput; //!< Pointer to command specific output structure -}; - -//! @} - -//! \addtogroup CMD_BLE_TX_TEST -//! @{ -#define CMD_BLE_TX_TEST 0x180A -struct __RFC_STRUCT rfc_CMD_BLE_TX_TEST_s { - uint16_t commandNo; //!< The command ID number 0x180A - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t channel; //!< \brief Channel to use
- //!< 0–39: BLE advertising/data channel number - //!< 60–207: Custom frequency; (2300 + channel) MHz - //!< 255: Use existing frequency - //!< Others: Reserved - struct { - uint8_t init:7; //!< \brief If bOverride = 1 or custom frequency is used:
- //!< 0: Do not use whitening
- //!< Other value: Initialization for 7-bit LFSR whitener - uint8_t bOverride:1; //!< \brief 0: Use default whitening for BLE advertising/data channels
- //!< 1: Override whitening initialization with value of init - } whitening; - rfc_bleTxTestPar_t *pParams; //!< Pointer to command specific parameter structure - rfc_bleTxTestOutput_t *pOutput; //!< Pointer to command specific output structure -}; - -//! @} - -//! \addtogroup CMD_BLE_ADV_PAYLOAD -//! @{ -#define CMD_BLE_ADV_PAYLOAD 0x1001 -struct __RFC_STRUCT rfc_CMD_BLE_ADV_PAYLOAD_s { - uint16_t commandNo; //!< The command ID number 0x1001 - uint8_t payloadType; //!< \brief 0: Advertising data
- //!< 1: Scan response data - uint8_t newLen; //!< Length of the new payload - uint8_t* pNewData; //!< Pointer to the buffer containing the new data - rfc_bleAdvPar_t *pParams; //!< Pointer to the parameter structure to update -}; - -//! @} - -//! \addtogroup bleMasterSlavePar -//! @{ -struct __RFC_STRUCT rfc_bleMasterSlavePar_s { - dataQueue_t* pRxQ; //!< Pointer to receive queue - dataQueue_t* pTxQ; //!< Pointer to transmit queue - struct { - uint8_t bAutoFlushIgnored:1; //!< If 1, automatically remove ignored packets from Rx queue - uint8_t bAutoFlushCrcErr:1; //!< If 1, automatically remove packets with CRC error from Rx queue - uint8_t bAutoFlushEmpty:1; //!< If 1, automatically remove empty packets from Rx queue - uint8_t bIncludeLenByte:1; //!< If 1, include the received length byte 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 bAppendStatus:1; //!< If 1, append a status byte to the packet in the Rx queue - uint8_t bAppendTimestamp:1; //!< If 1, append a timestamp to the packet in the Rx queue - } rxConfig; //!< Configuration bits for the receive queue entries - struct { - uint8_t lastRxSn:1; //!< The SN bit of the header of the last packet received with CRC OK - uint8_t lastTxSn:1; //!< The SN bit of the header of the last transmitted packet - uint8_t nextTxSn:1; //!< The SN bit of the header of the next packet to transmit - uint8_t bFirstPkt:1; //!< For slave: 0 if a packet has been transmitted on the connection, 1 otherwise - uint8_t bAutoEmpty:1; //!< 1 if the last transmitted packet was an auto-empty packet - uint8_t bLlCtrlTx:1; //!< 1 if the last transmitted packet was an LL control packet (LLID = 11) - uint8_t bLlCtrlAckRx:1; //!< 1 if the last received packet was the ACK of an LL control packet - uint8_t bLlCtrlAckPending:1; //!< 1 if the last successfully received packet was an LL control packet which has not yet been ACK'ed - } seqStat; - uint8_t maxNack; //!< Maximum number of NACKs received before operation ends. 0: No limit - uint8_t maxPkt; //!< Maximum number of packets transmitted in the operation before it ends. 0: No limit - uint32_t accessAddress; //!< Access address used on the connection - uint8_t crcInit0; //!< CRC initialization value used on the connection – least significant byte - uint8_t crcInit1; //!< CRC initialization value used on the connection – middle byte - uint8_t crcInit2; //!< CRC initialization value used on the connection – most significant byte -}; - -//! @} - -//! \addtogroup bleMasterPar -//! @{ -//! Parameter structure for master (CMD_BLE_MASTER) - -struct __RFC_STRUCT rfc_bleMasterPar_s { - dataQueue_t* pRxQ; //!< Pointer to receive queue - dataQueue_t* pTxQ; //!< Pointer to transmit queue - struct { - uint8_t bAutoFlushIgnored:1; //!< If 1, automatically remove ignored packets from Rx queue - uint8_t bAutoFlushCrcErr:1; //!< If 1, automatically remove packets with CRC error from Rx queue - uint8_t bAutoFlushEmpty:1; //!< If 1, automatically remove empty packets from Rx queue - uint8_t bIncludeLenByte:1; //!< If 1, include the received length byte 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 bAppendStatus:1; //!< If 1, append a status byte to the packet in the Rx queue - uint8_t bAppendTimestamp:1; //!< If 1, append a timestamp to the packet in the Rx queue - } rxConfig; //!< Configuration bits for the receive queue entries - struct { - uint8_t lastRxSn:1; //!< The SN bit of the header of the last packet received with CRC OK - uint8_t lastTxSn:1; //!< The SN bit of the header of the last transmitted packet - uint8_t nextTxSn:1; //!< The SN bit of the header of the next packet to transmit - uint8_t bFirstPkt:1; //!< For slave: 0 if a packet has been transmitted on the connection, 1 otherwise - uint8_t bAutoEmpty:1; //!< 1 if the last transmitted packet was an auto-empty packet - uint8_t bLlCtrlTx:1; //!< 1 if the last transmitted packet was an LL control packet (LLID = 11) - uint8_t bLlCtrlAckRx:1; //!< 1 if the last received packet was the ACK of an LL control packet - uint8_t bLlCtrlAckPending:1; //!< 1 if the last successfully received packet was an LL control packet which has not yet been ACK'ed - } seqStat; - uint8_t maxNack; //!< Maximum number of NACKs received before operation ends. 0: No limit - uint8_t maxPkt; //!< Maximum number of packets transmitted in the operation before it ends. 0: No limit - uint32_t accessAddress; //!< Access address used on the connection - uint8_t crcInit0; //!< CRC initialization value used on the connection – least significant byte - uint8_t crcInit1; //!< CRC initialization value used on the connection – middle byte - uint8_t crcInit2; //!< CRC initialization value used on the connection – most significant byte - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } endTrigger; //!< Trigger that causes the device to end the connection event as soon as allowed - ratmr_t endTime; //!< \brief Time used together with endTrigger that causes the device to end the - //!< connection event as soon as allowed -}; - -//! @} - -//! \addtogroup bleSlavePar -//! @{ -//! Parameter structure for slave (CMD_BLE_SLAVE) - -struct __RFC_STRUCT rfc_bleSlavePar_s { - dataQueue_t* pRxQ; //!< Pointer to receive queue - dataQueue_t* pTxQ; //!< Pointer to transmit queue - struct { - uint8_t bAutoFlushIgnored:1; //!< If 1, automatically remove ignored packets from Rx queue - uint8_t bAutoFlushCrcErr:1; //!< If 1, automatically remove packets with CRC error from Rx queue - uint8_t bAutoFlushEmpty:1; //!< If 1, automatically remove empty packets from Rx queue - uint8_t bIncludeLenByte:1; //!< If 1, include the received length byte 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 bAppendStatus:1; //!< If 1, append a status byte to the packet in the Rx queue - uint8_t bAppendTimestamp:1; //!< If 1, append a timestamp to the packet in the Rx queue - } rxConfig; //!< Configuration bits for the receive queue entries - struct { - uint8_t lastRxSn:1; //!< The SN bit of the header of the last packet received with CRC OK - uint8_t lastTxSn:1; //!< The SN bit of the header of the last transmitted packet - uint8_t nextTxSn:1; //!< The SN bit of the header of the next packet to transmit - uint8_t bFirstPkt:1; //!< For slave: 0 if a packet has been transmitted on the connection, 1 otherwise - uint8_t bAutoEmpty:1; //!< 1 if the last transmitted packet was an auto-empty packet - uint8_t bLlCtrlTx:1; //!< 1 if the last transmitted packet was an LL control packet (LLID = 11) - uint8_t bLlCtrlAckRx:1; //!< 1 if the last received packet was the ACK of an LL control packet - uint8_t bLlCtrlAckPending:1; //!< 1 if the last successfully received packet was an LL control packet which has not yet been ACK'ed - } seqStat; - uint8_t maxNack; //!< Maximum number of NACKs received before operation ends. 0: No limit - uint8_t maxPkt; //!< Maximum number of packets transmitted in the operation before it ends. 0: No limit - uint32_t accessAddress; //!< Access address used on the connection - uint8_t crcInit0; //!< CRC initialization value used on the connection – least significant byte - uint8_t crcInit1; //!< CRC initialization value used on the connection – middle byte - uint8_t crcInit2; //!< CRC initialization value used on the connection – most significant byte - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } timeoutTrigger; //!< Trigger that defines timeout of the first receive operation - ratmr_t timeoutTime; //!< \brief Time used together with timeoutTrigger that defines timeout of the first - //!< receive operation - uint16_t __dummy0; - uint8_t __dummy1; - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } endTrigger; //!< Trigger that causes the device to end the connection event as soon as allowed - ratmr_t endTime; //!< \brief Time used together with endTrigger that causes the device to end the - //!< connection event as soon as allowed -}; - -//! @} - -//! \addtogroup bleAdvPar -//! @{ -//! Parameter structure for advertiser (CMD_BLE_ADV*) - -struct __RFC_STRUCT rfc_bleAdvPar_s { - dataQueue_t* pRxQ; //!< Pointer to receive queue - struct { - uint8_t bAutoFlushIgnored:1; //!< If 1, automatically remove ignored packets from Rx queue - uint8_t bAutoFlushCrcErr:1; //!< If 1, automatically remove packets with CRC error from Rx queue - uint8_t bAutoFlushEmpty:1; //!< If 1, automatically remove empty packets from Rx queue - uint8_t bIncludeLenByte:1; //!< If 1, include the received length byte 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 bAppendStatus:1; //!< If 1, append a status byte to the packet in the Rx queue - uint8_t bAppendTimestamp:1; //!< If 1, append a timestamp to the packet in the Rx queue - } rxConfig; //!< Configuration bits for the receive queue entries - struct { - uint8_t advFilterPolicy:2; //!< \brief The advertiser filter policy, as defined in Volume 2, Part E, Section 7.8.5 of - //!< the Bluetooth 4.0 spec - uint8_t deviceAddrType:1; //!< The type of the device address – public (0) or random (1) - uint8_t peerAddrType:1; //!< Directed advertiser: The type of the peer address – public (0) or random (1) - uint8_t bStrictLenFilter:1; //!< 1: Discard messages with illegal length - } advConfig; - uint8_t advLen; //!< Size of advertiser data - uint8_t scanRspLen; //!< Size of scan response data - uint8_t* pAdvData; //!< Pointer to buffer containing ADV*_IND data - uint8_t* pScanRspData; //!< Pointer to buffer containing SCAN_RSP data - uint16_t* pDeviceAddress; //!< Pointer to device address used for this device - rfc_bleWhiteListEntry_t *pWhiteList; //!< Pointer to white list or peer address (directed advertiser) - uint16_t __dummy0; - uint8_t __dummy1; - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } endTrigger; //!< Trigger that causes the device to end the advertiser event as soon as allowed - ratmr_t endTime; //!< \brief Time used together with endTrigger that causes the device to end the - //!< advertiser event as soon as allowed -}; - -//! @} - -//! \addtogroup bleScannerPar -//! @{ -//! Parameter structure for scanner (CMD_BLE_SCANNER) - -struct __RFC_STRUCT rfc_bleScannerPar_s { - dataQueue_t* pRxQ; //!< Pointer to receive queue - struct { - uint8_t bAutoFlushIgnored:1; //!< If 1, automatically remove ignored packets from Rx queue - uint8_t bAutoFlushCrcErr:1; //!< If 1, automatically remove packets with CRC error from Rx queue - uint8_t bAutoFlushEmpty:1; //!< If 1, automatically remove empty packets from Rx queue - uint8_t bIncludeLenByte:1; //!< If 1, include the received length byte 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 bAppendStatus:1; //!< If 1, append a status byte to the packet in the Rx queue - uint8_t bAppendTimestamp:1; //!< If 1, append a timestamp to the packet in the Rx queue - } rxConfig; //!< Configuration bits for the receive queue entries - struct { - uint8_t scanFilterPolicy:1; //!< \brief The advertiser filter policy, as defined in Volume 2, Part E, Section 7.8.10 of - //!< the Bluetooth 4.0 spec - uint8_t bActiveScan:1; //!< \brief 0: Passive scan
- //!< 1: Active scan - uint8_t deviceAddrType:1; //!< The type of the device address – public (0) or random (1) - uint8_t :1; - uint8_t bStrictLenFilter:1; //!< 1: Discard messages with illegal length - uint8_t bAutoWlIgnore:1; //!< 1: Automatically set ignore bit in white list - uint8_t bEndOnRpt:1; //!< 1: End scanner operation after each reported ADV*_IND and potentially SCAN_RSP - } scanConfig; - uint16_t randomState; //!< State for pseudo-random number generation used in backoff procedure - uint16_t backoffCount; //!< Parameter backoffCount used in backoff procedure, cf. Bluetooth 4.0 spec - struct { - uint8_t logUpperLimit:4; //!< Binary logarithm of parameter upperLimit used in scanner backoff procedure - uint8_t bLastSucceeded:1; //!< \brief 1 if the last SCAN_RSP was successfully received and upperLimit - //!< not changed - uint8_t bLastFailed:1; //!< \brief 1 if reception of the last SCAN_RSP failed and upperLimit was not - //!< changed - } backoffPar; - uint8_t scanReqLen; //!< Size of scan request data - uint8_t* pScanReqData; //!< Pointer to buffer containing SCAN_REQ data - uint16_t* pDeviceAddress; //!< Pointer to device address used for this device - rfc_bleWhiteListEntry_t *pWhiteList; //!< Pointer to white list - uint16_t __dummy0; - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } timeoutTrigger; //!< Trigger that causes the device to stop receiving as soon as allowed - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } endTrigger; //!< Trigger that causes the device to stop receiving as soon as allowed - ratmr_t timeoutTime; //!< \brief Time used together with timeoutTrigger that causes the device to stop - //!< receiving as soon as allowed, ending with BLE_DONE_RXTIMEOUT - ratmr_t endTime; //!< \brief Time used together with endTrigger that causes the device to stop - //!< receiving as soon as allowed, ending with BLE_DONE_ENDED -}; - -//! @} - -//! \addtogroup bleInitiatorPar -//! @{ -//! Parameter structure for initiator (CMD_BLE_INITIATOR) - -struct __RFC_STRUCT rfc_bleInitiatorPar_s { - dataQueue_t* pRxQ; //!< Pointer to receive queue - struct { - uint8_t bAutoFlushIgnored:1; //!< If 1, automatically remove ignored packets from Rx queue - uint8_t bAutoFlushCrcErr:1; //!< If 1, automatically remove packets with CRC error from Rx queue - uint8_t bAutoFlushEmpty:1; //!< If 1, automatically remove empty packets from Rx queue - uint8_t bIncludeLenByte:1; //!< If 1, include the received length byte 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 bAppendStatus:1; //!< If 1, append a status byte to the packet in the Rx queue - uint8_t bAppendTimestamp:1; //!< If 1, append a timestamp to the packet in the Rx queue - } rxConfig; //!< Configuration bits for the receive queue entries - struct { - uint8_t bUseWhiteList:1; //!< \brief Initiator filter policy, cf. Volume 2, Part E, Section 7.8.10 of the - //!< Bluetooth 4.0 spec:
- //!< 0: Use specific peer address
- //!< 1: Use white list - uint8_t bDynamicWinOffset:1; //!< 1: Use dynamic WinOffset insertion - uint8_t deviceAddrType:1; //!< The type of the device address – public (0) or random (1) - uint8_t peerAddrType:1; //!< The type of the peer address – public (0) or random (1) - uint8_t bStrictLenFilter:1; //!< 1: Discard messages with illegal length - } initConfig; - uint8_t __dummy0; - uint8_t connectReqLen; //!< Size of connect request data - uint8_t* pConnectReqData; //!< Pointer to buffer containing LLData to go in the CONNECT_REQ - uint16_t* pDeviceAddress; //!< Pointer to device address used for this device - rfc_bleWhiteListEntry_t *pWhiteList; //!< Pointer to white list or peer address - ratmr_t connectTime; //!< \brief Indication of timer value of the first possible start time of the first connection event. - //!< Set to the calculated value if a connection is made and to the next possible connection - //!< time if not. - uint16_t __dummy1; - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } timeoutTrigger; //!< Trigger that causes the device to stop receiving as soon as allowed - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } endTrigger; //!< Trigger that causes the device to stop receiving as soon as allowed - ratmr_t timeoutTime; //!< \brief Time used together with timeoutTrigger that causes the device to stop - //!< receiving as soon as allowed, ending with BLE_DONE_RXTIMEOUT - ratmr_t endTime; //!< \brief Time used together with endTrigger that causes the device to stop - //!< receiving as soon as allowed, ending with BLE_DONE_ENDED -}; - -//! @} - -//! \addtogroup bleGenericRxPar -//! @{ -//! Parameter structure for generic Rx (CMD_BLE_GENERIC_RX) - -struct __RFC_STRUCT rfc_bleGenericRxPar_s { - dataQueue_t* pRxQ; //!< Pointer to receive queue. May be NULL; if so, received packets are not stored - struct { - uint8_t bAutoFlushIgnored:1; //!< If 1, automatically remove ignored packets from Rx queue - uint8_t bAutoFlushCrcErr:1; //!< If 1, automatically remove packets with CRC error from Rx queue - uint8_t bAutoFlushEmpty:1; //!< If 1, automatically remove empty packets from Rx queue - uint8_t bIncludeLenByte:1; //!< If 1, include the received length byte 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 bAppendStatus:1; //!< If 1, append a status byte to the packet in the Rx queue - uint8_t bAppendTimestamp:1; //!< If 1, append a timestamp to the packet in the Rx queue - } rxConfig; //!< Configuration bits for the receive queue entries - uint8_t bRepeat; //!< \brief 0: End operation after receiving a packet
- //!< 1: Restart receiver after receiving a packet - uint16_t __dummy0; - uint32_t accessAddress; //!< Access address used on the connection - uint8_t crcInit0; //!< CRC initialization value used on the connection – least significant byte - uint8_t crcInit1; //!< CRC initialization value used on the connection – middle byte - uint8_t crcInit2; //!< CRC initialization value used on the connection – most significant byte - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 endTrigger that causes the device to end the - //!< Rx operation -}; - -//! @} - -//! \addtogroup bleTxTestPar -//! @{ -//! Parameter structure for Tx test (CMD_BLE_TX_TEST) - -struct __RFC_STRUCT rfc_bleTxTestPar_s { - uint16_t numPackets; //!< \brief Number of packets to transmit
- //!< 0: Transmit unlimited number of packets - uint8_t payloadLength; //!< The number of payload bytes in each packet. - uint8_t packetType; //!< \brief The packet type to be used, encoded according to the Bluetooth 4.0 spec, Volume 2, Part E, - //!< Section 7.8.29 - ratmr_t period; //!< Number of radio timer cycles between the start of each packet - struct { - uint8_t bOverrideDefault:1; //!< \brief 0: Use default packet encoding
- //!< 1: Override packet contents - uint8_t bUsePrbs9:1; //!< \brief If bOverride is 1:
- //!< 1: Use PRBS9 encoding of packet - uint8_t bUsePrbs15:1; //!< \brief If bOverride is 1:
- //!< 1: Use PRBS15 encoding of packet - } config; - uint8_t byteVal; //!< If config.bOverride is 1, value of each byte to be sent - uint8_t __dummy0; - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } endTrigger; //!< Trigger that causes the device to end the Test Tx operation - ratmr_t endTime; //!< \brief Time used together with endTrigger that causes the device to end the - //!< Test Tx operation -}; - -//! @} - -//! \addtogroup bleMasterSlaveOutput -//! @{ -//! Output structure for master and slave (CMD_BLE_MASTER/CMD_BLE_SLAVE) - -struct __RFC_STRUCT rfc_bleMasterSlaveOutput_s { - uint8_t nTx; //!< \brief Total number of packets (including auto-empty and retransmissions) that have been - //!< transmitted - uint8_t nTxAck; //!< Total number of transmitted packets (including auto-empty) that have been ACK'ed - uint8_t nTxCtrl; //!< Number of unique LL control packets from the Tx queue that have been transmitted - uint8_t nTxCtrlAck; //!< Number of LL control packets from the Tx queue that have been finished (ACK'ed) - uint8_t nTxCtrlAckAck; //!< \brief Number of LL control packets that have been ACK'ed and where an ACK has been sent in - //!< response - uint8_t nTxRetrans; //!< Number of retransmissions that has been done - uint8_t nTxEntryDone; //!< Number of packets from the Tx queue that have been finished (ACK'ed) - uint8_t nRxOk; //!< Number of packets that have been received with payload, CRC OK and not ignored - uint8_t nRxCtrl; //!< Number of LL control packets that have been received with CRC OK and not ignored - uint8_t nRxCtrlAck; //!< \brief Number of LL control packets that have been received with CRC OK and not ignored, and - //!< then ACK'ed - uint8_t nRxNok; //!< Number of packets that have been received with CRC error - uint8_t nRxIgnored; //!< \brief Number of packets that have been received with CRC OK and ignored due to repeated - //!< sequence number - uint8_t nRxEmpty; //!< Number of packets that have been received with CRC OK and no payload - uint8_t nRxBufFull; //!< Number of packets that have been received and discarded due to lack of buffer space - int8_t lastRssi; //!< RSSI of last received packet - struct { - uint8_t bTimeStampValid:1; //!< 1 if a valid time stamp has been written to timeStamp; 0 otherwise - uint8_t bLastCrcErr:1; //!< 1 if the last received packet had CRC error; 0 otherwise - uint8_t bLastIgnored:1; //!< 1 if the last received packet with CRC OK was ignored; 0 otherwise - uint8_t bLastEmpty:1; //!< 1 if the last received packet with CRC OK was empty; 0 otherwise - uint8_t bLastCtrl:1; //!< 1 if the last received packet with CRC OK was empty; 0 otherwise - uint8_t bLastMd:1; //!< 1 if the last received packet with CRC OK had MD = 1; 0 otherwise - uint8_t bLastAck:1; //!< \brief 1 if the last received packet with CRC OK was an ACK of a transmitted packet; - //!< 0 otherwise - } pktStatus; - ratmr_t timeStamp; //!< Slave operation: Time stamp of first received packet -}; - -//! @} - -//! \addtogroup bleAdvOutput -//! @{ -//! Output structure for advertiser (CMD_BLE_ADV*) - -struct __RFC_STRUCT rfc_bleAdvOutput_s { - uint16_t nTxAdvInd; //!< Number of ADV*_IND packets completely transmitted - uint8_t nTxScanRsp; //!< Number of SCAN_RSP packets transmitted - uint8_t nRxScanReq; //!< Number of SCAN_REQ packets received OK and not ignored - uint8_t nRxConnectReq; //!< Number of CONNECT_REQ packets received OK and not ignored - uint8_t __dummy0; - uint16_t nRxNok; //!< Number of packets received with CRC error - uint16_t nRxIgnored; //!< Number of packets received with CRC OK, but ignored - uint8_t nRxBufFull; //!< Number of packets received that did not fit in Rx queue - int8_t lastRssi; //!< The RSSI of the last received packet - ratmr_t timeStamp; //!< Time stamp of the last received packet -}; - -//! @} - -//! \addtogroup bleScannerOutput -//! @{ -//! Output structure for scanner (CMD_BLE_SCANNER) - -struct __RFC_STRUCT rfc_bleScannerOutput_s { - uint16_t nTxScanReq; //!< Number of transmitted SCAN_REQ packets - uint16_t nBackedOffScanReq; //!< Number of SCAN_REQ packets not sent due to backoff procedure - uint16_t nRxAdvOk; //!< Number of ADV*_IND packets received with CRC OK and not ignored - uint16_t nRxAdvIgnored; //!< Number of ADV*_IND packets received with CRC OK, but ignored - uint16_t nRxAdvNok; //!< Number of ADV*_IND packets received with CRC error - uint16_t nRxScanRspOk; //!< Number of SCAN_RSP packets received with CRC OK and not ignored - uint16_t nRxScanRspIgnored; //!< Number of SCAN_RSP packets received with CRC OK, but ignored - uint16_t nRxScanRspNok; //!< Number of SCAN_RSP packets received with CRC error - uint8_t nRxAdvBufFull; //!< Number of ADV*_IND packets received that did not fit in Rx queue - uint8_t nRxScanRspBufFull; //!< Number of SCAN_RSP packets received that did not fit in Rx queue - int8_t lastRssi; //!< The RSSI of the last received packet - uint8_t __dummy0; - ratmr_t timeStamp; //!< Time stamp of the last successfully received ADV*_IND packet that was not ignored -}; - -//! @} - -//! \addtogroup bleInitiatorOutput -//! @{ -//! Output structure for initiator (CMD_BLE_INITIATOR) - -struct __RFC_STRUCT rfc_bleInitiatorOutput_s { - uint8_t nTxConnectReq; //!< Number of transmitted CONNECT_REQ packets - uint8_t nRxAdvOk; //!< Number of ADV*_IND packets received with CRC OK and not ignored - uint16_t nRxAdvIgnored; //!< Number of ADV*_IND packets received with CRC OK, but ignored - uint16_t nRxAdvNok; //!< Number of ADV*_IND packets received with CRC error - uint8_t nRxAdvBufFull; //!< Number of ADV*_IND packets received that did not fit in Rx queue - int8_t lastRssi; //!< The RSSI of the last received packet - ratmr_t timeStamp; //!< Time stamp of the received ADV*_IND packet that caused transmission of CONNECT_REQ -}; - -//! @} - -//! \addtogroup bleGenericRxOutput -//! @{ -//! Output structure for generic Rx (CMD_BLE_GENERIC_RX) - -struct __RFC_STRUCT rfc_bleGenericRxOutput_s { - uint16_t nRxOk; //!< Number of packets received with CRC OK - uint16_t nRxNok; //!< Number of packets received with CRC error - uint16_t nRxBufFull; //!< Number of packets that have been received and discarded due to lack of buffer space - int8_t lastRssi; //!< The RSSI of the last received packet - uint8_t __dummy0; - ratmr_t timeStamp; //!< Time stamp of the last received packet -}; - -//! @} - -//! \addtogroup bleTxTestOutput -//! @{ -//! Output structure for Tx test (CMD_BLE_TX_TEST) - -struct __RFC_STRUCT rfc_bleTxTestOutput_s { - uint16_t nTx; //!< Number of packets transmitted -}; - -//! @} - -//! \addtogroup bleWhiteListEntry -//! @{ -//! White list entry structure - -struct __RFC_STRUCT rfc_bleWhiteListEntry_s { - uint8_t size; //!< Number of while list entries. Used in the first entry of the list only - struct { - uint8_t bEnable:1; //!< 1 if the entry is in use, 0 if the entry is not in use - uint8_t addrType:1; //!< The type address in the entry – public (0) or random (1) - uint8_t bWlIgn:1; //!< \brief 1 if the entry is to be ignored by a scanner, 0 otherwise. Used to mask out - //!< entries that have already been scanned and reported. - } conf; - uint16_t address; //!< Least significant 16 bits of the address contained in the entry - uint32_t addressHi; //!< Most significant 32 bits of the address contained in the entry -}; - -//! @} - -//! \addtogroup bleRxStatus -//! @{ -//! Receive status byte that may be appended to message in receive buffer - -struct __RFC_STRUCT rfc_bleRxStatus_s { - struct { - uint8_t channel:6; //!< \brief The channel on which the packet was received, provided channel is in the range - //!< 0–39; otherwise 0x3F - uint8_t bIgnore:1; //!< 1 if the packet is marked as ignored, 0 otherwise - uint8_t bCrcErr:1; //!< 1 if the packet was received with CRC error, 0 otherwise - } status; -}; - -//! @} - -//! @} -//! @} -#endif /* BLE_CMD_H_ */ diff --git a/cpu/cc26xx-cc13xx/rf-core/api/ble_mailbox.h b/cpu/cc26xx-cc13xx/rf-core/api/ble_mailbox.h deleted file mode 100644 index dcce1996c..000000000 --- a/cpu/cc26xx-cc13xx/rf-core/api/ble_mailbox.h +++ /dev/null @@ -1,69 +0,0 @@ -/****************************************************************************** -* Filename: ble_mailbox.h -* Revised: $ $ -* Revision: $ $ -* -* Description: Definitions for BLE interface -* -* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ -* -* -* 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. -* -******************************************************************************/ - -#ifndef BLE_MAILBOX_H_ -#define BLE_MAILBOX_H_ - -/// \name Radio operation status -///@{ -/// \name Operation finished normally -///@{ -#define BLE_DONE_OK 0x1400 ///< Operation ended normally -#define BLE_DONE_RXTIMEOUT 0x1401 ///< Timeout of first Rx of slave operation or end of scan window -#define BLE_DONE_NOSYNC 0x1402 ///< Timeout of subsequent Rx -#define BLE_DONE_RXERR 0x1403 ///< Operation ended because of receive error (CRC or other) -#define BLE_DONE_CONNECT 0x1404 ///< CONNECT_REQ received or transmitted -#define BLE_DONE_MAXNACK 0x1405 ///< Maximum number of retransmissions exceeded -#define BLE_DONE_ENDED 0x1406 ///< Operation stopped after end trigger -#define BLE_DONE_ABORT 0x1407 ///< Operation aborted by command -#define BLE_DONE_STOPPED 0x1408 ///< Operation stopped after stop command -///@} -/// \name Operation finished with error -///@{ -#define BLE_ERROR_PAR 0x1800 ///< Illegal parameter -#define BLE_ERROR_RXBUF 0x1801 ///< No available Rx buffer (Advertiser, Scanner, Initiator) -#define BLE_ERROR_NO_SETUP 0x1802 ///< Operation using Rx or Tx attemted when not in BLE mode -#define BLE_ERROR_NO_FS 0x1803 ///< Operation using Rx or Tx attemted without frequency synth configured -#define BLE_ERROR_SYNTH_PROG 0x1804 ///< Synthesizer programming failed to complete on time -#define BLE_ERROR_RXOVF 0x1805 ///< Receiver overflowed during operation -#define BLE_ERROR_TXUNF 0x1806 ///< Transmitter underflowed during operation -///@} -///@} - -#endif /* BLE_MAILBOX_H_ */ diff --git a/cpu/cc26xx-cc13xx/rf-core/api/common_cmd.h b/cpu/cc26xx-cc13xx/rf-core/api/common_cmd.h deleted file mode 100644 index 308f0c3ee..000000000 --- a/cpu/cc26xx-cc13xx/rf-core/api/common_cmd.h +++ /dev/null @@ -1,1031 +0,0 @@ -/****************************************************************************** -* Filename: common_cmd.h -* Revised: 2015-08-04 10:40:45 +0200 (Tue, 04 Aug 2015) -* Revision: 44326 -* -* Description: CC13xx API for common/generic commands -* -* 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 COMMON_CMD_H_ -#define COMMON_CMD_H_ - -#ifndef __RFC_STRUCT -#ifdef __GNUC__ -#define __RFC_STRUCT __attribute__ ((aligned (4))) -#else -#define __RFC_STRUCT -#endif -#endif - -//! \addtogroup rfc -//! @{ - -//! \addtogroup common_cmd -//! @{ - -#include -#include "mailbox.h" - -typedef struct __RFC_STRUCT rfc_command_s rfc_command_t; -typedef struct __RFC_STRUCT rfc_radioOp_s rfc_radioOp_t; -typedef struct __RFC_STRUCT rfc_CMD_NOP_s rfc_CMD_NOP_t; -typedef struct __RFC_STRUCT rfc_CMD_RADIO_SETUP_s rfc_CMD_RADIO_SETUP_t; -typedef struct __RFC_STRUCT rfc_CMD_FS_s rfc_CMD_FS_t; -typedef struct __RFC_STRUCT rfc_CMD_FS_OFF_s rfc_CMD_FS_OFF_t; -typedef struct __RFC_STRUCT rfc_CMD_RX_s rfc_CMD_RX_t; -typedef struct __RFC_STRUCT rfc_CMD_TX_s rfc_CMD_TX_t; -typedef struct __RFC_STRUCT rfc_CMD_RX_TEST_s rfc_CMD_RX_TEST_t; -typedef struct __RFC_STRUCT rfc_CMD_TX_TEST_s rfc_CMD_TX_TEST_t; -typedef struct __RFC_STRUCT rfc_CMD_SYNC_STOP_RAT_s rfc_CMD_SYNC_STOP_RAT_t; -typedef struct __RFC_STRUCT rfc_CMD_SYNC_START_RAT_s rfc_CMD_SYNC_START_RAT_t; -typedef struct __RFC_STRUCT rfc_CMD_COUNT_s rfc_CMD_COUNT_t; -typedef struct __RFC_STRUCT rfc_CMD_FS_POWERUP_s rfc_CMD_FS_POWERUP_t; -typedef struct __RFC_STRUCT rfc_CMD_FS_POWERDOWN_s rfc_CMD_FS_POWERDOWN_t; -typedef struct __RFC_STRUCT rfc_CMD_SCH_IMM_s rfc_CMD_SCH_IMM_t; -typedef struct __RFC_STRUCT rfc_CMD_COUNT_BRANCH_s rfc_CMD_COUNT_BRANCH_t; -typedef struct __RFC_STRUCT rfc_CMD_PATTERN_CHECK_s rfc_CMD_PATTERN_CHECK_t; -typedef struct __RFC_STRUCT rfc_CMD_TX_POWER_BOOST_s rfc_CMD_TX_POWER_BOOST_t; -typedef struct __RFC_STRUCT rfc_CMD_ABORT_s rfc_CMD_ABORT_t; -typedef struct __RFC_STRUCT rfc_CMD_STOP_s rfc_CMD_STOP_t; -typedef struct __RFC_STRUCT rfc_CMD_GET_RSSI_s rfc_CMD_GET_RSSI_t; -typedef struct __RFC_STRUCT rfc_CMD_UPDATE_RADIO_SETUP_s rfc_CMD_UPDATE_RADIO_SETUP_t; -typedef struct __RFC_STRUCT rfc_CMD_TRIGGER_s rfc_CMD_TRIGGER_t; -typedef struct __RFC_STRUCT rfc_CMD_GET_FW_INFO_s rfc_CMD_GET_FW_INFO_t; -typedef struct __RFC_STRUCT rfc_CMD_START_RAT_s rfc_CMD_START_RAT_t; -typedef struct __RFC_STRUCT rfc_CMD_PING_s rfc_CMD_PING_t; -typedef struct __RFC_STRUCT rfc_CMD_ADD_DATA_ENTRY_s rfc_CMD_ADD_DATA_ENTRY_t; -typedef struct __RFC_STRUCT rfc_CMD_REMOVE_DATA_ENTRY_s rfc_CMD_REMOVE_DATA_ENTRY_t; -typedef struct __RFC_STRUCT rfc_CMD_FLUSH_QUEUE_s rfc_CMD_FLUSH_QUEUE_t; -typedef struct __RFC_STRUCT rfc_CMD_CLEAR_RX_s rfc_CMD_CLEAR_RX_t; -typedef struct __RFC_STRUCT rfc_CMD_REMOVE_PENDING_ENTRIES_s rfc_CMD_REMOVE_PENDING_ENTRIES_t; -typedef struct __RFC_STRUCT rfc_CMD_SET_RAT_CMP_s rfc_CMD_SET_RAT_CMP_t; -typedef struct __RFC_STRUCT rfc_CMD_SET_RAT_CPT_s rfc_CMD_SET_RAT_CPT_t; -typedef struct __RFC_STRUCT rfc_CMD_DISABLE_RAT_CH_s rfc_CMD_DISABLE_RAT_CH_t; -typedef struct __RFC_STRUCT rfc_CMD_SET_RAT_OUTPUT_s rfc_CMD_SET_RAT_OUTPUT_t; -typedef struct __RFC_STRUCT rfc_CMD_ARM_RAT_CH_s rfc_CMD_ARM_RAT_CH_t; -typedef struct __RFC_STRUCT rfc_CMD_DISARM_RAT_CH_s rfc_CMD_DISARM_RAT_CH_t; -typedef struct __RFC_STRUCT rfc_CMD_SET_TX_POWER_s rfc_CMD_SET_TX_POWER_t; -typedef struct __RFC_STRUCT rfc_CMD_UPDATE_FS_s rfc_CMD_UPDATE_FS_t; -typedef struct __RFC_STRUCT rfc_CMD_BUS_REQUEST_s rfc_CMD_BUS_REQUEST_t; - -//! \addtogroup command -//! @{ -struct __RFC_STRUCT rfc_command_s { - uint16_t commandNo; //!< The command ID number -}; - -//! @} - -//! \addtogroup radioOp -//! @{ -//! Common definition for radio operation commands - -struct __RFC_STRUCT rfc_radioOp_s { - uint16_t commandNo; //!< The command ID number - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; -}; - -//! @} - -//! \addtogroup CMD_NOP -//! @{ -#define CMD_NOP 0x0801 -struct __RFC_STRUCT rfc_CMD_NOP_s { - uint16_t commandNo; //!< The command ID number 0x0801 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; -}; - -//! @} - -//! \addtogroup CMD_RADIO_SETUP -//! @{ -#define CMD_RADIO_SETUP 0x0802 -struct __RFC_STRUCT rfc_CMD_RADIO_SETUP_s { - uint16_t commandNo; //!< The command ID number 0x0802 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t mode; //!< \brief The main mode to use
- //!< 0x00: BLE
- //!< 0x01: IEEE 802.15.4
- //!< 0x02: 2 Mbps GFSK
- //!< 0x05: 5 Mbps coded 8-FSK
- //!< 0x06: ANT
- //!< 0xFF: Keep existing mode; update overrides only
- //!< Others: Reserved - uint8_t loDivider; //!< \brief LO divider setting to use. Supported values: 0 (equivalent to 2), 2, 5, 6, 10, 12, 15, - //!< and 30.
- //!< Value of 0 or 2 only supported for devices that support 2.4 GHz operation - struct { - uint16_t frontEndMode:3; //!< \brief 0x00: Differential mode
- //!< 0x01: Single-ended mode RFP
- //!< 0x02: Single-ended mode RFN
- //!< 0x05 Single-ended mode RFP with external frontend control on RF pins (RFN and RXTX)
- //!< 0x06 Single-ended mode RFN with external frontend control on RF pins (RFP and RXTX)
- //!< Others: Reserved - uint16_t biasMode:1; //!< \brief 0: Internal bias
- //!< 1: External bias - uint16_t :6; - uint16_t bNoFsPowerUp:1; //!< \brief 0: Power up frequency synth
- //!< 1: Do not power up frequency synth - } config; //!< Configuration options - struct { - uint16_t IB:6; //!< Value to write to the PA power control field at 25 °C - uint16_t GC:2; //!< Value to write to the gain control of the 1st stage of the PA - uint16_t boost:1; //!< Value of boost bit in synth - uint16_t tempCoeff:7; //!< Temperature coefficient for IB. 0: No temperature compensation - } txPower; //!< Transmit power - uint32_t* pRegOverride; //!< \brief Pointer to a list of hardware and configuration registers to override. If NULL, no - //!< override is used. -}; - -//! @} - -//! \addtogroup CMD_FS -//! @{ -#define CMD_FS 0x0803 -struct __RFC_STRUCT rfc_CMD_FS_s { - uint16_t commandNo; //!< The command ID number 0x0803 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint16_t frequency; //!< The frequency in MHz to tune to - uint16_t fractFreq; //!< Fractional part of the frequency to tune to - struct { - uint8_t bTxMode:1; //!< \brief 0: Start synth in Rx mode
- //!< 1: Start synth in Tx mode - uint8_t refFreq:6; //!< \brief 0: Use default reference frequency
- //!< Others: Use reference frequency 24 MHz/refFreq - } synthConf; - uint8_t __dummy0; - uint8_t midPrecal; //!< Mid pre-calibration value to use when bOverrideCalib and bSkipCoarseCalib are both 1 - uint8_t ktPrecal; //!< KT pre-calibration value to use when bOverrideCalib and bSkipCoarseCalib are both 1 - uint16_t tdcPrecal; //!< TDC pre-calibration value to use when bOverrideCalib and bSkipCoarseCalib are both 1 -}; - -//! @} - -//! \addtogroup CMD_FS_OFF -//! @{ -#define CMD_FS_OFF 0x0804 -struct __RFC_STRUCT rfc_CMD_FS_OFF_s { - uint16_t commandNo; //!< The command ID number 0x0804 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; -}; - -//! @} - -//! \addtogroup CMD_RX -//! @{ -#define CMD_RX 0x0805 -struct __RFC_STRUCT rfc_CMD_RX_s { - uint16_t commandNo; //!< The command ID number 0x0805 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - struct { - uint16_t endianness:1; //!< \brief 0: Least significant bit first
- //!< 1: Most significant bit first - uint16_t numHdrBits:6; //!< Number of bits in the header - uint16_t bFsOff:1; //!< \brief 0: Keep frequency synth on after command
- //!< 1: Turn frequency synth off after command - uint16_t bUseCrc:1; //!< \brief 0: No CRC
- //!< 1: The last bytes of the packet are a CRC - uint16_t bCrcIncSw:1; //!< \brief 0: Do not include sync word in CRC calculation
- //!< 1: Include sync word in CRC calculation - uint16_t bCrcIncHdr:1; //!< \brief 0: Do not include header in CRC calculation
- //!< 1: Include header in CRC calculation - uint16_t bReportCrc:1; //!< \brief 0: Do not write CRC to receive buffer
- //!< 1: Write received CRC to receive buffer - uint16_t endType:1; //!< \brief 0: Packet is received to the end if end trigger happens after sync is obtained
- //!< 1: Packet reception is stopped if end trigger happens - uint16_t bDualSw:1; //!< \brief 0: Single sync word
- //!< 1: Dual sync word. - } pktConfig; - uint32_t syncWord; //!< Sync word to receive - uint32_t syncWord2; //!< Secondary sync word to receive if pktConfig.bDualSw = 1 - struct { - uint16_t numLenBits:4; //!< Number of bits in the length field - uint16_t lenFieldPos:5; //!< Bit position of the first bit in the length field - uint16_t lenOffset:7; //!< Signed number to add to the received length field - } lenConfig; - uint16_t maxLen; //!< Maximum number of bytes in the received packet (including header, excluding CRC) - uint8_t* pRecPkt; //!< Pointer to buffer for received packet. NULL: Do not store the contents. - ratmr_t endTime; //!< Time to end the operation - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } endTrigger; //!< Trigger classifier for ending the operation - int8_t rssi; //!< RSSI of received packet - uint16_t recLen; //!< Number of bytes written to receive buffer - ratmr_t timeStamp; //!< Time stamp of received packet - uint16_t nRxOk; //!< Counter of number of received packets with CRC OK and first sync word - uint16_t nRxNok; //!< Counter of number of received packets with CRC error and first sync word - uint16_t nRx2Ok; //!< \brief Counter of number of received packets with CRC OK and second sync word; may safely be - //!< omitted if pktConfig.bDualSw is 0 - uint16_t nRx2Nok; //!< \brief Counter of number of received packets with CRC error and second sync word; may safely be - //!< omitted if pktConfig.bDualSw is 0 -}; - -//! @} - -//! \addtogroup CMD_TX -//! @{ -#define CMD_TX 0x0806 -struct __RFC_STRUCT rfc_CMD_TX_s { - uint16_t commandNo; //!< The command ID number 0x0806 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - struct { - uint16_t endianness:1; //!< \brief 0: Least significant bit first
- //!< 1: Most significant bit first - uint16_t numHdrBits:6; //!< Number of bits in the header - uint16_t bFsOff:1; //!< \brief 0: Keep frequency synth on after command
- //!< 1: Turn frequency synth off after command - uint16_t bUseCrc:1; //!< \brief 0: No CRC
- //!< 1: Append a CRC to the packet - uint16_t bCrcIncSw:1; //!< \brief 0: Do not include sync word in CRC calculation
- //!< 1: Include sync word in CRC calculation - uint16_t bCrcIncHdr:1; //!< \brief 0: Do not include header in CRC calculation
- //!< 1: Include header in CRC calculation - } pktConfig; - uint32_t syncWord; //!< Sync word to transmit - uint8_t* pTxPkt; //!< Pointer to buffer for transmitted packet. - uint16_t pktLen; //!< Number of bytes in the transmitted packet -}; - -//! @} - -//! \addtogroup CMD_RX_TEST -//! @{ -#define CMD_RX_TEST 0x0807 -struct __RFC_STRUCT rfc_CMD_RX_TEST_s { - uint16_t commandNo; //!< The command ID number 0x0807 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - struct { - uint8_t bEnaFifo:1; //!< \brief 0: Do not enable FIFO in modem, so that received data is not available
- //!< 1: Enable FIFO in modem – the data must be read out by the application - uint8_t bFsOff:1; //!< \brief 0: Keep frequency synth on after command
- //!< 1: Turn frequency synth off after command - uint8_t bNoSync:1; //!< \brief 0: Run sync search as normal for the configured mode
- //!< 1: Write correlation thresholds to the maximum value to avoid getting sync - } config; - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } endTrigger; //!< Trigger classifier for ending the operation - uint32_t syncWord; //!< Sync word to use for receiver - ratmr_t endTime; //!< Time to end the operation -}; - -//! @} - -//! \addtogroup CMD_TX_TEST -//! @{ -#define CMD_TX_TEST 0x0808 -struct __RFC_STRUCT rfc_CMD_TX_TEST_s { - uint16_t commandNo; //!< The command ID number 0x0808 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - struct { - uint8_t bUseCw:1; //!< \brief 0: Send modulated signal
- //!< 1: Send continuous wave - uint8_t bFsOff:1; //!< \brief 0: Keep frequency synth on after command
- //!< 1: Turn frequency synth off after command - uint8_t whitenMode:2; //!< \brief 0: No whitening
- //!< 1: Default whitening
- //!< 2: PRBS-15
- //!< 3: PRBS-32 - } config; - uint8_t __dummy0; - uint16_t txWord; //!< Value to send to the modem before whitening - uint8_t __dummy1; - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } endTrigger; //!< Trigger classifier for ending the operation - uint32_t syncWord; //!< Sync word to use for transmitter - ratmr_t endTime; //!< Time to end the operation -}; - -//! @} - -//! \addtogroup CMD_SYNC_STOP_RAT -//! @{ -#define CMD_SYNC_STOP_RAT 0x0809 -struct __RFC_STRUCT rfc_CMD_SYNC_STOP_RAT_s { - uint16_t commandNo; //!< The command ID number 0x0809 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint16_t __dummy0; - ratmr_t rat0; //!< \brief The returned RAT timer value corresponding to the value the RAT would have had when the - //!< RTC was zero -}; - -//! @} - -//! \addtogroup CMD_SYNC_START_RAT -//! @{ -#define CMD_SYNC_START_RAT 0x080A -struct __RFC_STRUCT rfc_CMD_SYNC_START_RAT_s { - uint16_t commandNo; //!< The command ID number 0x080A - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint16_t __dummy0; - ratmr_t rat0; //!< \brief The desired RAT timer value corresponding to the value the RAT would have had when the - //!< RTC was zero. This parameter is returned by CMD_SYNC_STOP_RAT -}; - -//! @} - -//! \addtogroup CMD_COUNT -//! @{ -#define CMD_COUNT 0x080B -struct __RFC_STRUCT rfc_CMD_COUNT_s { - uint16_t commandNo; //!< The command ID number 0x080B - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint16_t counter; //!< \brief Counter. On start, the radio CPU decrements the value, and the end status of the operation - //!< differs if the result is zero -}; - -//! @} - -//! \addtogroup CMD_FS_POWERUP -//! @{ -#define CMD_FS_POWERUP 0x080C -struct __RFC_STRUCT rfc_CMD_FS_POWERUP_s { - uint16_t commandNo; //!< The command ID number 0x080C - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint16_t __dummy0; - uint32_t* pRegOverride; //!< Pointer to a list of hardware and configuration registers to override. If NULL, no override is used. -}; - -//! @} - -//! \addtogroup CMD_FS_POWERDOWN -//! @{ -#define CMD_FS_POWERDOWN 0x080D -struct __RFC_STRUCT rfc_CMD_FS_POWERDOWN_s { - uint16_t commandNo; //!< The command ID number 0x080D - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; -}; - -//! @} - -//! \addtogroup CMD_SCH_IMM -//! @{ -#define CMD_SCH_IMM 0x0810 -struct __RFC_STRUCT rfc_CMD_SCH_IMM_s { - uint16_t commandNo; //!< The command ID number 0x0810 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint16_t __dummy0; - uint32_t cmdrVal; //!< Value as would be written to CMDR - uint32_t cmdstaVal; //!< Value as would be returned in CMDSTA -}; - -//! @} - -//! \addtogroup CMD_COUNT_BRANCH -//! @{ -#define CMD_COUNT_BRANCH 0x0812 -struct __RFC_STRUCT rfc_CMD_COUNT_BRANCH_s { - uint16_t commandNo; //!< The command ID number 0x0812 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint16_t counter; //!< \brief Counter. On start, the radio CPU decrements the value, and the end status of the operation - //!< differs if the result is zero - rfc_radioOp_t *pNextOpIfOk; //!< Pointer to next operation if counter did not expire -}; - -//! @} - -//! \addtogroup CMD_PATTERN_CHECK -//! @{ -#define CMD_PATTERN_CHECK 0x0813 -struct __RFC_STRUCT rfc_CMD_PATTERN_CHECK_s { - uint16_t commandNo; //!< The command ID number 0x0813 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - struct { - uint16_t operation:2; //!< \brief Operation to perform
- //!< 0: True if value == compareVal
- //!< 1: True if value < compareVal
- //!< 2: True if value > compareVal
- //!< 3: Reserved - uint16_t bByteRev:1; //!< \brief If 1, interchange the four bytes of the value, so that they are read - //!< most-significant-byte-first. - uint16_t bBitRev:1; //!< If 1, perform bit reversal of the value - uint16_t signExtend:5; //!< \brief 0: Treat value and compareVal as unsigned
- //!< 1–31: Treat value and compareVal as signed, where the value - //!< gives the number of the most significant bit in the signed number. - uint16_t bRxVal:1; //!< \brief 0: Use pValue as a pointer
- //!< 1: Use pValue as a signed offset to the start of the last - //!< committed Rx entry element - } patternOpt; //!< Options for comparison - rfc_radioOp_t *pNextOpIfOk; //!< Pointer to next operation if comparison result was true - uint8_t* pValue; //!< Pointer to read from, or offset from last Rx entry if patternOpt.bRxVal == 1 - uint32_t mask; //!< Bit mask to apply before comparison - uint32_t compareVal; //!< Value to compare to -}; - -//! @} - -//! \addtogroup CMD_TX_POWER_BOOST -//! @{ -#define CMD_TX_POWER_BOOST 0x0816 -struct __RFC_STRUCT rfc_CMD_TX_POWER_BOOST_s { - uint16_t commandNo; //!< The command ID number 0x0816 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - uint8_t vddrLevel; //!< \brief VDDR level to set
- //!< 0xFD: Trim VDDR voltage to normal level (VDDR_TRIM), nominally 1.68 V
- //!< 0xFE: Trim VDDR voltage to high level (VDDR_TRIM_H), nominally 1.85 V
- //!< 0xFF: Trim VDDR voltage to higher level (VDDR_TRIM_HH), nominally 1.95 V
- //!< Other: reserved - uint8_t paTrimValue; //!< \brief Optional power amplifier trim setting manipulation
- //!< 0x00-0x1F: Value to write in ADI_0_RF:PACTL0.TRIM register field
- //!< 0xFE: Set PACTL0.TRIM to its default value from FCFG1
- //!< 0xFF: Do not write PACTL0.TRIM, use the setting that is already applied
-}; - -//! @} - -//! \addtogroup CMD_ABORT -//! @{ -#define CMD_ABORT 0x0401 -struct __RFC_STRUCT rfc_CMD_ABORT_s { - uint16_t commandNo; //!< The command ID number 0x0401 -}; - -//! @} - -//! \addtogroup CMD_STOP -//! @{ -#define CMD_STOP 0x0402 -struct __RFC_STRUCT rfc_CMD_STOP_s { - uint16_t commandNo; //!< The command ID number 0x0402 -}; - -//! @} - -//! \addtogroup CMD_GET_RSSI -//! @{ -#define CMD_GET_RSSI 0x0403 -struct __RFC_STRUCT rfc_CMD_GET_RSSI_s { - uint16_t commandNo; //!< The command ID number 0x0403 -}; - -//! @} - -//! \addtogroup CMD_UPDATE_RADIO_SETUP -//! @{ -#define CMD_UPDATE_RADIO_SETUP 0x0001 -struct __RFC_STRUCT rfc_CMD_UPDATE_RADIO_SETUP_s { - uint16_t commandNo; //!< The command ID number 0x0001 - uint16_t __dummy0; - uint32_t* pRegOverride; //!< Pointer to a list of hardware and configuration registers to override -}; - -//! @} - -//! \addtogroup CMD_TRIGGER -//! @{ -#define CMD_TRIGGER 0x0404 -struct __RFC_STRUCT rfc_CMD_TRIGGER_s { - uint16_t commandNo; //!< The command ID number 0x0404 - uint8_t triggerNo; //!< Command trigger number -}; - -//! @} - -//! \addtogroup CMD_GET_FW_INFO -//! @{ -#define CMD_GET_FW_INFO 0x0002 -struct __RFC_STRUCT rfc_CMD_GET_FW_INFO_s { - uint16_t commandNo; //!< The command ID number 0x0002 - uint16_t versionNo; //!< Firmware version number - uint16_t startOffset; //!< The start of free RAM - uint16_t freeRamSz; //!< The size of free RAM - uint16_t availRatCh; //!< Bitmap of available RAT channels -}; - -//! @} - -//! \addtogroup CMD_START_RAT -//! @{ -#define CMD_START_RAT 0x0405 -struct __RFC_STRUCT rfc_CMD_START_RAT_s { - uint16_t commandNo; //!< The command ID number 0x0405 -}; - -//! @} - -//! \addtogroup CMD_PING -//! @{ -#define CMD_PING 0x0406 -struct __RFC_STRUCT rfc_CMD_PING_s { - uint16_t commandNo; //!< The command ID number 0x0406 -}; - -//! @} - -//! \addtogroup CMD_ADD_DATA_ENTRY -//! @{ -#define CMD_ADD_DATA_ENTRY 0x0005 -struct __RFC_STRUCT rfc_CMD_ADD_DATA_ENTRY_s { - uint16_t commandNo; //!< The command ID number 0x0005 - uint16_t __dummy0; - dataQueue_t* pQueue; //!< Pointer to the queue structure to which the entry will be added - uint8_t* pEntry; //!< Pointer to the entry -}; - -//! @} - -//! \addtogroup CMD_REMOVE_DATA_ENTRY -//! @{ -#define CMD_REMOVE_DATA_ENTRY 0x0006 -struct __RFC_STRUCT rfc_CMD_REMOVE_DATA_ENTRY_s { - uint16_t commandNo; //!< The command ID number 0x0006 - uint16_t __dummy0; - dataQueue_t* pQueue; //!< Pointer to the queue structure from which the entry will be removed - uint8_t* pEntry; //!< Pointer to the entry that was removed -}; - -//! @} - -//! \addtogroup CMD_FLUSH_QUEUE -//! @{ -#define CMD_FLUSH_QUEUE 0x0007 -struct __RFC_STRUCT rfc_CMD_FLUSH_QUEUE_s { - uint16_t commandNo; //!< The command ID number 0x0007 - uint16_t __dummy0; - dataQueue_t* pQueue; //!< Pointer to the queue structure to be flushed - uint8_t* pFirstEntry; //!< Pointer to the first entry that was removed -}; - -//! @} - -//! \addtogroup CMD_CLEAR_RX -//! @{ -#define CMD_CLEAR_RX 0x0008 -struct __RFC_STRUCT rfc_CMD_CLEAR_RX_s { - uint16_t commandNo; //!< The command ID number 0x0008 - uint16_t __dummy0; - dataQueue_t* pQueue; //!< Pointer to the queue structure to be cleared -}; - -//! @} - -//! \addtogroup CMD_REMOVE_PENDING_ENTRIES -//! @{ -#define CMD_REMOVE_PENDING_ENTRIES 0x0009 -struct __RFC_STRUCT rfc_CMD_REMOVE_PENDING_ENTRIES_s { - uint16_t commandNo; //!< The command ID number 0x0009 - uint16_t __dummy0; - dataQueue_t* pQueue; //!< Pointer to the queue structure to be flushed - uint8_t* pFirstEntry; //!< Pointer to the first entry that was removed -}; - -//! @} - -//! \addtogroup CMD_SET_RAT_CMP -//! @{ -#define CMD_SET_RAT_CMP 0x000A -struct __RFC_STRUCT rfc_CMD_SET_RAT_CMP_s { - uint16_t commandNo; //!< The command ID number 0x000A - uint8_t ratCh; //!< The radio timer channel number - uint8_t __dummy0; - ratmr_t compareTime; //!< The time at which the compare occurs -}; - -//! @} - -//! \addtogroup CMD_SET_RAT_CPT -//! @{ -#define CMD_SET_RAT_CPT 0x0603 -struct __RFC_STRUCT rfc_CMD_SET_RAT_CPT_s { - uint16_t commandNo; //!< The command ID number 0x0603 - struct { - uint16_t :3; - uint16_t inputSrc:5; //!< Input source indicator - uint16_t ratCh:4; //!< The radio timer channel number - uint16_t bRepeated:1; //!< \brief 0: Single capture mode
- //!< 1: Repeated capture mode - uint16_t inputMode:2; //!< \brief Input mode:
- //!< 0: Capture on rising edge
- //!< 1: Capture on falling edge
- //!< 2: Capture on both edges
- //!< 3: Reserved - } config; -}; - -//! @} - -//! \addtogroup CMD_DISABLE_RAT_CH -//! @{ -#define CMD_DISABLE_RAT_CH 0x0408 -struct __RFC_STRUCT rfc_CMD_DISABLE_RAT_CH_s { - uint16_t commandNo; //!< The command ID number 0x0408 - uint8_t ratCh; //!< The radio timer channel number -}; - -//! @} - -//! \addtogroup CMD_SET_RAT_OUTPUT -//! @{ -#define CMD_SET_RAT_OUTPUT 0x0604 -struct __RFC_STRUCT rfc_CMD_SET_RAT_OUTPUT_s { - uint16_t commandNo; //!< The command ID number 0x0604 - struct { - uint16_t :2; - uint16_t outputSel:3; //!< Output event indicator - uint16_t outputMode:3; //!< \brief 0: Set output line low as default; and pulse on event. Duration of pulse is one RF Core clock period (ca. 41.67 ns).
- //!< 1: Set output line high on event
- //!< 2: Set output line low on event
- //!< 3: Toggle (invert) output line state on event
- //!< 4: Immediately set output line to low (does not change upon event)
- //!< 5: Immediately set output line to high (does not change upon event)
- //!< Others: Reserved - uint16_t ratCh:4; //!< The radio timer channel number - } config; -}; - -//! @} - -//! \addtogroup CMD_ARM_RAT_CH -//! @{ -#define CMD_ARM_RAT_CH 0x0409 -struct __RFC_STRUCT rfc_CMD_ARM_RAT_CH_s { - uint16_t commandNo; //!< The command ID number 0x0409 - uint8_t ratCh; //!< The radio timer channel number -}; - -//! @} - -//! \addtogroup CMD_DISARM_RAT_CH -//! @{ -#define CMD_DISARM_RAT_CH 0x040A -struct __RFC_STRUCT rfc_CMD_DISARM_RAT_CH_s { - uint16_t commandNo; //!< The command ID number 0x040A - uint8_t ratCh; //!< The radio timer channel number -}; - -//! @} - -//! \addtogroup CMD_SET_TX_POWER -//! @{ -#define CMD_SET_TX_POWER 0x0010 -struct __RFC_STRUCT rfc_CMD_SET_TX_POWER_s { - uint16_t commandNo; //!< The command ID number 0x0010 - struct { - uint16_t IB:6; //!< Value to write to the PA power control field at 25 °C - uint16_t GC:2; //!< Value to write to the gain control of the 1st stage of the PA - uint16_t boost:1; //!< Value of boost bit in synth - uint16_t tempCoeff:7; //!< Temperature coefficient for IB. 0: No temperature compensation - } txPower; //!< New Tx power setting -}; - -//! @} - -//! \addtogroup CMD_UPDATE_FS -//! @{ -#define CMD_UPDATE_FS 0x0011 -struct __RFC_STRUCT rfc_CMD_UPDATE_FS_s { - uint16_t commandNo; //!< The command ID number 0x0011 - uint16_t frequency; //!< The frequency in MHz to tune to - uint16_t fractFreq; //!< Fractional part of the frequency to tune to -}; - -//! @} - -//! \addtogroup CMD_BUS_REQUEST -//! @{ -#define CMD_BUS_REQUEST 0x040E -struct __RFC_STRUCT rfc_CMD_BUS_REQUEST_s { - uint16_t commandNo; //!< The command ID number 0x040E - uint8_t bSysBusNeeded; //!< \brief 0: System bus may sleep
- //!< 1: System bus access needed -}; - -//! @} - -//! @} -//! @} -#endif /* COMMON_CMD_H_ */ diff --git a/cpu/cc26xx-cc13xx/rf-core/api/data_entry.h b/cpu/cc26xx-cc13xx/rf-core/api/data_entry.h deleted file mode 100644 index c396a211f..000000000 --- a/cpu/cc26xx-cc13xx/rf-core/api/data_entry.h +++ /dev/null @@ -1,213 +0,0 @@ -/****************************************************************************** -* Filename: data_entry.h -* Revised: 2015-08-04 11:44:20 +0200 (Tue, 04 Aug 2015) -* Revision: 44329 -* -* Description: Definition of API for data exchange -* -* 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 DATA_ENTRY_H_ -#define DATA_ENTRY_H_ - -#ifndef __RFC_STRUCT -#ifdef __GNUC__ -#define __RFC_STRUCT __attribute__ ((aligned (4))) -#else -#define __RFC_STRUCT -#endif -#endif - -//! \addtogroup rfc -//! @{ - -//! \addtogroup data_entry -//! @{ - -#include -#include "mailbox.h" - -typedef struct __RFC_STRUCT rfc_dataEntry_s rfc_dataEntry_t; -typedef struct __RFC_STRUCT rfc_dataEntryGeneral_s rfc_dataEntryGeneral_t; -typedef struct __RFC_STRUCT rfc_dataEntryMulti_s rfc_dataEntryMulti_t; -typedef struct __RFC_STRUCT rfc_dataEntryPointer_s rfc_dataEntryPointer_t; -typedef struct __RFC_STRUCT rfc_dataEntryPartial_s rfc_dataEntryPartial_t; - -//! \addtogroup dataEntry -//! @{ -struct __RFC_STRUCT rfc_dataEntry_s { - uint8_t* pNextEntry; //!< Pointer to next entry in the queue, NULL if this is the last entry - uint8_t status; //!< Indicates status of entry, including whether it is free for the system CPU to write to - struct { - uint8_t type:2; //!< \brief Type of data entry structure
- //!< 0: General data entry
- //!< 1: Multi-element Rx entry
- //!< 2: Pointer entry
- //!< 3: Partial read Rx entry - uint8_t lenSz:2; //!< \brief Size of length word in start of each Rx entry element
- //!< 0: No length indicator
- //!< 1: One byte length indicator
- //!< 2: Two bytes length indicator
- //!< 3: Reserved - uint8_t irqIntv:4; //!< \brief For partial read Rx entry only: The number of bytes between interrupt generated - //!< by the radio CPU (0: 16 bytes) - } config; - uint16_t length; //!< \brief For pointer entries: Number of bytes in the data buffer pointed to
- //!< For other entries: Number of bytes following this length field -}; - -//! @} - -//! \addtogroup dataEntryGeneral -//! @{ -//! General data entry structure (type = 0) - -struct __RFC_STRUCT rfc_dataEntryGeneral_s { - uint8_t* pNextEntry; //!< Pointer to next entry in the queue, NULL if this is the last entry - uint8_t status; //!< Indicates status of entry, including whether it is free for the system CPU to write to - struct { - uint8_t type:2; //!< \brief Type of data entry structure
- //!< 0: General data entry
- //!< 1: Multi-element Rx entry
- //!< 2: Pointer entry
- //!< 3: Partial read Rx entry - uint8_t lenSz:2; //!< \brief Size of length word in start of each Rx entry element
- //!< 0: No length indicator
- //!< 1: One byte length indicator
- //!< 2: Two bytes length indicator
- //!< 3: Reserved - uint8_t irqIntv:4; //!< \brief For partial read Rx entry only: The number of bytes between interrupt generated - //!< by the radio CPU (0: 16 bytes) - } config; - uint16_t length; //!< \brief For pointer entries: Number of bytes in the data buffer pointed to
- //!< For other entries: Number of bytes following this length field - uint8_t data; //!< First byte of the data array to be received or transmitted -}; - -//! @} - -//! \addtogroup dataEntryMulti -//! @{ -//! Multi-element data entry structure (type = 1) - -struct __RFC_STRUCT rfc_dataEntryMulti_s { - uint8_t* pNextEntry; //!< Pointer to next entry in the queue, NULL if this is the last entry - uint8_t status; //!< Indicates status of entry, including whether it is free for the system CPU to write to - struct { - uint8_t type:2; //!< \brief Type of data entry structure
- //!< 0: General data entry
- //!< 1: Multi-element Rx entry
- //!< 2: Pointer entry
- //!< 3: Partial read Rx entry - uint8_t lenSz:2; //!< \brief Size of length word in start of each Rx entry element
- //!< 0: No length indicator
- //!< 1: One byte length indicator
- //!< 2: Two bytes length indicator
- //!< 3: Reserved - uint8_t irqIntv:4; //!< \brief For partial read Rx entry only: The number of bytes between interrupt generated - //!< by the radio CPU (0: 16 bytes) - } config; - uint16_t length; //!< \brief For pointer entries: Number of bytes in the data buffer pointed to
- //!< For other entries: Number of bytes following this length field - uint16_t numElements; //!< Number of entry elements committed in the entry - uint16_t nextIndex; //!< Index to the byte after the last byte of the last entry element committed by the radio CPU - uint8_t rxData; //!< First byte of the data array of received data entry elements -}; - -//! @} - -//! \addtogroup dataEntryPointer -//! @{ -//! Pointer data entry structure (type = 2) - -struct __RFC_STRUCT rfc_dataEntryPointer_s { - uint8_t* pNextEntry; //!< Pointer to next entry in the queue, NULL if this is the last entry - uint8_t status; //!< Indicates status of entry, including whether it is free for the system CPU to write to - struct { - uint8_t type:2; //!< \brief Type of data entry structure
- //!< 0: General data entry
- //!< 1: Multi-element Rx entry
- //!< 2: Pointer entry
- //!< 3: Partial read Rx entry - uint8_t lenSz:2; //!< \brief Size of length word in start of each Rx entry element
- //!< 0: No length indicator
- //!< 1: One byte length indicator
- //!< 2: Two bytes length indicator
- //!< 3: Reserved - uint8_t irqIntv:4; //!< \brief For partial read Rx entry only: The number of bytes between interrupt generated - //!< by the radio CPU (0: 16 bytes) - } config; - uint16_t length; //!< \brief For pointer entries: Number of bytes in the data buffer pointed to
- //!< For other entries: Number of bytes following this length field - uint8_t* pData; //!< Pointer to data buffer of data to be received ro transmitted -}; - -//! @} - -//! \addtogroup dataEntryPartial -//! @{ -//! Partial read data entry structure (type = 3) - -struct __RFC_STRUCT rfc_dataEntryPartial_s { - uint8_t* pNextEntry; //!< Pointer to next entry in the queue, NULL if this is the last entry - uint8_t status; //!< Indicates status of entry, including whether it is free for the system CPU to write to - struct { - uint8_t type:2; //!< \brief Type of data entry structure
- //!< 0: General data entry
- //!< 1: Multi-element Rx entry
- //!< 2: Pointer entry
- //!< 3: Partial read Rx entry - uint8_t lenSz:2; //!< \brief Size of length word in start of each Rx entry element
- //!< 0: No length indicator
- //!< 1: One byte length indicator
- //!< 2: Two bytes length indicator
- //!< 3: Reserved - uint8_t irqIntv:4; //!< \brief For partial read Rx entry only: The number of bytes between interrupt generated - //!< by the radio CPU (0: 16 bytes) - } config; - uint16_t length; //!< \brief For pointer entries: Number of bytes in the data buffer pointed to
- //!< For other entries: Number of bytes following this length field - struct { - uint16_t numElements:13; //!< Number of entry elements committed in the entry - uint16_t bEntryOpen:1; //!< 1 if the entry contains an element that is still open for appending data - uint16_t bFirstCont:1; //!< 1 if the first element is a continuation of the last packet from the previous entry - uint16_t bLastCont:1; //!< 1 if the packet in the last element continues in the next entry - } pktStatus; - uint16_t nextIndex; //!< Index to the byte after the last byte of the last entry element committed by the radio CPU - uint8_t rxData; //!< First byte of the data array of received data entry elements -}; - -//! @} - -//! @} -//! @} -#endif /* DATA_ENTRY_H_ */ diff --git a/cpu/cc26xx-cc13xx/rf-core/api/mailbox.h b/cpu/cc26xx-cc13xx/rf-core/api/mailbox.h deleted file mode 100644 index 119565959..000000000 --- a/cpu/cc26xx-cc13xx/rf-core/api/mailbox.h +++ /dev/null @@ -1,328 +0,0 @@ -/****************************************************************************** -* Filename: mailbox.h -* Revised: 2015-06-29 12:59:58 +0200 (Mon, 29 Jun 2015) -* Revision: 44063 -* -* Description: Definitions for interface between system and radio CPU -* -* 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 MAILBOX_H_ -#define MAILBOX_H_ - -#include -#include - -/// Type definition for RAT -typedef uint32_t ratmr_t; - - - -/// Type definition for a data queue -typedef struct { - uint8_t *pCurrEntry; ///< Pointer to the data queue entry to be used, NULL for an empty queue - uint8_t *pLastEntry; ///< Pointer to the last entry in the queue, NULL for a circular queue -} dataQueue_t; - - - -/// \name CPE interrupt definitions -/// Interrupt masks for the CPE interrupt in RDBELL. -///@{ -#define IRQN_COMMAND_DONE 0 ///< Radio operation command finished -#define IRQN_LAST_COMMAND_DONE 1 ///< Last radio operation command in a chain finished -#define IRQN_FG_COMMAND_DONE 2 ///< FG level Radio operation command finished -#define IRQN_LAST_FG_COMMAND_DONE 3 ///< Last FG level radio operation command in a chain finished -#define IRQN_TX_DONE 4 ///< Packet transmitted -#define IRQN_TX_ACK 5 ///< ACK packet transmitted -#define IRQN_TX_CTRL 6 ///< Control packet transmitted -#define IRQN_TX_CTRL_ACK 7 ///< Acknowledgement received on a transmitted control packet -#define IRQN_TX_CTRL_ACK_ACK 8 ///< Acknowledgement received on a transmitted control packet, and acknowledgement transmitted for that packet -#define IRQN_TX_RETRANS 9 ///< Packet retransmitted -#define IRQN_TX_ENTRY_DONE 10 ///< Tx queue data entry state changed to Finished -#define IRQN_TX_BUFFER_CHANGED 11 ///< A buffer change is complete -#define IRQN_RX_OK 16 ///< Packet received with CRC OK, payload, and not to be ignored -#define IRQN_RX_NOK 17 ///< Packet received with CRC error -#define IRQN_RX_IGNORED 18 ///< Packet received with CRC OK, but to be ignored -#define IRQN_RX_EMPTY 19 ///< Packet received with CRC OK, not to be ignored, no payload -#define IRQN_RX_CTRL 20 ///< Control packet received with CRC OK, not to be ignored -#define IRQN_RX_CTRL_ACK 21 ///< Control packet received with CRC OK, not to be ignored, then ACK sent -#define IRQN_RX_BUF_FULL 22 ///< Packet received that did not fit in the Rx queue -#define IRQN_RX_ENTRY_DONE 23 ///< Rx queue data entry changing state to Finished -#define IRQN_RX_DATA_WRITTEN 24 ///< Data written to partial read Rx buffer -#define IRQN_RX_N_DATA_WRITTEN 25 ///< Specified number of bytes written to partial read Rx buffer -#define IRQN_RX_ABORTED 26 ///< Packet reception stopped before packet was done -#define IRQN_RX_COLLISION_DETECTED 27 ///< A collision was indicated during packet reception -#define IRQN_SYNTH_NO_LOCK 28 ///< The synth has gone out of lock after calibration -#define IRQN_MODULES_UNLOCKED 29 ///< As part of the boot process, the CM0 has opened access to RF core modules and memories -#define IRQN_BOOT_DONE 30 ///< The RF core CPU boot is finished - -#define IRQN_INTERNAL_ERROR 31 ///< Internal error observed - -#define IRQ_COMMAND_DONE (1U << IRQN_COMMAND_DONE) -#define IRQ_LAST_COMMAND_DONE (1U << IRQN_LAST_COMMAND_DONE) -#define IRQ_FG_COMMAND_DONE (1U << IRQN_FG_COMMAND_DONE) -#define IRQ_LAST_FG_COMMAND_DONE (1U << IRQN_LAST_FG_COMMAND_DONE) - -#define IRQ_TX_DONE (1U << IRQN_TX_DONE) -#define IRQ_TX_ACK (1U << IRQN_TX_ACK) -#define IRQ_TX_CTRL (1U << IRQN_TX_CTRL) -#define IRQ_TX_CTRL_ACK (1U << IRQN_TX_CTRL_ACK) -#define IRQ_TX_CTRL_ACK_ACK (1U << IRQN_TX_CTRL_ACK_ACK) -#define IRQ_TX_RETRANS (1U << IRQN_TX_RETRANS) - -#define IRQ_TX_ENTRY_DONE (1U << IRQN_TX_ENTRY_DONE) -#define IRQ_TX_BUFFER_CHANGED (1U << IRQN_TX_BUFFER_CHANGED) - -#define IRQ_RX_OK (1U << IRQN_RX_OK) -#define IRQ_RX_NOK (1U << IRQN_RX_NOK) -#define IRQ_RX_IGNORED (1U << IRQN_RX_IGNORED) -#define IRQ_RX_EMPTY (1U << IRQN_RX_EMPTY) -#define IRQ_RX_CTRL (1U << IRQN_RX_CTRL) -#define IRQ_RX_CTRL_ACK (1U << IRQN_RX_CTRL_ACK) -#define IRQ_RX_BUF_FULL (1U << IRQN_RX_BUF_FULL) -#define IRQ_RX_ENTRY_DONE (1U << IRQN_RX_ENTRY_DONE) -#define IRQ_RX_DATA_WRITTEN (1U << IRQN_RX_DATA_WRITTEN) -#define IRQ_RX_N_DATA_WRITTEN (1U << IRQN_RX_N_DATA_WRITTEN) -#define IRQ_RX_ABORTED (1U << IRQN_RX_ABORTED) -#define IRQ_RX_COLLISION_DETECTED (1U << IRQN_RX_COLLISION_DETECTED) -#define IRQ_SYNTH_NO_LOCK (1U << IRQN_SYNTH_NO_LOCK) -#define IRQ_MODULES_UNLOCKED (1U << IRQN_MODULES_UNLOCKED) -#define IRQ_BOOT_DONE (1U << IRQN_BOOT_DONE) -#define IRQ_INTERNAL_ERROR (1U << IRQN_INTERNAL_ERROR) -///@} - - - -/// \name CMDSTA values -/// Values returned in result byte of CMDSTA -///@{ -#define CMDSTA_Pending 0x00 ///< The command has not yet been parsed -#define CMDSTA_Done 0x01 ///< Command successfully parsed - -#define CMDSTA_IllegalPointer 0x81 ///< The pointer signalled in CMDR is not valid -#define CMDSTA_UnknownCommand 0x82 ///< The command number in the command structure is unknown -#define CMDSTA_UnknownDirCommand 0x83 ///< The command number for a direct command is unknown, or the - ///< command is not a direct command -#define CMDSTA_ContextError 0x85 ///< An immediate or direct command was issued in a context - ///< where it is not supported -#define CMDSTA_SchedulingError 0x86 ///< A radio operation command was attempted to be scheduled - ///< while another operation was already running in the RF core -#define CMDSTA_ParError 0x87 ///< There were errors in the command parameters that are parsed - ///< on submission. -#define CMDSTA_QueueError 0x88 ///< An operation on a data entry queue was attempted that was - ///< not supported by the queue in its current state -#define CMDSTA_QueueBusy 0x89 ///< An operation on a data entry was attempted while that entry - ///< was busy -///@} - - - -/// \name Macros for sending direct commands -///@{ -/// Direct command with no parameter -#define CMDR_DIR_CMD(cmdId) (((cmdId) << 16) | 1) - -/// Direct command with 1-byte parameter -#define CMDR_DIR_CMD_1BYTE(cmdId, par) (((cmdId) << 16) | ((par) << 8) | 1) - -/// Direct command with 2-byte parameter -#define CMDR_DIR_CMD_2BYTE(cmdId, par) (((cmdId) << 16) | ((par) & 0xFFFC) | 1) - -///@} - - - -/// \name Definitions for trigger types -///@{ -#define TRIG_NOW 0 ///< Triggers immediately -#define TRIG_NEVER 1 ///< Never trigs -#define TRIG_ABSTIME 2 ///< Trigs at an absolute time -#define TRIG_REL_SUBMIT 3 ///< Trigs at a time relative to the command was submitted -#define TRIG_REL_START 4 ///< Trigs at a time relative to the command started -#define TRIG_REL_PREVSTART 5 ///< Trigs at a time relative to the previous command in the chain started -#define TRIG_REL_FIRSTSTART 6 ///< Trigs at a time relative to the first command in the chain started -#define TRIG_REL_PREVEND 7 ///< Trigs at a time relative to the previous command in the chain ended -#define TRIG_REL_EVT1 8 ///< Trigs at a time relative to the context defined "Event 1" -#define TRIG_REL_EVT2 9 ///< Trigs at a time relative to the context defined "Event 2" -#define TRIG_EXTERNAL 10 ///< Trigs at an external event to the radio timer -#define TRIG_PAST_BM 0x80 ///< Bitmask for setting pastTrig bit in order to trig immediately if - ///< trigger happened in the past -///@} - - -/// \name Definitions for conditional execution -///@{ -#define COND_ALWAYS 0 ///< Always run next command (except in case of Abort) -#define COND_NEVER 1 ///< Never run next command -#define COND_STOP_ON_FALSE 2 ///< Run next command if this command returned True, stop if it returned - ///< False -#define COND_STOP_ON_TRUE 3 ///< Stop if this command returned True, run next command if it returned - ///< False -#define COND_SKIP_ON_FALSE 4 ///< Run next command if this command returned True, skip a number of - ///< commands if it returned False -#define COND_SKIP_ON_TRUE 5 ///< Skip a number of commands if this command returned True, run next - ///< command if it returned False -///@} - - - -/// \name Radio operation status -///@{ -/// \name Operation not finished -///@{ -#define IDLE 0x0000 ///< Operation not started -#define PENDING 0x0001 ///< Start of command is pending -#define ACTIVE 0x0002 ///< Running -#define SKIPPED 0x0003 ///< Operation skipped due to condition in another command -///@} -/// \name Operation finished normally -///@{ -#define DONE_OK 0x0400 ///< Operation ended normally -#define DONE_COUNTDOWN 0x0401 ///< Counter reached zero -#define DONE_RXERR 0x0402 ///< Operation ended with CRC error -#define DONE_TIMEOUT 0x0403 ///< Operation ended with timeout -#define DONE_STOPPED 0x0404 ///< Operation stopped after CMD_STOP command -#define DONE_ABORT 0x0405 ///< Operation aborted by CMD_ABORT command -#define DONE_FAILED 0x0406 ///< Scheduled immediate command failed -///@} -/// \name Operation finished with error -///@{ -#define ERROR_PAST_START 0x0800 ///< The start trigger occurred in the past -#define ERROR_START_TRIG 0x0801 ///< Illegal start trigger parameter -#define ERROR_CONDITION 0x0802 ///< Illegal condition for next operation -#define ERROR_PAR 0x0803 ///< Error in a command specific parameter -#define ERROR_POINTER 0x0804 ///< Invalid pointer to next operation -#define ERROR_CMDID 0x0805 ///< Next operation has a command ID that is undefined or not a radio - ///< operation command -#define ERROR_WRONG_BG 0x0806 ///< FG level command not compatible with running BG level command -#define ERROR_NO_SETUP 0x0807 ///< Operation using Rx or Tx attempted without CMD_RADIO_SETUP -#define ERROR_NO_FS 0x0808 ///< Operation using Rx or Tx attempted without frequency synth configured -#define ERROR_SYNTH_PROG 0x0809 ///< Synthesizer calibration failed -#define ERROR_TXUNF 0x080A ///< Tx underflow observed -#define ERROR_RXOVF 0x080B ///< Rx overflow observed -#define ERROR_NO_RX 0x080C ///< Attempted to access data from Rx when no such data was yet received -#define ERROR_PENDING 0x080D ///< Command submitted in the future with another command at different level pending -///@} -///@} - - -/// \name Data entry types -///@{ -#define DATA_ENTRY_TYPE_GEN 0 ///< General type: Tx entry or single element Rx entry -#define DATA_ENTRY_TYPE_MULTI 1 ///< Multi-element Rx entry type -#define DATA_ENTRY_TYPE_PTR 2 ///< Pointer entry type -#define DATA_ENTRY_TYPE_PARTIAL 3 ///< Partial read entry type -///@ - - -/// \name Data entry statuses -///@{ -#define DATA_ENTRY_PENDING 0 ///< Entry not yet used -#define DATA_ENTRY_ACTIVE 1 ///< Entry in use by radio CPU -#define DATA_ENTRY_BUSY 2 ///< Entry being updated -#define DATA_ENTRY_FINISHED 3 ///< Radio CPU is finished accessing the entry -#define DATA_ENTRY_UNFINISHED 4 ///< Radio CPU is finished accessing the entry, but packet could not be finished -///@} - - - -/// \name Macros for RF register override -///@{ -/// Macro for ADI half-size value-mask combination -#define ADI_VAL_MASK(addr, mask, value) \ -(((addr) & 1) ? (((mask) & 0x0F) | (((value) & 0x0F) << 4)) : \ - ((((mask) & 0x0F) << 4) | ((value) & 0x0F))) -/// 32-bit write of 16-bit value -#define HW_REG_OVERRIDE(addr, val) ((((uintptr_t) (addr)) & 0xFFFC) | ((uint32_t)(val) << 16)) -/// ADI register, full-size write -#define ADI_REG_OVERRIDE(adiNo, addr, val) (2 | ((uint32_t)(val) << 16) | \ -(((addr) & 0x3F) << 24) | (((adiNo) ? 1U : 0) << 31)) -/// 2 ADI registers, full-size write -#define ADI_2REG_OVERRIDE(adiNo, addr, val, addr2, val2) \ -(2 | ((uint32_t)(val2) << 2) | (((addr2) & 0x3F) << 10) | ((uint32_t)(val) << 16) | \ -(((addr) & 0x3F) << 24) | (((adiNo) ? 1U : 0) << 31)) -/// ADI register, half-size read-modify-write -#define ADI_HALFREG_OVERRIDE(adiNo, addr, mask, val) (2 | (ADI_VAL_MASK(addr, mask, val) << 16) | \ -(((addr) & 0x3F) << 24) | (1U << 30) | (((adiNo) ? 1U : 0) << 31)) -/// 2 ADI registers, half-size read-modify-write -#define ADI_2HALFREG_OVERRIDE(adiNo, addr, mask, val, addr2, mask2, val2) \ -(2 | (ADI_VAL_MASK(addr2, mask2, val2) << 2) | (((addr2) & 0x3F) << 10) | \ -(ADI_VAL_MASK(addr, mask, val) << 16) | (((addr) & 0x3F) << 24) | (1U << 30) | (((adiNo) ? 1U : 0) << 31)) - -/// 16-bit SW register as defined in radio_par_def.txt -#define SW_REG_OVERRIDE(cmd, field, val) (3 | ((_POSITION_##cmd##_##field) << 4) | ((uint32_t)(val) << 16)) -/// SW register as defined in radio_par_def.txt with added index (for use with registers > 16 bits). -#define SW_REG_IND_OVERRIDE(cmd, field, offset, val) (3 | \ -(((_POSITION_##cmd##_##field) + ((offset) << 1)) << 4) | ((uint32_t)(val) << 16)) -/// 8-bit SW register as defined in radio_par_def.txt -#define SW_REG_BYTE_OVERRIDE(cmd, field, val) (0x8003 | ((_POSITION_##cmd##_##field) << 4) | \ -((uint32_t)(val) << 16)) -/// Two 8-bit SW registers as defined in radio_par_def.txt; the one given by field and the next byte. -#define SW_REG_2BYTE_OVERRIDE(cmd, field, val0, val1) (3 | (((_POSITION_##cmd##_##field) & 0xFFFE) << 4) | \ - (((uint32_t)(val0) << 16) & 0x00FF0000) | ((uint32_t)(val1) << 24)) -#define HW16_ARRAY_OVERRIDE(addr, length) (1 | (((uintptr_t) (addr)) & 0xFFFC) | ((uint32_t)(length) << 16)) -#define HW32_ARRAY_OVERRIDE(addr, length) (1 | (((uintptr_t) (addr)) & 0xFFFC) | \ -((uint32_t)(length) << 16) | (1U << 30)) -#define ADI_ARRAY_OVERRIDE(adiNo, addr, bHalfSize, length) (1 | ((((addr) & 0x3F) << 2)) | \ -((!!(bHalfSize)) << 8) | ((!!(adiNo)) << 9) | ((uint32_t)(length) << 16) | (2U << 30)) -#define SW_ARRAY_OVERRIDE(cmd, firstfield, length) (1 | (((_POSITION_##cmd##_##firstfield)) << 2) | \ -((uint32_t)(length) << 16) | (3U << 30)) -#define MCE_RFE_OVERRIDE(bMceRam, mceRomBank, mceMode, bRfeRam, rfeRomBank, rfeMode) \ - (7 | ((!!(bMceRam)) << 8) | (((mceRomBank) & 0x07) << 9) | ((!!(bRfeRam)) << 12) | (((rfeRomBank) & 0x07) << 13) | \ - (((mceMode) & 0x00FF) << 16) | (((rfeMode) & 0x00FF) << 24)) -#define NEW_OVERRIDE_SEGMENT(address) (((((uintptr_t)(address)) & 0x03FFFFFC) << 6) | 0x000F | \ - (((((uintptr_t)(address) >> 24) == 0x20) ? 0x01 : \ - (((uintptr_t)(address) >> 24) == 0x21) ? 0x02 : \ - (((uintptr_t)(address) >> 24) == 0xA0) ? 0x03 : \ - (((uintptr_t)(address) >> 24) == 0x00) ? 0x04 : \ - (((uintptr_t)(address) >> 24) == 0x10) ? 0x05 : \ - (((uintptr_t)(address) >> 24) == 0x11) ? 0x06 : \ - (((uintptr_t)(address) >> 24) == 0x40) ? 0x07 : \ - (((uintptr_t)(address) >> 24) == 0x50) ? 0x08 : \ - 0x09) << 4)) // Use illegal value for illegal address range -/// End of string for override register -#define END_OVERRIDE 0xFFFFFFFF - - -/// ADI address-value pair -#define ADI_ADDR_VAL(addr, value) ((((addr) & 0x7F) << 8) | ((value) & 0xFF)) -#define ADI_ADDR_VAL_MASK(addr, mask, value) ((((addr) & 0x7F) << 8) | ADI_VAL_MASK(addr, mask, value)) - -/// Low half-word -#define LOWORD(value) ((value) & 0xFFFF) -/// High half-word -#define HIWORD(value) ((value) >> 16) -///@} - - -#endif /* MAILBOX_H_ */ diff --git a/cpu/cc26xx-cc13xx/rf-core/api/prop_cmd.h b/cpu/cc26xx-cc13xx/rf-core/api/prop_cmd.h deleted file mode 100644 index e0d0a0c35..000000000 --- a/cpu/cc26xx-cc13xx/rf-core/api/prop_cmd.h +++ /dev/null @@ -1,596 +0,0 @@ -/****************************************************************************** -* Filename: prop_cmd.h -* Revised: 2015-08-04 10:40:45 +0200 (Tue, 04 Aug 2015) -* Revision: 44326 -* -* Description: CC13xx API for Proprietary mode commands -* -* 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 PROP_CMD_H_ -#define PROP_CMD_H_ - -#ifndef __RFC_STRUCT -#ifdef __GNUC__ -#define __RFC_STRUCT __attribute__ ((aligned (4))) -#else -#define __RFC_STRUCT -#endif -#endif - -//! \addtogroup rfc -//! @{ - -//! \addtogroup prop_cmd -//! @{ - -#include -#include "mailbox.h" -#include "common_cmd.h" - -typedef struct __RFC_STRUCT rfc_carrierSense_s rfc_carrierSense_t; -typedef struct __RFC_STRUCT rfc_CMD_PROP_TX_s rfc_CMD_PROP_TX_t; -typedef struct __RFC_STRUCT rfc_CMD_PROP_RX_s rfc_CMD_PROP_RX_t; -typedef struct __RFC_STRUCT rfc_CMD_PROP_TX_ADV_s rfc_CMD_PROP_TX_ADV_t; -typedef struct __RFC_STRUCT rfc_CMD_PROP_RX_ADV_s rfc_CMD_PROP_RX_ADV_t; -typedef struct __RFC_STRUCT rfc_CMD_PROP_RADIO_SETUP_s rfc_CMD_PROP_RADIO_SETUP_t; -typedef struct __RFC_STRUCT rfc_CMD_PROP_RADIO_DIV_SETUP_s rfc_CMD_PROP_RADIO_DIV_SETUP_t; -typedef struct __RFC_STRUCT rfc_CMD_PROP_SET_LEN_s rfc_CMD_PROP_SET_LEN_t; -typedef struct __RFC_STRUCT rfc_CMD_PROP_RESTART_RX_s rfc_CMD_PROP_RESTART_RX_t; -typedef struct __RFC_STRUCT rfc_propRxOutput_s rfc_propRxOutput_t; -typedef struct __RFC_STRUCT rfc_propRxStatus_s rfc_propRxStatus_t; - -//! \addtogroup carrierSense -//! @{ -struct __RFC_STRUCT rfc_carrierSense_s { - struct { - uint8_t bEnaRssi:1; //!< If 1, enable RSSI as a criterion - uint8_t bEnaCorr:1; //!< If 1, enable correlation as a criterion - uint8_t operation:1; //!< \brief 0: Busy if either RSSI or correlation indicates Busy
- //!< 1: Busy if both RSSI and correlation indicates Busy - uint8_t busyOp:1; //!< \brief 0: Continue carrier sense on channel Busy
- //!< 1: End carrier sense on channel Busy
- //!< For an Rx command, the receiver will continue when carrier sense ends, but it will then not end if channel goes Idle - uint8_t idleOp:1; //!< \brief 0: Continue on channel Idle
- //!< 1: End on channel Idle - uint8_t timeoutRes:1; //!< \brief 0: Timeout with channel state Invalid treated as Busy
- //!< 1: Timeout with channel state Invalid treated as Idle - } csConf; - int8_t rssiThr; //!< RSSI threshold - uint8_t numRssiIdle; //!< \brief Number of consecutive RSSI measurements below the threshold needed before the channel is - //!< declared Idle - uint8_t numRssiBusy; //!< \brief Number of consecutive RSSI measurements above the threshold needed before the channel is - //!< declared Busy - uint16_t corrPeriod; //!< Number of RAT ticks for a correlation observation periods - struct { - uint8_t numCorrInv:4; //!< \brief Number of subsequent correlation tops with maximum corrPeriod RAT - //!< ticks between them needed to go from Idle to Invalid - uint8_t numCorrBusy:4; //!< \brief Number of subsequent correlation tops with maximum corrPeriod RAT - //!< ticks between them needed to go from Invalid to Busy - } corrConfig; - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } csEndTrigger; //!< Trigger classifier for ending the carrier sense - ratmr_t csEndTime; //!< Time used together with csEndTrigger for ending the operation -}; - -//! @} - -//! \addtogroup CMD_PROP_TX -//! @{ -#define CMD_PROP_TX 0x3801 -struct __RFC_STRUCT rfc_CMD_PROP_TX_s { - uint16_t commandNo; //!< The command ID number 0x3801 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - struct { - uint8_t bFsOff:1; //!< \brief 0: Keep frequency synth on after command
- //!< 1: Turn frequency synth off after command - uint8_t :2; - uint8_t bUseCrc:1; //!< \brief 0: Do not append CRC
- //!< 1: Append CRC - uint8_t bVarLen:1; //!< \brief 0: Fixed length
- //!< 1: Transmit length as first byte - } pktConf; - uint8_t pktLen; //!< Packet length - uint32_t syncWord; //!< Sync word to transmit - uint8_t* pPkt; //!< Pointer to packet -}; - -//! @} - -//! \addtogroup CMD_PROP_RX -//! @{ -#define CMD_PROP_RX 0x3802 -struct __RFC_STRUCT rfc_CMD_PROP_RX_s { - uint16_t commandNo; //!< The command ID number 0x3802 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - struct { - uint8_t bFsOff:1; //!< \brief 0: Keep frequency synth on after command
- //!< 1: Turn frequency synth off after command - uint8_t bRepeatOk:1; //!< \brief 0: End operation after receiving a packet correctly
- //!< 1: Go back to sync search after receiving a packet correctly - uint8_t bRepeatNok:1; //!< \brief 0: End operation after receiving a packet with CRC error
- //!< 1: Go back to sync search after receiving a packet with CRC error - uint8_t bUseCrc:1; //!< \brief 0: Do not check CRC
- //!< 1: Check CRC - uint8_t bVarLen:1; //!< \brief 0: Fixed length
- //!< 1: Receive length as first byte - uint8_t bChkAddress:1; //!< \brief 0: No address check
- //!< 1: Check address - uint8_t endType:1; //!< \brief 0: Packet is received to the end if end trigger happens after sync is obtained
- //!< 1: Packet reception is stopped if end trigger happens - uint8_t filterOp:1; //!< \brief 0: Stop receiver and restart sync search on address mismatch
- //!< 1: Receive packet and mark it as ignored on address mismatch - } pktConf; - struct { - uint8_t bAutoFlushIgnored:1; //!< If 1, automatically discard ignored packets from Rx queue - uint8_t bAutoFlushCrcErr:1; //!< If 1, automatically discard packets with CRC error from Rx queue - uint8_t :1; - uint8_t bIncludeHdr:1; //!< If 1, include the received header or length byte 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 bAppendTimestamp:1; //!< If 1, append a timestamp to the packet in the Rx queue - uint8_t bAppendStatus:1; //!< If 1, append a status byte to the packet in the Rx queue - } rxConf; //!< Rx configuration - uint32_t syncWord; //!< Sync word to listen for - uint8_t maxPktLen; //!< \brief Packet length for fixed length, maximum packet length for variable length
- //!< 0: Unlimited or unknown length - uint8_t address0; //!< Address - uint8_t address1; //!< \brief Address (set equal to address0 to accept only one address. If 0xFF, accept - //!< 0x00 as well) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } endTrigger; //!< Trigger classifier for ending the operation - ratmr_t endTime; //!< Time used together with endTrigger for ending the operation - dataQueue_t* pQueue; //!< Pointer to receive queue - uint8_t* pOutput; //!< Pointer to output structure -}; - -//! @} - -//! \addtogroup CMD_PROP_TX_ADV -//! @{ -#define CMD_PROP_TX_ADV 0x3803 -struct __RFC_STRUCT rfc_CMD_PROP_TX_ADV_s { - uint16_t commandNo; //!< The command ID number 0x3803 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - struct { - uint8_t bFsOff:1; //!< \brief 0: Keep frequency synth on after command
- //!< 1: Turn frequency synth off after command - uint8_t :2; - uint8_t bUseCrc:1; //!< \brief 0: Do not append CRC
- //!< 1: Append CRC - uint8_t bCrcIncSw:1; //!< \brief 0:Do not include sync word in CRC calculation
- //!< 1: Include sync word in CRC calculation - uint8_t bCrcIncHdr:1; //!< \brief 0: Do not include header in CRC calculation
- //!< 1: Include header in CRC calculation - } pktConf; - uint8_t numHdrBits; //!< Number of bits in header (0–32) - uint16_t pktLen; //!< Packet length. 0: Unlimited - struct { - uint8_t bExtTxTrig:1; //!< \brief 0: Start packet on a fixed time from the command start trigger
- //!< 1: Start packet on an external trigger (input event to RAT) - uint8_t inputMode:2; //!< \brief Input mode if external trigger is used for Tx start
- //!< 0: Rising edge
- //!< 1: Falling edge
- //!< 2: Both edges
- //!< 3: Reserved - uint8_t source:5; //!< RAT input event number used for capture if external trigger is used for Tx start - } startConf; - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } preTrigger; //!< Trigger for transition from preamble to sync word - ratmr_t preTime; //!< \brief Time used together with preTrigger for transition from preamble to sync - //!< word. If preTrigger.triggerType is set to "now", one preamble as - //!< configured in the setup will be sent. Otherwise, the preamble will be repeated until - //!< this trigger is observed. - uint32_t syncWord; //!< Sync word to transmit - uint8_t* pPkt; //!< Pointer to packet, or Tx queue for unlimited length -}; - -//! @} - -//! \addtogroup CMD_PROP_RX_ADV -//! @{ -#define CMD_PROP_RX_ADV 0x3804 -struct __RFC_STRUCT rfc_CMD_PROP_RX_ADV_s { - uint16_t commandNo; //!< The command ID number 0x3804 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - struct { - uint8_t bFsOff:1; //!< \brief 0: Keep frequency synth on after command
- //!< 1: Turn frequency synth off after command - uint8_t bRepeatOk:1; //!< \brief 0: End operation after receiving a packet correctly
- //!< 1: Go back to sync search after receiving a packet correctly - uint8_t bRepeatNok:1; //!< \brief 0: End operation after receiving a packet with CRC error
- //!< 1: Go back to sync search after receiving a packet with CRC error - uint8_t bUseCrc:1; //!< \brief 0: Do not check CRC
- //!< 1: Check CRC - uint8_t bCrcIncSw:1; //!< \brief 0: Do not include sync word in CRC calculation
- //!< 1: Include sync word in CRC calculation - uint8_t bCrcIncHdr:1; //!< \brief 0: Do not include header in CRC calculation
- //!< 1: Include header in CRC calculation - uint8_t endType:1; //!< \brief 0: Packet is received to the end if end trigger happens after sync is obtained
- //!< 1: Packet reception is stopped if end trigger happens - uint8_t filterOp:1; //!< \brief 0: Stop receiver and restart sync search on address mismatch
- //!< 1: Receive packet and mark it as ignored on address mismatch - } pktConf; - struct { - uint8_t bAutoFlushIgnored:1; //!< If 1, automatically discard ignored packets from Rx queue - uint8_t bAutoFlushCrcErr:1; //!< If 1, automatically discard packets with CRC error from Rx queue - uint8_t :1; - uint8_t bIncludeHdr:1; //!< If 1, include the received header or length byte 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 bAppendTimestamp:1; //!< If 1, append a timestamp to the packet in the Rx queue - uint8_t bAppendStatus:1; //!< If 1, append a status byte to the packet in the Rx queue - } rxConf; //!< Rx configuration - uint32_t syncWord0; //!< Sync word to listen for - uint32_t syncWord1; //!< Alternative sync word if non-zero - uint16_t maxPktLen; //!< \brief Packet length for fixed length, maximum packet length for variable length
- //!< 0: Unlimited or unknown length - struct { - uint16_t numHdrBits:6; //!< Number of bits in header (0–32) - uint16_t lenPos:5; //!< Position of length field in header (0–31) - uint16_t numLenBits:5; //!< Number of bits in length field (0–16) - } hdrConf; - struct { - uint16_t addrType:1; //!< \brief 0: Address after header
- //!< 1: Address in header - uint16_t addrSize:5; //!< \brief If addrType = 0: Address size in bytes
- //!< If addrType = 1: Address size in bits - uint16_t addrPos:5; //!< \brief If addrType = 1: Bit position of address in header
- //!< If addrType = 0: Non-zero to extend address with sync word identifier - uint16_t numAddr:5; //!< Number of addresses in address list - } addrConf; - int8_t lenOffset; //!< Signed value to add to length field - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 1: A trigger in the past is triggered as soon as possible - } endTrigger; //!< Trigger classifier for ending the operation - ratmr_t endTime; //!< Time used together with endTrigger for ending the operation - uint8_t* pAddr; //!< Pointer to address list - dataQueue_t* pQueue; //!< Pointer to receive queue - uint8_t* pOutput; //!< Pointer to output structure -}; - -//! @} - -//! \addtogroup CMD_PROP_RADIO_SETUP -//! @{ -#define CMD_PROP_RADIO_SETUP 0x3806 -struct __RFC_STRUCT rfc_CMD_PROP_RADIO_SETUP_s { - uint16_t commandNo; //!< The command ID number 0x3806 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - struct { - uint16_t modType:3; //!< \brief 0: FSK
- //!< 1: GFSK
- //!< Others: Reserved - uint16_t deviation:13; //!< Deviation (250 Hz steps) - } modulation; - struct { - uint32_t preScale:4; //!< Prescaler value - uint32_t :4; - uint32_t rateWord:21; //!< Rate word - } symbolRate; - uint8_t rxBw; //!< Receiver bandwidth - struct { - uint8_t nPreamBytes:6; //!< \brief 0–30: Number of preamble bytes
- //!< 31: 4 preamble bits - uint8_t preamMode:2; //!< \brief 0: Send 0 as the first preamble bit
- //!< 1: Send 1 as the first preamble bit
- //!< 2: Send same first bit in preamble and sync word
- //!< 3: Send different first bit in preamble and sync word - } preamConf; - struct { - uint16_t nSwBits:6; //!< Number of sync word bits (up to 32) - uint16_t bBitReversal:1; //!< \brief 0: Use positive deviation for 1
- //!< 1: Use positive deviation for 0 - uint16_t bMsbFirst:1; //!< \brief 0: Least significant bit transmitted first
- //!< 1: Most significant bit transmitted first - uint16_t fecMode:4; //!< \brief Select coding
- //!< 0: Uncoded binary modulation
- //!< 10: Manchester coded binary modulation
- //!< Others: Reserved - uint16_t :1; - uint16_t whitenMode:3; //!< \brief 0: No whitening
- //!< 1: CC1101/CC2500 compatible whitening
- //!< 2: PN9 whitening without byte reversal
- //!< 3: Reserved
- //!< 4: No whitener, 32-bit IEEE 802.15.4g compatible CRC
- //!< 5: IEEE 802.15.4g compatible whitener and 32-bit CRC
- //!< 6: No whitener, dynamically IEEE 802.15.4g compatible 16-bit or 32-bit CRC
- //!< 7: Dynamically IEEE 802.15.4g compatible whitener and 16-bit or 32-bit CRC - } formatConf; - struct { - uint16_t frontEndMode:3; //!< \brief 0x00: Differential mode
- //!< 0x01: Single-ended mode RFP
- //!< 0x02: Single-ended mode RFN
- //!< 0x05 Single-ended mode RFP with external frontend control on RF pins (RFN and RXTX)
- //!< 0x06 Single-ended mode RFN with external frontend control on RF pins (RFP and RXTX)
- //!< Others: Reserved - uint16_t biasMode:1; //!< \brief 0: Internal bias
- //!< 1: External bias - uint16_t :6; - uint16_t bNoFsPowerUp:1; //!< \brief 0: Power up frequency synth
- //!< 1: Do not power up frequency synth - } config; //!< Configuration options - uint16_t txPower; //!< Transmit power - uint32_t* pRegOverride; //!< \brief Pointer to a list of hardware and configuration registers to override. If NULL, no - //!< override is used. -}; - -//! @} - -//! \addtogroup CMD_PROP_RADIO_DIV_SETUP -//! @{ -#define CMD_PROP_RADIO_DIV_SETUP 0x3807 -struct __RFC_STRUCT rfc_CMD_PROP_RADIO_DIV_SETUP_s { - uint16_t commandNo; //!< The command ID number 0x3807 - 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 startTrigger) - struct { - uint8_t triggerType:4; //!< The type of trigger - uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command
- //!< 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
- //!< 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 if the rule involves skipping - } condition; - struct { - uint16_t modType:3; //!< \brief 0: FSK
- //!< 1: GFSK
- //!< Others: Reserved - uint16_t deviation:13; //!< Deviation (250 Hz steps) - } modulation; - struct { - uint32_t preScale:4; //!< Prescaler value - uint32_t :4; - uint32_t rateWord:21; //!< Rate word - } symbolRate; - uint8_t rxBw; //!< Receiver bandwidth - struct { - uint8_t nPreamBytes:6; //!< \brief 0–30: Number of preamble bytes
- //!< 31: 4 preamble bits - uint8_t preamMode:2; //!< \brief 0: Send 0 as the first preamble bit
- //!< 1: Send 1 as the first preamble bit
- //!< 2: Send same first bit in preamble and sync word
- //!< 3: Send different first bit in preamble and sync word - } preamConf; - struct { - uint16_t nSwBits:6; //!< Number of sync word bits (up to 32) - uint16_t bBitReversal:1; //!< \brief 0: Use positive deviation for 1
- //!< 1: Use positive deviation for 0 - uint16_t bMsbFirst:1; //!< \brief 0: Least significant bit transmitted first
- //!< 1: Most significant bit transmitted first - uint16_t fecMode:4; //!< \brief Select coding
- //!< 0: Uncoded binary modulation
- //!< 10: Manchester coded binary modulation
- //!< Others: Reserved - uint16_t :1; - uint16_t whitenMode:3; //!< \brief 0: No whitening
- //!< 1: CC1101/CC2500 compatible whitening
- //!< 2: PN9 whitening without byte reversal
- //!< 3: Reserved
- //!< 4: No whitener, 32-bit IEEE 802.15.4g compatible CRC
- //!< 5: IEEE 802.15.4g compatible whitener and 32-bit CRC
- //!< 6: No whitener, dynamically IEEE 802.15.4g compatible 16-bit or 32-bit CRC
- //!< 7: Dynamically IEEE 802.15.4g compatible whitener and 16-bit or 32-bit CRC - } formatConf; - struct { - uint16_t frontEndMode:3; //!< \brief 0x00: Differential mode
- //!< 0x01: Single-ended mode RFP
- //!< 0x02: Single-ended mode RFN
- //!< 0x05 Single-ended mode RFP with external frontend control on RF pins (RFN and RXTX)
- //!< 0x06 Single-ended mode RFN with external frontend control on RF pins (RFP and RXTX)
- //!< Others: Reserved - uint16_t biasMode:1; //!< \brief 0: Internal bias
- //!< 1: External bias - uint16_t :6; - uint16_t bNoFsPowerUp:1; //!< \brief 0: Power up frequency synth
- //!< 1: Do not power up frequency synth - } config; //!< Configuration options - uint16_t txPower; //!< Transmit power - uint32_t* pRegOverride; //!< \brief Pointer to a list of hardware and configuration registers to override. If NULL, no - //!< override is used. - uint16_t centerFreq; //!< \brief Center frequency of the frequency band used, in MHz; used for calculating some internal Tx and Rx parameters. - //!< For a single channel RF system, this should be set equal to the RF frequency used. - //!< For a multi channel RF system (e.g. frequency hopping spread spectrum), this should be set equal - //!< to the center frequency of the frequency band used. - int16_t intFreq; //!< \brief Intermediate frequency to use for Rx, in MHz on 4.12 signed format. Tx will use same - //!< intermediate frequency if supported, otherwise 0.
- //!< 0x8000: Use default. - uint8_t loDivider; //!< LO frequency divider setting to use. Supported values: 2, 5, 6, 10, 12, 15, and 30 -}; - -//! @} - -//! \addtogroup CMD_PROP_SET_LEN -//! @{ -#define CMD_PROP_SET_LEN 0x3401 -struct __RFC_STRUCT rfc_CMD_PROP_SET_LEN_s { - uint16_t commandNo; //!< The command ID number 0x3401 - uint16_t rxLen; //!< Payload length to use -}; - -//! @} - -//! \addtogroup CMD_PROP_RESTART_RX -//! @{ -#define CMD_PROP_RESTART_RX 0x3402 -struct __RFC_STRUCT rfc_CMD_PROP_RESTART_RX_s { - uint16_t commandNo; //!< The command ID number 0x3402 -}; - -//! @} - -//! \addtogroup propRxOutput -//! @{ -//! Output structure for Rx operations - -struct __RFC_STRUCT rfc_propRxOutput_s { - uint16_t nRxOk; //!< Number of packets that have been received with payload, CRC OK and not ignored - uint16_t nRxNok; //!< Number of packets that have been received with CRC error - uint8_t nRxIgnored; //!< Number of packets that have been received with CRC OK and ignored due to address mismatch - uint8_t nRxStopped; //!< Number of packets not received due to illegal length or address mismatch with pktConf.filterOp = 1 - uint8_t nRxBufFull; //!< Number of packets that have been received and discarded due to lack of buffer space - int8_t lastRssi; //!< RSSI of last received packet - ratmr_t timeStamp; //!< Time stamp of last received packet -}; - -//! @} - -//! \addtogroup propRxStatus -//! @{ -//! Receive status byte that may be appended to message in receive buffer - -struct __RFC_STRUCT rfc_propRxStatus_s { - struct { - uint8_t addressInd:5; //!< Index of address found (0 if not applicable) - uint8_t syncWordId:1; //!< 0 for primary sync word, 1 for alternate sync word - uint8_t result:2; //!< \brief 0: Packet received correctly, not ignored
- //!< 1: Packet received with CRC error
- //!< 2: Packet received correctly, but can be ignored
- //!< 3: Packet reception was aborted - } status; -}; - -//! @} - -//! @} -//! @} -#endif /* PROP_CMD_H_ */ diff --git a/cpu/cc26xx-cc13xx/rf-core/api/prop_mailbox.h b/cpu/cc26xx-cc13xx/rf-core/api/prop_mailbox.h deleted file mode 100644 index ff7b6c25b..000000000 --- a/cpu/cc26xx-cc13xx/rf-core/api/prop_mailbox.h +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************************************************** -* Filename: prop_mailbox.h -* Revised: 2015-06-29 12:59:58 +0200 (Mon, 29 Jun 2015) -* Revision: 44063 -* -* Description: Definitions for proprietary mode radio interface -* -* 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 PROP_MAILBOX_H_ -#define PROP_MAILBOX_H_ - -/// \name Radio operation status -///@{ -/// \name Operation finished normally -///@{ -#define PROP_DONE_OK 0x3400 ///< Operation ended normally -#define PROP_DONE_RXTIMEOUT 0x3401 ///< Operation stopped after end trigger while waiting for sync -#define PROP_DONE_BREAK 0x3402 ///< Rx stopped due to time out in the middle of a packet -#define PROP_DONE_ENDED 0x3403 ///< Operation stopped after end trigger during reception -#define PROP_DONE_STOPPED 0x3404 ///< Operation stopped after stop command -#define PROP_DONE_ABORT 0x3405 ///< Operation aborted by abort command -#define PROP_DONE_RXERR 0x3406 ///< Operation ended after receiving packet with CRC error -#define PROP_DONE_IDLE 0x3407 ///< Carrier sense operation ended because of idle channel -#define PROP_DONE_BUSY 0x3408 ///< Carrier sense operation ended because of busy channel -#define PROP_DONE_IDLETIMEOUT 0x3409 ///< Carrier sense operation ended because of time out with csConf.timeoutRes = 1 -#define PROP_DONE_BUSYTIMEOUT 0x340A ///< Carrier sense operation ended because of time out with csConf.timeoutRes = 0 - -///@} -/// \name Operation finished with error -///@{ -#define PROP_ERROR_PAR 0x3800 ///< Illegal parameter -#define PROP_ERROR_RXBUF 0x3801 ///< No available Rx buffer at the start of a packet -#define PROP_ERROR_RXFULL 0x3802 ///< Out of Rx buffer during reception in a partial read buffer -#define PROP_ERROR_NO_SETUP 0x3803 ///< Radio was not set up in proprietary mode -#define PROP_ERROR_NO_FS 0x3804 ///< Synth was not programmed when running Rx or Tx -#define PROP_ERROR_RXOVF 0x3805 ///< Rx overflow observed during operation -#define PROP_ERROR_TXUNF 0x3806 ///< Tx underflow observed during operation -///@} -///@} - -#endif /* PROP_MAILBOX_H_ */ From 4d0051ad4d41c7e3f6ee1b05b891023c43acc8e8 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 13 Nov 2016 14:13:56 +0000 Subject: [PATCH 005/129] Switch to xxware-provided RF API headers --- cpu/cc26xx-cc13xx/rf-core/api/ieee_cmd.h | 4 ++-- cpu/cc26xx-cc13xx/rf-core/api/ieee_mailbox.h | 2 +- cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 6 +++--- cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 10 +++++----- cpu/cc26xx-cc13xx/rf-core/rf-ble.c | 4 ++-- cpu/cc26xx-cc13xx/rf-core/rf-core.c | 12 +++--------- cpu/cc26xx-cc13xx/rf-core/rf-core.h | 2 +- cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c | 6 +++--- cpu/cc26xx-cc13xx/rf-core/smartrf-settings.h | 6 +++--- 9 files changed, 23 insertions(+), 29 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/api/ieee_cmd.h b/cpu/cc26xx-cc13xx/rf-core/api/ieee_cmd.h index 62f9abd32..6cbaf24a2 100644 --- a/cpu/cc26xx-cc13xx/rf-core/api/ieee_cmd.h +++ b/cpu/cc26xx-cc13xx/rf-core/api/ieee_cmd.h @@ -55,8 +55,8 @@ //! @{ #include -#include "mailbox.h" -#include "common_cmd.h" +#include "driverlib/rf_mailbox.h" +#include "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; diff --git a/cpu/cc26xx-cc13xx/rf-core/api/ieee_mailbox.h b/cpu/cc26xx-cc13xx/rf-core/api/ieee_mailbox.h index c6784da09..f96c540ad 100644 --- a/cpu/cc26xx-cc13xx/rf-core/api/ieee_mailbox.h +++ b/cpu/cc26xx-cc13xx/rf-core/api/ieee_mailbox.h @@ -40,7 +40,7 @@ #ifndef IEEE_MAILBOX_H_ #define IEEE_MAILBOX_H_ -#include "mailbox.h" +#include "driverlib/rf_mailbox.h" /// \name Radio operation status diff --git a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index f76fe2beb..cf2dbce5e 100644 --- a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -63,11 +63,11 @@ #include "hw_rfc_pwr.h" /*---------------------------------------------------------------------------*/ /* RF Core Mailbox API */ -#include "rf-core/api/mailbox.h" -#include "rf-core/api/common_cmd.h" #include "rf-core/api/ieee_cmd.h" -#include "rf-core/api/data_entry.h" #include "rf-core/api/ieee_mailbox.h" +#include "driverlib/rf_mailbox.h" +#include "driverlib/rf_common_cmd.h" +#include "driverlib/rf_data_entry.h" /*---------------------------------------------------------------------------*/ #include "smartrf-settings.h" /*---------------------------------------------------------------------------*/ diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index 21e54c181..5700e7588 100644 --- a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -64,11 +64,11 @@ #include "hw_rfc_pwr.h" /*---------------------------------------------------------------------------*/ /* RF Core Mailbox API */ -#include "rf-core/api/mailbox.h" -#include "rf-core/api/common_cmd.h" -#include "rf-core/api/data_entry.h" -#include "rf-core/api/prop_mailbox.h" -#include "rf-core/api/prop_cmd.h" +#include "driverlib/rf_mailbox.h" +#include "driverlib/rf_common_cmd.h" +#include "driverlib/rf_data_entry.h" +#include "driverlib/rf_prop_mailbox.h" +#include "driverlib/rf_prop_cmd.h" /*---------------------------------------------------------------------------*/ /* CC13xxware patches */ #include "rf_patches/rf_patch_cpe_genfsk.h" diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-ble.c b/cpu/cc26xx-cc13xx/rf-core/rf-ble.c index 48daba69f..40a3ac9b4 100644 --- a/cpu/cc26xx-cc13xx/rf-core/rf-ble.c +++ b/cpu/cc26xx-cc13xx/rf-core/rf-ble.c @@ -46,8 +46,8 @@ #include "dev/oscillators.h" #include "rf-core/rf-core.h" #include "rf-core/rf-ble.h" -#include "rf-core/api/ble_cmd.h" -#include "rf-core/api/common_cmd.h" +#include "driverlib/rf_ble_cmd.h" +#include "driverlib/rf_common_cmd.h" #include "ti-lib.h" /*---------------------------------------------------------------------------*/ #include diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-core.c b/cpu/cc26xx-cc13xx/rf-core/rf-core.c index 4a974a8ea..9ce34c212 100644 --- a/cpu/cc26xx-cc13xx/rf-core/rf-core.c +++ b/cpu/cc26xx-cc13xx/rf-core/rf-core.c @@ -52,15 +52,9 @@ #include "hw_rfc_pwr.h" /*---------------------------------------------------------------------------*/ /* RF Core Mailbox API */ -#include "rf-core/api/mailbox.h" -#include "rf-core/api/common_cmd.h" -#include "rf-core/api/ble_cmd.h" -#include "rf-core/api/ieee_cmd.h" -#include "rf-core/api/data_entry.h" -#include "rf-core/api/ble_mailbox.h" -#include "rf-core/api/ieee_mailbox.h" -#include "rf-core/api/prop_mailbox.h" -#include "rf-core/api/prop_cmd.h" +#include "driverlib/rf_mailbox.h" +#include "driverlib/rf_common_cmd.h" +#include "driverlib/rf_data_entry.h" /*---------------------------------------------------------------------------*/ #include #include diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-core.h b/cpu/cc26xx-cc13xx/rf-core/rf-core.h index 474de4a87..7a75bde50 100644 --- a/cpu/cc26xx-cc13xx/rf-core/rf-core.h +++ b/cpu/cc26xx-cc13xx/rf-core/rf-core.h @@ -52,7 +52,7 @@ #define RF_CORE_H_ /*---------------------------------------------------------------------------*/ #include "contiki-conf.h" -#include "rf-core/api/common_cmd.h" +#include "driverlib/rf_common_cmd.h" #include #include diff --git a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c index 8eedf23cb..e89cb2342 100644 --- a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c +++ b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c @@ -28,9 +28,9 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ /*---------------------------------------------------------------------------*/ -#include "rf-core/api/mailbox.h" -#include "rf-core/api/common_cmd.h" -#include "rf-core/api/prop_cmd.h" +#include "driverlib/rf_mailbox.h" +#include "driverlib/rf_common_cmd.h" +#include "driverlib/rf_prop_cmd.h" /*---------------------------------------------------------------------------*/ /* Overrides for CMD_PROP_RADIO_DIV_SETUP */ uint32_t overrides[] = diff --git a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.h b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.h index bd36ed6d0..483f47a7c 100644 --- a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.h +++ b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.h @@ -31,9 +31,9 @@ #ifndef SMARTRF_SETTINGS_H_ #define SMARTRF_SETTINGS_H_ /*---------------------------------------------------------------------------*/ -#include "rf-core/api/mailbox.h" -#include "rf-core/api/common_cmd.h" -#include "rf-core/api/prop_cmd.h" +#include "driverlib/rf_mailbox.h" +#include "driverlib/rf_common_cmd.h" +#include "driverlib/rf_prop_cmd.h" /*---------------------------------------------------------------------------*/ extern rfc_CMD_PROP_RADIO_DIV_SETUP_t smartrf_settings_cmd_prop_radio_div_setup; extern rfc_CMD_FS_t smartrf_settings_cmd_fs; From a3c80cedb98fb5961bda7fd07c64631a93125bc6 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 13 Nov 2016 14:14:24 +0000 Subject: [PATCH 006/129] Adjust TX power settings to use current API fields --- cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 38 +++++++++++---------------- cpu/cc26xx-cc13xx/rf-core/rf-ble.c | 14 ++-------- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index cf2dbce5e..3f4e6e67d 100644 --- a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -166,25 +166,23 @@ static uint8_t rf_stats[16] = { 0 }; /* TX Power dBm lookup table - values from SmartRF Studio */ typedef struct output_config { radio_value_t dbm; - uint8_t register_ib; - uint8_t register_gc; - uint8_t temp_coeff; + uint16_t tx_power; /* Value for the CMD_RADIO_SETUP.txPower field */ } output_config_t; static const output_config_t output_power[] = { - { 5, 0x30, 0x00, 0x93 }, - { 4, 0x24, 0x00, 0x93 }, - { 3, 0x1c, 0x00, 0x5a }, - { 2, 0x18, 0x00, 0x4e }, - { 1, 0x14, 0x00, 0x42 }, - { 0, 0x21, 0x01, 0x31 }, - { -3, 0x18, 0x01, 0x25 }, - { -6, 0x11, 0x01, 0x1d }, - { -9, 0x0e, 0x01, 0x19 }, - {-12, 0x0b, 0x01, 0x14 }, - {-15, 0x0b, 0x03, 0x0c }, - {-18, 0x09, 0x03, 0x0c }, - {-21, 0x07, 0x03, 0x0c }, + { 5, 0x9330 }, + { 4, 0x9324 }, + { 3, 0x5a1c }, + { 2, 0x4e18 }, + { 1, 0x4214 }, + { 0, 0x3161 }, + { -3, 0x2558 }, + { -6, 0x1d52 }, + { -9, 0x194e }, + {-12, 0x144b }, + {-15, 0x0ccb }, + {-18, 0x0cc9 }, + {-21, 0x0cc7 }, }; #define OUTPUT_CONFIG_COUNT (sizeof(output_power) / sizeof(output_config_t)) @@ -455,9 +453,7 @@ set_tx_power(radio_value_t power) memset(&cmd, 0x00, sizeof(cmd)); cmd.commandNo = CMD_SET_TX_POWER; - cmd.txPower.IB = output_power[i].register_ib; - cmd.txPower.GC = output_power[i].register_gc; - cmd.txPower.tempCoeff = output_power[i].temp_coeff; + cmd.txPower = output_power[i].tx_power; if(rf_core_send_cmd((uint32_t)&cmd, &cmd_status) == RF_CORE_CMD_ERROR) { PRINTF("set_tx_power: CMDSTA=0x%08lx\n", cmd_status); @@ -473,9 +469,7 @@ rf_radio_setup() /* Create radio setup command */ rf_core_init_radio_op((rfc_radioOp_t *)&cmd, sizeof(cmd), CMD_RADIO_SETUP); - cmd.txPower.IB = tx_power_current->register_ib; - cmd.txPower.GC = tx_power_current->register_gc; - cmd.txPower.tempCoeff = tx_power_current->temp_coeff; + cmd.txPower = tx_power_current->tx_power; cmd.pRegOverride = ieee_overrides; cmd.mode = 1; diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-ble.c b/cpu/cc26xx-cc13xx/rf-core/rf-ble.c index 40a3ac9b4..3cfea03bd 100644 --- a/cpu/cc26xx-cc13xx/rf-core/rf-ble.c +++ b/cpu/cc26xx-cc13xx/rf-core/rf-ble.c @@ -81,14 +81,7 @@ static uint8_t payload[BLE_ADV_PAYLOAD_BUF_LEN]; static int p = 0; static int i; /*---------------------------------------------------------------------------*/ -typedef struct default_ble_tx_power_s { - uint16_t ib:6; - uint16_t gc:2; - uint16_t boost:1; - uint16_t temp_coeff:7; -} default_ble_tx_power_t; - -static default_ble_tx_power_t tx_power = { 0x29, 0x00, 0x00, 0x00 }; +static uint16_t tx_power = 0x9330; /*---------------------------------------------------------------------------*/ /* BLE beacond config */ static struct ble_beacond_config { @@ -220,10 +213,7 @@ rf_radio_setup() /* Create radio setup command */ rf_core_init_radio_op((rfc_radioOp_t *)&cmd, sizeof(cmd), CMD_RADIO_SETUP); - cmd.txPower.IB = tx_power.ib; - cmd.txPower.GC = tx_power.gc; - cmd.txPower.tempCoeff = tx_power.temp_coeff; - cmd.txPower.boost = tx_power.boost; + cmd.txPower = tx_power; cmd.pRegOverride = ble_overrides; cmd.mode = 0; From f9e6a78882cda5fa493c1f354c047cc7754ddb76 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 13 Nov 2016 14:53:36 +0000 Subject: [PATCH 007/129] Update CMD_FS' fields to the current API --- cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c index e89cb2342..24cef30e0 100644 --- a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c +++ b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c @@ -118,9 +118,9 @@ rfc_CMD_FS_t smartrf_settings_cmd_fs = .synthConf.bTxMode = 0x0, .synthConf.refFreq = 0x0, .__dummy0 = 0x00, - .midPrecal = 0x00, - .ktPrecal = 0x00, - .tdcPrecal = 0x0000, + .__dummy1 = 0x00, + .__dummy2 = 0x00, + .__dummy3 = 0x0000, }; /*---------------------------------------------------------------------------*/ /* CMD_PROP_TX_ADV */ From 3a070bd33202e921d0d863513ab37a73a7648c69 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 13 Nov 2016 17:39:08 +0000 Subject: [PATCH 008/129] Fix typo in TX power settings for prop mode (12.5 dBm) --- cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index 5700e7588..ee0696117 100644 --- a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -186,7 +186,7 @@ typedef struct output_config { static const output_config_t output_power[] = { { 14, 0xa73f }, - { 13, 0xa73f }, /* 12.5 */ + { 13, 0xa63f }, /* 12.5 */ { 12, 0xb818 }, { 11, 0x50da }, { 10, 0x38d3 }, From 2934c6bbe7b9aac8e207efd80222c9b554ab4629 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 3 Dec 2016 15:20:01 +0000 Subject: [PATCH 009/129] Define RFC-related ccxxware macros --- cpu/cc26xx-cc13xx/ti-lib.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpu/cc26xx-cc13xx/ti-lib.h b/cpu/cc26xx-cc13xx/ti-lib.h index c8b38c2c6..3ab5ceb28 100644 --- a/cpu/cc26xx-cc13xx/ti-lib.h +++ b/cpu/cc26xx-cc13xx/ti-lib.h @@ -391,6 +391,12 @@ #define ti_lib_pwr_ctrl_io_freeze_enable(...) PowerCtrlIOFreezeEnable(__VA_ARGS__) #define ti_lib_pwr_ctrl_io_freeze_disable(...) PowerCtrlIOFreezeDisable(__VA_ARGS__) /*---------------------------------------------------------------------------*/ +/* rfc.h */ +#include "driverlib/rfc.h" + +#define ti_lib_rfc_rtrim(...) RFCRTrim(__VA_ARGS__) +#define ti_lib_rfc_adi3vco_ldo_voltage_mode(...) RFCAdi3VcoLdoVoltageMode(__VA_ARGS__) +/*---------------------------------------------------------------------------*/ /* sys_ctrl.h */ #include "driverlib/sys_ctrl.h" From f07ed3fc01180382bf5b4bcdf9c66bce8d4ad381 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 3 Dec 2016 15:20:24 +0000 Subject: [PATCH 010/129] Allow CC13xxware to automatically configure RTRIM for us --- cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index ee0696117..6c1dd6e5e 100644 --- a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -599,6 +599,9 @@ init(void) /* Initialize current read pointer to first element (used in ISR) */ rx_read_entry = rx_buf_0; + /* Let CC13xxware automatically set a correct value for RTRIM for us */ + ti_lib_rfcrtrim((rfc_radioOp_t *)&smartrf_settings_cmd_prop_radio_div_setup); + smartrf_settings_cmd_prop_rx_adv.pQueue = &rx_data_queue; smartrf_settings_cmd_prop_rx_adv.pOutput = (uint8_t *)&rx_stats; From db54175d8de88363a045944a16bbf52163f3b62e Mon Sep 17 00:00:00 2001 From: Jonas Olsson Date: Thu, 1 Dec 2016 23:36:21 +0100 Subject: [PATCH 011/129] Add missing structure from radio setup command. --- cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c index 24cef30e0..fb99fc5cd 100644 --- a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c +++ b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c @@ -92,6 +92,7 @@ rfc_CMD_PROP_RADIO_DIV_SETUP_t smartrf_settings_cmd_prop_radio_div_setup = .formatConf.whitenMode = 0x7, .config.frontEndMode = 0x0, /* Differential mode */ .config.biasMode = 0x1, /* External bias*/ + .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, .txPower = 0x00, /* Driver sets correct value */ .pRegOverride = overrides, From e73ac7d26f97f863bb263055e649581e322087f3 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 6 Nov 2016 21:14:09 +0000 Subject: [PATCH 012/129] Update to latest overrides and patches --- cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 2 + cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c | 77 ++++++++++++++++---- 2 files changed, 64 insertions(+), 15 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index 6c1dd6e5e..b75d534d1 100644 --- a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -72,6 +72,7 @@ /*---------------------------------------------------------------------------*/ /* CC13xxware patches */ #include "rf_patches/rf_patch_cpe_genfsk.h" +#include "rf_patches/rf_patch_rfe_genfsk.h" /*---------------------------------------------------------------------------*/ #include "rf-core/smartrf-settings.h" /*---------------------------------------------------------------------------*/ @@ -895,6 +896,7 @@ on(void) } rf_patch_cpe_genfsk(); + rf_patch_rfe_genfsk(); if(rf_core_start_rat() != RF_CORE_CMD_OK) { PRINTF("on: rf_core_start_rat() failed\n"); diff --git a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c index fb99fc5cd..3d411463e 100644 --- a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c +++ b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c @@ -33,28 +33,75 @@ #include "driverlib/rf_prop_cmd.h" /*---------------------------------------------------------------------------*/ /* Overrides for CMD_PROP_RADIO_DIV_SETUP */ -uint32_t overrides[] = +static uint32_t overrides[] = { - /* override_synth.xml */ - HW32_ARRAY_OVERRIDE(0x6088, 1), - (uint32_t)0x0000001A, - ADI_HALFREG_OVERRIDE(0, 61, 0xF, 0xD), - HW32_ARRAY_OVERRIDE(0x4038, 1), - (uint32_t)0x0000003A, + /* + * override_use_patch_prop_genfsk.xml + * PHY: Use MCE ROM bank 4, RFE RAM patch + */ + MCE_RFE_OVERRIDE(0, 4, 0, 1, 0, 0), + /* + * override_synth_prop_863_930_div5.xml + * Synth: Set recommended RTRIM to 7 + */ + HW_REG_OVERRIDE(0x4038, 0x0037), + /* Synth: Set Fref to 4 MHz */ + (uint32_t)0x000684A3, + /* Synth: Configure fine calibration setting */ HW_REG_OVERRIDE(0x4020, 0x7F00), + /* Synth: Configure fine calibration setting */ HW_REG_OVERRIDE(0x4064, 0x0040), - (uint32_t)0x684A3, - (uint32_t)0xC0040141, - (uint32_t)0x0533B107, - (uint32_t)0xA480583, + /* Synth: Configure fine calibration setting */ + (uint32_t)0xB1070503, + /* Synth: Configure fine calibration setting */ + (uint32_t)0x05330523, + /* Synth: Set loop bandwidth after lock to 20 kHz */ + (uint32_t)0x0A480583, + /* Synth: Set loop bandwidth after lock to 20 kHz */ (uint32_t)0x7AB80603, - ADI_REG_OVERRIDE(1, 4, 0x1F), + /* + * Synth: Configure VCO LDO + * (in ADI1, set VCOLDOCFG=0x9F to use voltage input reference) + */ + ADI_REG_OVERRIDE(1, 4, 0x9F), + /* Synth: Configure synth LDO (in ADI1, set SLDOCTL0.COMP_CAP=1) */ ADI_HALFREG_OVERRIDE(1, 7, 0x4, 0x4), - HW_REG_OVERRIDE(0x6084, 0x35F1), + /* Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering */ + (uint32_t)0x02010403, + /* Synth: Configure extra PLL filtering */ + (uint32_t)0x00108463, + /* Synth: Increase synth programming timeout (0x04B0 RAT ticks = 300 us) */ + (uint32_t)0x04B00243, + /* + * override_phy_rx_aaf_bw_0xd.xml + * Rx: Set anti-aliasing filter bandwidth to 0xD + * (in ADI0, set IFAMPCTL3[7:4]=0xD) + */ + ADI_HALFREG_OVERRIDE(0, 61, 0xF, 0xD), + /* + * override_phy_gfsk_rx.xml + * Rx: Set LNA bias current trim offset to 3 + */ (uint32_t)0x00038883, + /* Rx: Freeze RSSI on sync found event */ + HW_REG_OVERRIDE(0x6084, 0x35F1), + /* + * override_phy_gfsk_pa_ramp_agc_reflevel_0x1a.xml + * Tx: Enable PA ramping (0x41). Rx: Set AGC reference level to 0x1A. + */ + HW_REG_OVERRIDE(0x6088, 0x411A), + /* Tx: Configure PA ramping setting */ + HW_REG_OVERRIDE(0x608C, 0x8213), + /* + * override_phy_rx_rssi_offset_5db.xml + * Rx: Set RSSI offset to adjust reported RSSI by +5 dB + */ (uint32_t)0x00FB88A3, - /* TX power override */ - ADI_REG_OVERRIDE(0, 12, 0xF9), + /* + * TX power override + * Tx: Set PA trim to max (in ADI0, set PACTL0=0xF8) + */ + ADI_REG_OVERRIDE(0, 12, 0xF8), /* Overrides for CRC16 functionality */ (uint32_t)0x943, From 43b9679bcc22f50f67ec086bebef4b4a925e3e28 Mon Sep 17 00:00:00 2001 From: Jonas Olsson Date: Thu, 1 Dec 2016 23:32:45 +0100 Subject: [PATCH 013/129] Move setting of RF mode to correct place, needs to be called on every boot. --- cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index b75d534d1..b5d870a95 100644 --- a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -573,8 +573,6 @@ init(void) return RF_CORE_CMD_ERROR; } - rf_core_set_modesel(); - /* Initialise RX buffers */ memset(rx_buf_0, 0, RX_BUF_SIZE); memset(rx_buf_1, 0, RX_BUF_SIZE); @@ -600,9 +598,6 @@ init(void) /* Initialize current read pointer to first element (used in ISR) */ rx_read_entry = rx_buf_0; - /* Let CC13xxware automatically set a correct value for RTRIM for us */ - ti_lib_rfcrtrim((rfc_radioOp_t *)&smartrf_settings_cmd_prop_radio_div_setup); - smartrf_settings_cmd_prop_rx_adv.pQueue = &rx_data_queue; smartrf_settings_cmd_prop_rx_adv.pOutput = (uint8_t *)&rx_stats; @@ -895,9 +890,30 @@ on(void) return RF_CORE_CMD_ERROR; } + /* Keep track of RF Core mode */ + rf_core_set_modesel(); + + /* Apply patches to radio core */ rf_patch_cpe_genfsk(); + while(!HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG)); + HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG) = 0; rf_patch_rfe_genfsk(); + /* Initialize bus request */ + HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG) = 0; + HWREG(RFC_DBELL_BASE + RFC_DBELL_O_CMDR) = + CMDR_DIR_CMD_1BYTE(CMD_BUS_REQUEST, 1); + + /* set VCOLDO reference */ + ti_lib_rfc_adi3vco_ldo_voltage_mode(true); + + /* Let CC13xxware automatically set a correct value for RTRIM for us */ + ti_lib_rfc_rtrim((rfc_radioOp_t *)&smartrf_settings_cmd_prop_radio_div_setup); + + /* Make sure BUS_REQUEST is done */ + while(!HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG)); + HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG) = 0; + if(rf_core_start_rat() != RF_CORE_CMD_OK) { PRINTF("on: rf_core_start_rat() failed\n"); From a56b5202156b03763f990e7eede5e0ea8aab1f43 Mon Sep 17 00:00:00 2001 From: Jonas Olsson Date: Thu, 1 Dec 2016 23:35:22 +0100 Subject: [PATCH 014/129] Make sure correct clocks is running in the RF Core (RFE). --- cpu/cc26xx-cc13xx/rf-core/rf-core.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-core.c b/cpu/cc26xx-cc13xx/rf-core/rf-core.c index 9ce34c212..81070bdc6 100644 --- a/cpu/cc26xx-cc13xx/rf-core/rf-core.c +++ b/cpu/cc26xx-cc13xx/rf-core/rf-core.c @@ -106,7 +106,12 @@ static bool rat_offset_known = false; PROCESS(rf_core_process, "CC13xx / CC26xx RF driver"); /*---------------------------------------------------------------------------*/ #define RF_CORE_CLOCKS_MASK (RFC_PWR_PWMCLKEN_RFC_M | RFC_PWR_PWMCLKEN_CPE_M \ - | RFC_PWR_PWMCLKEN_CPERAM_M) + | RFC_PWR_PWMCLKEN_CPERAM_M | RFC_PWR_PWMCLKEN_FSCA_M \ + | RFC_PWR_PWMCLKEN_PHA_M | RFC_PWR_PWMCLKEN_RAT_M \ + | RFC_PWR_PWMCLKEN_RFERAM_M | RFC_PWR_PWMCLKEN_RFE_M \ + | RFC_PWR_PWMCLKEN_MDMRAM_M | RFC_PWR_PWMCLKEN_MDM_M) +/*---------------------------------------------------------------------------*/ +#define RF_CMD0 0x0607 /*---------------------------------------------------------------------------*/ uint8_t rf_core_is_accessible() @@ -258,6 +263,12 @@ rf_core_power_up() /* Let CPE boot */ HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = RF_CORE_CLOCKS_MASK; + /* Turn on additional clocks on boot */ + HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG) = 0; + HWREG(RFC_DBELL_BASE+RFC_DBELL_O_CMDR) = + CMDR_DIR_CMD_2BYTE(RF_CMD0, + RFC_PWR_PWMCLKEN_MDMRAM | RFC_PWR_PWMCLKEN_RFERAM); + /* Send ping (to verify RFCore is ready and alive) */ if(rf_core_send_cmd(CMDR_DIR_CMD(CMD_PING), &cmd_status) != RF_CORE_CMD_OK) { PRINTF("rf_core_power_up: CMD_PING fail, CMDSTA=0x%08lx\n", cmd_status); From d6e8e7dab47993a3ef23affaaedc9f8ed37b35ed Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 3 Dec 2016 23:19:01 +0000 Subject: [PATCH 015/129] Adjust ContikiMAC timings to compensate for new patches/overrides --- platform/srf06-cc26xx/contiki-conf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/srf06-cc26xx/contiki-conf.h b/platform/srf06-cc26xx/contiki-conf.h index 85c99ee19..90fabfa86 100644 --- a/platform/srf06-cc26xx/contiki-conf.h +++ b/platform/srf06-cc26xx/contiki-conf.h @@ -120,8 +120,8 @@ #define CONTIKIMAC_CONF_CCA_SLEEP_TIME (RTIMER_ARCH_SECOND / 210) #define CONTIKIMAC_CONF_LISTEN_TIME_AFTER_PACKET_DETECTED (RTIMER_ARCH_SECOND / 20) #define CONTIKIMAC_CONF_SEND_SW_ACK 1 -#define CONTIKIMAC_CONF_AFTER_ACK_DETECTED_WAIT_TIME (RTIMER_SECOND / 1000) -#define CONTIKIMAC_CONF_INTER_PACKET_INTERVAL (RTIMER_SECOND / 240) +#define CONTIKIMAC_CONF_AFTER_ACK_DETECTED_WAIT_TIME (RTIMER_SECOND / 920) +#define CONTIKIMAC_CONF_INTER_PACKET_INTERVAL (RTIMER_SECOND / 220) #else #define NETSTACK_CONF_RADIO ieee_mode_driver From d9ea8883232bd2185c7537218bf53084344a4f96 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 6 Nov 2016 17:07:17 +0000 Subject: [PATCH 016/129] Delegate RF Front End and Bias settings to board.h --- cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 2 + cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 6 +++ cpu/cc26xx-cc13xx/rf-core/rf-ble.c | 2 + cpu/cc26xx-cc13xx/rf-core/rf-core.h | 39 ++++++++++++++++++++ cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c | 4 +- 5 files changed, 51 insertions(+), 2 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index 3f4e6e67d..00ae3a989 100644 --- a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -471,6 +471,8 @@ rf_radio_setup() cmd.txPower = tx_power_current->tx_power; cmd.pRegOverride = ieee_overrides; + cmd.config.frontEndMode = RF_CORE_RADIO_SETUP_FRONT_END_MODE; + cmd.config.biasMode = RF_CORE_RADIO_SETUP_BIAS_MODE; cmd.mode = 1; /* Send Radio setup to RF Core */ diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index b5d870a95..ad1e36c2b 100644 --- a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -371,6 +371,12 @@ prop_div_radio_setup(void) /* Update to the correct TX power setting */ smartrf_settings_cmd_prop_radio_div_setup.txPower = tx_power_current->tx_power; + /* Adjust RF Front End and Bias based on the board */ + smartrf_settings_cmd_prop_radio_div_setup.config.frontEndMode = + RF_CORE_PROP_FRONT_END_MODE; + smartrf_settings_cmd_prop_radio_div_setup.config.biasMode = + RF_CORE_PROP_BIAS_MODE; + /* Send Radio setup to RF Core */ if(rf_core_send_cmd((uint32_t)cmd, &cmd_status) != RF_CORE_CMD_OK) { PRINTF("prop_div_radio_setup: DIV_SETUP, CMDSTA=0x%08lx, status=0x%04x\n", diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-ble.c b/cpu/cc26xx-cc13xx/rf-core/rf-ble.c index 3cfea03bd..75a11213a 100644 --- a/cpu/cc26xx-cc13xx/rf-core/rf-ble.c +++ b/cpu/cc26xx-cc13xx/rf-core/rf-ble.c @@ -215,6 +215,8 @@ rf_radio_setup() cmd.txPower = tx_power; cmd.pRegOverride = ble_overrides; + cmd.config.frontEndMode = RF_CORE_RADIO_SETUP_FRONT_END_MODE; + cmd.config.biasMode = RF_CORE_RADIO_SETUP_BIAS_MODE; cmd.mode = 0; /* Send Radio setup to RF Core */ diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-core.h b/cpu/cc26xx-cc13xx/rf-core/rf-core.h index 7a75bde50..762aa5650 100644 --- a/cpu/cc26xx-cc13xx/rf-core/rf-core.h +++ b/cpu/cc26xx-cc13xx/rf-core/rf-core.h @@ -64,6 +64,45 @@ #define RF_CORE_CHANNEL 25 #endif /* RF_CORE_CONF_IEEE_MODE_CHANNEL */ /*---------------------------------------------------------------------------*/ +#define RF_CORE_FRONT_END_MODE_DIFFERENTIAL 0 +#define RF_CORE_FRONT_END_MODE_SINGLE_RFP 1 +#define RF_CORE_FRONT_END_MODE_SINGLE_RFN 2 + +#define RF_CORE_BIAS_MODE_INTERNAL 0 +#define RF_CORE_BIAS_MODE_EXTERNAL 1 +/*---------------------------------------------------------------------------*/ +/* + * RF Front-End Mode and Bias for CMD_RADIO_SETUP (IEEE and BLE) + * Default: Differential mode, internal bias + */ +#ifdef RF_CORE_CONF_RADIO_SETUP_FRONT_END_MODE +#define RF_CORE_RADIO_SETUP_FRONT_END_MODE RF_CORE_CONF_RADIO_SETUP_FRONT_END_MODE +#else +#define RF_CORE_RADIO_SETUP_FRONT_END_MODE RF_CORE_FRONT_END_MODE_DIFFERENTIAL +#endif + +#ifdef RF_CORE_CONF_RADIO_SETUP_BIAS_MODE +#define RF_CORE_RADIO_SETUP_BIAS_MODE RF_CORE_CONF_RADIO_SETUP_BIAS_MODE +#else +#define RF_CORE_RADIO_SETUP_BIAS_MODE RF_CORE_BIAS_MODE_INTERNAL +#endif +/*---------------------------------------------------------------------------*/ +/* + * RF Front-End Mode and Bias for CMD_PROP_DIV_RADIO_SETUP (PROP mode) + * Default: Differential mode, external bias + */ +#ifdef RF_CORE_CONF_PROP_FRONT_END_MODE +#define RF_CORE_PROP_FRONT_END_MODE RF_CORE_CONF_PROP_FRONT_END_MODE +#else +#define RF_CORE_PROP_FRONT_END_MODE RF_CORE_FRONT_END_MODE_DIFFERENTIAL +#endif + +#ifdef RF_CORE_CONF_PROP_BIAS_MODE +#define RF_CORE_PROP_BIAS_MODE RF_CORE_CONF_PROP_BIAS_MODE +#else +#define RF_CORE_PROP_BIAS_MODE RF_CORE_BIAS_MODE_EXTERNAL +#endif +/*---------------------------------------------------------------------------*/ #define RF_CORE_CMD_ERROR 0 #define RF_CORE_CMD_OK 1 /*---------------------------------------------------------------------------*/ diff --git a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c index 3d411463e..ea875f286 100644 --- a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c +++ b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c @@ -137,8 +137,8 @@ rfc_CMD_PROP_RADIO_DIV_SETUP_t smartrf_settings_cmd_prop_radio_div_setup = /* 7: .4g mode with dynamic whitening and CRC choice */ .formatConf.whitenMode = 0x7, - .config.frontEndMode = 0x0, /* Differential mode */ - .config.biasMode = 0x1, /* External bias*/ + .config.frontEndMode = 0x00, /* Set by the driver */ + .config.biasMode = 0x00, /* Set by the driver */ .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, .txPower = 0x00, /* Driver sets correct value */ From 00944ec6777e38cc1102b94c64885f1a77d90c1f Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 13 Nov 2016 18:09:56 +0000 Subject: [PATCH 017/129] Allow boards to append to overrides --- cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 7 +++++++ cpu/cc26xx-cc13xx/rf-core/rf-ble.c | 7 +++++++ cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c | 13 +++++++++++++ 3 files changed, 27 insertions(+) diff --git a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index 00ae3a989..67dc0f4ba 100644 --- a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -259,6 +259,12 @@ volatile static uint8_t *rx_read_entry; static uint8_t tx_buf[TX_BUF_HDR_LEN + TX_BUF_PAYLOAD_LEN] CC_ALIGN(4); /*---------------------------------------------------------------------------*/ +#ifdef IEEE_MODE_CONF_BOARD_OVERRIDES +#define IEEE_MODE_BOARD_OVERRIDES IEEE_MODE_CONF_BOARD_OVERRIDES +#else +#define IEEE_MODE_BOARD_OVERRIDES +#endif +/*---------------------------------------------------------------------------*/ /* Overrides for IEEE 802.15.4, differential mode */ static uint32_t ieee_overrides[] = { 0x00354038, /* Synth: Set RTRIM (POTAILRESTRIM) to 5 */ @@ -273,6 +279,7 @@ static uint32_t ieee_overrides[] = { 0x002B50DC, /* Adjust AGC DC filter */ 0x05000243, /* Increase synth programming timeout */ 0x002082C3, /* Increase synth programming timeout */ + IEEE_MODE_BOARD_OVERRIDES 0xFFFFFFFF, /* End of override list */ }; /*---------------------------------------------------------------------------*/ diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-ble.c b/cpu/cc26xx-cc13xx/rf-core/rf-ble.c index 75a11213a..f41011f5f 100644 --- a/cpu/cc26xx-cc13xx/rf-core/rf-ble.c +++ b/cpu/cc26xx-cc13xx/rf-core/rf-ble.c @@ -89,6 +89,12 @@ static struct ble_beacond_config { char adv_name[BLE_ADV_NAME_BUF_LEN]; } beacond_config = { .interval = BLE_ADV_INTERVAL }; /*---------------------------------------------------------------------------*/ +#ifdef RF_BLE_CONF_BOARD_OVERRIDES +#define RF_BLE_BOARD_OVERRIDES RF_BLE_CONF_BOARD_OVERRIDES +#else +#define RF_BLE_BOARD_OVERRIDES +#endif +/*---------------------------------------------------------------------------*/ /* BLE overrides */ static uint32_t ble_overrides[] = { 0x00364038, /* Synth: Set RTRIM (POTAILRESTRIM) to 6 */ @@ -97,6 +103,7 @@ static uint32_t ble_overrides[] = { 0xEAE00603, /* Synth: Set loop bandwidth after lock to 80 kHz (K3, LSB) */ 0x00010623, /* Synth: Set loop bandwidth after lock to 80 kHz (K3, MSB) */ 0x00456088, /* Adjust AGC reference level */ + RF_BLE_BOARD_OVERRIDES 0xFFFFFFFF, /* End of override list */ }; /*---------------------------------------------------------------------------*/ diff --git a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c index ea875f286..90018071e 100644 --- a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c +++ b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c @@ -28,9 +28,19 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ /*---------------------------------------------------------------------------*/ +#include "contiki-conf.h" + #include "driverlib/rf_mailbox.h" #include "driverlib/rf_common_cmd.h" #include "driverlib/rf_prop_cmd.h" + +#include +/*---------------------------------------------------------------------------*/ +#ifdef SMARTRF_SETTINGS_CONF_BOARD_OVERRIDES +#define SMARTRF_SETTINGS_BOARD_OVERRIDES SMARTRF_SETTINGS_CONF_BOARD_OVERRIDES +#else +#define SMARTRF_SETTINGS_BOARD_OVERRIDES +#endif /*---------------------------------------------------------------------------*/ /* Overrides for CMD_PROP_RADIO_DIV_SETUP */ static uint32_t overrides[] = @@ -107,6 +117,9 @@ static uint32_t overrides[] = (uint32_t)0x943, (uint32_t)0x963, + /* Board-specific overrides, if any */ + SMARTRF_SETTINGS_BOARD_OVERRIDES + (uint32_t)0xFFFFFFFF, }; /*---------------------------------------------------------------------------*/ From e0e6f82c46bed32ff16a695f88921b2640728142 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 4 Dec 2016 00:10:57 +0000 Subject: [PATCH 018/129] Allow boards to explicitly provide an RSSI offset --- cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c index 90018071e..3732240ea 100644 --- a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c +++ b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c @@ -42,6 +42,12 @@ #define SMARTRF_SETTINGS_BOARD_OVERRIDES #endif /*---------------------------------------------------------------------------*/ +#ifdef SMARTRF_SETTINGS_CONF_OVERRIDE_RSSI_OFFSET +#define SMARTRF_SETTINGS_OVERRIDE_RSSI_OFFSET SMARTRF_SETTINGS_CONF_OVERRIDE_RSSI_OFFSET +#else +#define SMARTRF_SETTINGS_OVERRIDE_RSSI_OFFSET 0x00FB88A3 +#endif +/*---------------------------------------------------------------------------*/ /* Overrides for CMD_PROP_RADIO_DIV_SETUP */ static uint32_t overrides[] = { @@ -103,10 +109,11 @@ static uint32_t overrides[] = /* Tx: Configure PA ramping setting */ HW_REG_OVERRIDE(0x608C, 0x8213), /* - * override_phy_rx_rssi_offset_5db.xml - * Rx: Set RSSI offset to adjust reported RSSI by +5 dB + * Rx: Set RSSI offset to adjust reported RSSI + * The board can override this */ - (uint32_t)0x00FB88A3, + (uint32_t)SMARTRF_SETTINGS_OVERRIDE_RSSI_OFFSET, + /* * TX power override * Tx: Set PA trim to max (in ADI0, set PACTL0=0xF8) From 6b7681c516389318fb3f64b46db03b876e7dfa98 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 6 Nov 2016 18:42:20 +0000 Subject: [PATCH 019/129] 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_ */ +/*---------------------------------------------------------------------------*/ +/** + * @} + * @} + */ From 6694e697885a5cc94094bfa04b6c55caf425aeb1 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 5 Nov 2016 18:10:46 +0000 Subject: [PATCH 020/129] Make Launchpad unused pins configurable --- platform/srf06-cc26xx/launchpad/board.c | 8 +------- platform/srf06-cc26xx/launchpad/cc1310/board.h | 9 +++++++++ platform/srf06-cc26xx/launchpad/cc2650/board.h | 10 ++++++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/platform/srf06-cc26xx/launchpad/board.c b/platform/srf06-cc26xx/launchpad/board.c index 6482212d8..9779809ae 100644 --- a/platform/srf06-cc26xx/launchpad/board.c +++ b/platform/srf06-cc26xx/launchpad/board.c @@ -66,13 +66,7 @@ LPM_MODULE(launchpad_module, NULL, NULL, wakeup_handler, LPM_DOMAIN_NONE); static void configure_unused_pins(void) { - uint32_t pins[] = { - BOARD_IOID_CS, BOARD_IOID_TDO, BOARD_IOID_TDI, BOARD_IOID_DIO12, - BOARD_IOID_DIO15, BOARD_IOID_DIO21, BOARD_IOID_DIO22, BOARD_IOID_DIO23, - BOARD_IOID_DIO24, BOARD_IOID_DIO25, BOARD_IOID_DIO26, BOARD_IOID_DIO27, - BOARD_IOID_DIO28, BOARD_IOID_DIO29, BOARD_IOID_DIO30, - IOID_UNUSED - }; + uint32_t pins[] = BOARD_UNUSED_PINS; uint32_t *pin; diff --git a/platform/srf06-cc26xx/launchpad/cc1310/board.h b/platform/srf06-cc26xx/launchpad/cc1310/board.h index 9c750e0f9..a4b2efbba 100644 --- a/platform/srf06-cc26xx/launchpad/cc1310/board.h +++ b/platform/srf06-cc26xx/launchpad/cc1310/board.h @@ -178,6 +178,7 @@ * Those values are not meant to be modified by the user * @{ */ +#define BOARD_IOID_DIO1 IOID_1 #define BOARD_IOID_CS IOID_11 #define BOARD_IOID_TDO IOID_16 #define BOARD_IOID_TDI IOID_17 @@ -193,6 +194,14 @@ #define BOARD_IOID_DIO28 IOID_28 #define BOARD_IOID_DIO29 IOID_29 #define BOARD_IOID_DIO30 IOID_30 + +#define BOARD_UNUSED_PINS { \ + BOARD_IOID_DIO1, BOARD_IOID_CS, BOARD_IOID_TDO, BOARD_IOID_TDI, \ + BOARD_IOID_DIO12, BOARD_IOID_DIO15, BOARD_IOID_DIO21, BOARD_IOID_DIO22, \ + BOARD_IOID_DIO23, BOARD_IOID_DIO24, BOARD_IOID_DIO25, BOARD_IOID_DIO26, \ + BOARD_IOID_DIO27, BOARD_IOID_DIO28, BOARD_IOID_DIO29, BOARD_IOID_DIO30, \ + IOID_UNUSED \ + } /** @} */ /*---------------------------------------------------------------------------*/ /** diff --git a/platform/srf06-cc26xx/launchpad/cc2650/board.h b/platform/srf06-cc26xx/launchpad/cc2650/board.h index d71896c3c..9b9d00bf0 100644 --- a/platform/srf06-cc26xx/launchpad/cc2650/board.h +++ b/platform/srf06-cc26xx/launchpad/cc2650/board.h @@ -178,6 +178,8 @@ * Those values are not meant to be modified by the user * @{ */ +#define BOARD_IOID_DIO0 IOID_0 +#define BOARD_IOID_DIO1 IOID_1 #define BOARD_IOID_CS IOID_11 #define BOARD_IOID_TDO IOID_16 #define BOARD_IOID_TDI IOID_17 @@ -193,6 +195,14 @@ #define BOARD_IOID_DIO28 IOID_28 #define BOARD_IOID_DIO29 IOID_29 #define BOARD_IOID_DIO30 IOID_30 + +#define BOARD_UNUSED_PINS { \ + BOARD_IOID_DIO0, BOARD_IOID_DIO1, BOARD_IOID_CS, BOARD_IOID_TDO, \ + BOARD_IOID_TDI, BOARD_IOID_DIO12, BOARD_IOID_DIO15, BOARD_IOID_DIO21, \ + BOARD_IOID_DIO22, BOARD_IOID_DIO23, BOARD_IOID_DIO24, BOARD_IOID_DIO25, \ + BOARD_IOID_DIO26, BOARD_IOID_DIO27, BOARD_IOID_DIO28, BOARD_IOID_DIO29, \ + BOARD_IOID_DIO30, IOID_UNUSED \ + } /** @} */ /*---------------------------------------------------------------------------*/ /** From 7ca3bea7010ebe907c86e4752f371e170ab3ae93 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Mon, 5 Dec 2016 12:11:58 +0000 Subject: [PATCH 021/129] Make LNA bias trim offset configurable --- cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c index 3732240ea..8e3454916 100644 --- a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c +++ b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c @@ -48,6 +48,12 @@ #define SMARTRF_SETTINGS_OVERRIDE_RSSI_OFFSET 0x00FB88A3 #endif /*---------------------------------------------------------------------------*/ +#ifdef SMARTRF_SETTINGS_CONF_OVERRIDE_TRIM_OFFSET +#define SMARTRF_SETTINGS_OVERRIDE_TRIM_OFFSET SMARTRF_SETTINGS_CONF_OVERRIDE_TRIM_OFFSET +#else +#define SMARTRF_SETTINGS_OVERRIDE_TRIM_OFFSET 0x00038883 +#endif +/*---------------------------------------------------------------------------*/ /* Overrides for CMD_PROP_RADIO_DIV_SETUP */ static uint32_t overrides[] = { @@ -96,9 +102,9 @@ static uint32_t overrides[] = ADI_HALFREG_OVERRIDE(0, 61, 0xF, 0xD), /* * override_phy_gfsk_rx.xml - * Rx: Set LNA bias current trim offset to 3 + * Rx: Set LNA bias current trim offset. The board can override this */ - (uint32_t)0x00038883, + (uint32_t)SMARTRF_SETTINGS_OVERRIDE_TRIM_OFFSET, /* Rx: Freeze RSSI on sync found event */ HW_REG_OVERRIDE(0x6084, 0x35F1), /* From 5756248949c448594356fe99a5fd33a89d640db3 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 10 Dec 2016 20:42:16 +0000 Subject: [PATCH 022/129] Factor-out CC13xx PROP mode TX power table The CC13xx PROP mode TX power table can differ between boards as well as across frequency bands. This commit provides defaults for all bands and allows the board to override. --- cpu/cc26xx-cc13xx/Makefile.cc13xx | 2 +- .../rf-core/prop-mode-tx-power.c | 76 ++++++++++++++++ cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 87 ++++++++++--------- cpu/cc26xx-cc13xx/rf-core/prop-mode.h | 61 +++++++++++++ 4 files changed, 184 insertions(+), 42 deletions(-) create mode 100644 cpu/cc26xx-cc13xx/rf-core/prop-mode-tx-power.c create mode 100644 cpu/cc26xx-cc13xx/rf-core/prop-mode.h diff --git a/cpu/cc26xx-cc13xx/Makefile.cc13xx b/cpu/cc26xx-cc13xx/Makefile.cc13xx index 56593ee9f..093aa1f02 100644 --- a/cpu/cc26xx-cc13xx/Makefile.cc13xx +++ b/cpu/cc26xx-cc13xx/Makefile.cc13xx @@ -1,6 +1,6 @@ TI_XXWARE_PATH = lib/cc13xxware -CONTIKI_CPU_SOURCEFILES += smartrf-settings.c prop-mode.c +CONTIKI_CPU_SOURCEFILES += smartrf-settings.c prop-mode.c prop-mode-tx-power.c CFLAGS += -DCPU_FAMILY_CC13XX=1 diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode-tx-power.c b/cpu/cc26xx-cc13xx/rf-core/prop-mode-tx-power.c new file mode 100644 index 000000000..2f14c30e9 --- /dev/null +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode-tx-power.c @@ -0,0 +1,76 @@ +/* + * 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-prop + * @{ + * + * \file + * Default TX power settings. The board can override + */ +/*---------------------------------------------------------------------------*/ +#include "contiki-conf.h" +#include "dev/radio.h" +#include "rf-core/prop-mode.h" +/*---------------------------------------------------------------------------*/ +/* Default TX power settings for the 779-930MHz band */ +const prop_mode_tx_power_config_t prop_mode_tx_power_779_930[] = { + { 14, 0xa73f }, + { 13, 0xa63f }, /* 12.5 */ + { 12, 0xb818 }, + { 11, 0x50da }, + { 10, 0x38d3 }, + { 9, 0x2ccd }, + { 8, 0x24cb }, + { 7, 0x20c9 }, + { 6, 0x1cc7 }, + { 5, 0x18c6 }, + { 4, 0x18c5 }, + { 3, 0x14c4 }, + { 2, 0x1042 }, + { 1, 0x10c3 }, + { 0, 0x0041 }, + { -10, 0x08c0 }, + {-128, 0xFFFF }, +}; +/*---------------------------------------------------------------------------*/ +/* Default TX power settings for the 431-527MHz band */ +const prop_mode_tx_power_config_t prop_mode_tx_power_431_527[] = { + { 15, 0x003f }, + { 14, 0xbe3f }, /* 13.7 */ + { 13, 0x6a0f }, + { 10, 0x3dcb }, + { 6, 0x22c4 }, + {-128, 0xFFFF }, +}; +/*---------------------------------------------------------------------------*/ +/** + * @} + */ diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index f3685eb74..49c8f875e 100644 --- a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -29,11 +29,7 @@ */ /*---------------------------------------------------------------------------*/ /** - * \addtogroup rf-core - * @{ - * - * \defgroup rf-core-prop CC13xx Prop mode driver - * + * \addtogroup rf-core-prop * @{ * * \file @@ -58,6 +54,7 @@ #include "rf-core/rf-core.h" #include "rf-core/rf-switch.h" #include "rf-core/rf-ble.h" +#include "rf-core/prop-mode.h" #include "rf-core/dot-15-4g.h" /*---------------------------------------------------------------------------*/ /* RF core and RF HAL API */ @@ -180,40 +177,35 @@ static rfc_propRxOutput_t rx_stats; /* How long to wait for the RF to enter RX in rf_cmd_ieee_rx */ #define ENTER_RX_WAIT_TIMEOUT (RTIMER_SECOND >> 10) /*---------------------------------------------------------------------------*/ -/* TX Power dBm lookup table - values from SmartRF Studio */ -typedef struct output_config { - radio_value_t dbm; - uint16_t tx_power; /* Value for the PROP_DIV_RADIO_SETUP.txPower field */ -} output_config_t; - -static const output_config_t output_power[] = { - { 14, 0xa73f }, - { 13, 0xa63f }, /* 12.5 */ - { 12, 0xb818 }, - { 11, 0x50da }, - { 10, 0x38d3 }, - { 9, 0x2ccd }, - { 8, 0x24cb }, - { 7, 0x20c9 }, - { 6, 0x1cc7 }, - { 5, 0x18c6 }, - { 4, 0x18c5 }, - { 3, 0x14c4 }, - { 2, 0x1042 }, - { 1, 0x10c3 }, - { 0, 0x0041 }, - {-10, 0x08c0 }, -}; - -#define OUTPUT_CONFIG_COUNT (sizeof(output_power) / sizeof(output_config_t)) +/* TX power table for the 431-527MHz band */ +#ifdef PROP_MODE_CONF_TX_POWER_431_527 +#define PROP_MODE_TX_POWER_431_527 PROP_MODE_CONF_TX_POWER_431_527 +#else +#define PROP_MODE_TX_POWER_431_527 prop_mode_tx_power_431_527 +#endif +/*---------------------------------------------------------------------------*/ +/* TX power table for the 779-930MHz band */ +#ifdef PROP_MODE_CONF_TX_POWER_779_930 +#define PROP_MODE_TX_POWER_779_930 PROP_MODE_CONF_TX_POWER_779_930 +#else +#define PROP_MODE_TX_POWER_779_930 prop_mode_tx_power_779_930 +#endif +/*---------------------------------------------------------------------------*/ +/* Select power table based on the frequency band */ +#if DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_470 +#define TX_POWER_DRIVER PROP_MODE_TX_POWER_431_527 +#else +#define TX_POWER_DRIVER PROP_MODE_TX_POWER_779_930 +#endif +/*---------------------------------------------------------------------------*/ +extern const prop_mode_tx_power_config_t TX_POWER_DRIVER[]; /* Max and Min Output Power in dBm */ -#define OUTPUT_POWER_MIN (output_power[OUTPUT_CONFIG_COUNT - 1].dbm) -#define OUTPUT_POWER_MAX (output_power[0].dbm) +#define OUTPUT_POWER_MAX (TX_POWER_DRIVER[0].dbm) #define OUTPUT_POWER_UNKNOWN 0xFFFF /* Default TX Power - position in output_power[] */ -const output_config_t *tx_power_current = &output_power[1]; +const prop_mode_tx_power_config_t *tx_power_current = &TX_POWER_DRIVER[1]; /*---------------------------------------------------------------------------*/ #ifdef PROP_MODE_CONF_LO_DIVIDER #define PROP_MODE_LO_DIVIDER PROP_MODE_CONF_LO_DIVIDER @@ -330,6 +322,19 @@ set_channel(uint8_t channel) smartrf_settings_cmd_fs.fractFreq = frac; } /*---------------------------------------------------------------------------*/ +static uint8_t +get_tx_power_array_last_element(void) +{ + const prop_mode_tx_power_config_t *array = TX_POWER_DRIVER; + uint8_t count = 0; + + while(array->tx_power != OUTPUT_POWER_UNKNOWN) { + count++; + array++; + } + return count - 1; +} +/*---------------------------------------------------------------------------*/ /* Returns the current TX power in dBm */ static radio_value_t get_tx_power(void) @@ -338,7 +343,7 @@ get_tx_power(void) } /*---------------------------------------------------------------------------*/ /* - * The caller must make sure to send a new CMD_PROP_RADIO_DIV_SETP to the + * The caller must make sure to send a new CMD_PROP_RADIO_DIV_SETUP to the * radio after calling this function. */ static void @@ -346,14 +351,14 @@ set_tx_power(radio_value_t power) { int i; - for(i = OUTPUT_CONFIG_COUNT - 1; i >= 0; --i) { - if(power <= output_power[i].dbm) { + for(i = get_tx_power_array_last_element(); i >= 0; --i) { + if(power <= TX_POWER_DRIVER[i].dbm) { /* * Merely save the value. It will be used in all subsequent usages of * CMD_PROP_RADIO_DIV_SETP, including one immediately after this function * has returned */ - tx_power_current = &output_power[i]; + tx_power_current = &TX_POWER_DRIVER[i]; return; } @@ -1023,7 +1028,7 @@ get_value(radio_param_t param, radio_value_t *value) *value = DOT_15_4G_CHANNEL_MAX; return RADIO_RESULT_OK; case RADIO_CONST_TXPOWER_MIN: - *value = OUTPUT_POWER_MIN; + *value = TX_POWER_DRIVER[get_tx_power_array_last_element()].dbm; return RADIO_RESULT_OK; case RADIO_CONST_TXPOWER_MAX: *value = OUTPUT_POWER_MAX; @@ -1068,7 +1073,8 @@ set_value(radio_param_t param, radio_value_t value) set_channel((uint8_t)value); break; case RADIO_PARAM_TXPOWER: - if(value < OUTPUT_POWER_MIN || value > OUTPUT_POWER_MAX) { + if(value < TX_POWER_DRIVER[get_tx_power_array_last_element()].dbm || + value > OUTPUT_POWER_MAX) { return RADIO_RESULT_INVALID_VALUE; } @@ -1148,6 +1154,5 @@ const struct radio_driver prop_mode_driver = { }; /*---------------------------------------------------------------------------*/ /** - * @} * @} */ diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode.h b/cpu/cc26xx-cc13xx/rf-core/prop-mode.h new file mode 100644 index 000000000..55048777a --- /dev/null +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode.h @@ -0,0 +1,61 @@ +/* + * 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-core-prop CC13xx Prop mode driver + * + * @{ + * + * \file + * Header file for the CC13xx prop mode NETSTACK_RADIO driver + */ +/*---------------------------------------------------------------------------*/ +#ifndef PROP_MODE_H_ +#define PROP_MODE_H_ +/*---------------------------------------------------------------------------*/ +#include "contiki-conf.h" +#include "rf-core/dot-15-4g.h" + +#include +/*---------------------------------------------------------------------------*/ +typedef struct prop_mode_tx_power_config { + radio_value_t dbm; + uint16_t tx_power; /* Value for the PROP_DIV_RADIO_SETUP.txPower field */ +} prop_mode_tx_power_config_t; +/*---------------------------------------------------------------------------*/ +#endif /* PROP_MODE_H_ */ +/*---------------------------------------------------------------------------*/ +/** + * @} + * @} + */ From c745199d53bced2e98c82b451f4778c63960aed1 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 10 Dec 2016 20:57:58 +0000 Subject: [PATCH 023/129] Allow frequency band-specific overrides --- cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c index 8e3454916..2e45000af 100644 --- a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c +++ b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c @@ -30,6 +30,7 @@ /*---------------------------------------------------------------------------*/ #include "contiki-conf.h" +#include "rf-core/dot-15-4g.h" #include "driverlib/rf_mailbox.h" #include "driverlib/rf_common_cmd.h" #include "driverlib/rf_prop_cmd.h" @@ -42,6 +43,12 @@ #define SMARTRF_SETTINGS_BOARD_OVERRIDES #endif /*---------------------------------------------------------------------------*/ +#ifdef SMARTRF_SETTINGS_CONF_BAND_OVERRIDES +#define SMARTRF_SETTINGS_BAND_OVERRIDES SMARTRF_SETTINGS_CONF_BAND_OVERRIDES +#else +#define SMARTRF_SETTINGS_BAND_OVERRIDES +#endif +/*---------------------------------------------------------------------------*/ #ifdef SMARTRF_SETTINGS_CONF_OVERRIDE_RSSI_OFFSET #define SMARTRF_SETTINGS_OVERRIDE_RSSI_OFFSET SMARTRF_SETTINGS_CONF_OVERRIDE_RSSI_OFFSET #else @@ -133,6 +140,9 @@ static uint32_t overrides[] = /* Board-specific overrides, if any */ SMARTRF_SETTINGS_BOARD_OVERRIDES + /* Band-specific overrides, if any */ + SMARTRF_SETTINGS_BAND_OVERRIDES + (uint32_t)0xFFFFFFFF, }; /*---------------------------------------------------------------------------*/ From 47bda9b6be27b0f47c83de734582b2649b08981f Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 10 Dec 2016 21:20:13 +0000 Subject: [PATCH 024/129] Provide additional overrides for the 470MHz frequency band --- cpu/cc26xx-cc13xx/rf-core/dot-15-4g.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpu/cc26xx-cc13xx/rf-core/dot-15-4g.h b/cpu/cc26xx-cc13xx/rf-core/dot-15-4g.h index 30dc63367..37a88fbff 100644 --- a/cpu/cc26xx-cc13xx/rf-core/dot-15-4g.h +++ b/cpu/cc26xx-cc13xx/rf-core/dot-15-4g.h @@ -45,6 +45,8 @@ #define DOT_15_4G_H_ /*---------------------------------------------------------------------------*/ #include "contiki-conf.h" + +#include "driverlib/rf_mailbox.h" /*---------------------------------------------------------------------------*/ /* IEEE 802.15.4g frequency band identifiers (Table 68f) */ #define DOT_15_4G_FREQUENCY_BAND_169 0 /* 169.400–169.475 (Europe) - 169 MHz band */ @@ -81,6 +83,8 @@ #define DOT_15_4G_CHANNEL_SPACING 200 #define DOT_15_4G_CHAN0_FREQUENCY 470200 #define PROP_MODE_CONF_LO_DIVIDER 0x0A +#define SMARTRF_SETTINGS_CONF_BAND_OVERRIDES HW32_ARRAY_OVERRIDE(0x405C,1), \ + (uint32_t)0x18000280, #elif DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_780 #define DOT_15_4G_CHANNEL_MAX 38 From 7603e104c44da91179f2e35e8191e3e7e7de4a89 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 10 Dec 2016 21:21:02 +0000 Subject: [PATCH 025/129] Allow band-specific RSSI offset override --- cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c index 2e45000af..e42b6b66f 100644 --- a/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c +++ b/cpu/cc26xx-cc13xx/rf-core/smartrf-settings.c @@ -49,10 +49,18 @@ #define SMARTRF_SETTINGS_BAND_OVERRIDES #endif /*---------------------------------------------------------------------------*/ -#ifdef SMARTRF_SETTINGS_CONF_OVERRIDE_RSSI_OFFSET -#define SMARTRF_SETTINGS_OVERRIDE_RSSI_OFFSET SMARTRF_SETTINGS_CONF_OVERRIDE_RSSI_OFFSET +/* RSSI offset configuration for the 431-527MHz band */ +#ifdef SMARTRF_SETTINGS_CONF_RSSI_OFFSET_431_527 +#define SMARTRF_SETTINGS_RSSI_OFFSET_431_527 SMARTRF_SETTINGS_CONF_RSSI_OFFSET_431_527 #else -#define SMARTRF_SETTINGS_OVERRIDE_RSSI_OFFSET 0x00FB88A3 +#define SMARTRF_SETTINGS_RSSI_OFFSET_431_527 0x000288A3 +#endif +/*---------------------------------------------------------------------------*/ +/* RSSI offset configuration for the 779-930MHz band */ +#ifdef SMARTRF_SETTINGS_CONF_RSSI_OFFSET_779_930 +#define SMARTRF_SETTINGS_RSSI_OFFSET_779_930 SMARTRF_SETTINGS_CONF_RSSI_OFFSET_779_930 +#else +#define SMARTRF_SETTINGS_RSSI_OFFSET_779_930 0x00FB88A3 #endif /*---------------------------------------------------------------------------*/ #ifdef SMARTRF_SETTINGS_CONF_OVERRIDE_TRIM_OFFSET @@ -61,6 +69,13 @@ #define SMARTRF_SETTINGS_OVERRIDE_TRIM_OFFSET 0x00038883 #endif /*---------------------------------------------------------------------------*/ +/* Select RSSI offset value based on the frequency band */ +#if DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_470 +#define RSSI_OFFSET SMARTRF_SETTINGS_RSSI_OFFSET_431_527 +#else +#define RSSI_OFFSET SMARTRF_SETTINGS_RSSI_OFFSET_779_930 +#endif +/*---------------------------------------------------------------------------*/ /* Overrides for CMD_PROP_RADIO_DIV_SETUP */ static uint32_t overrides[] = { @@ -125,7 +140,7 @@ static uint32_t overrides[] = * Rx: Set RSSI offset to adjust reported RSSI * The board can override this */ - (uint32_t)SMARTRF_SETTINGS_OVERRIDE_RSSI_OFFSET, + (uint32_t)RSSI_OFFSET, /* * TX power override From d291ec53e68810c07698b3ea379eca6e8b8c2cde Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 6 Nov 2016 17:17:56 +0000 Subject: [PATCH 026/129] Add support for the CC1350 sensortag --- .../sensortag/cc1350/Makefile.cc1350 | 11 + .../srf06-cc26xx/sensortag/cc1350/board.h | 277 ++++++++++++++++++ .../srf06-cc26xx/sensortag/cc1350/leds-arch.c | 77 +++++ 3 files changed, 365 insertions(+) create mode 100644 platform/srf06-cc26xx/sensortag/cc1350/Makefile.cc1350 create mode 100644 platform/srf06-cc26xx/sensortag/cc1350/board.h create mode 100644 platform/srf06-cc26xx/sensortag/cc1350/leds-arch.c diff --git a/platform/srf06-cc26xx/sensortag/cc1350/Makefile.cc1350 b/platform/srf06-cc26xx/sensortag/cc1350/Makefile.cc1350 new file mode 100644 index 000000000..3cacec197 --- /dev/null +++ b/platform/srf06-cc26xx/sensortag/cc1350/Makefile.cc1350 @@ -0,0 +1,11 @@ +### Add to the source list +BOARD_SOURCEFILES += leds-arch.c + +### Will allow the inclusion of the correct CPU makefile +CPU_FAMILY = cc13xx + +### Add to the source dirs +CONTIKI_TARGET_DIRS += sensortag/cc1350 + +### Include the common sensortag makefile +include $(PLATFORM_ROOT_DIR)/sensortag/Makefile.sensortag diff --git a/platform/srf06-cc26xx/sensortag/cc1350/board.h b/platform/srf06-cc26xx/sensortag/cc1350/board.h new file mode 100644 index 000000000..a98b955b2 --- /dev/null +++ b/platform/srf06-cc26xx/sensortag/cc1350/board.h @@ -0,0 +1,277 @@ +/* + * Copyright (c) 2014, 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 cc26xx-srf-tag + * @{ + * + * \defgroup sensortag-cc13xx-peripherals Sensortag Peripherals + * + * Defines related to the Sensortag-CC1350 + * + * This file provides connectivity information on LEDs, Buttons, UART and + * other peripherals + * + * This file can be used as the basis to configure other boards using the + * CC13xx code as their basis. + * + * This file is not meant to be modified by the user. + * @{ + * + * \file + * Header file with definitions related to the I/O connections on the TI + * Sensortag + * + * \note Do not include this file directly. It gets included by contiki-conf + * after all relevant directives have been set. + */ +/*---------------------------------------------------------------------------*/ +#ifndef BOARD_H_ +#define BOARD_H_ +/*---------------------------------------------------------------------------*/ +#include "ioc.h" +/*---------------------------------------------------------------------------*/ +/** + * \name LED configurations + * + * Those values are not meant to be modified by the user + * @{ + */ +/* Some files include leds.h before us, so we need to get rid of defaults in + * leds.h before we provide correct definitions */ +#undef LEDS_GREEN +#undef LEDS_YELLOW +#undef LEDS_RED +#undef LEDS_CONF_ALL + +#define LEDS_RED 1 +#define LEDS_GREEN LEDS_RED +#define LEDS_YELLOW LEDS_RED +#define LEDS_ORANGE LEDS_RED + +#define LEDS_CONF_ALL 1 + +/* Notify various examples that we have LEDs */ +#define PLATFORM_HAS_LEDS 1 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name LED IOID mappings + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_LED_1 IOID_10 +#define BOARD_LED_1 (1 << BOARD_IOID_LED_1) +#define BOARD_LED_ALL BOARD_LED_1 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name UART IOID mapping + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_DP4_UARTRX IOID_28 +#define BOARD_IOID_DP5_UARTTX IOID_29 + +#if BOARD_CONF_DEBUGGER_DEVPACK +#define BOARD_IOID_UART_RX BOARD_IOID_DP4_UARTRX +#define BOARD_IOID_UART_TX BOARD_IOID_DP5_UARTTX +#else +#define BOARD_IOID_UART_RX IOID_17 +#define BOARD_IOID_UART_TX IOID_16 +#endif + +#define BOARD_IOID_UART_CTS IOID_UNUSED +#define BOARD_IOID_UART_RTS IOID_UNUSED +#define BOARD_UART_RX (1 << BOARD_IOID_UART_RX) +#define BOARD_UART_TX (1 << BOARD_IOID_UART_TX) +#define BOARD_UART_CTS (1 << BOARD_IOID_UART_CTS) +#define BOARD_UART_RTS (1 << BOARD_IOID_UART_RTS) +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name Button IOID mapping + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_KEY_LEFT IOID_15 +#define BOARD_IOID_KEY_RIGHT IOID_4 +#define BOARD_KEY_LEFT (1 << BOARD_IOID_KEY_LEFT) +#define BOARD_KEY_RIGHT (1 << BOARD_IOID_KEY_RIGHT) +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief SPI IOID mappings + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_SPI_MOSI IOID_19 +#define BOARD_IOID_SPI_MISO IOID_18 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name Buzzer configuration + * @{ + */ +#define BOARD_IOID_BUZZER IOID_21 /**< Buzzer Pin */ +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name Reed Relay IOID mapping + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_REED_RELAY IOID_1 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name External flash IOID mapping and part-related constants + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_FLASH_CS IOID_14 +#define BOARD_FLASH_CS (1 << BOARD_IOID_FLASH_CS) +#define BOARD_IOID_SPI_CLK_FLASH IOID_17 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief I2C IOID mappings + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_SDA IOID_5 /**< Interface 0 SDA: All sensors bar MPU */ +#define BOARD_IOID_SCL IOID_6 /**< Interface 0 SCL: All sensors bar MPU */ +#define BOARD_IOID_SDA_HP IOID_8 /**< Interface 1 SDA: MPU */ +#define BOARD_IOID_SCL_HP IOID_9 /**< Interface 1 SCL: MPU */ +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief MPU IOID mappings + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_MPU_INT IOID_7 +#define BOARD_IOID_MPU_POWER IOID_12 +#define BOARD_MPU_INT (1 << BOARD_IOID_MPU_INT) +#define BOARD_MPU_POWER (1 << BOARD_IOID_MPU_POWER) +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief Board devpack IOID mappings (LCD etc.) + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_AUDIOFS_TDO IOID_16 +#define BOARD_IOID_DEVPACK_CS IOID_20 +#define BOARD_IOID_DEVPK_LCD_EXTCOMIN IOID_22 +#define BOARD_IOID_AUDIODO IOID_22 +#define BOARD_IOID_DP2 IOID_23 +#define BOARD_IOID_DP1 IOID_24 +#define BOARD_IOID_DP0 IOID_25 +#define BOARD_IOID_DP3 IOID_27 +#define BOARD_IOID_DEVPK_ID IOID_30 +#define BOARD_DEVPACK_CS (1 << BOARD_IOID_DEVPACK_CS) +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief TMP Sensor + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_TMP_RDY IOID_11 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief Digital Microphone + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_MIC_POWER IOID_13 +#define BOARD_IOID_AUDIO_DI IOID_2 +#define BOARD_IOID_AUDIO_CLK IOID_3 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name RF Front End configuration + * + * Those values are not meant to be modified by the user + * @{ + */ +#define RF_CORE_CONF_RADIO_SETUP_FRONT_END_MODE 0x01 /* Single-Ended, RFP */ +#define RF_CORE_CONF_RADIO_SETUP_BIAS_MODE 0x01 /* External */ +#define RF_CORE_CONF_PROP_FRONT_END_MODE 0x02 /* Single-Ended, RFN */ +#define RF_CORE_CONF_PROP_BIAS_MODE 0x01 /* External */ +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name Board-specific overrides + * + * Those values are not meant to be modified by the user + * @{ + */ +#define IEEE_MODE_CONF_BOARD_OVERRIDES ADI_HALFREG_OVERRIDE(0, 16, 0x7, 1), +#define RF_BLE_CONF_BOARD_OVERRIDES ADI_HALFREG_OVERRIDE(0, 16, 0x7, 1), +#define SMARTRF_SETTINGS_CONF_BOARD_OVERRIDES ADI_HALFREG_OVERRIDE(0, 16, 0x7, 2), + +#define SMARTRF_SETTINGS_CONF_RSSI_OFFSET_779_930 0x00F688A3 +#define SMARTRF_SETTINGS_CONF_OVERRIDE_TRIM_OFFSET 0x00018883 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name Device string used on startup + * @{ + */ +#define BOARD_STRING "TI CC1350 SensorTag" + +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief Board specific iniatialisation + * @{ + */ +void board_init(void); +/** @} */ +/*---------------------------------------------------------------------------*/ +#endif /* BOARD_H_ */ +/*---------------------------------------------------------------------------*/ +/** + * @} + * @} + */ diff --git a/platform/srf06-cc26xx/sensortag/cc1350/leds-arch.c b/platform/srf06-cc26xx/sensortag/cc1350/leds-arch.c new file mode 100644 index 000000000..f4214628e --- /dev/null +++ b/platform/srf06-cc26xx/sensortag/cc1350/leds-arch.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014, 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 sensortag-cc13xx-peripherals + * @{ + * + * \file + * Driver for the Sensortag-CC1350 LEDs + */ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" +#include "dev/leds.h" + +#include "ti-lib.h" +/*---------------------------------------------------------------------------*/ +static unsigned char c; +static int inited = 0; +/*---------------------------------------------------------------------------*/ +void +leds_arch_init(void) +{ + if(inited) { + return; + } + inited = 1; + + ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_1); + + ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL); +} +/*---------------------------------------------------------------------------*/ +unsigned char +leds_arch_get(void) +{ + return c; +} +/*---------------------------------------------------------------------------*/ +void +leds_arch_set(unsigned char leds) +{ + c = leds; + ti_lib_gpio_clear_dio(BOARD_IOID_LED_1); + + if((leds & LEDS_RED) == LEDS_RED) { + ti_lib_gpio_set_dio(BOARD_IOID_LED_1); + } +} +/*---------------------------------------------------------------------------*/ +/** @} */ From a864ebbce45563983cdb885beadadea034472a7d Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 17 Jul 2016 01:56:35 +0100 Subject: [PATCH 027/129] Re-organise sensortag documentation modules Many of those doxygen blocks are now applicable to both sensortags, with only a couple of them being different between the CC1350 and CC2650 tags --- platform/srf06-cc26xx/common/ext-flash.c | 2 +- .../srf06-cc26xx/sensortag/bmp-280-sensor.c | 2 +- .../srf06-cc26xx/sensortag/bmp-280-sensor.h | 2 +- platform/srf06-cc26xx/sensortag/board-i2c.c | 2 +- platform/srf06-cc26xx/sensortag/board-i2c.h | 2 +- .../sensortag/board-peripherals.h | 11 ++++++- .../srf06-cc26xx/sensortag/button-sensor.c | 2 +- .../srf06-cc26xx/sensortag/button-sensor.h | 2 +- platform/srf06-cc26xx/sensortag/buzzer.c | 2 +- platform/srf06-cc26xx/sensortag/buzzer.h | 2 +- .../srf06-cc26xx/sensortag/cc1350/board.h | 4 +-- .../srf06-cc26xx/sensortag/cc2650/board.h | 2 +- .../srf06-cc26xx/sensortag/hdc-1000-sensor.c | 2 +- .../srf06-cc26xx/sensortag/hdc-1000-sensor.h | 31 +------------------ .../srf06-cc26xx/sensortag/mpu-9250-sensor.c | 2 +- .../srf06-cc26xx/sensortag/mpu-9250-sensor.h | 2 +- .../srf06-cc26xx/sensortag/opt-3001-sensor.c | 2 +- .../srf06-cc26xx/sensortag/opt-3001-sensor.h | 2 +- platform/srf06-cc26xx/sensortag/reed-relay.c | 2 +- platform/srf06-cc26xx/sensortag/reed-relay.h | 2 +- .../srf06-cc26xx/sensortag/sensor-common.h | 2 +- .../sensortag/sensortag-sensors.c | 2 +- .../srf06-cc26xx/sensortag/tmp-007-sensor.c | 2 +- .../srf06-cc26xx/sensortag/tmp-007-sensor.h | 2 +- 24 files changed, 34 insertions(+), 54 deletions(-) diff --git a/platform/srf06-cc26xx/common/ext-flash.c b/platform/srf06-cc26xx/common/ext-flash.c index 7faaab0c0..5631297ac 100644 --- a/platform/srf06-cc26xx/common/ext-flash.c +++ b/platform/srf06-cc26xx/common/ext-flash.c @@ -33,7 +33,7 @@ * @{ * * \file - * Driver for the LaunchPad Flash and the Sensortag WinBond W25X20CL/W25X40CL + * Sensortag/LaunchPad External Flash Driver */ /*---------------------------------------------------------------------------*/ #include "contiki.h" diff --git a/platform/srf06-cc26xx/sensortag/bmp-280-sensor.c b/platform/srf06-cc26xx/sensortag/bmp-280-sensor.c index 4ed9e06fc..a6e525cb1 100644 --- a/platform/srf06-cc26xx/sensortag/bmp-280-sensor.c +++ b/platform/srf06-cc26xx/sensortag/bmp-280-sensor.c @@ -33,7 +33,7 @@ * @{ * * \file - * Driver for the Sensortag-CC26XX BMP280 Altimeter / Pressure Sensor + * Driver for the Sensortag BMP280 Altimeter / Pressure Sensor */ /*---------------------------------------------------------------------------*/ #include "contiki-conf.h" diff --git a/platform/srf06-cc26xx/sensortag/bmp-280-sensor.h b/platform/srf06-cc26xx/sensortag/bmp-280-sensor.h index 8bff65787..0047aaa9a 100644 --- a/platform/srf06-cc26xx/sensortag/bmp-280-sensor.h +++ b/platform/srf06-cc26xx/sensortag/bmp-280-sensor.h @@ -49,7 +49,7 @@ * @{ * * \file - * Header file for the Sensortag-CC26xx BMP280 Altimeter / Pressure Sensor + * Header file for the Sensortag BMP280 Altimeter / Pressure Sensor */ /*---------------------------------------------------------------------------*/ #ifndef BMP_280_SENSOR_H_ diff --git a/platform/srf06-cc26xx/sensortag/board-i2c.c b/platform/srf06-cc26xx/sensortag/board-i2c.c index 17486d65b..262ef4772 100644 --- a/platform/srf06-cc26xx/sensortag/board-i2c.c +++ b/platform/srf06-cc26xx/sensortag/board-i2c.c @@ -33,7 +33,7 @@ * @{ * * \file - * Board-specific I2C driver for the Sensortag-CC26xx + * Board-specific I2C driver for the Sensortags */ /*---------------------------------------------------------------------------*/ #include "contiki-conf.h" diff --git a/platform/srf06-cc26xx/sensortag/board-i2c.h b/platform/srf06-cc26xx/sensortag/board-i2c.h index 40832c9bd..46233c332 100644 --- a/platform/srf06-cc26xx/sensortag/board-i2c.h +++ b/platform/srf06-cc26xx/sensortag/board-i2c.h @@ -36,7 +36,7 @@ * @{ * * \file - * Header file for the Sensortag-CC26xx I2C Driver + * Header file for the Sensortag I2C Driver */ /*---------------------------------------------------------------------------*/ #ifndef BOARD_I2C_H_ diff --git a/platform/srf06-cc26xx/sensortag/board-peripherals.h b/platform/srf06-cc26xx/sensortag/board-peripherals.h index 9c994d9e6..42e22d4c8 100644 --- a/platform/srf06-cc26xx/sensortag/board-peripherals.h +++ b/platform/srf06-cc26xx/sensortag/board-peripherals.h @@ -29,10 +29,18 @@ */ /*---------------------------------------------------------------------------*/ /** \addtogroup cc26xx-srf-tag + * @{ + * + * \defgroup sensortag-cc26xx-peripherals Sensortag CC1350/CC2650 common + * + * Defines related to Sensortag sensors. The two sensortags are identical to a + * very large extent. Everything documented within this group applies to both + * sensortags. + * * @{ * * \file - * Header file with definitions related to the sensors on the Sensortag-CC26xx + * Header file with definitions related to the sensors on the Sensortags * * \note Do not include this file directly. */ @@ -52,5 +60,6 @@ #endif /* BOARD_PERIPHERALS_H_ */ /*---------------------------------------------------------------------------*/ /** + * @} * @} */ diff --git a/platform/srf06-cc26xx/sensortag/button-sensor.c b/platform/srf06-cc26xx/sensortag/button-sensor.c index 9df55d21d..7ec0a5a18 100644 --- a/platform/srf06-cc26xx/sensortag/button-sensor.c +++ b/platform/srf06-cc26xx/sensortag/button-sensor.c @@ -33,7 +33,7 @@ * @{ * * \file - * Driver for the Sensortag-CC26xx buttons + * Driver for Sensortag buttons */ /*---------------------------------------------------------------------------*/ #include "contiki.h" diff --git a/platform/srf06-cc26xx/sensortag/button-sensor.h b/platform/srf06-cc26xx/sensortag/button-sensor.h index 25acb104f..1355a5855 100644 --- a/platform/srf06-cc26xx/sensortag/button-sensor.h +++ b/platform/srf06-cc26xx/sensortag/button-sensor.h @@ -38,7 +38,7 @@ * @{ * * \file - * Header file for the Sensortag-CC26xx Button Driver + * Header file for the Sensortag Button Driver */ /*---------------------------------------------------------------------------*/ #ifndef BUTTON_SENSOR_H_ diff --git a/platform/srf06-cc26xx/sensortag/buzzer.c b/platform/srf06-cc26xx/sensortag/buzzer.c index d7f48e4de..47ce799d4 100644 --- a/platform/srf06-cc26xx/sensortag/buzzer.c +++ b/platform/srf06-cc26xx/sensortag/buzzer.c @@ -33,7 +33,7 @@ * @{ * * \file - * Driver for the Sensortag-CC26XX Buzzer + * Driver for the Sensortag Buzzer */ /*---------------------------------------------------------------------------*/ #include "contiki-conf.h" diff --git a/platform/srf06-cc26xx/sensortag/buzzer.h b/platform/srf06-cc26xx/sensortag/buzzer.h index 653b46f88..679729245 100644 --- a/platform/srf06-cc26xx/sensortag/buzzer.h +++ b/platform/srf06-cc26xx/sensortag/buzzer.h @@ -36,7 +36,7 @@ * @{ * * \file - * Header file for the Sensortag-CC26xx Buzzer + * Header file for the Sensortag Buzzer */ /*---------------------------------------------------------------------------*/ #ifndef BUZZER_H_ diff --git a/platform/srf06-cc26xx/sensortag/cc1350/board.h b/platform/srf06-cc26xx/sensortag/cc1350/board.h index a98b955b2..7db4c9357 100644 --- a/platform/srf06-cc26xx/sensortag/cc1350/board.h +++ b/platform/srf06-cc26xx/sensortag/cc1350/board.h @@ -31,9 +31,9 @@ /** \addtogroup cc26xx-srf-tag * @{ * - * \defgroup sensortag-cc13xx-peripherals Sensortag Peripherals + * \defgroup sensortag-cc13xx-peripherals CC1350 Sensortag Peripherals * - * Defines related to the Sensortag-CC1350 + * Defines related to the CC1350 Sensortag * * This file provides connectivity information on LEDs, Buttons, UART and * other peripherals diff --git a/platform/srf06-cc26xx/sensortag/cc2650/board.h b/platform/srf06-cc26xx/sensortag/cc2650/board.h index 9f0a7abd3..aaf26dae3 100644 --- a/platform/srf06-cc26xx/sensortag/cc2650/board.h +++ b/platform/srf06-cc26xx/sensortag/cc2650/board.h @@ -31,7 +31,7 @@ /** \addtogroup cc26xx-srf-tag * @{ * - * \defgroup sensortag-cc26xx-peripherals Sensortag Peripherals + * \defgroup sensortag-cc26xx-specific CC2650 Sensortag Peripherals * * Defines related to the CC2650 Sensortag * diff --git a/platform/srf06-cc26xx/sensortag/hdc-1000-sensor.c b/platform/srf06-cc26xx/sensortag/hdc-1000-sensor.c index 8fdd6d847..bdc688fe4 100644 --- a/platform/srf06-cc26xx/sensortag/hdc-1000-sensor.c +++ b/platform/srf06-cc26xx/sensortag/hdc-1000-sensor.c @@ -33,7 +33,7 @@ * @{ * * \file - * Driver for the Sensortag-CC26xx HDC sensor + * Driver for the Sensortag HDC sensor */ /*---------------------------------------------------------------------------*/ #include "contiki-conf.h" diff --git a/platform/srf06-cc26xx/sensortag/hdc-1000-sensor.h b/platform/srf06-cc26xx/sensortag/hdc-1000-sensor.h index 990b1ab69..d3089d742 100755 --- a/platform/srf06-cc26xx/sensortag/hdc-1000-sensor.h +++ b/platform/srf06-cc26xx/sensortag/hdc-1000-sensor.h @@ -1,32 +1,3 @@ -/* - * Copyright (c) 2014, 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. - */ /* * Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/ * All rights reserved. @@ -85,7 +56,7 @@ * @{ * * \file - * Header file for the Sensortag-CC26ss TI HDC1000 sensor + * Header file for the Sensortag TI HDC1000 sensor */ /*---------------------------------------------------------------------------*/ #ifndef HDC_1000_SENSOR_H diff --git a/platform/srf06-cc26xx/sensortag/mpu-9250-sensor.c b/platform/srf06-cc26xx/sensortag/mpu-9250-sensor.c index 5a97666b3..886cccb6e 100644 --- a/platform/srf06-cc26xx/sensortag/mpu-9250-sensor.c +++ b/platform/srf06-cc26xx/sensortag/mpu-9250-sensor.c @@ -33,7 +33,7 @@ * @{ * * \file - * Driver for the Sensortag-CC26XX Invensense MPU9250 motion processing unit + * Driver for the Sensortag Invensense MPU9250 motion processing unit */ /*---------------------------------------------------------------------------*/ #include "contiki-conf.h" diff --git a/platform/srf06-cc26xx/sensortag/mpu-9250-sensor.h b/platform/srf06-cc26xx/sensortag/mpu-9250-sensor.h index c6c4d5534..da4386412 100644 --- a/platform/srf06-cc26xx/sensortag/mpu-9250-sensor.h +++ b/platform/srf06-cc26xx/sensortag/mpu-9250-sensor.h @@ -62,7 +62,7 @@ * @{ * * \file - * Header file for the Sensortag-CC26XX Invensense MPU9250 motion processing unit + * Header file for the Sensortag Invensense MPU9250 motion processing unit */ /*---------------------------------------------------------------------------*/ #ifndef MPU_9250_SENSOR_H_ diff --git a/platform/srf06-cc26xx/sensortag/opt-3001-sensor.c b/platform/srf06-cc26xx/sensortag/opt-3001-sensor.c index 7d903e18b..a9b7ba01f 100644 --- a/platform/srf06-cc26xx/sensortag/opt-3001-sensor.c +++ b/platform/srf06-cc26xx/sensortag/opt-3001-sensor.c @@ -33,7 +33,7 @@ * @{ * * \file - * Driver for the Sensortag-CC26xx Opt3001 light sensor + * Driver for the Sensortag Opt3001 light sensor */ /*---------------------------------------------------------------------------*/ #include "contiki-conf.h" diff --git a/platform/srf06-cc26xx/sensortag/opt-3001-sensor.h b/platform/srf06-cc26xx/sensortag/opt-3001-sensor.h index a4160b729..e9fa379a4 100644 --- a/platform/srf06-cc26xx/sensortag/opt-3001-sensor.h +++ b/platform/srf06-cc26xx/sensortag/opt-3001-sensor.h @@ -53,7 +53,7 @@ * @{ * * \file - * Header file for the Sensortag-CC26xx Opt3001 light sensor + * Header file for the Sensortag Opt3001 light sensor */ /*---------------------------------------------------------------------------*/ #ifndef OPT_3001_SENSOR_H_ diff --git a/platform/srf06-cc26xx/sensortag/reed-relay.c b/platform/srf06-cc26xx/sensortag/reed-relay.c index 598bfd970..8cecad9d6 100644 --- a/platform/srf06-cc26xx/sensortag/reed-relay.c +++ b/platform/srf06-cc26xx/sensortag/reed-relay.c @@ -33,7 +33,7 @@ * @{ * * \file - * Driver for the Sensortag-CC26XX Reed Relay + * Driver for the Sensortag Reed Relay */ /*---------------------------------------------------------------------------*/ #include "contiki.h" diff --git a/platform/srf06-cc26xx/sensortag/reed-relay.h b/platform/srf06-cc26xx/sensortag/reed-relay.h index 3ec712719..0ed6dd819 100644 --- a/platform/srf06-cc26xx/sensortag/reed-relay.h +++ b/platform/srf06-cc26xx/sensortag/reed-relay.h @@ -41,7 +41,7 @@ * @{ * * \file - * Header file for the Sensortag-CC26XX Reed Relay + * Header file for the Sensortag Reed Relay */ /*---------------------------------------------------------------------------*/ #ifndef REED_RELAY_H diff --git a/platform/srf06-cc26xx/sensortag/sensor-common.h b/platform/srf06-cc26xx/sensortag/sensor-common.h index 977650d5e..7f2bab4f1 100644 --- a/platform/srf06-cc26xx/sensortag/sensor-common.h +++ b/platform/srf06-cc26xx/sensortag/sensor-common.h @@ -36,7 +36,7 @@ * @{ * * \file - * Header file for the Sensortag-CC26xx Common sensor utilities + * Header file for the Sensortag Common sensor utilities */ /*---------------------------------------------------------------------------*/ #ifndef SENSOR_H diff --git a/platform/srf06-cc26xx/sensortag/sensortag-sensors.c b/platform/srf06-cc26xx/sensortag/sensortag-sensors.c index bcd0fe367..26d08591d 100644 --- a/platform/srf06-cc26xx/sensortag/sensortag-sensors.c +++ b/platform/srf06-cc26xx/sensortag/sensortag-sensors.c @@ -33,7 +33,7 @@ * @{ * * \file - * Generic module controlling sensors on CC26XX Sensortag + * Generic module controlling sensors on Sensortags */ /*---------------------------------------------------------------------------*/ #include "contiki.h" diff --git a/platform/srf06-cc26xx/sensortag/tmp-007-sensor.c b/platform/srf06-cc26xx/sensortag/tmp-007-sensor.c index 1c462a0e0..fdbd975b1 100644 --- a/platform/srf06-cc26xx/sensortag/tmp-007-sensor.c +++ b/platform/srf06-cc26xx/sensortag/tmp-007-sensor.c @@ -33,7 +33,7 @@ * @{ * * \file - * Driver for the Sensortag-CC26xx TI TMP007 infrared thermophile sensor + * Driver for the Sensortag TI TMP007 infrared thermophile sensor */ /*---------------------------------------------------------------------------*/ #include "contiki-conf.h" diff --git a/platform/srf06-cc26xx/sensortag/tmp-007-sensor.h b/platform/srf06-cc26xx/sensortag/tmp-007-sensor.h index 10c96c8a0..5260c9152 100644 --- a/platform/srf06-cc26xx/sensortag/tmp-007-sensor.h +++ b/platform/srf06-cc26xx/sensortag/tmp-007-sensor.h @@ -56,7 +56,7 @@ * @{ * * \file - * Header file for the Sensortag-CC26xx TI TMP007 infrared thermophile sensor + * Header file for the Sensortag TI TMP007 infrared thermophile sensor */ /*---------------------------------------------------------------------------*/ #ifndef TMP_007_SENSOR_H_ From fd3d733e4b838297e96f1ae7160a1e5d7797cd69 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 6 Nov 2016 17:19:55 +0000 Subject: [PATCH 028/129] Add support for the CC1350 Launchpad --- platform/srf06-cc26xx/launchpad/board.c | 8 +- .../launchpad/cc1350/Makefile.cc1350 | 10 + .../srf06-cc26xx/launchpad/cc1350/board.h | 236 ++++++++++++++++++ .../srf06-cc26xx/launchpad/cc1350/rf-switch.c | 92 +++++++ .../launchpad/cc1350/tx-power-driver.c | 65 +++++ 5 files changed, 409 insertions(+), 2 deletions(-) create mode 100644 platform/srf06-cc26xx/launchpad/cc1350/Makefile.cc1350 create mode 100644 platform/srf06-cc26xx/launchpad/cc1350/board.h create mode 100644 platform/srf06-cc26xx/launchpad/cc1350/rf-switch.c create mode 100644 platform/srf06-cc26xx/launchpad/cc1350/tx-power-driver.c diff --git a/platform/srf06-cc26xx/launchpad/board.c b/platform/srf06-cc26xx/launchpad/board.c index 9779809ae..11a213cf1 100644 --- a/platform/srf06-cc26xx/launchpad/board.c +++ b/platform/srf06-cc26xx/launchpad/board.c @@ -41,6 +41,7 @@ #include "lpm.h" #include "ti-lib.h" #include "board-peripherals.h" +#include "rf-core/rf-switch.h" #include #include @@ -51,8 +52,8 @@ wakeup_handler(void) { /* Turn on the PERIPH PD */ ti_lib_prcm_power_domain_on(PRCM_DOMAIN_PERIPH); - while((ti_lib_prcm_power_domain_status(PRCM_DOMAIN_PERIPH) - != PRCM_DOMAIN_POWER_ON)); + while(ti_lib_prcm_power_domain_status(PRCM_DOMAIN_PERIPH) + != PRCM_DOMAIN_POWER_ON); } /*---------------------------------------------------------------------------*/ /* @@ -100,6 +101,9 @@ board_init() /* For unsupported peripherals, select a default pin configuration */ configure_unused_pins(); + /* Initialise the RF switch if present */ + rf_switch_init(); + /* Re-enable interrupt if initially enabled. */ if(!int_disabled) { ti_lib_int_master_enable(); diff --git a/platform/srf06-cc26xx/launchpad/cc1350/Makefile.cc1350 b/platform/srf06-cc26xx/launchpad/cc1350/Makefile.cc1350 new file mode 100644 index 000000000..0d1f65359 --- /dev/null +++ b/platform/srf06-cc26xx/launchpad/cc1350/Makefile.cc1350 @@ -0,0 +1,10 @@ +### Will allow the inclusion of the correct CPU makefile +CPU_FAMILY = cc13xx + +### Add to the source dirs +CONTIKI_TARGET_DIRS += launchpad/cc1350 + +BOARD_SOURCEFILES += rf-switch.c tx-power-driver.c + +### Include the common launchpad makefile +include $(PLATFORM_ROOT_DIR)/launchpad/Makefile.launchpad diff --git a/platform/srf06-cc26xx/launchpad/cc1350/board.h b/platform/srf06-cc26xx/launchpad/cc1350/board.h new file mode 100644 index 000000000..e645b8b0b --- /dev/null +++ b/platform/srf06-cc26xx/launchpad/cc1350/board.h @@ -0,0 +1,236 @@ +/* + * 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 launchpad-peripherals + * @{ + * + * \defgroup launchpad-cc1350-specific CC1350 LaunchPad Peripherals + * + * Defines related to the CC1350 LaunchPad + * + * This file provides connectivity information on LEDs, Buttons, UART and + * other peripherals + * + * This file is not meant to be modified by the user. + * @{ + * + * \file + * Header file with definitions related to the I/O connections on the TI + * CC1350 LaunchPad + * + * \note Do not include this file directly. It gets included by contiki-conf + * after all relevant directives have been set. + */ +/*---------------------------------------------------------------------------*/ +#ifndef BOARD_H_ +#define BOARD_H_ +/*---------------------------------------------------------------------------*/ +#include "ioc.h" +/*---------------------------------------------------------------------------*/ +/** + * \name LED configurations + * + * Those values are not meant to be modified by the user + * @{ + */ +/* Some files include leds.h before us, so we need to get rid of defaults in + * leds.h before we provide correct definitions */ +#undef LEDS_GREEN +#undef LEDS_YELLOW +#undef LEDS_RED +#undef LEDS_CONF_ALL + +#define LEDS_RED 1 +#define LEDS_GREEN 2 +#define LEDS_YELLOW LEDS_GREEN +#define LEDS_ORANGE LEDS_RED + +#define LEDS_CONF_ALL 3 + +/* Notify various examples that we have LEDs */ +#define PLATFORM_HAS_LEDS 1 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name LED IOID mappings + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_LED_1 IOID_6 +#define BOARD_IOID_LED_2 IOID_7 +#define BOARD_LED_1 (1 << BOARD_IOID_LED_1) +#define BOARD_LED_2 (1 << BOARD_IOID_LED_2) +#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2) +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name UART IOID mapping + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_UART_RX IOID_2 +#define BOARD_IOID_UART_TX IOID_3 +#define BOARD_IOID_UART_RTS IOID_18 +#define BOARD_IOID_UART_CTS IOID_19 +#define BOARD_UART_RX (1 << BOARD_IOID_UART_RX) +#define BOARD_UART_TX (1 << BOARD_IOID_UART_TX) +#define BOARD_UART_RTS (1 << BOARD_IOID_UART_RTS) +#define BOARD_UART_CTS (1 << BOARD_IOID_UART_CTS) +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name Button IOID mapping + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_KEY_LEFT IOID_13 +#define BOARD_IOID_KEY_RIGHT IOID_14 +#define BOARD_KEY_LEFT (1 << BOARD_IOID_KEY_LEFT) +#define BOARD_KEY_RIGHT (1 << BOARD_IOID_KEY_RIGHT) +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief SPI IOID mappings + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_SPI_MOSI IOID_9 +#define BOARD_IOID_SPI_MISO IOID_8 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name External flash IOID mapping + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_FLASH_CS IOID_20 +#define BOARD_FLASH_CS (1 << BOARD_IOID_FLASH_CS) +#define BOARD_IOID_SPI_CLK_FLASH IOID_10 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief I2C IOID mappings + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_SCL IOID_4 +#define BOARD_IOID_SDA IOID_5 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief CC1350LP RF Switch + * + * Those values are not meant to be modified by the user + * @{ + */ +#define RF_SWITCH_CONF_ENABLE 1 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief TX power settings + * + * Those values are not meant to be modified by the user + * @{ + */ +#define PROP_MODE_CONF_TX_POWER_779_930 tx_power_driver_779_930 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief ROM bootloader configuration + * + * Change SET_CCFG_BL_CONFIG_BL_PIN_NUMBER to BOARD_IOID_KEY_xyz to select + * which button triggers the bootloader on reset. + * + * The remaining values are not meant to be modified by the user + * @{ + */ +#if ROM_BOOTLOADER_ENABLE +#define SET_CCFG_BL_CONFIG_BOOTLOADER_ENABLE 0xC5 +#define SET_CCFG_BL_CONFIG_BL_LEVEL 0x00 +#define SET_CCFG_BL_CONFIG_BL_PIN_NUMBER BOARD_IOID_KEY_LEFT +#define SET_CCFG_BL_CONFIG_BL_ENABLE 0xC5 +#else +#define SET_CCFG_BL_CONFIG_BOOTLOADER_ENABLE 0x00 +#define SET_CCFG_BL_CONFIG_BL_LEVEL 0x01 +#define SET_CCFG_BL_CONFIG_BL_PIN_NUMBER 0xFF +#define SET_CCFG_BL_CONFIG_BL_ENABLE 0xFF +#endif +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \brief Remaining pins + * + * Those values are not meant to be modified by the user + * @{ + */ +#define BOARD_IOID_CS IOID_11 +#define BOARD_IOID_TDO IOID_16 +#define BOARD_IOID_TDI IOID_17 +#define BOARD_IOID_DIO12 IOID_12 +#define BOARD_IOID_DIO15 IOID_15 +#define BOARD_IOID_DIO21 IOID_21 +#define BOARD_IOID_DIO22 IOID_22 +#define BOARD_IOID_DIO23 IOID_23 +#define BOARD_IOID_DIO24 IOID_24 +#define BOARD_IOID_DIO25 IOID_25 +#define BOARD_IOID_DIO26 IOID_26 +#define BOARD_IOID_DIO27 IOID_27 +#define BOARD_IOID_DIO28 IOID_28 +#define BOARD_IOID_DIO29 IOID_29 +#define BOARD_IOID_DIO30 IOID_30 + +#define BOARD_UNUSED_PINS { \ + BOARD_IOID_CS, BOARD_IOID_TDO, BOARD_IOID_TDI, BOARD_IOID_DIO12, \ + BOARD_IOID_DIO15, BOARD_IOID_DIO21, BOARD_IOID_DIO22, BOARD_IOID_DIO23, \ + BOARD_IOID_DIO24, BOARD_IOID_DIO25, BOARD_IOID_DIO26, BOARD_IOID_DIO27, \ + BOARD_IOID_DIO28, BOARD_IOID_DIO29, \ + IOID_UNUSED \ + } +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name Device string used on startup + * @{ + */ +#define BOARD_STRING "TI CC1350 LaunchPad" +/** @} */ +/*---------------------------------------------------------------------------*/ +#endif /* BOARD_H_ */ +/*---------------------------------------------------------------------------*/ +/** + * @} + * @} + */ diff --git a/platform/srf06-cc26xx/launchpad/cc1350/rf-switch.c b/platform/srf06-cc26xx/launchpad/cc1350/rf-switch.c new file mode 100644 index 000000000..3e0ccff0e --- /dev/null +++ b/platform/srf06-cc26xx/launchpad/cc1350/rf-switch.c @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2015, 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-switch + * @{ + * + * \file + * CC1350 LP RF switch driver + */ +/*---------------------------------------------------------------------------*/ +#include "contiki-conf.h" +#include "lpm.h" +#include "rf-core/rf-switch.h" +#include "ti-lib.h" + +#include +#include +#include +/*---------------------------------------------------------------------------*/ +#define POWER_PIN IOID_30 +#define SELECT_PIN IOID_1 +/*---------------------------------------------------------------------------*/ +static void +shutdown_handler(uint8_t mode) +{ + ti_lib_gpio_clear_dio(POWER_PIN); +} +/*---------------------------------------------------------------------------*/ +/* + * Declare a data structure to register with LPM. Always turn off the switch + * when we are dropping to deep sleep. We let the RF driver turn it on though. + */ +LPM_MODULE(rf_switch_module, NULL, shutdown_handler, NULL, LPM_DOMAIN_NONE); +/*---------------------------------------------------------------------------*/ +void +rf_switch_init() +{ + ti_lib_rom_ioc_pin_type_gpio_output(POWER_PIN); + ti_lib_gpio_clear_dio(POWER_PIN); + ti_lib_rom_ioc_pin_type_gpio_output(SELECT_PIN); + ti_lib_gpio_clear_dio(SELECT_PIN); + + lpm_register_module(&rf_switch_module); +} +/*---------------------------------------------------------------------------*/ +void +rf_switch_power_up() +{ + ti_lib_gpio_set_dio(POWER_PIN); +} +/*---------------------------------------------------------------------------*/ +void +rf_switch_power_down() +{ + ti_lib_gpio_clear_dio(POWER_PIN); +} +/*---------------------------------------------------------------------------*/ +void +rf_switch_select_path(uint8_t path) +{ + ti_lib_gpio_write_dio(SELECT_PIN, path); +} +/*---------------------------------------------------------------------------*/ +/** @} */ diff --git a/platform/srf06-cc26xx/launchpad/cc1350/tx-power-driver.c b/platform/srf06-cc26xx/launchpad/cc1350/tx-power-driver.c new file mode 100644 index 000000000..d39556a51 --- /dev/null +++ b/platform/srf06-cc26xx/launchpad/cc1350/tx-power-driver.c @@ -0,0 +1,65 @@ +/* + * 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-prop + * @{ + * + * \file + * TX power settings for the CC1350 LP + */ +/*---------------------------------------------------------------------------*/ +#include "contiki-conf.h" +#include "dev/radio.h" +#include "rf-core/prop-mode.h" +/*---------------------------------------------------------------------------*/ +/* TX power settings for the 779-930MHz band */ +const prop_mode_tx_power_config_t tx_power_driver_779_930[] = { + { 14, 0xab3f }, + { 12, 0xbc2b }, + { 11, 0x90e5 }, + { 10, 0x58d8 }, + { 9, 0x40d2 }, + { 8, 0x32ce }, + { 7, 0x2acb }, + { 6, 0x24c9 }, + { 5, 0x20c8 }, + { 4, 0x1844 }, + { 3, 0x1cc6 }, + { 2, 0x18c5 }, + { 1, 0x16c4 }, + { 0, 0x12c3 }, + { -10, 0x04c0 }, + {-128, 0xFFFF }, +}; +/*---------------------------------------------------------------------------*/ +/** + * @} + */ From 08439a878d9e8b731b92334d8d66f70a35422756 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 5 Nov 2016 18:47:45 +0000 Subject: [PATCH 029/129] Add travis tests for CC1350 boards --- regression-tests/18-compile-arm-ports/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/regression-tests/18-compile-arm-ports/Makefile b/regression-tests/18-compile-arm-ports/Makefile index a5bbb1e34..69cf33000 100644 --- a/regression-tests/18-compile-arm-ports/Makefile +++ b/regression-tests/18-compile-arm-ports/Makefile @@ -9,9 +9,11 @@ ipv6/multicast/ev-aducrf101mkxz \ cc26xx/cc26xx-web-demo/srf06-cc26xx \ cc26xx/very-sleepy-demo/srf06-cc26xx:BOARD=sensortag/cc2650 \ cc26xx/cc26xx-web-demo/srf06-cc26xx:BOARD=sensortag/cc2650 \ +cc26xx/cc26xx-web-demo/srf06-cc26xx:BOARD=sensortag/cc1350 \ cc26xx/cc26xx-web-demo/srf06-cc26xx:BOARD=srf06/cc13xx \ cc26xx/cc26xx-web-demo/srf06-cc26xx:BOARD=launchpad/cc2650 \ cc26xx/cc26xx-web-demo/srf06-cc26xx:BOARD=launchpad/cc1310 \ +cc26xx/cc26xx-web-demo/srf06-cc26xx:BOARD=launchpad/cc1350 \ cc26xx/very-sleepy-demo/srf06-cc26xx \ hello-world/cc2538dk \ ipv6/rpl-border-router/cc2538dk \ From a6b14a0731500dc1ce5fb4d61ed991a694bb173d Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 6 Nov 2016 17:18:30 +0000 Subject: [PATCH 030/129] Add documentation for the new boards --- examples/cc26xx/cc26xx-demo.c | 17 ++++------------- examples/cc26xx/very-sleepy-demo/README.md | 2 +- platform/srf06-cc26xx/README.md | 6 +++++- platform/srf06-cc26xx/contiki-main.c | 6 ++++-- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/examples/cc26xx/cc26xx-demo.c b/examples/cc26xx/cc26xx-demo.c index 50d2190d3..f5045a5bd 100644 --- a/examples/cc26xx/cc26xx-demo.c +++ b/examples/cc26xx/cc26xx-demo.c @@ -39,21 +39,12 @@ * * \defgroup cc26xx-demo CC26xx Demo Project * - * Example project demonstrating the CC26xx platforms + * Example project demonstrating the CC13xx/CC26xx platforms * * This example will work for the following boards: - * - srf06-cc26xx: SmartRF06EB + CC26XX EM - * - sensortag-cc26xx: CC26XX sensortag - * - The CC2650 LaunchPad - * - * By default, the example will build for the srf06-cc26xx board. To switch - * between platforms: - * - make clean - * - make BOARD=sensortag-cc26xx savetarget - * - * or - * - * make BOARD=srf06-cc26xx savetarget + * - srf06-cc26xx: SmartRF06EB + CC13xx/CC26xx EM + * - CC2650 and CC1350 SensorTag + * - CC1310, CC1350, CC2650 LaunchPads * * This is an IPv6/RPL-enabled example. Thus, if you have a border router in * your installation (same RDC layer, same PAN ID and RF channel), you should diff --git a/examples/cc26xx/very-sleepy-demo/README.md b/examples/cc26xx/very-sleepy-demo/README.md index fcdedf77f..851150432 100644 --- a/examples/cc26xx/very-sleepy-demo/README.md +++ b/examples/cc26xx/very-sleepy-demo/README.md @@ -23,7 +23,7 @@ as per the instructions below. When the node is duty-cycling the radio, either because it is in normal mode or because network maintenance is taking place, it will keep its green LED on thus -providing an indication that it is reachable. +providing an indication that it is reachable (red LED for the CC1350 tag). A normal mode stint can be manually triggered by pressing the left button. diff --git a/platform/srf06-cc26xx/README.md b/platform/srf06-cc26xx/README.md index b95f3e9cd..ae8645426 100644 --- a/platform/srf06-cc26xx/README.md +++ b/platform/srf06-cc26xx/README.md @@ -2,13 +2,15 @@ Getting Started with Contiki for TI CC26xx ========================================== This guide's aim is to help you start using Contiki for TI's CC26xx. The -platform supports two different boards: +platform supports multiple boards: * SmartRF 06 Evaluation Board with a CC26xx or CC13xx Evaluation Module (relevant files and drivers are under `srf06/`) * CC2650 SensorTag 2.0 (relevant drivers under `sensortag/cc2650`) +* CC1350 SensorTag 2.0 (relevant drivers under `sensortag/cc1350`) * CC2650 LaunchPad (relevant drivers under `launchpad/cc2650`) * CC1310 LaunchPad (relevant drivers under `launchpad/cc1310`) +* CC1350 LaunchPad (relevant drivers under `launchpad/cc1350`) The CPU code, common for both platforms, can be found under `$(CONTIKI)/cpu/cc26xx-cc13xx`. The port was developed and tested with CC2650s, but the intention is for it to @@ -100,8 +102,10 @@ Other options for the `BOARD` make variable are: * Srf06+CC26xxEM: Set `BOARD=srf06/cc26xx` * Srf06+CC13xxEM: Set `BOARD=srf06/cc13xx` * CC2650 tag: Set `BOARD=sensortag/cc2650` +* CC1350 tag: Set `BOARD=sensortag/cc1350` * CC2650 Launchpad: Set `BOARD=launchpad/cc2650` * CC1310 Launchpad: Set `BOARD=launchpad/cc1310` +* CC1350 Launchpad: Set `BOARD=launchpad/cc1350` If the `BOARD` variable is unspecified, an image for the Srf06 CC26XXEM will be built. diff --git a/platform/srf06-cc26xx/contiki-main.c b/platform/srf06-cc26xx/contiki-main.c index 0aa1c4526..78b10d0df 100644 --- a/platform/srf06-cc26xx/contiki-main.c +++ b/platform/srf06-cc26xx/contiki-main.c @@ -32,14 +32,16 @@ * \addtogroup cc26xx-platforms * @{ * - * \defgroup cc26xx-srf-tag SmartRF+CC13xx/CC26xx EM, CC2650 SensorTag and LaunchPads + * \defgroup cc26xx-srf-tag SmartRF+CC13xx/CC26xx EM, SensorTags and LaunchPads * * This platform supports a number of different boards: * - A standard TI SmartRF06EB with a CC26xx EM mounted on it * - A standard TI SmartRF06EB with a CC1310 EM mounted on it - * - The new TI SensorTag2.0 + * - The TI CC2650 SensorTag + * - The TI CC1350 SensorTag * - The TI CC2650 LaunchPad * - The TI CC1310 LaunchPad + * - The TI CC1350 LaunchPad * @{ */ #include "ti-lib.h" From 1a993da8fcf71535e65ec64cadc54cf2727c2d21 Mon Sep 17 00:00:00 2001 From: Pere Tuset Date: Thu, 29 Dec 2016 12:09:07 +0100 Subject: [PATCH 031/129] Add support for automatic bootloading with the cc2538-bsl.py script on the OpenUSB carrier board. --- platform/openmote-cc2538/Makefile.openmote-cc2538 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/openmote-cc2538/Makefile.openmote-cc2538 b/platform/openmote-cc2538/Makefile.openmote-cc2538 index 3439a3211..156599494 100644 --- a/platform/openmote-cc2538/Makefile.openmote-cc2538 +++ b/platform/openmote-cc2538/Makefile.openmote-cc2538 @@ -31,7 +31,7 @@ MODULES += core/net core/net/mac \ core/net/llsec core/net/llsec/noncoresec PYTHON = python -BSL_FLAGS += -e -w -v -b 450000 +BSL_FLAGS += -e --bootloader-invert-lines -w -v -b 500000 ifdef PORT BSL_FLAGS += -p $(PORT) From b72110fe8a2348911fe13bf2110c8740aba49f2f Mon Sep 17 00:00:00 2001 From: Pere Tuset Date: Thu, 29 Dec 2016 12:10:21 +0100 Subject: [PATCH 032/129] Add support for the OpenMote-CC2538 Rev.A1 board that uses the CC2538SF23 (256 KB) chip instead of the CC2538SF53 (512 KB) chip. --- platform/openmote-cc2538/Makefile.openmote-cc2538 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform/openmote-cc2538/Makefile.openmote-cc2538 b/platform/openmote-cc2538/Makefile.openmote-cc2538 index 156599494..ef891fe3c 100644 --- a/platform/openmote-cc2538/Makefile.openmote-cc2538 +++ b/platform/openmote-cc2538/Makefile.openmote-cc2538 @@ -1,5 +1,10 @@ # openmote-cc2538 platform makefile +### Allow the OpenMote-CC2538 platform to support different CC2538 chip revisions +ifeq ($(findstring REV_A1,$(BOARD_REVISION)),REV_A1) + CFLAGS+=-DCC2538_DEV_CONF=CC2538_DEV_CC2538SF23 +endif + ifndef CONTIKI $(error CONTIKI not defined! You must specify where CONTIKI resides!) endif From 93828d867e0803420f897f8924485032e393dec5 Mon Sep 17 00:00:00 2001 From: Pere Tuset Date: Thu, 29 Dec 2016 12:30:58 +0100 Subject: [PATCH 033/129] Updated OpenMote-CC2538 README.md file with new features. --- platform/openmote-cc2538/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platform/openmote-cc2538/README.md b/platform/openmote-cc2538/README.md index 2f3ee7d07..88bcaa210 100644 --- a/platform/openmote-cc2538/README.md +++ b/platform/openmote-cc2538/README.md @@ -1,6 +1,6 @@ OpenMote-CC2538 platform ======================== -The OpenMote-CC2538 is based on TI's CC2538 SoC (System on Chip), featuring an ARM Cortex-M3 running at 16/32 MHz and with 32 kbytes of RAM and 512 kbytes of FLASH. It has the following key features: +The OpenMote-CC2538 is based on TI's CC2538 SoC (System on Chip), featuring an ARM Cortex-M3 running at 16/32 MHz and with 32 kbytes of RAM and 256/512 kbytes of FLASH. It has the following key features: * Standard Cortex M3 peripherals (NVIC, SCB, SysTick) * Sleep Timer (underpins rtimers) @@ -24,7 +24,7 @@ Requirements ============ To start using Contiki with the OpenMote-CC2538, the following is required: - * An OpenMote-CC2538 board. + * An OpenMote-CC2538 board with a OpenUSB, OpenBase or OpenBattery carrier boards. * A toolchain to compile Contiki for the CC2538. * Drivers so that your OS can communicate with your hardware. * Software to upload images to the CC2538. @@ -47,7 +47,7 @@ The OpenMote-CC2538 can be programmed via the jtag interface or via the serial b The OpenMote-CC2538 has a mini JTAG 10-pin male header, compatible with the `SmartRF06` development board, which can be used to flash and debug the platforms. Alternatively one could use the `JLink` programmer with a 20-to-10 pin converter like the following: . -The serial boot loader on the chip is exposed to the user via the USB interface. To activate the bootloader short the ON/SLEEP pin to GND and then press the reset button. +The serial boot loader on the chip is exposed to the user via the USB interface of both the OpenUSB and the OpenBase carrier boards. The OpenUSB carrier board is capable to automatically detect the boot loader sequence and flash the CC2538 without user intervention. The OpenBase carrier board does not have such feature, so to activate the bootloader the user needs to short the ON/SLEEP pin to GND and then press the reset button. Instructions to flash for different OS are given below. @@ -88,6 +88,8 @@ If you want to upload the compiled firmware to a node via the serial boot loader Then use `make openmote-demo.upload`. +If you are compiling for the OpenMote-CC2538 Rev.A1 board (CC2538SF53, 256 KB Flash) you have to pass `BOARD_REVISION=REV_A1` in all your `make` commands to ensure that the linking stage configures the linker script with the appropriate parameters. If you are compiling for older OpenMote-CC2538 revisions (CC2538SF53, 512 KB Flash) you can skip this parameter since the default values are already correct. + The `PORT` argument could be used to specify in which port the device is connected, in case we have multiple devices connected at the same time. To generate an assembly listing of the compiled firmware, run `make openmote-demo.lst`. This may be useful for debugging or optimizing your application code. To intersperse the C source code within the assembly listing, you must instruct the compiler to include debugging information by adding `CFLAGS += -g` to the project Makefile and rebuild by running `make clean openmote-demo.lst`. From 361cb612a7db3c885bd2789b11e17a4303a1a93d Mon Sep 17 00:00:00 2001 From: Pere Tuset Date: Tue, 10 Jan 2017 10:59:06 +0100 Subject: [PATCH 034/129] Reduce bootloader baudrate to be on the safe side. --- platform/openmote-cc2538/Makefile.openmote-cc2538 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/openmote-cc2538/Makefile.openmote-cc2538 b/platform/openmote-cc2538/Makefile.openmote-cc2538 index ef891fe3c..48ace1fc5 100644 --- a/platform/openmote-cc2538/Makefile.openmote-cc2538 +++ b/platform/openmote-cc2538/Makefile.openmote-cc2538 @@ -36,7 +36,7 @@ MODULES += core/net core/net/mac \ core/net/llsec core/net/llsec/noncoresec PYTHON = python -BSL_FLAGS += -e --bootloader-invert-lines -w -v -b 500000 +BSL_FLAGS += -e --bootloader-invert-lines -w -v -b 450000 ifdef PORT BSL_FLAGS += -p $(PORT) From 0da6e128ebc727e8fd44cdb15bf01b5ccf2743f2 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Sun, 12 Apr 2015 09:51:18 +0200 Subject: [PATCH 035/129] Remove servername from DHCP request --- core/net/ip64/ip64-dhcpc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/core/net/ip64/ip64-dhcpc.c b/core/net/ip64/ip64-dhcpc.c index 1ed3ac249..eda46bece 100644 --- a/core/net/ip64/ip64-dhcpc.c +++ b/core/net/ip64/ip64-dhcpc.c @@ -163,7 +163,6 @@ create_msg(CC_REGISTER_ARG struct dhcp_msg *m) memset(&m->chaddr[s.mac_len], 0, sizeof(m->chaddr) - s.mac_len); memset(m->sname, 0, sizeof(m->sname)); - strcpy((char *)m->sname, "Thingsquare"); memset(m->file, 0, sizeof(m->file)); From 37fe6a2fa6efda4e17db4e7e46a0fc7838de79b1 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 25 Mar 2016 12:33:45 +0100 Subject: [PATCH 036/129] Use uip-debug in ip64-ipv4-dhcp.c --- core/net/ip64/ip64-ipv4-dhcp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/net/ip64/ip64-ipv4-dhcp.c b/core/net/ip64/ip64-ipv4-dhcp.c index ab8c6a517..a8de88b6f 100644 --- a/core/net/ip64/ip64-ipv4-dhcp.c +++ b/core/net/ip64/ip64-ipv4-dhcp.c @@ -39,6 +39,9 @@ #include +#define DEBUG DEBUG_NONE +#include "net/ip/uip-debug.h" + PROCESS(ip64_ipv4_dhcp_process, "IPv4 DHCP"); uip_ipaddr_t uip_hostaddr; /* Needed because it is referenced by dhcpc.c */ @@ -48,7 +51,7 @@ uip_ipaddr_t uip_hostaddr; /* Needed because it is referenced by dhcpc.c */ void ip64_ipv4_dhcp_init(void) { - printf("Starting DHCPv4\n"); + printf("IP64: Starting DHCPv4\n"); process_start(&ip64_ipv4_dhcp_process, NULL); } /*---------------------------------------------------------------------------*/ @@ -58,10 +61,10 @@ PROCESS_THREAD(ip64_ipv4_dhcp_process, ev, data) ip64_dhcpc_init(&ip64_eth_addr, sizeof(ip64_eth_addr)); - printf("Inited\n"); + PRINTF("IP64: Inited\n"); ip64_dhcpc_request(); - printf("Requested\n"); + PRINTF("IP64: Requested\n"); while(1) { PROCESS_WAIT_EVENT(); @@ -78,7 +81,7 @@ void ip64_dhcpc_configured(const struct ip64_dhcpc_state *s) { uip_ip6addr_t ip6dnsaddr; - printf("DHCP Configured with %d.%d.%d.%d\n", + PRINTF("IP64: DHCP Configured with %d.%d.%d.%d\n", s->ipaddr.u8[0], s->ipaddr.u8[1], s->ipaddr.u8[2], s->ipaddr.u8[3]); From 10be59cc15a57ff4d6d0050f9fa816f469d64237 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Mon, 14 Mar 2016 14:47:38 +0100 Subject: [PATCH 037/129] Update nameserver using DHCP info --- core/net/ip64/ip64-ipv4-dhcp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/net/ip64/ip64-ipv4-dhcp.c b/core/net/ip64/ip64-ipv4-dhcp.c index a8de88b6f..a22c9f903 100644 --- a/core/net/ip64/ip64-ipv4-dhcp.c +++ b/core/net/ip64/ip64-ipv4-dhcp.c @@ -88,8 +88,15 @@ ip64_dhcpc_configured(const struct ip64_dhcpc_state *s) ip64_set_hostaddr((uip_ip4addr_t *)&s->ipaddr); ip64_set_netmask((uip_ip4addr_t *)&s->netmask); ip64_set_draddr((uip_ip4addr_t *)&s->default_router); - ip64_addr_4to6((uip_ip4addr_t *)&s->dnsaddr, &ip6dnsaddr); - // mdns_conf(&ip6dnsaddr); + if(!uip_ip4addr_cmp((uip_ip4addr_t *)&s->dnsaddr, &uip_all_zeroes_addr)) { + /* Note: Currently we assume only one DNS server */ + uip_ipaddr_t * dns = uip_nameserver_get(0); + /* Only update DNS entry if it is empty or already IPv4 */ + if(uip_is_addr_unspecified(dns) || ip64_addr_is_ip64(dns)) { + ip64_addr_4to6((uip_ip4addr_t *)&s->dnsaddr, &ip6dnsaddr); + uip_nameserver_update(&ip6dnsaddr, uip_ntohs(s->lease_time[0])*65536ul + uip_ntohs(s->lease_time[1])); + } + } } /*---------------------------------------------------------------------------*/ void From e5a604552e8a3d3deac0c4aa313c413e87a5d790 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 11 Mar 2016 11:45:31 +0100 Subject: [PATCH 038/129] Allow modification of IP64 prefix --- core/net/ip/ip64-addr.c | 48 ++++++++++++++++------------------------- core/net/ip/ip64-addr.h | 3 +++ 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/core/net/ip/ip64-addr.c b/core/net/ip/ip64-addr.c index 4d1fa378e..38ae04f1f 100644 --- a/core/net/ip/ip64-addr.c +++ b/core/net/ip/ip64-addr.c @@ -35,6 +35,10 @@ #include #define printf(...) + +static uip_ip6addr_t ip64_prefix = {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0, 0, 0, 0}}; +static uint8_t ip64_prefix_len = 96; + /*---------------------------------------------------------------------------*/ void ip64_addr_copy4(uip_ip4addr_t *dest, const uip_ip4addr_t *src) @@ -56,20 +60,7 @@ ip64_addr_4to6(const uip_ip4addr_t *ipv4addr, addresses. It returns 0 if it failed to convert the address and non-zero if it could successfully convert the address. */ - /* The IPv4 address is encoded as an IPv6-encoded IPv4 address in - the ::ffff:0000/24 prefix.*/ - ipv6addr->u8[0] = 0; - ipv6addr->u8[1] = 0; - ipv6addr->u8[2] = 0; - ipv6addr->u8[3] = 0; - ipv6addr->u8[4] = 0; - ipv6addr->u8[5] = 0; - ipv6addr->u8[6] = 0; - ipv6addr->u8[7] = 0; - ipv6addr->u8[8] = 0; - ipv6addr->u8[9] = 0; - ipv6addr->u8[10] = 0xff; - ipv6addr->u8[11] = 0xff; + uip_ipaddr_copy(ipv6addr, &ip64_prefix); ipv6addr->u8[12] = ipv4addr->u8[0]; ipv6addr->u8[13] = ipv4addr->u8[1]; ipv6addr->u8[14] = ipv4addr->u8[2]; @@ -90,21 +81,7 @@ ip64_addr_6to4(const uip_ip6addr_t *ipv6addr, returns 0 if it failed to convert the address and non-zero if it could successfully convert the address. */ - /* If the IPv6 address is an IPv6-encoded - IPv4 address (i.e. in the ::ffff:0/8 prefix), we simply use the - IPv4 addresses directly. */ - if(ipv6addr->u8[0] == 0 && - ipv6addr->u8[1] == 0 && - ipv6addr->u8[2] == 0 && - ipv6addr->u8[3] == 0 && - ipv6addr->u8[4] == 0 && - ipv6addr->u8[5] == 0 && - ipv6addr->u8[6] == 0 && - ipv6addr->u8[7] == 0 && - ipv6addr->u8[8] == 0 && - ipv6addr->u8[9] == 0 && - ipv6addr->u8[10] == 0xff && - ipv6addr->u8[11] == 0xff) { + if(ip64_addr_is_ip64(ipv6addr)) { ipv4addr->u8[0] = ipv6addr->u8[12]; ipv4addr->u8[1] = ipv6addr->u8[13]; ipv4addr->u8[2] = ipv6addr->u8[14]; @@ -121,3 +98,16 @@ ip64_addr_6to4(const uip_ip6addr_t *ipv6addr, return 0; } /*---------------------------------------------------------------------------*/ +int +ip64_addr_is_ip64(const uip_ip6addr_t *ipv6addr) +{ + return uip_ipaddr_prefixcmp(ipv6addr, &ip64_prefix, ip64_prefix_len); +} +/*---------------------------------------------------------------------------*/ +void +ip64_addr_set_prefix(const uip_ip6addr_t *prefix, uint8_t prefix_len) +{ + uip_ipaddr_copy(&ip64_prefix, prefix); + ip64_prefix_len = prefix_len; +} +/*---------------------------------------------------------------------------*/ diff --git a/core/net/ip/ip64-addr.h b/core/net/ip/ip64-addr.h index 3027d846a..67f71b635 100644 --- a/core/net/ip/ip64-addr.h +++ b/core/net/ip/ip64-addr.h @@ -58,6 +58,9 @@ int ip64_addr_6to4(const uip_ip6addr_t *ipv6addr, int ip64_addr_4to6(const uip_ip4addr_t *ipv4addr, uip_ip6addr_t *ipv6addr); +int ip64_addr_is_ip64(const uip_ip6addr_t *ipv6addr); + +void ip64_addr_set_prefix(const uip_ip6addr_t *prefix, uint8_t prefix_len); #endif /* IP64_ADDR_H */ From cd1bcb101d578aebfc18e6ea9ea6a0b9cbf634ce Mon Sep 17 00:00:00 2001 From: Atis Elsts Date: Thu, 26 Jan 2017 13:23:30 +0000 Subject: [PATCH 039/129] CC26xx IEEE mode radio: fix reading lqi --- cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index f76fe2beb..d1e7ab7f9 100644 --- a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -103,8 +103,9 @@ #define IEEE_MODE_RSSI_THRESHOLD 0xA6 #endif /* IEEE_MODE_CONF_RSSI_THRESHOLD */ /*---------------------------------------------------------------------------*/ -#define STATUS_CRC_OK 0x80 -#define STATUS_CORRELATION 0x7f +#define STATUS_CRC_FAIL 0x80 /* bit 7 */ +#define STATUS_REJECT_FRAME 0x40 /* bit 6 */ +#define STATUS_CORRELATION 0x3f /* bits 0-5 */ /*---------------------------------------------------------------------------*/ /* Data entry status field constants */ #define DATA_ENTRY_STATUS_PENDING 0x00 /* Not in use by the Radio CPU */ @@ -1057,7 +1058,7 @@ read_frame(void *buf, unsigned short buf_len) memcpy(buf, (char *)&rx_read_entry[9], len); last_rssi = (int8_t)rx_read_entry[9 + len + 2]; - last_corr_lqi = (uint8_t)rx_read_entry[9 + len + 2] & STATUS_CORRELATION; + last_corr_lqi = (uint8_t)rx_read_entry[9 + len + 3] & STATUS_CORRELATION; /* get the timestamp */ memcpy(&rat_timestamp, (char *)rx_read_entry + 9 + len + 4, 4); From 6463c91a4f310c525e36bcd398b0cff25bc0b028 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 5 Feb 2017 23:14:52 +0100 Subject: [PATCH 040/129] Removed artifacts of former uip_appdata handling. Adam Dunkels writes on 2/5/2017 on the Contiki mailing list: [...] the original idea was that the application could just point the uip_appdata pointer to wherever the data was, but we then changed it so that the data actually had to be copied into the uip_aligned_buf buffer. So, yes, the network device driver should only need to read from this buffer. [...] This change removes comments on the possibility of uip_appdata pointing somewhere outside the uip_aligned_buf. And it removes code in the SLIP drivers not necessary anymore. Additionally it makes code in a SLIP driver optional that takes care of the Microsoft-specific CLIENT / SERVER / CLIENTSERVER chat. --- core/dev/slip.c | 6 +++--- core/net/ip/slipdev.c | 3 --- core/net/ip/uip.h | 22 ++-------------------- core/net/ip/uip_arch.h | 4 ---- platform/jn516x/lib/slip.c | 3 --- tools/sky/uip6-bridge/dev/slip.c | 3 --- tools/stm32w/uip6_bridge/dev/slip.c | 3 --- 7 files changed, 5 insertions(+), 39 deletions(-) diff --git a/core/dev/slip.c b/core/dev/slip.c index 299c78e3f..fe5a58046 100644 --- a/core/dev/slip.c +++ b/core/dev/slip.c @@ -107,9 +107,6 @@ slip_send(void) ptr = &uip_buf[UIP_LLH_LEN]; for(i = 0; i < uip_len; ++i) { - if(i == UIP_TCPIP_HLEN) { - ptr = (uint8_t *)uip_appdata; - } c = *ptr++; if(c == SLIP_END) { slip_arch_writeb(SLIP_ESC); @@ -161,6 +158,7 @@ rxbuf_init(void) static uint16_t slip_poll_handler(uint8_t *outbuf, uint16_t blen) { +#ifdef SLIP_CONF_MICROSOFT_CHAT /* This is a hack and won't work across buffer edge! */ if(rxbuf[begin] == 'C') { int i; @@ -177,6 +175,8 @@ slip_poll_handler(uint8_t *outbuf, uint16_t blen) return 0; } } +#endif /* SLIP_CONF_MICROSOFT_CHAT */ + #ifdef SLIP_CONF_ANSWER_MAC_REQUEST else if(rxbuf[begin] == '?') { /* Used by tapslip6 to request mac for auto configure */ diff --git a/core/net/ip/slipdev.c b/core/net/ip/slipdev.c index 8bc688557..3ef4e3cc8 100644 --- a/core/net/ip/slipdev.c +++ b/core/net/ip/slipdev.c @@ -102,9 +102,6 @@ slipdev_send(void) ptr = &uip_buf[UIP_LLH_LEN]; for(i = 0; i < uip_len; ++i) { - if(i == UIP_TCPIP_HLEN) { - ptr = (uint8_t *)uip_appdata; - } c = *ptr++; switch(c) { case SLIP_END: diff --git a/core/net/ip/uip.h b/core/net/ip/uip.h index dd41b25f0..c120ad90e 100755 --- a/core/net/ip/uip.h +++ b/core/net/ip/uip.h @@ -490,26 +490,8 @@ void uip_reass_over(void); * * The uip_aligned_buf array is used to hold incoming and outgoing * packets. The device driver should place incoming data into this - * buffer. When sending data, the device driver should read the link - * level headers and the TCP/IP headers from this buffer. The size of - * the link level headers is configured by the UIP_LLH_LEN define. - * - * \note The application data need not be placed in this buffer, so - * the device driver must read it from the place pointed to by the - * uip_appdata pointer as illustrated by the following example: - \code - void - devicedriver_send(void) - { - hwsend(&uip_buf[0], UIP_LLH_LEN); - if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) { - hwsend(&uip_buf[UIP_LLH_LEN], uip_len - UIP_LLH_LEN); - } else { - hwsend(&uip_buf[UIP_LLH_LEN], UIP_TCPIP_HLEN); - hwsend(uip_appdata, uip_len - UIP_TCPIP_HLEN - UIP_LLH_LEN); - } - } - \endcode + * buffer. When sending data, the device driver should read the + * outgoing data from this buffer. */ typedef union { diff --git a/core/net/ip/uip_arch.h b/core/net/ip/uip_arch.h index 352a39711..77a27684c 100644 --- a/core/net/ip/uip_arch.h +++ b/core/net/ip/uip_arch.h @@ -120,10 +120,6 @@ uint16_t uip_ipchksum(void); * The TCP checksum is the Internet checksum of data contents of the * TCP segment, and a pseudo-header as defined in RFC793. * - * \note The uip_appdata pointer that points to the packet data may - * point anywhere in memory, so it is not possible to simply calculate - * the Internet checksum of the contents of the uip_buf buffer. - * * \return The TCP checksum of the TCP segment in uip_buf and pointed * to by uip_appdata. */ diff --git a/platform/jn516x/lib/slip.c b/platform/jn516x/lib/slip.c index 31828e7e3..88272a75a 100644 --- a/platform/jn516x/lib/slip.c +++ b/platform/jn516x/lib/slip.c @@ -200,9 +200,6 @@ slip_send(void) ptr = &uip_buf[UIP_LLH_LEN]; for(i = 0; i < uip_len; ++i) { - if(i == UIP_TCPIP_HLEN) { - ptr = (uint8_t *)uip_appdata; - } c = *ptr++; slip_write_char(c); } diff --git a/tools/sky/uip6-bridge/dev/slip.c b/tools/sky/uip6-bridge/dev/slip.c index 4cb65cfd5..8bf848c52 100644 --- a/tools/sky/uip6-bridge/dev/slip.c +++ b/tools/sky/uip6-bridge/dev/slip.c @@ -112,9 +112,6 @@ slip_send(void) ptr = &uip_buf[UIP_LLH_LEN]; for(i = 0; i < uip_len; ++i) { - if(i == UIP_TCPIP_HLEN) { - ptr = (uint8_t *)uip_appdata; - } c = *ptr++; if(c == SLIP_END) { slip_arch_writeb(SLIP_ESC); diff --git a/tools/stm32w/uip6_bridge/dev/slip.c b/tools/stm32w/uip6_bridge/dev/slip.c index 543896266..ff14af8d7 100644 --- a/tools/stm32w/uip6_bridge/dev/slip.c +++ b/tools/stm32w/uip6_bridge/dev/slip.c @@ -127,9 +127,6 @@ slip_send(void) ptr = &uip_buf[UIP_LLH_LEN]; for(i = 0; i < uip_len; ++i) { - if(i == UIP_TCPIP_HLEN) { - ptr = (uint8_t *)uip_appdata; - } c = *ptr++; if(c == SLIP_END) { slip_arch_writeb(SLIP_ESC); From 25ac43dae96068eb815e7bb828df2dff256353fc Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 7 Feb 2017 23:09:04 +0100 Subject: [PATCH 041/129] RPL: move a debug message for RPL_LEAF_ONLY to a correct place --- core/net/rpl/rpl-icmp6.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/net/rpl/rpl-icmp6.c b/core/net/rpl/rpl-icmp6.c index 0b32c6371..733b4e6a4 100644 --- a/core/net/rpl/rpl-icmp6.c +++ b/core/net/rpl/rpl-icmp6.c @@ -218,16 +218,15 @@ dis_input(void) for(instance = &instance_table[0], end = instance + RPL_MAX_INSTANCES; instance < end; ++instance) { if(instance->used == 1) { -#if RPL_LEAF_ONLY - if(!uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) { - PRINTF("RPL: LEAF ONLY Multicast DIS will NOT reset DIO timer\n"); -#else /* !RPL_LEAF_ONLY */ if(uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) { +#if RPL_LEAF_ONLY + PRINTF("RPL: LEAF ONLY Multicast DIS will NOT reset DIO timer\n"); +#else /* !RPL_LEAF_ONLY */ PRINTF("RPL: Multicast DIS => reset DIO timer\n"); rpl_reset_dio_timer(instance); - } else { #endif /* !RPL_LEAF_ONLY */ - /* Check if this neighbor should be added according to the policy. */ + } else { + /* Check if this neighbor should be added according to the policy. */ if(rpl_icmp6_update_nbr_table(&UIP_IP_BUF->srcipaddr, NBR_TABLE_REASON_RPL_DIS, NULL) == NULL) { PRINTF("RPL: Out of Memory, not sending unicast DIO, DIS from "); From effdc6e212b423fc4ce1e1ef5bc64e52df2d26b5 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Fri, 10 Feb 2017 16:56:14 +0100 Subject: [PATCH 042/129] TSCH: add debug messages to track queued packet addresses --- core/net/mac/tsch/tsch-queue.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/net/mac/tsch/tsch-queue.c b/core/net/mac/tsch/tsch-queue.c index e8ebe7aa3..41f319b1c 100644 --- a/core/net/mac/tsch/tsch-queue.c +++ b/core/net/mac/tsch/tsch-queue.c @@ -202,6 +202,7 @@ tsch_queue_flush_nbr_queue(struct tsch_neighbor *n) /* Free packet queuebuf */ tsch_queue_free_packet(p); } + PRINTF("TSCH-queue: packet is deleted packet=%p\n", p); } } /*---------------------------------------------------------------------------*/ @@ -253,6 +254,8 @@ tsch_queue_add_packet(const linkaddr_t *addr, mac_callback_t sent, void *ptr) /* Add to ringbuf (actual add committed through atomic operation) */ n->tx_array[put_index] = p; ringbufindex_put(&n->tx_ringbuf); + PRINTF("TSCH-queue: packet is added put_index=%u, packet=%p\n", + put_index, p); return p; } else { memb_free(&packet_memb, p); @@ -288,6 +291,7 @@ tsch_queue_remove_packet_from_queue(struct tsch_neighbor *n) /* Get and remove packet from ringbuf (remove committed through an atomic operation */ int16_t get_index = ringbufindex_get(&n->tx_ringbuf); if(get_index != -1) { + PRINTF("TSCH-queue: packet is removed, get_index=%u\n", get_index); return n->tx_array[get_index]; } else { return NULL; From 8b77c5ef4ccb7d818fafa87cbbe26fc39aa367d6 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Fri, 10 Feb 2017 16:57:04 +0100 Subject: [PATCH 043/129] TSCH: add a regression test for tsch_queue_flush_nbr_queue() --- .../27-tsch/01-cooja-flush-nbr-queue.csc | 147 ++++++++++++++++++ regression-tests/27-tsch/Makefile | 1 + regression-tests/27-tsch/code/Makefile | 11 ++ regression-tests/27-tsch/code/common.c | 54 +++++++ regression-tests/27-tsch/code/common.h | 39 +++++ regression-tests/27-tsch/code/project-conf.h | 63 ++++++++ .../27-tsch/code/test-flush-nbr-queue.c | 105 +++++++++++++ regression-tests/27-tsch/js/unit-test.js | 27 ++++ 8 files changed, 447 insertions(+) create mode 100644 regression-tests/27-tsch/01-cooja-flush-nbr-queue.csc create mode 100644 regression-tests/27-tsch/Makefile create mode 100644 regression-tests/27-tsch/code/Makefile create mode 100644 regression-tests/27-tsch/code/common.c create mode 100644 regression-tests/27-tsch/code/common.h create mode 100644 regression-tests/27-tsch/code/project-conf.h create mode 100644 regression-tests/27-tsch/code/test-flush-nbr-queue.c create mode 100644 regression-tests/27-tsch/js/unit-test.js diff --git a/regression-tests/27-tsch/01-cooja-flush-nbr-queue.csc b/regression-tests/27-tsch/01-cooja-flush-nbr-queue.csc new file mode 100644 index 000000000..948822670 --- /dev/null +++ b/regression-tests/27-tsch/01-cooja-flush-nbr-queue.csc @@ -0,0 +1,147 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/collect-view + [APPS_DIR]/powertracker + + My simulation + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype476 + Cooja Mote Type #1 + [CONTIKI_DIR]/regression-tests/27-tsch/code/test-flush-nbr-queue.c + make test-flush-nbr-queue.cooja TARGET=cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 38.79981729133275 + 97.05367953429746 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype476 + + + + org.contikios.cooja.plugins.SimControl + 280 + 4 + 160 + 400 + 0 + + + org.contikios.cooja.plugins.Visualizer + + true + org.contikios.cooja.plugins.skins.IDVisualizerSkin + org.contikios.cooja.plugins.skins.GridVisualizerSkin + org.contikios.cooja.plugins.skins.TrafficVisualizerSkin + org.contikios.cooja.plugins.skins.UDGMVisualizerSkin + 0.9090909090909091 0.0 0.0 0.9090909090909091 158.72743882606113 84.76938224154777 + + 400 + 3 + 400 + 1 + 1 + + + org.contikios.cooja.plugins.LogListener + + + + + + 1320 + 2 + 240 + 400 + 160 + + + org.contikios.cooja.plugins.TimeLine + + 0 + + + + 500.0 + + 1720 + 1 + 166 + 0 + 957 + + + org.contikios.cooja.plugins.Notes + + Enter notes here + true + + 1040 + 0 + 160 + 680 + 0 + + + org.contikios.cooja.plugins.ScriptRunner + + [CONTIKI_DIR]/regression-tests/27-tsch/js/unit-test.js + true + + 495 + 0 + 525 + 663 + 105 + + + diff --git a/regression-tests/27-tsch/Makefile b/regression-tests/27-tsch/Makefile new file mode 100644 index 000000000..272bc7da1 --- /dev/null +++ b/regression-tests/27-tsch/Makefile @@ -0,0 +1 @@ +include ../Makefile.simulation-test diff --git a/regression-tests/27-tsch/code/Makefile b/regression-tests/27-tsch/code/Makefile new file mode 100644 index 000000000..5c3708798 --- /dev/null +++ b/regression-tests/27-tsch/code/Makefile @@ -0,0 +1,11 @@ +all: + +CFLAGS += -D PROJECT_CONF_H=\"project-conf.h\" +APPS += unit-test +MODULES += core/net/mac/tsch core/net/mac/tsch/sixtop + +PROJECT_SOURCEFILES += common.c + +CONTIKI = ../../.. +CONTIKI_WITH_IPV6 = 1 +include $(CONTIKI)/Makefile.include diff --git a/regression-tests/27-tsch/code/common.c b/regression-tests/27-tsch/code/common.c new file mode 100644 index 000000000..51fd1fbfb --- /dev/null +++ b/regression-tests/27-tsch/code/common.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017, Yasuyuki Tanaka + * 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. + */ + +#include +#include + +#include "unit-test.h" +#include "common.h" + +#include "lib/simEnvChange.h" +#include "sys/cooja_mt.h" + +void +test_print_report(const unit_test_t *utp) +{ + printf("=check-me= "); + if(utp->result == unit_test_failure) { + printf("FAILED - %s: exit at L%u\n", utp->descr, utp->exit_line); + } else { + printf("SUCCEEDED - %s\n", utp->descr); + } + + /* give up the CPU so that the mote can output messages in the serial buffer */ + simProcessRunValue = 1; + cooja_mt_yield(); +} diff --git a/regression-tests/27-tsch/code/common.h b/regression-tests/27-tsch/code/common.h new file mode 100644 index 000000000..5b7f1f645 --- /dev/null +++ b/regression-tests/27-tsch/code/common.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, Yasuyuki Tanaka + * 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 _COMMON_H +#define _COMMON_H + +#include "unit-test.h" + +void test_print_report(const unit_test_t *utp); + +#endif /* !_COMMON_H */ diff --git a/regression-tests/27-tsch/code/project-conf.h b/regression-tests/27-tsch/code/project-conf.h new file mode 100644 index 000000000..e15264432 --- /dev/null +++ b/regression-tests/27-tsch/code/project-conf.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2017, Yasuyuki Tanaka + * 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 _PROJECT_CONF_H_ +#define _PROJECT_CONF_H_ + +#define UNIT_TEST_PRINT_FUNCTION test_print_report + +/* Set the minimum value of QUEUEBUF_CONF_NUM for the flush_nbr_queue test */ +#undef QUEUEBUF_CONF_NUM +#define QUEUEBUF_CONF_NUM 1 + +#undef TSCH_LOG_CONF_LEVEL +#define TSCH_LOG_CONF_LEVEL 2 + +#undef TSCH_CONF_AUTOSTART +#define TSCH_CONF_AUTOSTART 1 + +#undef NETSTACK_CONF_MAC +#define NETSTACK_CONF_MAC tschmac_driver + +#undef NETSTACK_CONF_RDC +#define NETSTACK_CONF_RDC nordc_driver + +#undef NETSTACK_CONF_FRAMER +#define NETSTACK_CONF_FRAMER framer_802154 + +#undef FRAME802154_CONF_VERSION +#define FRAME802154_CONF_VERSION FRAME802154_IEEE802154E_2012 + +#if CONTIKI_TARGET_COOJA +#define COOJA_CONF_SIMULATE_TURNAROUND 0 +#endif /* CONTIKI_TARGET_COOJA */ + +#endif /* __PROJECT_CONF_H__ */ diff --git a/regression-tests/27-tsch/code/test-flush-nbr-queue.c b/regression-tests/27-tsch/code/test-flush-nbr-queue.c new file mode 100644 index 000000000..6af9c156c --- /dev/null +++ b/regression-tests/27-tsch/code/test-flush-nbr-queue.c @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2017, Yasuyuki Tanaka + * 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. + */ + +#include + +#include "contiki.h" +#include "contiki-net.h" +#include "contiki-lib.h" +#include "lib/assert.h" + +#include "net/linkaddr.h" +#include "net/mac/tsch/tsch.h" +#include "net/mac/tsch/tsch-queue.h" + +#include "unit-test.h" +#include "common.h" + +PROCESS(test_process, "tsch_queue_flush_nbr_queue() test"); +AUTOSTART_PROCESSES(&test_process); + +static linkaddr_t test_nbr_addr = {{ 0x01 }}; +#define TEST_PEER_ADDR &test_nbr_addr + +UNIT_TEST_REGISTER(test, + "flush_nbr_queue() should delete all the packet in the queue"); +UNIT_TEST(test) +{ + struct tsch_packet *packet; + struct tsch_neighbor *nbr; + + UNIT_TEST_BEGIN(); + + packet = tsch_queue_add_packet(TEST_PEER_ADDR, NULL, NULL); + UNIT_TEST_ASSERT(packet != NULL); + + nbr = tsch_queue_get_nbr(TEST_PEER_ADDR); + UNIT_TEST_ASSERT(nbr != NULL); + + /* + * QUEUEBUF_CONF_NUM is set with 1; so another addition should fail due to + * lack of memory. + */ + packet = tsch_queue_add_packet(TEST_PEER_ADDR, NULL, NULL); + UNIT_TEST_ASSERT(packet == NULL); + + /* tsch_queue_flush_nbr_queue() is called inside of tsch_queue_reset(). */ + tsch_queue_reset(); + + /* After flushing the nbr queue, we should be able to add a new packet */ + packet = tsch_queue_add_packet(TEST_PEER_ADDR, NULL, NULL); + UNIT_TEST_ASSERT(packet != NULL); + + UNIT_TEST_END(); +} + +PROCESS_THREAD(test_process, ev, data) +{ + static struct etimer et; + + PROCESS_BEGIN(); + + tsch_set_coordinator(1); + + etimer_set(&et, CLOCK_SECOND); + while(tsch_is_associated == 0) { + PROCESS_YIELD_UNTIL(etimer_expired(&et)); + etimer_reset(&et); + } + + printf("Run unit-test\n"); + printf("---\n"); + + UNIT_TEST_RUN(test); + + printf("=check-me= DONE\n"); + PROCESS_END(); +} diff --git a/regression-tests/27-tsch/js/unit-test.js b/regression-tests/27-tsch/js/unit-test.js new file mode 100644 index 000000000..015d3b63b --- /dev/null +++ b/regression-tests/27-tsch/js/unit-test.js @@ -0,0 +1,27 @@ +TIMEOUT(10000, log.testFailed()); + +var failed = false; +var done = 0; + +while(done < sim.getMotes().length) { + YIELD(); + + log.log(time + " " + "node-" + id + " "+ msg + "\n"); + + if(msg.contains("=check-me=") == false) { + continue; + } + + if(msg.contains("FAILED")) { + failed = true; + } + + if(msg.contains("DONE")) { + done++; + } +} +if(failed) { + log.testFailed(); +} +log.testOK(); + From 91beb8670f9c8000330c11e54ed46c8e5ac4049f Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Wed, 15 Feb 2017 23:43:28 +0100 Subject: [PATCH 044/129] Added SLIP support to retro platforms. The cc65 tool chain comes with V.24 drivers so it seems reasonable to use the existing Contiki SLIP driver to implement network access via SLIP as alternative to Ethernet. Some notes: - The Ethernet configuration was simplified in order to allow share it with SLIP. - The Contiki SLIP driver presumes an interrupt driven serial receiver to write into the SLIP buffer. However the cc65 V.24 drivers aren't up to that. Therefore the main loops were extended to pull received data from the V.24 buffers and push it into the SLIP buffer. - As far as I understand the serial sender is supposed to block until the data is sent. Therefore a loop calls the non-blocking V.24 driver until the data is sent. On all platforms there's only one V.24 driver available. Therefore V.24 drivers are always loaded statically. On the Apple][ the mouse driver is now loaded statically - independently from SLIP vs. Ethernet. After all there's only one mouse driver available. However there's a major benefit with SLIP: Here all drivers are loaded statically. Therefore the dynamic module loader isn't necessary at all. And without the loader the heap manager isn't necessary at all. This allows for a reduction in code size roughly compensating for the size of the SLIP buffer. --- cpu/6502/6502def.h | 7 +- cpu/6502/Makefile.6502 | 6 +- cpu/6502/README.md | 20 +- cpu/6502/ctk/ctk-mouse.c | 11 + cpu/6502/ethconfig/ethconfig.c | 7 +- cpu/6502/lib/config.c | 60 +++-- cpu/6502/lib/config.h | 18 +- cpu/6502/net/ethernet-drv.c | 2 +- cpu/6502/net/ethernet-drv.h | 5 - cpu/6502/net/ethernet.c | 47 ++-- cpu/6502/net/ethernet.h | 2 +- cpu/6502/net/slip_arch.c | 84 +++++++ cpu/6502/serconfig/Makefile | 6 + cpu/6502/serconfig/Makefile.c128.defines | 1 + cpu/6502/serconfig/Makefile.c64.defines | 1 + cpu/6502/serconfig/serconfig.c | 105 +++++++++ platform/apple2enh/Makefile.apple2enh | 11 +- platform/apple2enh/contiki-main.c | 48 ++-- platform/atarixl/Makefile.atarixl | 10 +- platform/atarixl/contiki-main.c | 47 ++-- platform/c128/Makefile.c128 | 8 + platform/c128/contiki-main.c | 47 ++-- platform/c64/Makefile.c64 | 8 + platform/c64/contiki-main.c | 47 ++-- tools/6502/Makefile | 279 +++++++++++++++-------- tools/6502/default.cfg | Bin 0 -> 21 bytes tools/6502/sample.cfg | Bin 0 -> 21 bytes 27 files changed, 615 insertions(+), 272 deletions(-) create mode 100644 cpu/6502/net/slip_arch.c create mode 100644 cpu/6502/serconfig/Makefile create mode 100644 cpu/6502/serconfig/Makefile.c128.defines create mode 100644 cpu/6502/serconfig/Makefile.c64.defines create mode 100644 cpu/6502/serconfig/serconfig.c create mode 100644 tools/6502/default.cfg create mode 100644 tools/6502/sample.cfg diff --git a/cpu/6502/6502def.h b/cpu/6502/6502def.h index c0f5c999a..4552f1b6f 100644 --- a/cpu/6502/6502def.h +++ b/cpu/6502/6502def.h @@ -68,7 +68,6 @@ typedef unsigned short uip_stats_t; #define UIP_ARCH_ADD32 1 #define UIP_ARCH_CHKSUM 1 -#define UIP_CONF_LLH_LEN 14 #define RESOLV_CONF_SUPPORTS_MDNS 0 #define RESOLV_CONF_SUPPORTS_RECORD_EXPIRATION 0 @@ -80,6 +79,12 @@ void logscr(const void *msg, unsigned len); #define logscr(msg, len) write(STDERR_FILENO, msg, len) #endif +#if WITH_SLIP +#define UIP_CONF_LLH_LEN 0 +#else /* WITH_SLIP */ +#define UIP_CONF_LLH_LEN 14 +#endif /* WITH_SLIP */ + #if MTU_SIZE #define UIP_CONF_BUFFER_SIZE (UIP_LLH_LEN + MTU_SIZE) #else /* MTU_SIZE */ diff --git a/cpu/6502/Makefile.6502 b/cpu/6502/Makefile.6502 index 07e8e3af6..1ddf9599c 100644 --- a/cpu/6502/Makefile.6502 +++ b/cpu/6502/Makefile.6502 @@ -31,6 +31,10 @@ # Author: Oliver Schmidt # +ifdef SLIP + DEFINES += WITH_SLIP +endif + .SUFFIXES: CONTIKI_TARGET_DIRS = . lib sys @@ -39,7 +43,7 @@ CONTIKI_CPU_DIRS = . lib sys ctk net CONTIKI_TARGET_SOURCEFILES += contiki-main.c CONTIKI_CPU_SOURCEFILES += log.c error.c unload.c config.c ctk-mouse.c \ clock.c mtarch.c mtarch-asm.S lc-asm.S \ - uip_arch.c ethernet-drv.c ethernet.c + uip_arch.c slip_arch.c ethernet-drv.c ethernet.c ETHERNET_SOURCEFILES = cs8900a.S lan91c96.S w5100.S diff --git a/cpu/6502/README.md b/cpu/6502/README.md index 103631b58..13c7b7019 100644 --- a/cpu/6502/README.md +++ b/cpu/6502/README.md @@ -6,7 +6,7 @@ cc65 compiler [http://cc65.github.io/cc65/](http://cc65.github.io/cc65/). The Contiki network configuration for 6502-based targets is loaded from a binary configuration file (by default named contiki.cfg). It has the following -format: +format for Ethernet: - Bytes 1 - 4: IP Address (HiByte first) - Bytes 5 - 8: Subnet Mask (HiByte first) @@ -15,10 +15,13 @@ format: - Bytes 17 - 18: Ethernet card I/O address (LoByte first !) - Bytes 19 - xx: Ethernet card driver name (ASCII / PETSCII) -An online Contiki configuration file generator is available at two sites: +It has the following format for SLIP (based on RS232 driver coming with cc65): -- [http://www.a2retrosystems.com/contiki.html](http://www.a2retrosystems.com/contiki.html) -- [http://contiki.cbm8bit.com](http://contiki.cbm8bit.com) +- Bytes 1 - 4: IP Address (HiByte first) +- Bytes 5 - 8: Subnet Mask (HiByte first) +- Bytes 9 - 12: Default Router (HiByte first) +- Bytes 13 - 16: DNS Server (HiByte first) +- Bytes 17 - 21: struct ser_params (see cc65 serial.h) The build for 6502-based machines includes the 'disk' make goal which creates a bootable floppy disk image containing the project binary, a sample @@ -32,6 +35,11 @@ make goal. The values of the high-level configuration macros are not tracked by the build so a manual rebuild is necessary on any change. The following high-level configuration macros may be set: +- WITH_SLIP + - Default: 0 + - Purpose: Use SLIP (based on RS232 driver coming with cc65) instead of + Ethernet. + - MTU_SIZE - Default: 1500 - Purpose: Set the Maximum Transfer Unit size. @@ -78,6 +86,10 @@ high-level configuration macros may be set: - Default: 0 - Purpose: Enable CTK mouse support and load a mouse driver. +- STATIC_MOUSE + - Default: N/A + - Purpose: Link mouse driver statically instead of loading it dynamically. + - WITH_ARGS - Default: 0 - Purpose: Enable support for contiki_argc / contiki_argv. diff --git a/cpu/6502/ctk/ctk-mouse.c b/cpu/6502/ctk/ctk-mouse.c index e578dfb0a..c3a718dbc 100644 --- a/cpu/6502/ctk/ctk-mouse.c +++ b/cpu/6502/ctk/ctk-mouse.c @@ -49,6 +49,15 @@ static uint8_t okay; void ctk_mouse_init(void) { +#ifdef STATIC_MOUSE + + okay = mouse_install(&mouse_def_callbacks, &STATIC_MOUSE) == MOUSE_ERR_OK; + if(okay) { + atexit((void (*)(void))mouse_uninstall); + } + +#else /* STATIC_MOUSE */ + struct mod_ctrl module_control = {cfs_read}; module_control.callerdata = cfs_open("contiki.mou", CFS_READ); @@ -65,6 +74,8 @@ ctk_mouse_init(void) } cfs_close(module_control.callerdata); } + +#endif /* STATIC_MOUSE */ } /*-----------------------------------------------------------------------------------*/ unsigned short diff --git a/cpu/6502/ethconfig/ethconfig.c b/cpu/6502/ethconfig/ethconfig.c index 8dd9dba2f..058f56a86 100644 --- a/cpu/6502/ethconfig/ethconfig.c +++ b/cpu/6502/ethconfig/ethconfig.c @@ -42,6 +42,7 @@ choose(uint8_t max) exit(0); } + putchar('\n'); return val - '0'; } /*-----------------------------------------------------------------------------------*/ @@ -65,13 +66,13 @@ main(void) d = choose(d) - 1; #ifdef __APPLE2__ - printf("\nSlot (1-7)\n"); + printf("Slot (1-7)\n"); drivers[d].address += choose(7) * 0x10; #endif f = cfs_open("contiki.cfg", CFS_WRITE); if(f == -1) { - printf("\nSaving Config - Error\n"); + printf("Saving Config - Error\n"); return; } cfs_write(f, ipcfg, sizeof(ipcfg)); @@ -79,6 +80,6 @@ main(void) cfs_write(f, drivers[d].driver, strlen(drivers[d].driver)); cfs_close(f); - printf("\nSaving Config - Done\n"); + printf("Saving Config - Done\n"); } /*-----------------------------------------------------------------------------------*/ diff --git a/cpu/6502/lib/config.c b/cpu/6502/lib/config.c index e1c2cecc6..b296f89df 100644 --- a/cpu/6502/lib/config.c +++ b/cpu/6502/lib/config.c @@ -39,7 +39,24 @@ #include "cfs/cfs.h" #include "sys/log.h" #include "lib/error.h" -#include "net/ethernet-drv.h" + +#include "lib/config.h" + +struct { + uip_ipaddr_t hostaddr; + uip_ipaddr_t netmask; + uip_ipaddr_t draddr; + uip_ipaddr_t resolvaddr; + union { + struct { + uint16_t addr; +#ifndef STATIC_DRIVER + char name[12+1]; +#endif /* !STATIC_DRIVER */ + } ethernet; + uint8_t slip[5]; + }; +} config; /*-----------------------------------------------------------------------------------*/ #if LOG_CONF_ENABLED @@ -59,16 +76,9 @@ ipaddrtoa(uip_ipaddr_t *ipaddr, char *buffer) } #endif /* LOG_CONF_ENABLED */ /*-----------------------------------------------------------------------------------*/ -struct ethernet_config * +void config_read(char *filename) { - static struct { - uip_ipaddr_t hostaddr; - uip_ipaddr_t netmask; - uip_ipaddr_t draddr; - uip_ipaddr_t resolvaddr; - struct ethernet_config ethernetcfg; - } config; int file; file = cfs_open(filename, CFS_READ); @@ -77,29 +87,35 @@ config_read(char *filename) error_exit(); } - if(cfs_read(file, &config, sizeof(config)) < sizeof(config) - - sizeof(config.ethernetcfg.name)) { + if(cfs_read(file, &config, sizeof(config)) < sizeof(uip_ipaddr_t) * 4 + + sizeof(uint16_t)) { log_message(filename, ": No config file"); error_exit(); } cfs_close(file); - log_message("IP Address: ", ipaddrtoa(&config.hostaddr, uip_buf)); - log_message("Subnet Mask: ", ipaddrtoa(&config.netmask, uip_buf)); - log_message("Def. Router: ", ipaddrtoa(&config.draddr, uip_buf)); - log_message("DNS Server: ", ipaddrtoa(&config.resolvaddr, uip_buf)); + log_message("IP Address: ", ipaddrtoa(&config.hostaddr, uip_buf)); + log_message("Subnet Mask: ", ipaddrtoa(&config.netmask, uip_buf)); + log_message("Def. Router: ", ipaddrtoa(&config.draddr, uip_buf)); + log_message("DNS Server: ", ipaddrtoa(&config.resolvaddr, uip_buf)); -#ifndef STATIC_DRIVER - log_message("Eth. Driver: ", config.ethernetcfg.name); -#else /* !STATIC_DRIVER */ +#ifdef STATIC_DRIVER #define _stringize(arg) #arg #define stringize(arg) _stringize(arg) - log_message("Eth. Driver: ", stringize(ETHERNET)); +#if WITH_SLIP + log_message("SLIP Driver: ", stringize(STATIC_DRIVER)); +#else /* WITH_SLIP */ + log_message("Eth. Driver: ", stringize(STATIC_DRIVER)); +#endif /* WITH_SLIP */ #undef _stringize #undef stringize -#endif /* !STATIC_DRIVER */ - log_message("Driver Port: $", utoa(config.ethernetcfg.addr, uip_buf, 16)); +#else /* STATIC_DRIVER */ + log_message("Eth. Driver: ", config.ethernet.name); +#endif /* STATIC_DRIVER */ +#if !WITH_SLIP + log_message("Driver Port: $", utoa(config.ethernet.addr, uip_buf, 16)); +#endif /* !WITH_SLIP */ uip_sethostaddr(&config.hostaddr); uip_setnetmask(&config.netmask); @@ -107,7 +123,5 @@ config_read(char *filename) #if WITH_DNS uip_nameserver_update(&config.resolvaddr, UIP_NAMESERVER_INFINITE_LIFETIME); #endif /* WITH_DNS */ - - return &config.ethernetcfg; } /*-----------------------------------------------------------------------------------*/ diff --git a/cpu/6502/lib/config.h b/cpu/6502/lib/config.h index 11bc03463..af660f128 100644 --- a/cpu/6502/lib/config.h +++ b/cpu/6502/lib/config.h @@ -35,6 +35,22 @@ #ifndef CONFIG_H_ #define CONFIG_H_ -struct ethernet_config * config_read(char *filename); +extern struct { + uip_ipaddr_t hostaddr; + uip_ipaddr_t netmask; + uip_ipaddr_t draddr; + uip_ipaddr_t resolvaddr; + union { + struct { + uint16_t addr; +#ifndef STATIC_DRIVER + char name[12+1]; +#endif /* !STATIC_DRIVER */ + } ethernet; + uint8_t slip[5]; + }; +} config; + +void config_read(char *filename); #endif /* CONFIG_H_ */ diff --git a/cpu/6502/net/ethernet-drv.c b/cpu/6502/net/ethernet-drv.c index d5348e644..6c38fbeb5 100644 --- a/cpu/6502/net/ethernet-drv.c +++ b/cpu/6502/net/ethernet-drv.c @@ -92,7 +92,7 @@ PROCESS_THREAD(ethernet_process, ev, data) PROCESS_BEGIN(); - ethernet_init((struct ethernet_config *)data); + ethernet_init(); tcpip_set_outputfunc(ethernet_output); diff --git a/cpu/6502/net/ethernet-drv.h b/cpu/6502/net/ethernet-drv.h index 4602e9fab..a6c8c3a89 100644 --- a/cpu/6502/net/ethernet-drv.h +++ b/cpu/6502/net/ethernet-drv.h @@ -35,11 +35,6 @@ #include "contiki.h" -struct ethernet_config { - uint16_t addr; - char name[12+1]; -}; - PROCESS_NAME(ethernet_process); #if NETSTACK_CONF_WITH_IPV6 diff --git a/cpu/6502/net/ethernet.c b/cpu/6502/net/ethernet.c index 54a7b4afd..3db36a500 100644 --- a/cpu/6502/net/ethernet.c +++ b/cpu/6502/net/ethernet.c @@ -38,7 +38,7 @@ #include "cfs/cfs.h" #include "sys/log.h" #include "lib/error.h" -#include "net/ethernet-drv.h" +#include "lib/config.h" #include "net/ethernet.h" @@ -59,25 +59,42 @@ struct { /*---------------------------------------------------------------------------*/ void -ethernet_init(struct ethernet_config *config) +ethernet_init(void) { static const char signature[4] = {0x65, 0x74, 0x68, 0x01}; -#ifndef STATIC_DRIVER +#ifdef STATIC_DRIVER + + extern void STATIC_DRIVER; + + module = &STATIC_DRIVER; + + module->buffer = uip_buf; + module->buffer_size = UIP_BUFSIZE; + if(module->init(config.ethernet.addr)) { + #define _stringize(arg) #arg + #define stringize(arg) _stringize(arg) + log_message(stringize(STATIC_DRIVER), ": No hardware"); + #undef _stringize + #undef stringize + error_exit(); + } + +#else /* STATIC_DRIVER */ struct mod_ctrl module_control = {cfs_read}; uint8_t byte; - module_control.callerdata = cfs_open(config->name, CFS_READ); + module_control.callerdata = cfs_open(config.ethernet.name, CFS_READ); if(module_control.callerdata < 0) { - log_message(config->name, ": File not found"); + log_message(config.ethernet.name, ": File not found"); error_exit(); } byte = mod_load(&module_control); if(byte != MLOAD_OK) { - log_message(config->name, byte == MLOAD_ERR_MEM? ": Out of memory": - ": No module"); + log_message(config.ethernet.name, byte == MLOAD_ERR_MEM? ": Out of memory": + ": No module"); error_exit(); } @@ -86,26 +103,20 @@ ethernet_init(struct ethernet_config *config) for(byte = 0; byte < 4; ++byte) { if(module->signature[byte] != signature[byte]) { - log_message(config->name, ": No ETH driver"); + log_message(config.ethernet.name, ": No ETH driver"); error_exit(); } } -#else /* !STATIC_DRIVER */ - - extern void STATIC_DRIVER; - - module = &STATIC_DRIVER; - -#endif /* !STATIC_DRIVER */ - module->buffer = uip_buf; module->buffer_size = UIP_BUFSIZE; - if(module->init(config->addr)) { - log_message(config->name, ": No hardware"); + if(module->init(config.ethernet.addr)) { + log_message(config.ethernet.name, ": No hardware"); error_exit(); } +#endif /* STATIC_DRIVER */ + uip_setethaddr(module->ethernet_address); } /*---------------------------------------------------------------------------*/ diff --git a/cpu/6502/net/ethernet.h b/cpu/6502/net/ethernet.h index ce06f6e7a..b2b62029e 100644 --- a/cpu/6502/net/ethernet.h +++ b/cpu/6502/net/ethernet.h @@ -35,7 +35,7 @@ #ifndef ETHERNET_H_ #define ETHERNET_H_ -void ethernet_init(struct ethernet_config *config); +void ethernet_init(void); uint16_t ethernet_poll(void); void ethernet_send(void); void ethernet_exit(void); diff --git a/cpu/6502/net/slip_arch.c b/cpu/6502/net/slip_arch.c new file mode 100644 index 000000000..53450805a --- /dev/null +++ b/cpu/6502/net/slip_arch.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2017, Swedish Institute of Computer Science + * 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 Institute 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 INSTITUTE 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 INSTITUTE 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. + * + * This file is part of the Contiki operating system. + * + * Author: Oliver Schmidt + * + */ + +#include +#include + +#include "contiki-net.h" +#include "sys/log.h" +#include "lib/error.h" +#include "lib/config.h" + +#include "dev/slip.h" + +/*---------------------------------------------------------------------------*/ +void +slip_arch_init(unsigned long ubr) +{ + unsigned err; + +#if WITH_SLIP + err = ser_install(STATIC_DRIVER); +#endif /* WITH_SLIP */ + if(err == SER_ERR_OK) { + err = ser_open((struct ser_params *)config.slip); + if(err == SER_ERR_OK) + atexit((void (*)(void))ser_close); + } + if(err != SER_ERR_OK) { + err += '0'; + /* High byte of err serves as string termination. */ + log_message("Serial init error code: ", (char *)&err); + error_exit(); + } + + tcpip_set_outputfunc(slip_send); +} +/*---------------------------------------------------------------------------*/ +void +slip_arch_writeb(unsigned char c) +{ + while(ser_put(c) == SER_ERR_OVERFLOW) + ; +} +/*---------------------------------------------------------------------------*/ +void +slip_arch_poll(void) +{ + static unsigned char c; + + while(ser_get(&c) != SER_ERR_NO_DATA) + slip_input_byte(c); +} +/*---------------------------------------------------------------------------*/ diff --git a/cpu/6502/serconfig/Makefile b/cpu/6502/serconfig/Makefile new file mode 100644 index 000000000..00e1373d0 --- /dev/null +++ b/cpu/6502/serconfig/Makefile @@ -0,0 +1,6 @@ +CONTIKI_PROJECT = serconfig +all: $(CONTIKI_PROJECT) + +CONTIKI = ../../.. +CONTIKI_WITH_IPV4 = 1 +include $(CONTIKI)/Makefile.include diff --git a/cpu/6502/serconfig/Makefile.c128.defines b/cpu/6502/serconfig/Makefile.c128.defines new file mode 100644 index 000000000..0b150a411 --- /dev/null +++ b/cpu/6502/serconfig/Makefile.c128.defines @@ -0,0 +1 @@ +DEFINES = WITH_PFS diff --git a/cpu/6502/serconfig/Makefile.c64.defines b/cpu/6502/serconfig/Makefile.c64.defines new file mode 100644 index 000000000..0b150a411 --- /dev/null +++ b/cpu/6502/serconfig/Makefile.c64.defines @@ -0,0 +1 @@ +DEFINES = WITH_PFS diff --git a/cpu/6502/serconfig/serconfig.c b/cpu/6502/serconfig/serconfig.c new file mode 100644 index 000000000..178400517 --- /dev/null +++ b/cpu/6502/serconfig/serconfig.c @@ -0,0 +1,105 @@ +#include +#include +#include +#include + +#include "cfs/cfs.h" + +static struct { + char *screen; + uint8_t value; +} baud[] = { + {" 300 baud", SER_BAUD_300}, + {" 600 baud", SER_BAUD_600}, + {" 1200 baud", SER_BAUD_1200}, + {" 2400 baud", SER_BAUD_2400}, + {" 4800 baud", SER_BAUD_4800}, + {" 9600 baud", SER_BAUD_9600}, + {"19200 baud", SER_BAUD_19200} +}; + +static struct { + char *screen; + uint8_t value; +} stop[] = { + {"1 stop bit", SER_STOP_1}, + {"2 stop bits", SER_STOP_2} +}; + +static struct { + char *screen; + uint8_t value; +} parity[] = { + {" No parity", SER_PAR_NONE}, + {" Odd parity", SER_PAR_ODD}, + {"Even parity", SER_PAR_EVEN} +}; + +uint8_t ipcfg[16]; +struct ser_params params; + +/*-----------------------------------------------------------------------------------*/ +uint8_t +choose(uint8_t max) +{ + char val; + + do { + printf("\n?"); + val = getchar(); + } while(val < '0' || val > max + '0'); + + putchar('\n'); + if(val == '0') { + exit(0); + } + + putchar('\n'); + return val - '0'; +} +/*-----------------------------------------------------------------------------------*/ +void +main(void) +{ + int f; + uint8_t c; + + f = cfs_open("contiki.cfg", CFS_READ); + if(f == -1) { + printf("Loading Config - Error\n"); + return; + } + cfs_read(f, ipcfg, sizeof(ipcfg)); + cfs_close(f); + + for(c = 0; c < sizeof(baud) / sizeof(baud[0]); ++c) { + printf("%d: %s\n", c + 1, baud[c].screen); + } + params.baudrate = baud[choose(c) - 1].value; + + params.databits = SER_BITS_8; + + for(c = 0; c < sizeof(stop) / sizeof(stop[0]); ++c) { + printf("%d: %s\n", c + 1, stop[c].screen); + } + params.stopbits = stop[choose(c) - 1].value; + + for(c = 0; c < sizeof(parity) / sizeof(parity[0]); ++c) { + printf("%d: %s\n", c + 1, parity[c].screen); + } + params.parity = parity[choose(c) - 1].value; + + params.handshake = SER_HS_HW; + + f = cfs_open("contiki.cfg", CFS_WRITE); + if(f == -1) { + printf("\nSaving Config - Error\n"); + return; + } + cfs_write(f, ipcfg, sizeof(ipcfg)); + cfs_write(f, ¶ms, sizeof(params)); + cfs_close(f); + + printf("Saving Config - Done\n"); +} +/*-----------------------------------------------------------------------------------*/ diff --git a/platform/apple2enh/Makefile.apple2enh b/platform/apple2enh/Makefile.apple2enh index 01734c6ea..65402bb24 100644 --- a/platform/apple2enh/Makefile.apple2enh +++ b/platform/apple2enh/Makefile.apple2enh @@ -31,6 +31,12 @@ # Author: Oliver Schmidt # +DEFINES += STATIC_MOUSE=a2e_stdmou_mou + +ifdef SLIP + DEFINES += STATIC_DRIVER=a2e_ssc_ser +endif + CONTIKI_TARGET_SOURCEFILES += pfs.S CONTIKI_CPU = $(CONTIKI)/cpu/6502 @@ -57,12 +63,13 @@ disk: all cp $(CONTIKI)/tools/$(TARGET)/prodos.dsk contiki.dsk java -jar $(AC) -p contiki.dsk contiki.system sys < $(CC65_TARGET_DIR)/util/loader.system java -jar $(AC) -cc65 contiki.dsk contiki bin < $(CONTIKI_PROJECT).$(TARGET) +ifdef SLIP + java -jar $(AC) -p contiki.dsk contiki.cfg bin 0 < $(CONTIKI)/tools/6502/sample.cfg +else java -jar $(AC) -p contiki.dsk contiki.cfg bin 0 < $(CONTIKI)/tools/$(TARGET)/sample.cfg java -jar $(AC) -p contiki.dsk cs8900a.eth rel 0 < cs8900a.eth java -jar $(AC) -p contiki.dsk lan91c96.eth rel 0 < lan91c96.eth java -jar $(AC) -p contiki.dsk w5100.eth rel 0 < w5100.eth -ifeq ($(findstring WITH_MOUSE,$(DEFINES)),WITH_MOUSE) - java -jar $(AC) -p contiki.dsk contiki.mou rel 0 < $(CC65_TARGET_DIR)/drv/mou/a2e.stdmou.mou endif ifeq ($(HTTPD-CFS),1) java -jar $(AC) -p contiki.dsk index.htm bin 0 < httpd-cfs/index.htm diff --git a/platform/apple2enh/contiki-main.c b/platform/apple2enh/contiki-main.c index f65a4fe94..545d9b7a2 100644 --- a/platform/apple2enh/contiki-main.c +++ b/platform/apple2enh/contiki-main.c @@ -36,8 +36,19 @@ #include "ctk/ctk.h" #include "sys/log.h" #include "lib/config.h" +#include "dev/slip.h" #include "net/ethernet-drv.h" +#if WITH_SLIP +#define DRIVER_PROCESS &slip_process, +#define SLIP_INIT slip_arch_init(0); +#define SLIP_POLL slip_arch_poll(); +#else /* WITH_SLIP */ +#define DRIVER_PROCESS ðernet_process, +#define SLIP_INIT +#define SLIP_POLL +#endif /* WITH_SLIP */ + #if WITH_GUI #define CTK_PROCESS &ctk_process, #else /* WITH_GUI */ @@ -52,12 +63,12 @@ PROCINIT(&etimer_process, CTK_PROCESS + DRIVER_PROCESS &tcpip_process RESOLV_PROCESS); -static struct ethernet_config *ethernet_config; - void clock_update(void); +void slip_arch_poll(void); /*-----------------------------------------------------------------------------------*/ #if WITH_ARGS @@ -87,35 +98,12 @@ main(void) videomode(VIDEOMODE_80COL); #endif /* WITH_80COL */ + config_read("contiki.cfg"); + + SLIP_INIT + process_init(); - -#if 1 - ethernet_config = config_read("contiki.cfg"); -#else - { - static struct ethernet_config config = {0xC0B0, "cs8900a.eth"}; - uip_ipaddr_t addr; - - uip_ipaddr(&addr, 192,168,0,128); - uip_sethostaddr(&addr); - - uip_ipaddr(&addr, 255,255,255,0); - uip_setnetmask(&addr); - - uip_ipaddr(&addr, 192,168,0,1); - uip_setdraddr(&addr); - - uip_ipaddr(&addr, 192,168,0,1); - uip_nameserver_update(&addr, UIP_NAMESERVER_INFINITE_LIFETIME); - - ethernet_config = &config; - } -#endif - procinit_init(); - - process_start((struct process *)ðernet_process, (void *)ethernet_config); - autostart_start(autostart_processes); log_message("Contiki up and running ...", ""); @@ -126,6 +114,8 @@ main(void) etimer_request_poll(); + SLIP_POLL + clock_update(); } } diff --git a/platform/atarixl/Makefile.atarixl b/platform/atarixl/Makefile.atarixl index 2bb1d1edf..c32a558ed 100644 --- a/platform/atarixl/Makefile.atarixl +++ b/platform/atarixl/Makefile.atarixl @@ -31,7 +31,11 @@ # Author: Oliver Schmidt # -DEFINES += STATIC_DRIVER=cs8900a +ifdef SLIP + DEFINES += STATIC_DRIVER=atrxrdev_ser +else + DEFINES += STATIC_DRIVER=cs8900a +endif CONTIKI_CPU = $(CONTIKI)/cpu/6502 include $(CONTIKI_CPU)/Makefile.6502 @@ -54,7 +58,11 @@ disk: all cp $(CONTIKI)/tools/$(TARGET)/dos25/dos.sys atr/dos.sys cp $(CONTIKI)/tools/$(TARGET)/dos25/dup.sys atr/dup.sys cp $(CONTIKI_PROJECT).$(TARGET) atr/autorun.sys +ifdef SLIP + cp $(CONTIKI)/tools/6502/sample.cfg atr/contiki.cfg +else cp $(CONTIKI)/tools/$(TARGET)/sample.cfg atr/contiki.cfg +endif ifeq ($(findstring WITH_MOUSE,$(DEFINES)),WITH_MOUSE) cp $(CC65_TARGET_DIR)/drv/mou/atrxst.mou atr/contiki.mou endif diff --git a/platform/atarixl/contiki-main.c b/platform/atarixl/contiki-main.c index 91cb35367..fa4136dbd 100644 --- a/platform/atarixl/contiki-main.c +++ b/platform/atarixl/contiki-main.c @@ -36,8 +36,19 @@ #include "ctk/ctk.h" #include "sys/log.h" #include "lib/config.h" +#include "dev/slip.h" #include "net/ethernet-drv.h" +#if WITH_SLIP +#define DRIVER_PROCESS &slip_process, +#define SLIP_INIT slip_arch_init(0); +#define SLIP_POLL slip_arch_poll(); +#else /* WITH_SLIP */ +#define DRIVER_PROCESS ðernet_process, +#define SLIP_INIT +#define SLIP_POLL +#endif /* WITH_SLIP */ + #if WITH_GUI #define CTK_PROCESS &ctk_process, #else /* WITH_GUI */ @@ -52,10 +63,11 @@ PROCINIT(&etimer_process, CTK_PROCESS + DRIVER_PROCESS &tcpip_process RESOLV_PROCESS); -static struct ethernet_config *ethernet_config; +void slip_arch_poll(void); /*-----------------------------------------------------------------------------------*/ #if WITH_ARGS @@ -81,35 +93,12 @@ main(void) bordercolor(BORDERCOLOR); bgcolor(SCREENCOLOR); + config_read("contiki.cfg"); + + SLIP_INIT + process_init(); - -#if 1 - ethernet_config = config_read("contiki.cfg"); -#else - { - static struct ethernet_config config = {0xD500, "cs8900a.eth"}; - uip_ipaddr_t addr; - - uip_ipaddr(&addr, 192,168,0,128); - uip_sethostaddr(&addr); - - uip_ipaddr(&addr, 255,255,255,0); - uip_setnetmask(&addr); - - uip_ipaddr(&addr, 192,168,0,1); - uip_setdraddr(&addr); - - uip_ipaddr(&addr, 192,168,0,1); - uip_nameserver_update(&addr, UIP_NAMESERVER_INFINITE_LIFETIME); - - ethernet_config = &config; - } -#endif - procinit_init(); - - process_start((struct process *)ðernet_process, (void *)ethernet_config); - autostart_start(autostart_processes); log_message("Contiki up and running ...", ""); @@ -119,6 +108,8 @@ main(void) process_run(); etimer_request_poll(); + + SLIP_POLL } } /*-----------------------------------------------------------------------------------*/ diff --git a/platform/c128/Makefile.c128 b/platform/c128/Makefile.c128 index c1adbaf08..bd1122c33 100644 --- a/platform/c128/Makefile.c128 +++ b/platform/c128/Makefile.c128 @@ -31,6 +31,10 @@ # Author: Oliver Schmidt # +ifdef SLIP + DEFINES += STATIC_DRIVER=c128_swlink_ser +endif + CONTIKI_TARGET_SOURCEFILES += exec.c logscr.S lseek.c \ pfs.S pfs-dir.c pfs-dir-asm.S pfs_remove.S pfs_seek.S pfs_write.S @@ -48,9 +52,13 @@ endif disk: all $(C1541) -format contiki,00 d71 contiki.d71 $(C1541) -attach contiki.d71 -write $(CONTIKI_PROJECT).$(TARGET) contiki,p +ifdef SLIP + $(C1541) -attach contiki.d71 -write $(CONTIKI)/tools/6502/sample.cfg contiki.cfg,s +else $(C1541) -attach contiki.d71 -write $(CONTIKI)/tools/$(TARGET)/sample.cfg contiki.cfg,s $(C1541) -attach contiki.d71 -write cs8900a.eth cs8900a.eth,s $(C1541) -attach contiki.d71 -write lan91c96.eth lan91c96.eth,s +endif ifeq ($(findstring WITH_MOUSE,$(DEFINES)),WITH_MOUSE) $(C1541) -attach contiki.d71 -write $(CC65_TARGET_DIR)/drv/mou/c128-1351.mou contiki.mou,s endif diff --git a/platform/c128/contiki-main.c b/platform/c128/contiki-main.c index a1856d405..a6eef0176 100644 --- a/platform/c128/contiki-main.c +++ b/platform/c128/contiki-main.c @@ -36,8 +36,19 @@ #include "ctk/ctk.h" #include "sys/log.h" #include "lib/config.h" +#include "dev/slip.h" #include "net/ethernet-drv.h" +#if WITH_SLIP +#define DRIVER_PROCESS &slip_process, +#define SLIP_INIT slip_arch_init(0); +#define SLIP_POLL slip_arch_poll(); +#else /* WITH_SLIP */ +#define DRIVER_PROCESS ðernet_process, +#define SLIP_INIT +#define SLIP_POLL +#endif /* WITH_SLIP */ + #if WITH_GUI #define CTK_PROCESS &ctk_process, #else /* WITH_GUI */ @@ -52,10 +63,11 @@ PROCINIT(&etimer_process, CTK_PROCESS + DRIVER_PROCESS &tcpip_process RESOLV_PROCESS); -static struct ethernet_config *ethernet_config; +void slip_arch_poll(void); /*-----------------------------------------------------------------------------------*/ #if WITH_ARGS @@ -81,35 +93,12 @@ main(void) videomode(VIDEOMODE_80COL); #endif /* WITH_80COL */ + config_read("contiki.cfg"); + + SLIP_INIT + process_init(); - -#if 1 - ethernet_config = config_read("contiki.cfg"); -#else - { - static struct ethernet_config config = {0xDE08, "cs8900a.eth"}; - uip_ipaddr_t addr; - - uip_ipaddr(&addr, 192,168,0,128); - uip_sethostaddr(&addr); - - uip_ipaddr(&addr, 255,255,255,0); - uip_setnetmask(&addr); - - uip_ipaddr(&addr, 192,168,0,1); - uip_setdraddr(&addr); - - uip_ipaddr(&addr, 192,168,0,1); - uip_nameserver_update(&addr, UIP_NAMESERVER_INFINITE_LIFETIME); - - ethernet_config = &config; - } -#endif - procinit_init(); - - process_start((struct process *)ðernet_process, (void *)ethernet_config); - autostart_start(autostart_processes); log_message("Contiki up and running ...", ""); @@ -119,6 +108,8 @@ main(void) process_run(); etimer_request_poll(); + + SLIP_POLL } } /*-----------------------------------------------------------------------------------*/ diff --git a/platform/c64/Makefile.c64 b/platform/c64/Makefile.c64 index 7fcb4d19f..f1b8b09b8 100644 --- a/platform/c64/Makefile.c64 +++ b/platform/c64/Makefile.c64 @@ -31,6 +31,10 @@ # Author: Oliver Schmidt # +ifdef SLIP + DEFINES += STATIC_DRIVER=c64_swlink_ser +endif + CONTIKI_TARGET_SOURCEFILES += exec.c logscr.S lseek.c \ pfs.S pfs-dir.c pfs-dir-asm.S pfs_remove.S pfs_seek.S pfs_write.S @@ -52,9 +56,13 @@ endif disk: all $(C1541) -format contiki,00 d64 contiki.d64 $(C1541) -attach contiki.d64 -write $(CONTIKI_PROJECT).$(TARGET) contiki,p +ifdef SLIP + $(C1541) -attach contiki.d64 -write $(CONTIKI)/tools/6502/sample.cfg contiki.cfg,s +else $(C1541) -attach contiki.d64 -write $(CONTIKI)/tools/$(TARGET)/sample.cfg contiki.cfg,s $(C1541) -attach contiki.d64 -write cs8900a.eth cs8900a.eth,s $(C1541) -attach contiki.d64 -write lan91c96.eth lan91c96.eth,s +endif ifeq ($(findstring WITH_MOUSE,$(DEFINES)),WITH_MOUSE) $(C1541) -attach contiki.d64 -write $(CC65_TARGET_DIR)/drv/mou/c64-1351.mou contiki.mou,s endif diff --git a/platform/c64/contiki-main.c b/platform/c64/contiki-main.c index f2b4aae18..30f9776ba 100644 --- a/platform/c64/contiki-main.c +++ b/platform/c64/contiki-main.c @@ -38,8 +38,19 @@ #include "ctk/ctk.h" #include "sys/log.h" #include "lib/config.h" +#include "dev/slip.h" #include "net/ethernet-drv.h" +#if WITH_SLIP +#define DRIVER_PROCESS &slip_process, +#define SLIP_INIT slip_arch_init(0); +#define SLIP_POLL slip_arch_poll(); +#else /* WITH_SLIP */ +#define DRIVER_PROCESS ðernet_process, +#define SLIP_INIT +#define SLIP_POLL +#endif /* WITH_SLIP */ + #if WITH_GUI #define CTK_PROCESS &ctk_process, #else /* WITH_GUI */ @@ -54,10 +65,11 @@ PROCINIT(&etimer_process, CTK_PROCESS + DRIVER_PROCESS &tcpip_process RESOLV_PROCESS); -static struct ethernet_config *ethernet_config; +void slip_arch_poll(void); /*-----------------------------------------------------------------------------------*/ #if WITH_ARGS @@ -83,35 +95,12 @@ main(void) _heapadd((void *)0x0400, 0x0400); #endif /* WITH_80COL */ + config_read("contiki.cfg"); + + SLIP_INIT + process_init(); - -#if 1 - ethernet_config = config_read("contiki.cfg"); -#else - { - static struct ethernet_config config = {0xDE08, "cs8900a.eth"}; - uip_ipaddr_t addr; - - uip_ipaddr(&addr, 192,168,0,128); - uip_sethostaddr(&addr); - - uip_ipaddr(&addr, 255,255,255,0); - uip_setnetmask(&addr); - - uip_ipaddr(&addr, 192,168,0,1); - uip_setdraddr(&addr); - - uip_ipaddr(&addr, 192,168,0,1); - uip_nameserver_update(&addr, UIP_NAMESERVER_INFINITE_LIFETIME); - - ethernet_config = &config; - } -#endif - procinit_init(); - - process_start((struct process *)ðernet_process, (void *)ethernet_config); - autostart_start(autostart_processes); log_message("Contiki up and running ...", ""); @@ -121,6 +110,8 @@ main(void) process_run(); etimer_request_poll(); + + SLIP_POLL } } /*-----------------------------------------------------------------------------------*/ diff --git a/tools/6502/Makefile b/tools/6502/Makefile index fef30e632..8f845bf12 100644 --- a/tools/6502/Makefile +++ b/tools/6502/Makefile @@ -61,10 +61,16 @@ endif CC65 := $(shell cl65 --print-target-path) +ifdef SLIP +DEV = ser +else +DEV = eth +endif + define makes .PHONY: $1-$2makes $1-$2makes: - $(MAKE) -C ../../cpu/6502/ethconfig TARGET=$1 $2 + $(MAKE) -C ../../cpu/6502/$(DEV)config TARGET=$1 $2 $(MAKE) -C ../../cpu/6502/ipconfig TARGET=$1 $2 $(MAKE) -C ../../examples/webbrowser TARGET=$1 $2 $(MAKE) -C ../../examples/webbrowser-80col TARGET=$1 $2 @@ -93,83 +99,96 @@ contiki-apple2.zip: contiki-apple2-1.dsk contiki-apple2-2.dsk contiki-apple2-3.d contiki-apple2-1.dsk: apple2enh-makes cp ../apple2enh/prodos.dsk $@ - java -jar $(AC) -p $@ menu.system sys < ../apple2enh/menu.system - java -jar $(AC) -p $@ ethconfi.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ ethconfi bin < ../../cpu/6502/ethconfig/ethconfig.apple2enh - java -jar $(AC) -p $@ ipconfig.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ ipconfig bin < ../../cpu/6502/ipconfig/ipconfig.apple2enh - java -jar $(AC) -p $@ webbrows.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ webbrows bin < ../../examples/webbrowser-80col/webbrowser.apple2enh - java -jar $(AC) -p $@ wget.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ wget bin < ../../examples/wget/wget.apple2enh - java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg - java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ethconfig/cs8900a.eth - java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ethconfig/lan91c96.eth - java -jar $(AC) -p $@ w5100.eth rel 0 < ../../cpu/6502/ethconfig/w5100.eth - java -jar $(AC) -p $@ contiki.mou rel 0 < $(CC65)/apple2enh/drv/mou/a2e.stdmou.mou + java -jar $(AC) -p $@ menu.system sys < ../apple2enh/menu.system + java -jar $(AC) -p $@ $(DEV)confi.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ $(DEV)confi bin < ../../cpu/6502/$(DEV)config/$(DEV)config.apple2enh + java -jar $(AC) -p $@ ipconfig.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ ipconfig bin < ../../cpu/6502/ipconfig/ipconfig.apple2enh + java -jar $(AC) -p $@ webbrows.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ webbrows bin < ../../examples/webbrowser-80col/webbrowser.apple2enh + java -jar $(AC) -p $@ wget.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ wget bin < ../../examples/wget/wget.apple2enh +ifdef SLIP + java -jar $(AC) -p $@ contiki.cfg bin 0 < default.cfg +else + java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg + java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ethconfig/cs8900a.eth + java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ethconfig/lan91c96.eth + java -jar $(AC) -p $@ w5100.eth rel 0 < ../../cpu/6502/ethconfig/w5100.eth +endif contiki-apple2-2.dsk: apple2enh-makes cp ../apple2enh/prodos.dsk $@ - java -jar $(AC) -p $@ menu.system sys < ../apple2enh/menu.system - java -jar $(AC) -p $@ ethconfi.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ ethconfi bin < ../../cpu/6502/ethconfig/ethconfig.apple2enh - java -jar $(AC) -p $@ ipconfig.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ ipconfig bin < ../../cpu/6502/ipconfig/ipconfig.apple2enh - java -jar $(AC) -p $@ irc.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ irc bin < ../../examples/irc-80col/irc-client.apple2enh - java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg - java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ethconfig/cs8900a.eth - java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ethconfig/lan91c96.eth - java -jar $(AC) -p $@ w5100.eth rel 0 < ../../cpu/6502/ethconfig/w5100.eth - java -jar $(AC) -p $@ contiki.mou rel 0 < $(CC65)/apple2enh/drv/mou/a2e.stdmou.mou + java -jar $(AC) -p $@ menu.system sys < ../apple2enh/menu.system + java -jar $(AC) -p $@ $(DEV)confi.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ $(DEV)confi bin < ../../cpu/6502/$(DEV)config/$(DEV)config.apple2enh + java -jar $(AC) -p $@ ipconfig.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ ipconfig bin < ../../cpu/6502/ipconfig/ipconfig.apple2enh + java -jar $(AC) -p $@ irc.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ irc bin < ../../examples/irc-80col/irc-client.apple2enh +ifdef SLIP + java -jar $(AC) -p $@ contiki.cfg bin 0 < default.cfg +else + java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg + java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ethconfig/cs8900a.eth + java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ethconfig/lan91c96.eth + java -jar $(AC) -p $@ w5100.eth rel 0 < ../../cpu/6502/ethconfig/w5100.eth +endif contiki-apple2-3.dsk: apple2enh-makes cp ../apple2enh/prodos.dsk $@ - java -jar $(AC) -p $@ menu.system sys < ../apple2enh/menu.system - java -jar $(AC) -p $@ ethconfi.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ ethconfi bin < ../../cpu/6502/ethconfig/ethconfig.apple2enh - java -jar $(AC) -p $@ ipconfig.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ ipconfig bin < ../../cpu/6502/ipconfig/ipconfig.apple2enh - java -jar $(AC) -p $@ webserv.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ webserv bin < ../../examples/webserver/webserver-example.apple2enh - java -jar $(AC) -p $@ telnetd.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ telnetd bin < ../../examples/telnet-server/telnet-server.apple2enh - java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg - java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ethconfig/cs8900a.eth - java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ethconfig/lan91c96.eth - java -jar $(AC) -p $@ w5100.eth rel 0 < ../../cpu/6502/ethconfig/w5100.eth - java -jar $(AC) -p $@ contiki.mou rel 0 < $(CC65)/apple2enh/drv/mou/a2e.stdmou.mou - java -jar $(AC) -p $@ index.htm bin 0 < ../../examples/webserver/httpd-cfs/index.htm - java -jar $(AC) -p $@ backgrnd.gif bin 0 < ../../examples/webserver/httpd-cfs/backgrnd.gif - java -jar $(AC) -p $@ contiki.gif bin 0 < ../../examples/webserver/httpd-cfs/contiki.gif - java -jar $(AC) -p $@ notfound.htm bin 0 < ../../examples/webserver/httpd-cfs/notfound.htm + java -jar $(AC) -p $@ menu.system sys < ../apple2enh/menu.system + java -jar $(AC) -p $@ $(DEV)confi.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ $(DEV)confi bin < ../../cpu/6502/$(DEV)config/$(DEV)config.apple2enh + java -jar $(AC) -p $@ ipconfig.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ ipconfig bin < ../../cpu/6502/ipconfig/ipconfig.apple2enh + java -jar $(AC) -p $@ webserv.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ webserv bin < ../../examples/webserver/webserver-example.apple2enh + java -jar $(AC) -p $@ telnetd.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ telnetd bin < ../../examples/telnet-server/telnet-server.apple2enh +ifdef SLIP + java -jar $(AC) -p $@ contiki.cfg bin 0 < default.cfg +else + java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg + java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ethconfig/cs8900a.eth + java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ethconfig/lan91c96.eth + java -jar $(AC) -p $@ w5100.eth rel 0 < ../../cpu/6502/ethconfig/w5100.eth +endif + java -jar $(AC) -p $@ index.htm bin 0 < ../../examples/webserver/httpd-cfs/index.htm + java -jar $(AC) -p $@ backgrnd.gif bin 0 < ../../examples/webserver/httpd-cfs/backgrnd.gif + java -jar $(AC) -p $@ contiki.gif bin 0 < ../../examples/webserver/httpd-cfs/contiki.gif + java -jar $(AC) -p $@ notfound.htm bin 0 < ../../examples/webserver/httpd-cfs/notfound.htm contiki-apple2.po: apple2enh-makes cp ../apple2enh/prodos.po $@ - java -jar $(AC) -p $@ menu.system sys < ../apple2enh/menu.system - java -jar $(AC) -p $@ ethconfi.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ ethconfi bin < ../../cpu/6502/ethconfig/ethconfig.apple2enh - java -jar $(AC) -p $@ ipconfig.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ ipconfig bin < ../../cpu/6502/ipconfig/ipconfig.apple2enh - java -jar $(AC) -p $@ webbrows.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ webbrows bin < ../../examples/webbrowser-80col/webbrowser.apple2enh - java -jar $(AC) -p $@ wget.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ wget bin < ../../examples/wget/wget.apple2enh - java -jar $(AC) -p $@ irc.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ irc bin < ../../examples/irc-80col/irc-client.apple2enh - java -jar $(AC) -p $@ webserv.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ webserv bin < ../../examples/webserver/webserver-example.apple2enh - java -jar $(AC) -p $@ telnetd.system sys < $(CC65)/apple2enh/util/loader.system - java -jar $(AC) -cc65 $@ telnetd bin < ../../examples/telnet-server/telnet-server.apple2enh - java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg - java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ethconfig/cs8900a.eth - java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ethconfig/lan91c96.eth - java -jar $(AC) -p $@ w5100.eth rel 0 < ../../cpu/6502/ethconfig/w5100.eth - java -jar $(AC) -p $@ contiki.mou rel 0 < $(CC65)/apple2enh/drv/mou/a2e.stdmou.mou - java -jar $(AC) -p $@ index.htm bin 0 < ../../examples/webserver/httpd-cfs/index.htm - java -jar $(AC) -p $@ backgrnd.gif bin 0 < ../../examples/webserver/httpd-cfs/backgrnd.gif - java -jar $(AC) -p $@ contiki.gif bin 0 < ../../examples/webserver/httpd-cfs/contiki.gif - java -jar $(AC) -p $@ notfound.htm bin 0 < ../../examples/webserver/httpd-cfs/notfound.htm + java -jar $(AC) -p $@ menu.system sys < ../apple2enh/menu.system + java -jar $(AC) -p $@ $(DEV)confi.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ $(DEV)confi bin < ../../cpu/6502/$(DEV)config/$(DEV)config.apple2enh + java -jar $(AC) -p $@ ipconfig.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ ipconfig bin < ../../cpu/6502/ipconfig/ipconfig.apple2enh + java -jar $(AC) -p $@ webbrows.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ webbrows bin < ../../examples/webbrowser-80col/webbrowser.apple2enh + java -jar $(AC) -p $@ wget.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ wget bin < ../../examples/wget/wget.apple2enh + java -jar $(AC) -p $@ irc.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ irc bin < ../../examples/irc-80col/irc-client.apple2enh + java -jar $(AC) -p $@ webserv.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ webserv bin < ../../examples/webserver/webserver-example.apple2enh + java -jar $(AC) -p $@ telnetd.system sys < $(CC65)/apple2enh/util/loader.system + java -jar $(AC) -cc65 $@ telnetd bin < ../../examples/telnet-server/telnet-server.apple2enh +ifdef SLIP + java -jar $(AC) -p $@ contiki.cfg bin 0 < default.cfg +else + java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg + java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ethconfig/cs8900a.eth + java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ethconfig/lan91c96.eth + java -jar $(AC) -p $@ w5100.eth rel 0 < ../../cpu/6502/ethconfig/w5100.eth +endif + java -jar $(AC) -p $@ contiki.mou rel 0 < $(CC65)/apple2enh/drv/mou/a2e.stdmou.mou + java -jar $(AC) -p $@ index.htm bin 0 < ../../examples/webserver/httpd-cfs/index.htm + java -jar $(AC) -p $@ backgrnd.gif bin 0 < ../../examples/webserver/httpd-cfs/backgrnd.gif + java -jar $(AC) -p $@ contiki.gif bin 0 < ../../examples/webserver/httpd-cfs/contiki.gif + java -jar $(AC) -p $@ notfound.htm bin 0 < ../../examples/webserver/httpd-cfs/notfound.htm $(eval $(call makes,atarixl)) $(eval $(call makes,atarixl,clean)) @@ -185,10 +204,17 @@ contiki-atari-1.atr: atarixl-makes mkdir atr cp ../atarixl/dos25/dos.sys atr/dos.sys cp ../atarixl/dos25/dup.sys atr/dup.sys +ifdef SLIP + cp ../../cpu/6502/serconfig/serconfig.atarixl atr/serconfi.com +endif cp ../../cpu/6502/ipconfig/ipconfig.atarixl atr/ipconfig.com cp ../../examples/webbrowser/webbrowser.atarixl atr/webbrows.com cp ../../examples/wget/wget.atarixl atr/wget.com +ifdef SLIP + cp default.cfg atr/contiki.cfg +else cp ../atarixl/default.cfg atr/contiki.cfg +endif cp $(CC65)/atarixl/drv/mou/atrxst.mou atr/contiki.mou cp $(CC65)/atarixl/drv/mou/atrxami.mou atr/ami.mou cp $(CC65)/atarixl/drv/mou/atrxjoy.mou atr/joy.mou @@ -199,16 +225,23 @@ contiki-atari-1.atr: atarixl-makes contiki-atari-2.atr: atarixl-makes mkdir atr - cp ../atarixl/dos25/dos.sys atr/dos.sys - cp ../atarixl/dos25/dup.sys atr/dup.sys - cp ../../cpu/6502/ipconfig/ipconfig.atarixl atr/ipconfig.com - cp ../../examples/irc/irc-client.atarixl atr/irc.com - cp ../atarixl/default.cfg atr/contiki.cfg - cp $(CC65)/atarixl/drv/mou/atrxst.mou atr/contiki.mou - cp $(CC65)/atarixl/drv/mou/atrxami.mou atr/ami.mou - cp $(CC65)/atarixl/drv/mou/atrxjoy.mou atr/joy.mou - cp $(CC65)/atarixl/drv/mou/atrxtrk.mou atr/trk.mou - cp $(CC65)/atarixl/drv/mou/atrxtt.mou atr/tt.mou + cp ../atarixl/dos25/dos.sys atr/dos.sys + cp ../atarixl/dos25/dup.sys atr/dup.sys +ifdef SLIP + cp ../../cpu/6502/serconfig/serconfig.atarixl atr/serconfi.com +endif + cp ../../cpu/6502/ipconfig/ipconfig.atarixl atr/ipconfig.com + cp ../../examples/irc/irc-client.atarixl atr/irc.com +ifdef SLIP + cp default.cfg atr/contiki.cfg +else + cp ../atarixl/default.cfg atr/contiki.cfg +endif + cp $(CC65)/atarixl/drv/mou/atrxst.mou atr/contiki.mou + cp $(CC65)/atarixl/drv/mou/atrxami.mou atr/ami.mou + cp $(CC65)/atarixl/drv/mou/atrxjoy.mou atr/joy.mou + cp $(CC65)/atarixl/drv/mou/atrxtrk.mou atr/trk.mou + cp $(CC65)/atarixl/drv/mou/atrxtt.mou atr/tt.mou $(DIR2ATR) -b Dos25 1040 $@ atr rm -r atr @@ -216,10 +249,17 @@ contiki-atari-3.atr: atarixl-makes mkdir atr cp ../atarixl/dos25/dos.sys atr/dos.sys cp ../atarixl/dos25/dup.sys atr/dup.sys +ifdef SLIP + cp ../../cpu/6502/serconfig/serconfig.atarixl atr/serconfi.com +endif cp ../../cpu/6502/ipconfig/ipconfig.atarixl atr/ipconfig.com cp ../../examples/webserver/webserver-example.atarixl atr/webserv.com cp ../../examples/telnet-server/telnet-server.atarixl atr/telnetd.com +ifdef SLIP + cp default.cfg atr/contiki.cfg +else cp ../atarixl/default.cfg atr/contiki.cfg +endif cp $(CC65)/atarixl/drv/mou/atrxst.mou atr/contiki.mou cp $(CC65)/atarixl/drv/mou/atrxami.mou atr/ami.mou cp $(CC65)/atarixl/drv/mou/atrxjoy.mou atr/joy.mou @@ -236,13 +276,20 @@ contiki-atari.atr: atarixl-makes mkdir atr cp ../atarixl/mydos4534/dos.sys atr/dos.sys cp ../atarixl/mydos4534/dup.sys atr/dup.sys +ifdef SLIP + cp ../../cpu/6502/serconfig/serconfig.atarixl atr/serconfi.com +endif cp ../../cpu/6502/ipconfig/ipconfig.atarixl atr/ipconfig.com cp ../../examples/webbrowser/webbrowser.atarixl atr/webbrows.com cp ../../examples/wget/wget.atarixl atr/wget.com cp ../../examples/irc/irc-client.atarixl atr/irc.com cp ../../examples/webserver/webserver-example.atarixl atr/webserv.com cp ../../examples/telnet-server/telnet-server.atarixl atr/telnetd.com +ifdef SLIP + cp default.cfg atr/contiki.cfg +else cp ../atarixl/default.cfg atr/contiki.cfg +endif cp $(CC65)/atarixl/drv/mou/atrxst.mou atr/contiki.mou cp $(CC65)/atarixl/drv/mou/atrxami.mou atr/ami.mou cp $(CC65)/atarixl/drv/mou/atrxjoy.mou atr/joy.mou @@ -267,14 +314,18 @@ contiki-c64.zip: contiki-c64-1.d64 contiki-c64-2.d64 contiki-c64-3.d64 contiki-c contiki-c64-1.d64: c64-makes $(C1541) -format contiki-1,00 d64 $@ - $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/ethconfig.c64 ethconfig,p >$(NULLDEV) + $(C1541) -attach $@ -write ../../cpu/6502/$(DEV)config/$(DEV)config.c64 $(DEV)config,p >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ipconfig/ipconfig.c64 ipconfig,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webbrowser/webbrowser.c64 webbrowser,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webbrowser-80col/webbrowser.c64 webbrowser80,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/wget/wget.c64 wget,p >$(NULLDEV) +ifdef SLIP + $(C1541) -attach $@ -write default.cfg contiki.cfg,s >$(NULLDEV) +else $(C1541) -attach $@ -write ../c64/default.cfg contiki.cfg,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/cs8900a.eth cs8900a.eth,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/lan91c96.eth lan91c96.eth,s >$(NULLDEV) +endif $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-1351.mou contiki.mou,s >$(NULLDEV) $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-inkwell.mou inkwell.mou,s >$(NULLDEV) $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-joy.mou joy.mou,s >$(NULLDEV) @@ -282,27 +333,35 @@ contiki-c64-1.d64: c64-makes contiki-c64-2.d64: c64-makes $(C1541) -format contiki-2,00 d64 $@ - $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/ethconfig.c64 ethconfig,p >$(NULLDEV) - $(C1541) -attach $@ -write ../../cpu/6502/ipconfig/ipconfig.c64 ipconfig,p >$(NULLDEV) - $(C1541) -attach $@ -write ../../examples/irc/irc-client.c64 irc,p >$(NULLDEV) - $(C1541) -attach $@ -write ../../examples/irc-80col/irc-client.c64 irc80,p >$(NULLDEV) - $(C1541) -attach $@ -write ../c64/default.cfg contiki.cfg,s >$(NULLDEV) - $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/cs8900a.eth cs8900a.eth,s >$(NULLDEV) - $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/lan91c96.eth lan91c96.eth,s >$(NULLDEV) - $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-1351.mou contiki.mou,s >$(NULLDEV) - $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-inkwell.mou inkwell.mou,s >$(NULLDEV) - $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-joy.mou joy.mou,s >$(NULLDEV) - $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-pot.mou pot.mou,s >$(NULLDEV) + $(C1541) -attach $@ -write ../../cpu/6502/$(DEV)config/$(DEV)config.c64 $(DEV)config,p >$(NULLDEV) + $(C1541) -attach $@ -write ../../cpu/6502/ipconfig/ipconfig.c64 ipconfig,p >$(NULLDEV) + $(C1541) -attach $@ -write ../../examples/irc/irc-client.c64 irc,p >$(NULLDEV) + $(C1541) -attach $@ -write ../../examples/irc-80col/irc-client.c64 irc80,p >$(NULLDEV) +ifdef SLIP + $(C1541) -attach $@ -write default.cfg contiki.cfg,s >$(NULLDEV) +else + $(C1541) -attach $@ -write ../c64/default.cfg contiki.cfg,s >$(NULLDEV) + $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/cs8900a.eth cs8900a.eth,s >$(NULLDEV) + $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/lan91c96.eth lan91c96.eth,s >$(NULLDEV) +endif + $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-1351.mou contiki.mou,s >$(NULLDEV) + $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-inkwell.mou inkwell.mou,s >$(NULLDEV) + $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-joy.mou joy.mou,s >$(NULLDEV) + $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-pot.mou pot.mou,s >$(NULLDEV) contiki-c64-3.d64: c64-makes $(C1541) -format contiki-3,00 d64 $@ - $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/ethconfig.c64 ethconfig,p >$(NULLDEV) + $(C1541) -attach $@ -write ../../cpu/6502/$(DEV)config/$(DEV)config.c64 $(DEV)config,p >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ipconfig/ipconfig.c64 ipconfig,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webserver/webserver-example.c64 webserver,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/telnet-server/telnet-server.c64 telnetd,p >$(NULLDEV) +ifdef SLIP + $(C1541) -attach $@ -write default.cfg contiki.cfg,s >$(NULLDEV) +else $(C1541) -attach $@ -write ../c64/default.cfg contiki.cfg,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/cs8900a.eth cs8900a.eth,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/lan91c96.eth lan91c96.eth,s >$(NULLDEV) +endif $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-1351.mou contiki.mou,s >$(NULLDEV) $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-inkwell.mou inkwell.mou,s >$(NULLDEV) $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-joy.mou joy.mou,s >$(NULLDEV) @@ -314,7 +373,7 @@ contiki-c64-3.d64: c64-makes contiki-c64.d71: c64-makes $(C1541) -format contiki,00 d71 $@ - $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/ethconfig.c64 ethconfig,p >$(NULLDEV) + $(C1541) -attach $@ -write ../../cpu/6502/$(DEV)config/$(DEV)config.c64 $(DEV)config,p >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ipconfig/ipconfig.c64 ipconfig,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webbrowser/webbrowser.c64 webbrowser,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webbrowser-80col/webbrowser.c64 webbrowser80,p >$(NULLDEV) @@ -323,9 +382,13 @@ contiki-c64.d71: c64-makes $(C1541) -attach $@ -write ../../examples/irc-80col/irc-client.c64 irc80,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webserver/webserver-example.c64 webserver,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/telnet-server/telnet-server.c64 telnetd,p >$(NULLDEV) +ifdef SLIP + $(C1541) -attach $@ -write default.cfg contiki.cfg,s >$(NULLDEV) +else $(C1541) -attach $@ -write ../c64/default.cfg contiki.cfg,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/cs8900a.eth cs8900a.eth,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/lan91c96.eth lan91c96.eth,s >$(NULLDEV) +endif $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-1351.mou contiki.mou,s >$(NULLDEV) $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-inkwell.mou inkwell.mou,s >$(NULLDEV) $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-joy.mou joy.mou,s >$(NULLDEV) @@ -337,7 +400,7 @@ contiki-c64.d71: c64-makes contiki-c64.d81: c64-makes $(C1541) -format contiki,00 d81 $@ - $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/ethconfig.c64 ethconfig,p >$(NULLDEV) + $(C1541) -attach $@ -write ../../cpu/6502/$(DEV)config/$(DEV)config.c64 $(DEV)config,p >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ipconfig/ipconfig.c64 ipconfig,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webbrowser/webbrowser.c64 webbrowser,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webbrowser-80col/webbrowser.c64 webbrowser80,p >$(NULLDEV) @@ -346,9 +409,13 @@ contiki-c64.d81: c64-makes $(C1541) -attach $@ -write ../../examples/irc-80col/irc-client.c64 irc80,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webserver/webserver-example.c64 webserver,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/telnet-server/telnet-server.c64 telnetd,p >$(NULLDEV) +ifdef SLIP + $(C1541) -attach $@ -write default.cfg contiki.cfg,s >$(NULLDEV) +else $(C1541) -attach $@ -write ../c64/default.cfg contiki.cfg,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/cs8900a.eth cs8900a.eth,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/lan91c96.eth lan91c96.eth,s >$(NULLDEV) +endif $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-1351.mou contiki.mou,s >$(NULLDEV) $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-inkwell.mou inkwell.mou,s >$(NULLDEV) $(C1541) -attach $@ -write $(CC65)/c64/drv/mou/c64-joy.mou joy.mou,s >$(NULLDEV) @@ -370,24 +437,32 @@ contiki-c128.zip: contiki-c128-1.d64 contiki-c128-2.d64 contiki-c128.d71 contiki contiki-c128-1.d64: c128-makes $(C1541) -format contiki-1,00 d64 $@ - $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/ethconfig.c128 ethconfig,p >$(NULLDEV) + $(C1541) -attach $@ -write ../../cpu/6502/$(DEV)config/$(DEV)config.c128 $(DEV)config,p >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ipconfig/ipconfig.c128 ipconfig,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webbrowser-80col/webbrowser.c128 webbrowser,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/wget/wget.c128 wget,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/irc-80col/irc-client.c128 irc,p >$(NULLDEV) +ifdef SLIP + $(C1541) -attach $@ -write default.cfg contiki.cfg,s >$(NULLDEV) +else $(C1541) -attach $@ -write ../c128/default.cfg contiki.cfg,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/cs8900a.eth cs8900a.eth,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/lan91c96.eth lan91c96.eth,s >$(NULLDEV) +endif contiki-c128-2.d64: c128-makes $(C1541) -format contiki-3,00 d64 $@ - $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/ethconfig.c128 ethconfig,p >$(NULLDEV) + $(C1541) -attach $@ -write ../../cpu/6502/$(DEV)config/$(DEV)config.c128 $(DEV)config,p >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ipconfig/ipconfig.c128 ipconfig,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webserver/webserver-example.c128 webserver,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/telnet-server/telnet-server.c128 telnetd,p >$(NULLDEV) +ifdef SLIP + $(C1541) -attach $@ -write default.cfg contiki.cfg,s >$(NULLDEV) +else $(C1541) -attach $@ -write ../c128/default.cfg contiki.cfg,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/cs8900a.eth cs8900a.eth,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/lan91c96.eth lan91c96.eth,s >$(NULLDEV) +endif $(C1541) -attach $@ -write ../../examples/webserver/httpd-cfs/index.htm index.htm,s >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webserver/httpd-cfs/backgrnd.gif backgrnd.gif,s >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webserver/httpd-cfs/contiki.gif contiki.gif,s >$(NULLDEV) @@ -395,16 +470,20 @@ contiki-c128-2.d64: c128-makes contiki-c128.d71: c128-makes $(C1541) -format contiki,00 d71 $@ - $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/ethconfig.c128 ethconfig,p >$(NULLDEV) + $(C1541) -attach $@ -write ../../cpu/6502/$(DEV)config/$(DEV)config.c128 $(DEV)config,p >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ipconfig/ipconfig.c128 ipconfig,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webbrowser-80col/webbrowser.c128 webbrowser,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/wget/wget.c128 wget,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/irc-80col/irc-client.c128 irc,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webserver/webserver-example.c128 webserver,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/telnet-server/telnet-server.c128 telnetd,p >$(NULLDEV) +ifdef SLIP + $(C1541) -attach $@ -write default.cfg contiki.cfg,s >$(NULLDEV) +else $(C1541) -attach $@ -write ../c128/default.cfg contiki.cfg,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/cs8900a.eth cs8900a.eth,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/lan91c96.eth lan91c96.eth,s >$(NULLDEV) +endif $(C1541) -attach $@ -write ../../examples/webserver/httpd-cfs/index.htm index.htm,s >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webserver/httpd-cfs/backgrnd.gif backgrnd.gif,s >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webserver/httpd-cfs/contiki.gif contiki.gif,s >$(NULLDEV) @@ -412,16 +491,20 @@ contiki-c128.d71: c128-makes contiki-c128.d81: c128-makes $(C1541) -format contiki,00 d81 $@ - $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/ethconfig.c128 ethconfig,p >$(NULLDEV) + $(C1541) -attach $@ -write ../../cpu/6502/$(DEV)config/$(DEV)config.c128 $(DEV)config,p >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ipconfig/ipconfig.c128 ipconfig,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webbrowser-80col/webbrowser.c128 webbrowser,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/wget/wget.c128 wget,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/irc-80col/irc-client.c128 irc,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webserver/webserver-example.c128 webserver,p >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/telnet-server/telnet-server.c128 telnetd,p >$(NULLDEV) +ifdef SLIP + $(C1541) -attach $@ -write default.cfg contiki.cfg,s >$(NULLDEV) +else $(C1541) -attach $@ -write ../c128/default.cfg contiki.cfg,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/cs8900a.eth cs8900a.eth,s >$(NULLDEV) $(C1541) -attach $@ -write ../../cpu/6502/ethconfig/lan91c96.eth lan91c96.eth,s >$(NULLDEV) +endif $(C1541) -attach $@ -write ../../examples/webserver/httpd-cfs/index.htm index.htm,s >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webserver/httpd-cfs/backgrnd.gif backgrnd.gif,s >$(NULLDEV) $(C1541) -attach $@ -write ../../examples/webserver/httpd-cfs/contiki.gif contiki.gif,s >$(NULLDEV) diff --git a/tools/6502/default.cfg b/tools/6502/default.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f6c0401fc7ac252720fce8ef3be45574c9b8127c GIT binary patch literal 21 PcmZQzKm~lv3=E6_0B8Uc literal 0 HcmV?d00001 diff --git a/tools/6502/sample.cfg b/tools/6502/sample.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1a40699e44dd8ed5550eb9f0856257116f4a49ee GIT binary patch literal 21 acmX@Gf+7F^|NjgJRxmJvFds7m10w)(mIt{2 literal 0 HcmV?d00001 From be9711d92e222e9ae910ff8bdfac19da79b35d38 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Thu, 23 Feb 2017 21:43:51 +0100 Subject: [PATCH 045/129] Made rest of Microsoft-specific chat optional. Made code rest of the code in the SLIP driver optional that takes care of the Microsoft-specific CLIENT / SERVER / CLIENTSERVER chat. --- core/dev/slip.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/dev/slip.c b/core/dev/slip.c index fe5a58046..fc79e22f3 100644 --- a/core/dev/slip.c +++ b/core/dev/slip.c @@ -425,11 +425,13 @@ slip_input_byte(unsigned char c) } rxbuf[cur_end] = c; +#ifdef SLIP_CONF_MICROSOFT_CHAT /* There could be a separate poll routine for this. */ if(c == 'T' && rxbuf[begin] == 'C') { process_poll(&slip_process); return 1; } +#endif /* SLIP_CONF_MICROSOFT_CHAT */ if(c == SLIP_END) { /* From ae554aa25644c4f6be84b4e0c45f37e32135ec50 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Wed, 8 Mar 2017 11:24:35 +0100 Subject: [PATCH 046/129] jn516x: update SDK --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 355feb5ac..5aefc0db8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -85,7 +85,7 @@ before_script: - if [ ${BUILD_ARCH:-0} = jn516x ] ; then $WGET http://simonduq.github.io/resources/ba-elf-gcc-4.7.4-part1.tar.bz2 && $WGET http://simonduq.github.io/resources/ba-elf-gcc-4.7.4-part2.tar.bz2 && - $WGET http://simonduq.github.io/resources/jn516x-sdk-4163.tar.bz2 && + $WGET http://simonduq.github.io/resources/jn516x-sdk-4163-1416.tar.bz2 && mkdir /tmp/jn516x-sdk /tmp/ba-elf-gcc && tar xjf jn516x-sdk-*.tar.bz2 -C /tmp/jn516x-sdk && tar xjf ba-elf-gcc-*part1.tar.bz2 -C /tmp/ba-elf-gcc && From 04bce213e6e4bcc21ab8d0385ef164fd7064ce55 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Wed, 8 Mar 2017 12:13:37 +0100 Subject: [PATCH 047/129] jn516x: remove redundant declaration --- platform/jn516x/dev/micromac-radio.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/platform/jn516x/dev/micromac-radio.c b/platform/jn516x/dev/micromac-radio.c index e2d087aa2..6b91cc51b 100644 --- a/platform/jn516x/dev/micromac-radio.c +++ b/platform/jn516x/dev/micromac-radio.c @@ -57,8 +57,6 @@ #include "JPT.h" #include "PeripheralRegs.h" -void vMMAC_SetChannelAndPower(uint8 u8Channel, int8 i8power); - /* This driver configures the radio in PHY mode and does address decoding * and acknowledging in software. */ From d80f362a2be688098b9fb3c3cbcbe1c32b31eb92 Mon Sep 17 00:00:00 2001 From: Thanos Tsakiris Date: Wed, 8 Mar 2017 15:55:28 +0200 Subject: [PATCH 048/129] Adjust CC26xx/CC13xx ADC reading for gain and offset --- cpu/cc26xx-cc13xx/dev/adc-sensor.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cpu/cc26xx-cc13xx/dev/adc-sensor.c b/cpu/cc26xx-cc13xx/dev/adc-sensor.c index 3ccf90e6d..1bf6c291e 100644 --- a/cpu/cc26xx-cc13xx/dev/adc-sensor.c +++ b/cpu/cc26xx-cc13xx/dev/adc-sensor.c @@ -107,7 +107,7 @@ static int value(int type) { if(type == ADC_SENSOR_VALUE) { - int val; + int val, adj_val, adj_mv; if(!is_active) { puts("ADC not active"); @@ -119,10 +119,15 @@ value(int type) ti_lib_aux_adc_gen_manual_trigger(); val = ti_lib_aux_adc_read_fifo(); - + adj_val = ti_lib_aux_adc_adjust_value_for_gain_and_offset( + val, + ti_lib_aux_adc_get_adjustment_gain(AUXADC_REF_FIXED), + ti_lib_aux_adc_get_adjustment_offset(AUXADC_REF_FIXED) ); + adj_mv = ti_lib_aux_adc_value_to_microvolts(AUXADC_FIXED_REF_VOLTAGE_NORMAL, adj_val); + ti_lib_aux_adc_disable(); - return val; + return adj_mv; } return 0; From 9b6ba3c0090afd94f7141fc90b2d4b9e15f4f70f Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Thu, 22 Dec 2016 09:00:38 +0100 Subject: [PATCH 049/129] Make frame fcf creation and parsing standalone functions --- core/net/mac/frame802154.c | 66 +++++++++++++++++++++++--------------- core/net/mac/frame802154.h | 2 ++ 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/core/net/mac/frame802154.c b/core/net/mac/frame802154.c index c970cd964..d5c55c4e8 100644 --- a/core/net/mac/frame802154.c +++ b/core/net/mac/frame802154.c @@ -183,7 +183,7 @@ frame802154_has_panid(frame802154_fcf_t *fcf, int *has_src_pan_id, int *has_dest } else { /* No PAN ID in ACK */ if(fcf->frame_type != FRAME802154_ACKFRAME) { - if(!fcf->panid_compression && fcf->src_addr_mode & 3) { + if(!fcf->panid_compression && (fcf->src_addr_mode & 3)) { /* If compressed, don't include source PAN ID */ src_pan_id = 1; } @@ -304,7 +304,7 @@ field_len(frame802154_t *p, field_length_t *flen) * up to the caller. */ if(p->fcf.frame_version < FRAME802154_IEEE802154E_2012) { /* Set PAN ID compression bit if src pan id matches dest pan id. */ - if(p->fcf.dest_addr_mode & 3 && p->fcf.src_addr_mode & 3 && + if((p->fcf.dest_addr_mode & 3) && (p->fcf.src_addr_mode & 3) && p->src_pid == p->dest_pid) { p->fcf.panid_compression = 1; } else { @@ -362,6 +362,20 @@ frame802154_hdrlen(frame802154_t *p) return 2 + flen.seqno_len + flen.dest_pid_len + flen.dest_addr_len + flen.src_pid_len + flen.src_addr_len + flen.aux_sec_len; } +void +frame802154_create_fcf(frame802154_fcf_t *fcf, uint8_t *buf) +{ + buf[0] = (fcf->frame_type & 7) | + ((fcf->security_enabled & 1) << 3) | + ((fcf->frame_pending & 1) << 4) | + ((fcf->ack_required & 1) << 5) | + ((fcf->panid_compression & 1) << 6); + buf[1] = ((fcf->sequence_number_suppression & 1)) | + ((fcf->ie_list_present & 1)) << 1 | + ((fcf->dest_addr_mode & 3) << 2) | + ((fcf->frame_version & 3) << 4) | + ((fcf->src_addr_mode & 3) << 6); +} /*----------------------------------------------------------------------------*/ /** * \brief Creates a frame for transmission over the air. This function is @@ -388,17 +402,7 @@ frame802154_create(frame802154_t *p, uint8_t *buf) /* OK, now we have field lengths. Time to actually construct */ /* the outgoing frame, and store it in buf */ - buf[0] = (p->fcf.frame_type & 7) | - ((p->fcf.security_enabled & 1) << 3) | - ((p->fcf.frame_pending & 1) << 4) | - ((p->fcf.ack_required & 1) << 5) | - ((p->fcf.panid_compression & 1) << 6); - buf[1] = ((p->fcf.sequence_number_suppression & 1)) | - ((p->fcf.ie_list_present & 1)) << 1 | - ((p->fcf.dest_addr_mode & 3) << 2) | - ((p->fcf.frame_version & 3) << 4) | - ((p->fcf.src_addr_mode & 3) << 6); - + frame802154_create_fcf(&p->fcf, buf); pos = 2; /* Sequence number */ @@ -460,6 +464,28 @@ frame802154_create(frame802154_t *p, uint8_t *buf) return (int)pos; } + +void +frame802154_parse_fcf(uint8_t *data, frame802154_fcf_t *pfcf) +{ + frame802154_fcf_t fcf; + + /* decode the FCF */ + fcf.frame_type = data[0] & 7; + fcf.security_enabled = (data[0] >> 3) & 1; + fcf.frame_pending = (data[0] >> 4) & 1; + fcf.ack_required = (data[0] >> 5) & 1; + fcf.panid_compression = (data[0] >> 6) & 1; + + fcf.sequence_number_suppression = data[1] & 1; + fcf.ie_list_present = (data[1] >> 1) & 1; + fcf.dest_addr_mode = (data[1] >> 2) & 3; + fcf.frame_version = (data[1] >> 4) & 3; + fcf.src_addr_mode = (data[1] >> 6) & 3; + + /* copy fcf */ + memcpy(pfcf, &fcf, sizeof(frame802154_fcf_t)); +} /*----------------------------------------------------------------------------*/ /** * \brief Parses an input frame. Scans the input frame to find each @@ -489,19 +515,7 @@ frame802154_parse(uint8_t *data, int len, frame802154_t *pf) p = data; /* decode the FCF */ - fcf.frame_type = p[0] & 7; - fcf.security_enabled = (p[0] >> 3) & 1; - fcf.frame_pending = (p[0] >> 4) & 1; - fcf.ack_required = (p[0] >> 5) & 1; - fcf.panid_compression = (p[0] >> 6) & 1; - - fcf.sequence_number_suppression = p[1] & 1; - fcf.ie_list_present = (p[1] >> 1) & 1; - fcf.dest_addr_mode = (p[1] >> 2) & 3; - fcf.frame_version = (p[1] >> 4) & 3; - fcf.src_addr_mode = (p[1] >> 6) & 3; - - /* copy fcf and seqNum */ + frame802154_parse_fcf(p, &fcf); memcpy(&pf->fcf, &fcf, sizeof(frame802154_fcf_t)); p += 2; /* Skip first two bytes */ diff --git a/core/net/mac/frame802154.h b/core/net/mac/frame802154.h index defb64b53..2ff067a26 100644 --- a/core/net/mac/frame802154.h +++ b/core/net/mac/frame802154.h @@ -207,8 +207,10 @@ typedef struct { /* Prototypes */ int frame802154_hdrlen(frame802154_t *p); +void frame802154_create_fcf(frame802154_fcf_t *fcf, uint8_t *buf); int frame802154_create(frame802154_t *p, uint8_t *buf); int frame802154_parse(uint8_t *data, int length, frame802154_t *pf); +void frame802154_parse_fcf(uint8_t *data, frame802154_fcf_t *pfcf); /* Get current PAN ID */ uint16_t frame802154_get_pan_id(void); From 79b06879fe269ac6124f54b59e4da0e88b5929d1 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Thu, 22 Dec 2016 09:03:03 +0100 Subject: [PATCH 050/129] Add to jn516x micromac driver full MAC layer support --- platform/jn516x/dev/micromac-radio.c | 144 +++++++++++++++++++++++++-- 1 file changed, 138 insertions(+), 6 deletions(-) diff --git a/platform/jn516x/dev/micromac-radio.c b/platform/jn516x/dev/micromac-radio.c index 6b91cc51b..53bbaadb5 100644 --- a/platform/jn516x/dev/micromac-radio.c +++ b/platform/jn516x/dev/micromac-radio.c @@ -63,6 +63,18 @@ #define DEBUG DEBUG_NONE #include "net/ip/uip-debug.h" +#ifdef MICROMAC_CONF_RADIO_MAC +#define MICROMAC_RADIO_MAC MICROMAC_CONF_RADIO_MAC +#else +#define MICROMAC_RADIO_MAC 0 +#endif + +#if MICROMAC_RADIO_MAC +#define MICROMAC_FRAME tsMacFrame +#else +#define MICROMAC_FRAME tsPhyFrame +#endif + /* Perform CRC check for received packets in SW, * since we use PHY mode which does not calculate CRC in HW */ #define CRC_SW 1 @@ -165,17 +177,17 @@ static volatile uint8_t listen_on = 0; static uint8_t in_ack_transmission = 0; /* TX frame buffer */ -static tsPhyFrame tx_frame_buffer; +static MICROMAC_FRAME tx_frame_buffer; /* RX frame buffer */ -static tsPhyFrame *rx_frame_buffer; +static MICROMAC_FRAME *rx_frame_buffer; /* Frame buffer pointer to read from */ -static tsPhyFrame *input_frame_buffer = NULL; +static MICROMAC_FRAME *input_frame_buffer = NULL; /* Ringbuffer for received packets in interrupt enabled mode */ static struct ringbufindex input_ringbuf; -static tsPhyFrame input_array[MIRCOMAC_CONF_BUF_NUM]; +static MICROMAC_FRAME input_array[MIRCOMAC_CONF_BUF_NUM]; /* SFD timestamp in RTIMER ticks */ static volatile uint32_t last_packet_timestamp = 0; @@ -183,7 +195,9 @@ static volatile uint32_t last_packet_timestamp = 0; /* Local functions prototypes */ static int on(void); static int off(void); +#if !MICROMAC_RADIO_MAC static int is_packet_for_us(uint8_t *buf, int len, int do_send_ack); +#endif static void set_frame_filtering(uint8_t enable); static rtimer_clock_t get_packet_timestamp(void); static void set_txpower(int8_t power); @@ -305,10 +319,21 @@ on(void) { /* No address matching or frame decoding */ if(rx_frame_buffer != NULL) { +#if MICROMAC_RADIO_MAC + vMMAC_StartMacReceive(rx_frame_buffer, + (uint16_t)(E_MMAC_RX_START_NOW + | E_MMAC_RX_USE_AUTO_ACK + | E_MMAC_RX_NO_MALFORMED + | E_MMAC_RX_NO_FCS_ERROR + | E_MMAC_RX_ADDRESS_MATCH + | E_MMAC_RX_ALIGN_NORMAL) + ); +#else vMMAC_StartPhyReceive(rx_frame_buffer, (uint16_t)(E_MMAC_RX_START_NOW | E_MMAC_RX_NO_FCS_ERROR) /* means: reject FCS errors */ ); +#endif } else { missed_radio_on_request = 1; } @@ -347,10 +372,16 @@ transmit(unsigned short payload_len) ENERGEST_ON(ENERGEST_TYPE_TRANSMIT); /* Transmit and wait */ +#if MICROMAC_RADIO_MAC + vMMAC_StartMacTransmit(&tx_frame_buffer, + E_MMAC_TX_START_NOW | + E_MMAC_TX_USE_AUTO_ACK | + (send_on_cca ? E_MMAC_TX_USE_CCA : E_MMAC_TX_NO_CCA)); +#else vMMAC_StartPhyTransmit(&tx_frame_buffer, E_MMAC_TX_START_NOW | (send_on_cca ? E_MMAC_TX_USE_CCA : E_MMAC_TX_NO_CCA)); - +#endif if(poll_mode) { BUSYWAIT_UNTIL(u32MMAC_PollInterruptSource(E_MMAC_INT_TX_COMPLETE), MAX_PACKET_DURATION); } else { @@ -394,8 +425,10 @@ transmit(unsigned short payload_len) static int prepare(const void *payload, unsigned short payload_len) { +#if !MICROMAC_RADIO_MAC uint8_t i; uint16_t checksum; +#endif RIMESTATS_ADD(lltx); @@ -405,6 +438,30 @@ prepare(const void *payload, unsigned short payload_len) if(payload_len > 127 || payload == NULL) { return 1; } +#if MICROMAC_RADIO_MAC + frame802154_t info154; + int hdr_len = frame802154_parse((unsigned char *)payload, payload_len, &info154); + //TODO: hdr_len contains security header, which are not managed by micromac + tx_frame_buffer.u8PayloadLength = payload_len - hdr_len; + tx_frame_buffer.u8SequenceNum = info154.seq; + tx_frame_buffer.u16FCF = ((uint8_t*)payload)[0] | (((uint8_t*)payload)[1] << 8); + tx_frame_buffer.u16DestPAN = info154.dest_pid; + tx_frame_buffer.u16SrcPAN = info154.src_pid; + if(info154.fcf.dest_addr_mode == FRAME802154_SHORTADDRMODE) { + tx_frame_buffer.uDestAddr.u16Short = info154.dest_addr[0] | (info154.dest_addr[0] << 8); + } else if(info154.fcf.dest_addr_mode == FRAME802154_LONGADDRMODE) { + tx_frame_buffer.uDestAddr.sExt.u32L = *(uint32_t*)(&info154.dest_addr[4]); + tx_frame_buffer.uDestAddr.sExt.u32H = *(uint32_t*)(&info154.dest_addr[0]); + } + if(info154.fcf.src_addr_mode == FRAME802154_SHORTADDRMODE) { + tx_frame_buffer.uSrcAddr.u16Short = info154.src_addr[0] | (info154.src_addr[0] << 8); + } else if(info154.fcf.src_addr_mode == FRAME802154_LONGADDRMODE) { + tx_frame_buffer.uSrcAddr.sExt.u32L = *(uint32_t*)(&info154.src_addr[4]); + tx_frame_buffer.uSrcAddr.sExt.u32H = *(uint32_t*)(&info154.src_addr[0]); + } + tx_frame_buffer.u16FCS = crc16_data(payload, payload_len, 0); + memcpy(tx_frame_buffer.uPayload.au8Byte, info154.payload, info154.payload_len); +#else /* Copy payload to (soft) Ttx buffer */ memcpy(tx_frame_buffer.uPayload.au8Byte, payload, payload_len); i = payload_len; @@ -416,6 +473,7 @@ prepare(const void *payload, unsigned short payload_len) tx_frame_buffer.u8PayloadLength = payload_len + CHECKSUM_LEN; #else tx_frame_buffer.u8PayloadLength = payload_len; +#endif #endif return 0; @@ -445,6 +503,7 @@ set_channel(int c) vMMAC_SetChannel(current_channel); } /*---------------------------------------------------------------------------*/ +#if !MICROMAC_RADIO_MAC static int is_broadcast_addr(uint8_t mode, uint8_t *addr) { @@ -504,11 +563,59 @@ is_packet_for_us(uint8_t *buf, int len, int do_send_ack) return 0; } } +#endif /*---------------------------------------------------------------------------*/ static int read(void *buf, unsigned short bufsize) { int len = 0; +#if MICROMAC_RADIO_MAC + frame802154_fcf_t fcf; + uint8_t *p = (uint8_t*)buf; + int has_src_panid; + int has_dest_panid; + int c; + + p[len++] = input_frame_buffer->u16FCF & 0xff; + p[len++] = (input_frame_buffer->u16FCF >> 8) & 0xff; + frame802154_parse_fcf(p, &fcf); + p[len++] = input_frame_buffer->u8SequenceNum; + frame802154_has_panid(&fcf, &has_src_panid, &has_dest_panid); + if(has_dest_panid) { + p[len++] = input_frame_buffer->u16DestPAN & 0xff; + p[len++] = (input_frame_buffer->u16DestPAN >> 8) & 0xff; + } + if(fcf.dest_addr_mode == FRAME802154_SHORTADDRMODE) { + p[len++] = input_frame_buffer->uDestAddr.u16Short & 0xff; + p[len++] = (input_frame_buffer->uDestAddr.u16Short >> 8) & 0xff; + } else if(fcf.dest_addr_mode == FRAME802154_LONGADDRMODE) { + for(c = 0; c < 4; c++) { + p[len + c] = ((uint8_t*)(&input_frame_buffer->uDestAddr.sExt.u32L))[3 - c]; + } + for(c = 0; c < 4; c++) { + p[len + c + 4] = ((uint8_t*)(&input_frame_buffer->uDestAddr.sExt.u32H))[3 - c]; + } + len += 8; + } + if(has_src_panid) { + p[len++] = input_frame_buffer->u16SrcPAN & 0xff; + p[len++] = (input_frame_buffer->u16SrcPAN >> 8) & 0xff; + } + if(fcf.src_addr_mode == FRAME802154_SHORTADDRMODE) { + p[len++] = input_frame_buffer->uSrcAddr.u16Short & 0xff; + p[len++] = (input_frame_buffer->uSrcAddr.u16Short >> 8) & 0xff; + } else if(fcf.src_addr_mode == FRAME802154_LONGADDRMODE) { + for(c = 0; c < 4; c++) { + p[len + c] = ((uint8_t*)(&input_frame_buffer->uSrcAddr.sExt.u32L))[3 - c]; + } + for(c = 0; c < 4; c++) { + p[len + c + 4] = ((uint8_t*)(&input_frame_buffer->uSrcAddr.sExt.u32H))[3 - c]; + } + len += 8; + } + memcpy(&p[len], input_frame_buffer->uPayload.au8Byte, input_frame_buffer->u8PayloadLength); + len += input_frame_buffer->u8PayloadLength; +#else uint16_t radio_last_rx_crc; uint8_t radio_last_rx_crc_ok = 1; @@ -556,7 +663,7 @@ read(void *buf, unsigned short bufsize) /* Disable further read attempts */ input_frame_buffer->u8PayloadLength = 0; } - +#endif return len; } /*---------------------------------------------------------------------------*/ @@ -670,7 +777,9 @@ radio_interrupt_handler(uint32 mac_event) uint8_t overflow = 0; int get_index; int put_index; +#if !MICROMAC_RADIO_MAC int packet_for_me = 0; +#endif if(mac_event & E_MMAC_INT_TX_COMPLETE) { /* Transmission attempt has finished */ @@ -683,6 +792,28 @@ radio_interrupt_handler(uint32 mac_event) last_packet_timestamp = get_packet_timestamp(); if(!poll_mode && (mac_event & E_MMAC_INT_RX_COMPLETE)) { +#if MICROMAC_RADIO_MAC + /* read and cache RSSI and LQI values */ + read_last_rssi(); + /* Put received frame in queue */ + ringbufindex_put(&input_ringbuf); + + if((get_index = ringbufindex_peek_get(&input_ringbuf)) != -1) { + input_frame_buffer = &input_array[get_index]; + } + process_poll(µmac_radio_process); + + /* get pointer to next input slot */ + put_index = ringbufindex_peek_put(&input_ringbuf); + /* is there space? */ + if(put_index != -1) { + /* move rx_frame_buffer to next empty slot */ + rx_frame_buffer = &input_array[put_index]; + } else { + overflow = 1; + rx_frame_buffer = NULL; + } +#else if(rx_frame_buffer->u8PayloadLength > CHECKSUM_LEN) { if(frame_filtering) { /* Check RX address */ @@ -716,6 +847,7 @@ radio_interrupt_handler(uint32 mac_event) rx_frame_buffer = NULL; } } +#endif } } else { /* if rx is not successful */ if(rx_status & E_MMAC_RXSTAT_ABORTED) { From da45afdf275271d50f6b3ddbe1d009082208590a Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Thu, 22 Dec 2016 09:06:04 +0100 Subject: [PATCH 051/129] Add basic contikimac parameters for jn516x --- platform/jn516x/contiki-conf.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/platform/jn516x/contiki-conf.h b/platform/jn516x/contiki-conf.h index 1a326f62b..e3c3a21d9 100644 --- a/platform/jn516x/contiki-conf.h +++ b/platform/jn516x/contiki-conf.h @@ -112,6 +112,16 @@ /* Configure NullRDC for when it is selected */ #define NULLRDC_CONF_802154_AUTOACK_HW 1 +/* Configure ContikiMAC for when it's selected */ +#define CONTIKIMAC_CONF_WITH_CONTIKIMAC_HEADER 0 +#define CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION 0 +#define WITH_FAST_SLEEP 1 + +#ifndef NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE +#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8 +#endif +#define RDC_CONF_HARDWARE_ACK 1 + #define UIP_CONF_LL_802154 1 #define UIP_CONF_LLH_LEN 0 From 0a85ccdc563d2ca4ca2d9da0c4934338b0544896 Mon Sep 17 00:00:00 2001 From: andrewbrannan Date: Wed, 8 Mar 2017 12:42:56 +0000 Subject: [PATCH 052/129] prevent the rpl root from dropping packets bound for outside the dodag while in NS mode --- core/net/rpl/rpl-ext-header.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/net/rpl/rpl-ext-header.c b/core/net/rpl/rpl-ext-header.c index 80de287d9..1dd0850a2 100644 --- a/core/net/rpl/rpl-ext-header.c +++ b/core/net/rpl/rpl-ext-header.c @@ -642,12 +642,18 @@ rpl_update_header(void) if(default_instance->current_dag->rank == ROOT_RANK(default_instance)) { /* At the root, remove headers if any, and insert SRH or HBH - * (SRH is inserted only if the destination is in the DODAG) */ + * (SRH is inserted only if the destination is in the DODAG) */ rpl_remove_header(); - if(RPL_IS_NON_STORING(default_instance)) { - return insert_srh_header(); + if(rpl_get_dag(&UIP_IP_BUF->destipaddr) != NULL) { + /* dest is in a DODAG; the packet is going down. */ + if(RPL_IS_NON_STORING(default_instance)) { + return insert_srh_header(); + } else { + return insert_hbh_header(default_instance); + } } else { - return insert_hbh_header(default_instance); + /* dest is outside of DODAGs; no ext header is needed. */ + return 1; } } else { if(uip_ds6_is_my_addr(&UIP_IP_BUF->srcipaddr) From dbcac67aab2c90bf24602a60208d8566e00aea05 Mon Sep 17 00:00:00 2001 From: Thanos Tsakiris Date: Wed, 8 Mar 2017 17:09:53 +0200 Subject: [PATCH 053/129] Normalize code style with uncrustify --- cpu/cc26xx-cc13xx/dev/adc-sensor.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cpu/cc26xx-cc13xx/dev/adc-sensor.c b/cpu/cc26xx-cc13xx/dev/adc-sensor.c index 1bf6c291e..1f736bb53 100644 --- a/cpu/cc26xx-cc13xx/dev/adc-sensor.c +++ b/cpu/cc26xx-cc13xx/dev/adc-sensor.c @@ -120,11 +120,10 @@ value(int type) ti_lib_aux_adc_gen_manual_trigger(); val = ti_lib_aux_adc_read_fifo(); adj_val = ti_lib_aux_adc_adjust_value_for_gain_and_offset( - val, - ti_lib_aux_adc_get_adjustment_gain(AUXADC_REF_FIXED), - ti_lib_aux_adc_get_adjustment_offset(AUXADC_REF_FIXED) ); + val, + ti_lib_aux_adc_get_adjustment_gain(AUXADC_REF_FIXED), + ti_lib_aux_adc_get_adjustment_offset(AUXADC_REF_FIXED)); adj_mv = ti_lib_aux_adc_value_to_microvolts(AUXADC_FIXED_REF_VOLTAGE_NORMAL, adj_val); - ti_lib_aux_adc_disable(); return adj_mv; From 42cbe85a493219286396c41ca44c6f5b65aa969f Mon Sep 17 00:00:00 2001 From: root Date: Wed, 8 Mar 2017 16:13:27 +0000 Subject: [PATCH 054/129] add CPU energest measurements that were lacking in this platform --- platform/avr-rss2/contiki-main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/platform/avr-rss2/contiki-main.c b/platform/avr-rss2/contiki-main.c index a079c5a55..35628c2da 100644 --- a/platform/avr-rss2/contiki-main.c +++ b/platform/avr-rss2/contiki-main.c @@ -258,6 +258,10 @@ initialize(void) /* rtimers needed for radio cycling */ rtimer_init(); +/* after the timer intitialisation we start the cpu measurement */ + ENERGEST_ON(ENERGEST_TYPE_CPU); + + /* Initialize process subsystem */ process_init(); @@ -458,6 +462,11 @@ main(void) #if NETSTACK_CONF_WITH_IPV6 uip_ds6_nbr_t *nbr; #endif /* NETSTACK_CONF_WITH_IPV6 */ + +/* we can initialize the energest here, before the hardware */ + energest_init(); + + initialize(); while(1) { From 8df0f7dd0187ebaeedd0d99ef72ffd37f8fc8752 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Wed, 11 Jan 2017 20:49:50 +0100 Subject: [PATCH 055/129] Add a regression test for ringbufindex APIs --- regression-tests/03-base/04-ringbufindex.csc | 148 +++++++ regression-tests/03-base/code/Makefile | 8 + regression-tests/03-base/code/project-conf.h | 37 ++ .../03-base/code/test-ringbufindex.c | 366 ++++++++++++++++++ .../03-base/js/04-ringbufindex.js | 26 ++ 5 files changed, 585 insertions(+) create mode 100644 regression-tests/03-base/04-ringbufindex.csc create mode 100644 regression-tests/03-base/code/Makefile create mode 100644 regression-tests/03-base/code/project-conf.h create mode 100644 regression-tests/03-base/code/test-ringbufindex.c create mode 100644 regression-tests/03-base/js/04-ringbufindex.js diff --git a/regression-tests/03-base/04-ringbufindex.csc b/regression-tests/03-base/04-ringbufindex.csc new file mode 100644 index 000000000..bdc2cc3ab --- /dev/null +++ b/regression-tests/03-base/04-ringbufindex.csc @@ -0,0 +1,148 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/collect-view + [APPS_DIR]/powertracker + [APPS_DIR]/radiologger-headless + + Test ringbufindex + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype297 + ringbufindex testee + [CONTIKI_DIR]/regression-tests/03-base/code/test-ringbufindex.c + make test-ringbufindex.cooja TARGET=cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 0.0 + 0.0 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype297 + + + + org.contikios.cooja.plugins.SimControl + 280 + 1 + 160 + 400 + 0 + + + org.contikios.cooja.plugins.Visualizer + + true + org.contikios.cooja.plugins.skins.IDVisualizerSkin + org.contikios.cooja.plugins.skins.GridVisualizerSkin + org.contikios.cooja.plugins.skins.TrafficVisualizerSkin + org.contikios.cooja.plugins.skins.UDGMVisualizerSkin + 0.9090909090909091 0.0 0.0 0.9090909090909091 194.0 173.0 + + 400 + 4 + 400 + 1 + 1 + + + org.contikios.cooja.plugins.LogListener + + + + + + 1320 + 3 + 240 + 400 + 160 + + + org.contikios.cooja.plugins.TimeLine + + 0 + + + + 500.0 + + 1720 + 2 + 166 + 0 + 957 + + + org.contikios.cooja.plugins.Notes + + Enter notes here + true + + 1040 + 5 + 160 + 680 + 0 + + + org.contikios.cooja.plugins.ScriptRunner + + [CONTIKI_DIR]/regression-tests/03-base/js/04-ringbufindex.js + true + + 495 + 0 + 525 + 663 + 105 + + + diff --git a/regression-tests/03-base/code/Makefile b/regression-tests/03-base/code/Makefile new file mode 100644 index 000000000..2445ab386 --- /dev/null +++ b/regression-tests/03-base/code/Makefile @@ -0,0 +1,8 @@ +all: test-ringbufindex + +CFLAGS += -D PROJECT_CONF_H=\"project-conf.h\" +APPS += unit-test + +CONTIKI = ../../.. +CONTIKI_WITH_IPV6 = 1 +include $(CONTIKI)/Makefile.include diff --git a/regression-tests/03-base/code/project-conf.h b/regression-tests/03-base/code/project-conf.h new file mode 100644 index 000000000..a7683dbb5 --- /dev/null +++ b/regression-tests/03-base/code/project-conf.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, Yasuyuki Tanaka + * 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 _PROJECT_CONF_H_ +#define _PROJECT_CONF_H_ + +#define UNIT_TEST_PRINT_FUNCTION test_print_report + +#endif /* !_PROJECT_CONF_H_ */ diff --git a/regression-tests/03-base/code/test-ringbufindex.c b/regression-tests/03-base/code/test-ringbufindex.c new file mode 100644 index 000000000..0f9d1c701 --- /dev/null +++ b/regression-tests/03-base/code/test-ringbufindex.c @@ -0,0 +1,366 @@ +/* + * Copyright (c) 2017, Yasuyuki Tanaka + * 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. + */ + +#include + +#include "contiki.h" +#include "unit-test.h" + +#include "lib/ringbufindex.h" + +PROCESS(test_process, "ringbuf-index.c test"); +AUTOSTART_PROCESSES(&test_process); + +static struct ringbufindex ri; +static const uint8_t ri_size = 2; + +static void +test_print_report(const unit_test_t *utp) +{ + printf("=check-me= "); + if(utp->result == unit_test_failure) { + printf("FAILED - %s: exit at L%u\n", utp->descr, utp->exit_line); + } else { + printf("SUCCEEDED - %s\n", utp->descr); + } +} + +UNIT_TEST_REGISTER(test_ringbufindex_init, "Init"); +UNIT_TEST(test_ringbufindex_init) +{ + UNIT_TEST_BEGIN(); + + ringbufindex_init(&ri, ri_size); + + UNIT_TEST_ASSERT(ri.mask == ri_size - 1 && + ri.put_ptr == 0 && + ri.get_ptr == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_ringbufindex_put, "Put"); +UNIT_TEST(test_ringbufindex_put) +{ + int ret; + + UNIT_TEST_BEGIN(); + + ringbufindex_init(&ri, ri_size); + + /* Put the first item */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 1 && ri.get_ptr == 0); + + /* + * This one must fail because the ringbuf is full. The ringbuf can have one + * item (size - 1) at most. + */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 1 && ri.get_ptr == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_ringbufindex_peek_put, "PeekPut"); +UNIT_TEST(test_ringbufindex_peek_put) +{ + int ret; + + UNIT_TEST_BEGIN(); + + ringbufindex_init(&ri, ri_size); + + /* Get index for the first item */ + ret = ringbufindex_peek_put(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 0 && ri.get_ptr == 0); + + /* Put the first item */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 1 && ri.get_ptr == 0); + + /* Get index for the second item; should be -1 because it's full */ + ret = ringbufindex_peek_put(&ri); + UNIT_TEST_ASSERT(ret == -1 && ri.put_ptr == 1 && ri.get_ptr == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_ringbufindex_get, "Get"); +UNIT_TEST(test_ringbufindex_get) +{ + int ret; + + UNIT_TEST_BEGIN(); + + ringbufindex_init(&ri, ri_size); + + /* Get the first item; it's been not put yet. */ + ret = ringbufindex_get(&ri); + UNIT_TEST_ASSERT(ret == -1 && ri.put_ptr == 0 && ri.get_ptr == 0); + + /* Put the first item */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 1 && ri.get_ptr == 0); + + /* Get the first item */ + ret = ringbufindex_get(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 1 && ri.get_ptr == 1); + + /* Put the second item */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 1); + + /* Get the second item */ + ret = ringbufindex_get(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_ringbufindex_peek_get, "PeekGet"); +UNIT_TEST(test_ringbufindex_peek_get) +{ + int ret; + + UNIT_TEST_BEGIN(); + + ringbufindex_init(&ri, ri_size); + + /* Get the index of the first item; it's been not put yet. */ + ret = ringbufindex_peek_get(&ri); + UNIT_TEST_ASSERT(ret == -1 && ri.put_ptr == 0 && ri.get_ptr == 0); + + /* Put the first item */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 1 && ri.get_ptr == 0); + + /* Get the index of the first item */ + ret = ringbufindex_peek_get(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 1 && ri.get_ptr == 0); + + /* Get and remove the first item */ + ret = ringbufindex_get(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 1 && ri.get_ptr == 1); + + /* Put the second item */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 1); + + /* Get the index of the second item */ + ret = ringbufindex_peek_get(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 1); + + /* Get and remove the second item */ + ret = ringbufindex_get(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_ringbufindex_size, "Size"); +UNIT_TEST(test_ringbufindex_size) +{ + int ret; + + UNIT_TEST_BEGIN(); + + ringbufindex_init(&ri, ri_size); + + ret = ringbufindex_size(&ri); + UNIT_TEST_ASSERT(ret == ri_size); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_ringbufindex_elements, "Elements"); +UNIT_TEST(test_ringbufindex_elements) +{ + int ret; + + UNIT_TEST_BEGIN(); + + ringbufindex_init(&ri, ri_size); + + /* Nothing in ringbuf */ + ret = ringbufindex_elements(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 0 && ri.get_ptr == 0); + + /* Put the first item */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 1 && ri.get_ptr == 0); + + /* One item in ringbuf */ + ret = ringbufindex_elements(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 1 && ri.get_ptr == 0); + + /* Get the first item */ + ret = ringbufindex_get(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 1 && ri.get_ptr == 1); + + /* Nothing in ringbuf */ + ret = ringbufindex_elements(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 1 && ri.get_ptr == 1); + + /* Put the second item */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 1); + + /* One item in ringbuf */ + ret = ringbufindex_elements(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 1); + + /* Get the second item */ + ret = ringbufindex_get(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 0); + + /* Nothing in ringbuf */ + ret = ringbufindex_elements(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 0 && ri.get_ptr == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_ringbufindex_full, "Full"); +UNIT_TEST(test_ringbufindex_full) +{ + int ret; + + UNIT_TEST_BEGIN(); + + ringbufindex_init(&ri, ri_size); + + /* Nothing in ringbuf; not full */ + ret = ringbufindex_full(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 0 && ri.get_ptr == 0); + + /* Put the first item */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 1 && ri.get_ptr == 0); + + /* One item in ringbuf; full */ + ret = ringbufindex_full(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 1 && ri.get_ptr == 0); + + /* Get the first item */ + ret = ringbufindex_get(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 1 && ri.get_ptr == 1); + + /* Nothing in ringbuf; not full */ + ret = ringbufindex_full(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 1 && ri.get_ptr == 1); + + /* Put the second item */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 1); + + /* One item in ringbuf; full */ + ret = ringbufindex_full(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 1); + + /* Get the second item */ + ret = ringbufindex_get(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 0); + + /* Nothing in ringbuf; not full */ + ret = ringbufindex_full(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 0 && ri.get_ptr == 0); + + UNIT_TEST_END(); +} + +UNIT_TEST_REGISTER(test_ringbufindex_empty, "Empty"); +UNIT_TEST(test_ringbufindex_empty) +{ + int ret; + + UNIT_TEST_BEGIN(); + + ringbufindex_init(&ri, ri_size); + + /* Nothing in ringbuf; empty */ + ret = ringbufindex_empty(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 0); + + /* Put the first item */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 1 && ri.get_ptr == 0); + + /* One item in ringbuf; not empty */ + ret = ringbufindex_empty(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 1 && ri.get_ptr == 0); + + /* Get the first item */ + ret = ringbufindex_get(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 1 && ri.get_ptr == 1); + + /* Nothing in ringbuf; empty */ + ret = ringbufindex_empty(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 1 && ri.get_ptr == 1); + + /* Put the second item */ + ret = ringbufindex_put(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 1); + + /* One item in ringbuf; not empty */ + ret = ringbufindex_empty(&ri); + UNIT_TEST_ASSERT(ret == 0 && ri.put_ptr == 0 && ri.get_ptr == 1); + + /* Get the second item */ + ret = ringbufindex_get(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 0); + + /* Nothing in ringbuf; empty */ + ret = ringbufindex_empty(&ri); + UNIT_TEST_ASSERT(ret == 1 && ri.put_ptr == 0 && ri.get_ptr == 0); + + UNIT_TEST_END(); +} + +PROCESS_THREAD(test_process, ev, data) +{ + PROCESS_BEGIN(); + printf("Run unit-test\n"); + printf("---\n"); + + UNIT_TEST_RUN(test_ringbufindex_init); + UNIT_TEST_RUN(test_ringbufindex_put); + UNIT_TEST_RUN(test_ringbufindex_peek_put); + UNIT_TEST_RUN(test_ringbufindex_get); + UNIT_TEST_RUN(test_ringbufindex_peek_get); + UNIT_TEST_RUN(test_ringbufindex_size); + UNIT_TEST_RUN(test_ringbufindex_elements); + UNIT_TEST_RUN(test_ringbufindex_full); + UNIT_TEST_RUN(test_ringbufindex_empty); + + printf("=check-me= DONE\n"); + PROCESS_END(); +} diff --git a/regression-tests/03-base/js/04-ringbufindex.js b/regression-tests/03-base/js/04-ringbufindex.js new file mode 100644 index 000000000..153f920af --- /dev/null +++ b/regression-tests/03-base/js/04-ringbufindex.js @@ -0,0 +1,26 @@ +TIMEOUT(10000, log.testFailed()); + +var failed = false; + +while(true) { + YIELD(); + + log.log(time + " " + "node-" + id + " "+ msg + "\n"); + + if(msg.contains("=check-me=") == false) { + continue; + } + + if(msg.contains("FAILED")) { + failed = true; + } + + if(msg.contains("DONE")) { + break; + } +} +if(failed) { + log.testFailed(); +} +log.testOK(); + From baaa3da23e78ecccd64a7ee51d00f0eecaeca6f1 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Wed, 11 Jan 2017 21:13:16 +0100 Subject: [PATCH 056/129] ringbufindex: fix a typo in a comment --- core/lib/ringbufindex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/ringbufindex.h b/core/lib/ringbufindex.h index c39f99d18..722676b49 100644 --- a/core/lib/ringbufindex.h +++ b/core/lib/ringbufindex.h @@ -58,7 +58,7 @@ int ringbufindex_peek_put(const struct ringbufindex *r); /* Remove the first element and return its index */ int ringbufindex_get(struct ringbufindex *r); /* Return the index of the first element - * (which will be removed if calling ringbufindex_peek) */ + * (which will be removed if calling ringbufindex_get) */ int ringbufindex_peek_get(const struct ringbufindex *r); /* Return the ring buffer size */ int ringbufindex_size(const struct ringbufindex *r); From fbf9bb9e644a54fca7b001bd287d32405c2e0a9f Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Wed, 11 Jan 2017 21:42:39 +0100 Subject: [PATCH 057/129] ringbufindex: explain return values by the APIs --- core/lib/ringbufindex.h | 69 ++++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 11 deletions(-) diff --git a/core/lib/ringbufindex.h b/core/lib/ringbufindex.h index 722676b49..6fa07b966 100644 --- a/core/lib/ringbufindex.h +++ b/core/lib/ringbufindex.h @@ -48,25 +48,72 @@ struct ringbufindex { uint8_t put_ptr, get_ptr; }; -/* Initialize a ring buffer. The size must be a power of two */ +/** + * \brief Initialize a ring buffer. The size must be a power of two + * \param r Pointer to ringbufindex + * \param size Size of ring buffer + */ void ringbufindex_init(struct ringbufindex *r, uint8_t size); -/* Put one element to the ring buffer */ + +/** + * \brief Put one element to the ring buffer + * \param r Pointer to ringbufindex + * \retval 0 Failure; the ring buffer is full + * \retval 1 Success; an element is added + */ int ringbufindex_put(struct ringbufindex *r); -/* Check if there is space to put an element. - * Return the index where the next element is to be added */ + +/** + * \brief Check if there is space to put an element. + * \param r Pinter to ringbufindex + * \retval >= 0 The index where the next element is to be added. + * \retval -1 Failure; the ring buffer is full + */ int ringbufindex_peek_put(const struct ringbufindex *r); -/* Remove the first element and return its index */ + +/** + * \brief Remove the first element and return its index + * \param r Pinter to ringbufindex + * \retval >= 0 The index of the first element + * \retval -1 No element in the ring buffer + */ int ringbufindex_get(struct ringbufindex *r); -/* Return the index of the first element - * (which will be removed if calling ringbufindex_get) */ + +/** + * \brief Return the index of the first element which will be removed if calling + * ringbufindex_get. + * \param r Pinter to ringbufindex + * \retval >= 0 The index of the first element + * \retval -1 No element in the ring buffer + */ int ringbufindex_peek_get(const struct ringbufindex *r); -/* Return the ring buffer size */ + +/** + * \brief Return the ring buffer size + * \param r Pinter to ringbufindex + * \return The size of the ring buffer + */ int ringbufindex_size(const struct ringbufindex *r); -/* Return the number of elements currently in the ring buffer */ + +/** + * \brief Return the number of elements currently in the ring buffer. + * \param r Pinter to ringbufindex + * \return The number of elements in the ring buffer + */ int ringbufindex_elements(const struct ringbufindex *r); -/* Is the ring buffer full? */ + +/** + * \brief Is the ring buffer full? + * \retval 0 Not full + * \retval 1 Full + */ int ringbufindex_full(const struct ringbufindex *r); -/* Is the ring buffer empty? */ + +/** + * \brief Is the ring buffer empty? + * \retval 0 Not empty + * \retval 1 Empty + */ int ringbufindex_empty(const struct ringbufindex *r); #endif /* __RINGBUFINDEX_H__ */ From 2d42b91c7bd6212f6fcc6b69267f787ea259b94e Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Wed, 11 Jan 2017 21:44:29 +0100 Subject: [PATCH 058/129] ringbufindex: fix bugs of ringbufindex_peek_{put,get} --- core/lib/ringbufindex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/ringbufindex.c b/core/lib/ringbufindex.c index 0b2149ff7..a30e85f74 100644 --- a/core/lib/ringbufindex.c +++ b/core/lib/ringbufindex.c @@ -83,7 +83,7 @@ ringbufindex_peek_put(const struct ringbufindex *r) if(((r->put_ptr - r->get_ptr) & r->mask) == r->mask) { return -1; } - return (r->put_ptr + 1) & r->mask; + return r->put_ptr; } /* Remove the first element and return its index */ int @@ -118,7 +118,7 @@ ringbufindex_peek_get(const struct ringbufindex *r) first one. If there are no bytes left, we return -1. */ if(((r->put_ptr - r->get_ptr) & r->mask) > 0) { - return (r->get_ptr + 1) & r->mask; + return r->get_ptr; } else { return -1; } From 9acf1770369a131d89e3434a84e874d793f04194 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Thu, 9 Mar 2017 16:41:13 +0900 Subject: [PATCH 059/129] Enable TSCH regression testing --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5aefc0db8..7f92c751c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -163,3 +163,4 @@ env: - BUILD_TYPE='llsec' MAKE_TARGETS='cooja' - BUILD_TYPE='compile-avr' BUILD_CATEGORY='compile' BUILD_ARCH='avr-rss2' - BUILD_TYPE='ieee802154' + - BUILD_TYPE='tsch' From ed1b27e40b89599b0b856d4c20fa8a314c1a0f63 Mon Sep 17 00:00:00 2001 From: Thomas Blank Date: Fri, 27 Jan 2017 15:22:59 +0100 Subject: [PATCH 060/129] Fix Bug in MQTT App: Refused Connections should not be pursued. No means no. --- apps/mqtt/mqtt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/mqtt/mqtt.c b/apps/mqtt/mqtt.c index 64b2d9454..0be8e83bc 100644 --- a/apps/mqtt/mqtt.c +++ b/apps/mqtt/mqtt.c @@ -751,6 +751,8 @@ handle_connack(struct mqtt_connection *conn) call_event(conn, MQTT_EVENT_CONNECTION_REFUSED_ERROR, &conn->in_packet.payload[1]); + abort_connection(conn); + return; } conn->out_packet.qos_state = MQTT_QOS_STATE_GOT_ACK; From cc4aa440a0886d406bdb706bda55d9d814b5e7f5 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 13 Mar 2017 13:54:40 +0000 Subject: [PATCH 061/129] moved energest init to after the rtimer init --- platform/avr-rss2/contiki-main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/platform/avr-rss2/contiki-main.c b/platform/avr-rss2/contiki-main.c index 35628c2da..f220a168a 100644 --- a/platform/avr-rss2/contiki-main.c +++ b/platform/avr-rss2/contiki-main.c @@ -258,6 +258,8 @@ initialize(void) /* rtimers needed for radio cycling */ rtimer_init(); +/* we can initialize the energest arrays here */ + energest_init(); /* after the timer intitialisation we start the cpu measurement */ ENERGEST_ON(ENERGEST_TYPE_CPU); @@ -462,9 +464,6 @@ main(void) #if NETSTACK_CONF_WITH_IPV6 uip_ds6_nbr_t *nbr; #endif /* NETSTACK_CONF_WITH_IPV6 */ - -/* we can initialize the energest here, before the hardware */ - energest_init(); initialize(); From dbd9d32daf6955cedff1589e2a6fc919ddf781a4 Mon Sep 17 00:00:00 2001 From: Atis Elsts Date: Tue, 14 Mar 2017 18:36:23 +0000 Subject: [PATCH 062/129] CC26xx RF core: don't bail out from restarting the radio timer if just stopping it failed --- cpu/cc26xx-cc13xx/rf-core/rf-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-core.c b/cpu/cc26xx-cc13xx/rf-core/rf-core.c index 4a974a8ea..f64e5524d 100644 --- a/cpu/cc26xx-cc13xx/rf-core/rf-core.c +++ b/cpu/cc26xx-cc13xx/rf-core/rf-core.c @@ -419,8 +419,7 @@ rf_core_restart_rat(void) { if(rf_core_stop_rat() != RF_CORE_CMD_OK) { PRINTF("rf_core_restart_rat: rf_core_stop_rat() failed\n"); - - return RF_CORE_CMD_ERROR; + /* Don't bail out here, still try to start it */ } if(rf_core_start_rat() != RF_CORE_CMD_OK) { From 3b090d97c78b1d3b29e18e4ebea4db2c1129ccbe Mon Sep 17 00:00:00 2001 From: Atis Elsts Date: Tue, 14 Mar 2017 18:41:05 +0000 Subject: [PATCH 063/129] CC26xx IEEE mode: more robust radio timer handling: do not crash the system in case the radio timer failed to start; allow the overflow checker to be called when the radio is off --- cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 55 +++++++++++++++++++-------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index d1e7ab7f9..285c88467 100644 --- a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -211,7 +211,7 @@ static uint64_t last_rat_timestamp64 = 0; /* For RAT overflow handling */ static struct ctimer rat_overflow_timer; -static uint32_t rat_overflow_counter = 0; +static volatile uint32_t rat_overflow_counter = 0; static rtimer_clock_t last_rat_overflow = 0; /* RAT has 32-bit register, overflows once 18 minutes */ @@ -759,20 +759,25 @@ static const rf_core_primary_mode_t mode_ieee = { soft_on, }; /*---------------------------------------------------------------------------*/ -static void +static uint8_t check_rat_overflow(bool first_time) { static uint32_t last_value; uint32_t current_value; uint8_t interrupts_disabled; + /* Bail out if the RF is not on */ + if(!rf_is_on()) { + return 0; + } + interrupts_disabled = ti_lib_int_master_disable(); if(first_time) { last_value = HWREG(RFC_RAT_BASE + RATCNT); } else { current_value = HWREG(RFC_RAT_BASE + RATCNT); if(current_value + RAT_RANGE / 4 < last_value) { - /* overflow detected */ + /* Overflow detected */ last_rat_overflow = RTIMER_NOW(); rat_overflow_counter++; } @@ -781,31 +786,40 @@ check_rat_overflow(bool first_time) if(!interrupts_disabled) { ti_lib_int_master_enable(); } + return 1; } /*---------------------------------------------------------------------------*/ static void handle_rat_overflow(void *unused) { + uint8_t success; uint8_t was_off = 0; if(!rf_is_on()) { was_off = 1; if(on() != RF_CORE_CMD_OK) { PRINTF("overflow: on() failed\n"); - ctimer_set(&rat_overflow_timer, RAT_OVERFLOW_PERIOD_SECONDS * CLOCK_SECOND / 2, + ctimer_set(&rat_overflow_timer, CLOCK_SECOND, handle_rat_overflow, NULL); return; } } - check_rat_overflow(false); + success = check_rat_overflow(false); if(was_off) { off(); } - ctimer_set(&rat_overflow_timer, RAT_OVERFLOW_PERIOD_SECONDS * CLOCK_SECOND / 2, - handle_rat_overflow, NULL); + if(success) { + /* Retry after half of the interval */ + ctimer_set(&rat_overflow_timer, RAT_OVERFLOW_PERIOD_SECONDS * CLOCK_SECOND / 2, + handle_rat_overflow, NULL); + } else { + /* Retry sooner */ + ctimer_set(&rat_overflow_timer, CLOCK_SECOND, + handle_rat_overflow, NULL); + } } /*---------------------------------------------------------------------------*/ static int @@ -995,7 +1009,22 @@ static uint32_t calc_last_packet_timestamp(uint32_t rat_timestamp) { uint64_t rat_timestamp64; - uint32_t adjusted_overflow_counter = rat_overflow_counter; + uint32_t adjusted_overflow_counter; + uint8_t was_off = 0; + + if(!rf_is_on()) { + was_off = 1; + on(); + } + + if(rf_is_on()) { + check_rat_overflow(false); + if(was_off) { + off(); + } + } + + adjusted_overflow_counter = rat_overflow_counter; /* if the timestamp is large and the last oveflow was recently, assume that the timestamp refers to the time before the overflow */ @@ -1023,10 +1052,6 @@ read_frame(void *buf, unsigned short buf_len) rfc_dataEntryGeneral_t *entry = (rfc_dataEntryGeneral_t *)rx_read_entry; uint32_t rat_timestamp; - if(rf_is_on()) { - check_rat_overflow(false); - } - /* wait for entry to become finished */ rtimer_clock_t t0 = RTIMER_NOW(); while(entry->status == DATA_ENTRY_STATUS_BUSY @@ -1498,9 +1523,9 @@ set_value(radio_param_t param, radio_value_t value) /* Restart the radio timer (RAT). This causes resynchronization between RAT and RTC: useful for TSCH. */ - rf_core_restart_rat(); - - check_rat_overflow(false); + if(rf_core_restart_rat() == RF_CORE_CMD_OK) { + check_rat_overflow(false); + } if(rx_on() != RF_CORE_CMD_OK) { PRINTF("set_value: rx_on() failed\n"); From c850bae18634523d9c663a0a5cc0eedcae6ec96c Mon Sep 17 00:00:00 2001 From: Atis Elsts Date: Tue, 14 Mar 2017 18:42:09 +0000 Subject: [PATCH 064/129] CC26xx IEEE mode: introduce and use LIMITED_BUSYWAIT macro; avoids watchdog reboots in cases when the radio fails to turn off --- cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index 285c88467..b89d0337c 100644 --- a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -163,6 +163,18 @@ static uint8_t rf_stats[16] = { 0 }; /* How long to wait for the RF to enter RX in rf_cmd_ieee_rx */ #define ENTER_RX_WAIT_TIMEOUT (RTIMER_SECOND >> 10) + +/* How long to wait for the RF to react on CMD_ABORT: around 1 msec */ +#define RF_TURN_OFF_WAIT_TIMEOUT (RTIMER_SECOND >> 10) + +#define LIMITED_BUSYWAIT(cond, timeout) do { \ + rtimer_clock_t end_time = RTIMER_NOW() + timeout; \ + while(cond) { \ + if(!RTIMER_CLOCK_LT(RTIMER_NOW(), end_time)) { \ + break; \ + } \ + } \ + } while(0) /*---------------------------------------------------------------------------*/ /* TX Power dBm lookup table - values from SmartRF Studio */ typedef struct output_config { @@ -511,7 +523,6 @@ static uint8_t rf_cmd_ieee_rx() { uint32_t cmd_status; - rtimer_clock_t t0; int ret; ret = rf_core_send_cmd((uint32_t)cmd_ieee_rx_buf, &cmd_status); @@ -522,10 +533,8 @@ rf_cmd_ieee_rx() return RF_CORE_CMD_ERROR; } - t0 = RTIMER_NOW(); - - while(RF_RADIO_OP_GET_STATUS(cmd_ieee_rx_buf) != RF_CORE_RADIO_OP_STATUS_ACTIVE && - (RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + ENTER_RX_WAIT_TIMEOUT))); + LIMITED_BUSYWAIT(RF_RADIO_OP_GET_STATUS(cmd_ieee_rx_buf) != RF_CORE_RADIO_OP_STATUS_ACTIVE, + ENTER_RX_WAIT_TIMEOUT); /* Wait to enter RX */ if(RF_RADIO_OP_GET_STATUS(cmd_ieee_rx_buf) != RF_CORE_RADIO_OP_STATUS_ACTIVE) { @@ -688,7 +697,7 @@ rx_off(void) /* Continue nonetheless */ } - while(rf_is_on()); + LIMITED_BUSYWAIT(rf_is_on(), RF_TURN_OFF_WAIT_TIMEOUT); if(RF_RADIO_OP_GET_STATUS(cmd_ieee_rx_buf) == IEEE_DONE_STOPPED || RF_RADIO_OP_GET_STATUS(cmd_ieee_rx_buf) == IEEE_DONE_ABORT) { @@ -739,8 +748,8 @@ soft_off(void) return; } - while((cmd->status & RF_CORE_RADIO_OP_MASKED_STATUS) == - RF_CORE_RADIO_OP_MASKED_STATUS_RUNNING); + LIMITED_BUSYWAIT((cmd->status & RF_CORE_RADIO_OP_MASKED_STATUS) == + RF_CORE_RADIO_OP_MASKED_STATUS_RUNNING, RF_TURN_OFF_WAIT_TIMEOUT); } /*---------------------------------------------------------------------------*/ static uint8_t From a0a2881ab0981700b8cb6d91c65b93f4cc9a4e9c Mon Sep 17 00:00:00 2001 From: Atis Elsts Date: Tue, 14 Mar 2017 18:52:10 +0000 Subject: [PATCH 065/129] CC26xx SensorTag I2C: add and use LIMITED_BUSYWAIT macro --- platform/srf06-cc26xx/sensortag/board-i2c.c | 47 +++++++++++++-------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/platform/srf06-cc26xx/sensortag/board-i2c.c b/platform/srf06-cc26xx/sensortag/board-i2c.c index 17486d65b..3fa54a7d1 100644 --- a/platform/srf06-cc26xx/sensortag/board-i2c.c +++ b/platform/srf06-cc26xx/sensortag/board-i2c.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (c) 2017, University of Bristol - http://www.bris.ac.uk/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,10 +41,22 @@ #include "ti-lib.h" #include "board-i2c.h" #include "lpm.h" +#include "rtimer.h" #include #include /*---------------------------------------------------------------------------*/ +#define I2C_MAX_WAIT_TIME (RTIMER_SECOND / 10) + +#define LIMITED_BUSYWAIT(cond) do { \ + rtimer_clock_t end_time = RTIMER_NOW() + I2C_MAX_WAIT_TIME; \ + while(cond) { \ + if(!RTIMER_CLOCK_LT(RTIMER_NOW(), end_time)) { \ + return false; \ + } \ + } \ + } while(0) +/*---------------------------------------------------------------------------*/ #define NO_INTERFACE 0xFF /*---------------------------------------------------------------------------*/ static uint8_t slave_addr = 0x00; @@ -141,11 +154,11 @@ board_i2c_write(uint8_t *data, uint8_t len) ti_lib_i2c_master_data_put(I2C0_BASE, data[0]); /* Check if another master has access */ - while(ti_lib_i2c_master_bus_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_bus_busy(I2C0_BASE)); /* Assert RUN + START */ ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START); - while(ti_lib_i2c_master_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_busy(I2C0_BASE)); success = i2c_status(); for(i = 1; i < len && success; i++) { @@ -154,7 +167,7 @@ board_i2c_write(uint8_t *data, uint8_t len) if(i < len - 1) { /* Clear START */ ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_CONT); - while(ti_lib_i2c_master_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_busy(I2C0_BASE)); success = i2c_status(); } } @@ -163,9 +176,9 @@ board_i2c_write(uint8_t *data, uint8_t len) if(success) { /* Assert STOP */ ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH); - while(ti_lib_i2c_master_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_busy(I2C0_BASE)); success = i2c_status(); - while(ti_lib_i2c_master_bus_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_bus_busy(I2C0_BASE)); } return success; @@ -181,11 +194,11 @@ board_i2c_write_single(uint8_t data) ti_lib_i2c_master_data_put(I2C0_BASE, data); /* Check if another master has access */ - while(ti_lib_i2c_master_bus_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_bus_busy(I2C0_BASE)); /* Assert RUN + START + STOP */ ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND); - while(ti_lib_i2c_master_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_busy(I2C0_BASE)); return i2c_status(); } @@ -200,7 +213,7 @@ board_i2c_read(uint8_t *data, uint8_t len) ti_lib_i2c_master_slave_addr_set(I2C0_BASE, slave_addr, true); /* Check if another master has access */ - while(ti_lib_i2c_master_bus_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_bus_busy(I2C0_BASE)); /* Assert RUN + START + ACK */ ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START); @@ -208,7 +221,7 @@ board_i2c_read(uint8_t *data, uint8_t len) i = 0; success = true; while(i < (len - 1) && success) { - while(ti_lib_i2c_master_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_busy(I2C0_BASE)); success = i2c_status(); if(success) { data[i] = ti_lib_i2c_master_data_get(I2C0_BASE); @@ -219,11 +232,11 @@ board_i2c_read(uint8_t *data, uint8_t len) if(success) { ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH); - while(ti_lib_i2c_master_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_busy(I2C0_BASE)); success = i2c_status(); if(success) { data[len - 1] = ti_lib_i2c_master_data_get(I2C0_BASE); - while(ti_lib_i2c_master_bus_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_bus_busy(I2C0_BASE)); } } @@ -243,11 +256,11 @@ board_i2c_write_read(uint8_t *wdata, uint8_t wlen, uint8_t *rdata, uint8_t rlen) ti_lib_i2c_master_data_put(I2C0_BASE, wdata[0]); /* Check if another master has access */ - while(ti_lib_i2c_master_bus_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_bus_busy(I2C0_BASE)); /* Assert RUN + START */ ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START); - while(ti_lib_i2c_master_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_busy(I2C0_BASE)); success = i2c_status(); for(i = 1; i < wlen && success; i++) { @@ -256,7 +269,7 @@ board_i2c_write_read(uint8_t *wdata, uint8_t wlen, uint8_t *rdata, uint8_t rlen) /* Clear START */ ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_CONT); - while(ti_lib_i2c_master_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_busy(I2C0_BASE)); success = i2c_status(); } if(!success) { @@ -271,7 +284,7 @@ board_i2c_write_read(uint8_t *wdata, uint8_t wlen, uint8_t *rdata, uint8_t rlen) i = 0; while(i < (rlen - 1) && success) { - while(ti_lib_i2c_master_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_busy(I2C0_BASE)); success = i2c_status(); if(success) { rdata[i] = ti_lib_i2c_master_data_get(I2C0_BASE); @@ -282,11 +295,11 @@ board_i2c_write_read(uint8_t *wdata, uint8_t wlen, uint8_t *rdata, uint8_t rlen) if(success) { ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH); - while(ti_lib_i2c_master_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_busy(I2C0_BASE)); success = i2c_status(); if(success) { rdata[rlen - 1] = ti_lib_i2c_master_data_get(I2C0_BASE); - while(ti_lib_i2c_master_bus_busy(I2C0_BASE)); + LIMITED_BUSYWAIT(ti_lib_i2c_master_bus_busy(I2C0_BASE)); } } From 08b12f2346ad4e618d2748d0aaef1195e8e7737e Mon Sep 17 00:00:00 2001 From: Mohamed Seliem Date: Fri, 17 Mar 2017 20:21:56 +0200 Subject: [PATCH 066/129] fix a macro related to multicast, which are not user configuration fix a macro related to multicast, which are not user configuration - RPL_CONF_MULTICAST -> RPL_WITH_MULTICAST --- core/net/ipv6/multicast/uip-mcast6.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/net/ipv6/multicast/uip-mcast6.h b/core/net/ipv6/multicast/uip-mcast6.h index 211f1128b..91accf41c 100644 --- a/core/net/ipv6/multicast/uip-mcast6.h +++ b/core/net/ipv6/multicast/uip-mcast6.h @@ -162,7 +162,7 @@ struct uip_mcast6_driver { #define UIP_MCAST6 smrf_driver #elif UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_ESMRF -#define RPL_CONF_MULTICAST 1 +#define RPL_WITH_MULTICAST 1 #define UIP_MCAST6 esmrf_driver #else From 7e6d5c2971549d3fd23e2872f990cfdb7a70d8c9 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Fri, 17 Mar 2017 22:30:43 +0000 Subject: [PATCH 067/129] Don't force RPL MOP configuration in contiki-default-conf.h rpl-private.h handles the default MOP correctly, whereas the block in `contiki-default-conf.h` is not only redundant but also fails to handle situations where RPL multicast is required. --- core/contiki-default-conf.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/core/contiki-default-conf.h b/core/contiki-default-conf.h index 8fb380f87..cd002414e 100644 --- a/core/contiki-default-conf.h +++ b/core/contiki-default-conf.h @@ -148,13 +148,6 @@ #endif /* NBR_TABLE_FIND_REMOVABLE */ #endif /* UIP_CONF_IPV6_RPL */ -/* RPL_CONF_MOP specifies the RPL mode of operation that will be - * advertised by the RPL root. Possible values: RPL_MOP_NO_DOWNWARD_ROUTES, - * RPL_MOP_NON_STORING, RPL_MOP_STORING_NO_MULTICAST, RPL_MOP_STORING_MULTICAST */ -#ifndef RPL_CONF_MOP -#define RPL_CONF_MOP RPL_MOP_STORING_NO_MULTICAST -#endif /* RPL_CONF_MOP */ - /* UIP_CONF_MAX_ROUTES specifies the maximum number of routes that each node will be able to handle. */ #ifndef UIP_CONF_MAX_ROUTES From 79855ff02d88faba095f2b4a478bd7d08194a345 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sat, 18 Mar 2017 14:05:36 +0100 Subject: [PATCH 068/129] Beautified SLIP macros. --- platform/apple2enh/contiki-main.c | 12 ++++++------ platform/atarixl/contiki-main.c | 12 ++++++------ platform/c64/contiki-main.c | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/platform/apple2enh/contiki-main.c b/platform/apple2enh/contiki-main.c index 545d9b7a2..35d84aabd 100644 --- a/platform/apple2enh/contiki-main.c +++ b/platform/apple2enh/contiki-main.c @@ -41,12 +41,12 @@ #if WITH_SLIP #define DRIVER_PROCESS &slip_process, -#define SLIP_INIT slip_arch_init(0); -#define SLIP_POLL slip_arch_poll(); +#define SLIP_INIT() slip_arch_init(0) +#define SLIP_POLL() slip_arch_poll() #else /* WITH_SLIP */ #define DRIVER_PROCESS ðernet_process, -#define SLIP_INIT -#define SLIP_POLL +#define SLIP_INIT() +#define SLIP_POLL() #endif /* WITH_SLIP */ #if WITH_GUI @@ -100,7 +100,7 @@ main(void) config_read("contiki.cfg"); - SLIP_INIT + SLIP_INIT(); process_init(); procinit_init(); @@ -114,7 +114,7 @@ main(void) etimer_request_poll(); - SLIP_POLL + SLIP_POLL(); clock_update(); } diff --git a/platform/atarixl/contiki-main.c b/platform/atarixl/contiki-main.c index fa4136dbd..9eadee59b 100644 --- a/platform/atarixl/contiki-main.c +++ b/platform/atarixl/contiki-main.c @@ -41,12 +41,12 @@ #if WITH_SLIP #define DRIVER_PROCESS &slip_process, -#define SLIP_INIT slip_arch_init(0); -#define SLIP_POLL slip_arch_poll(); +#define SLIP_INIT() slip_arch_init(0) +#define SLIP_POLL() slip_arch_poll() #else /* WITH_SLIP */ #define DRIVER_PROCESS ðernet_process, -#define SLIP_INIT -#define SLIP_POLL +#define SLIP_INIT() +#define SLIP_POLL() #endif /* WITH_SLIP */ #if WITH_GUI @@ -95,7 +95,7 @@ main(void) config_read("contiki.cfg"); - SLIP_INIT + SLIP_INIT(); process_init(); procinit_init(); @@ -109,7 +109,7 @@ main(void) etimer_request_poll(); - SLIP_POLL + SLIP_POLL(); } } /*-----------------------------------------------------------------------------------*/ diff --git a/platform/c64/contiki-main.c b/platform/c64/contiki-main.c index 30f9776ba..91bf73804 100644 --- a/platform/c64/contiki-main.c +++ b/platform/c64/contiki-main.c @@ -43,12 +43,12 @@ #if WITH_SLIP #define DRIVER_PROCESS &slip_process, -#define SLIP_INIT slip_arch_init(0); -#define SLIP_POLL slip_arch_poll(); +#define SLIP_INIT() slip_arch_init(0) +#define SLIP_POLL() slip_arch_poll() #else /* WITH_SLIP */ #define DRIVER_PROCESS ðernet_process, -#define SLIP_INIT -#define SLIP_POLL +#define SLIP_INIT() +#define SLIP_POLL() #endif /* WITH_SLIP */ #if WITH_GUI @@ -97,7 +97,7 @@ main(void) config_read("contiki.cfg"); - SLIP_INIT + SLIP_INIT(); process_init(); procinit_init(); @@ -111,7 +111,7 @@ main(void) etimer_request_poll(); - SLIP_POLL + SLIP_POLL(); } } /*-----------------------------------------------------------------------------------*/ From a0134ff35efc7dd635ba8af45b7de5c0290bf680 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sat, 18 Mar 2017 14:06:11 +0100 Subject: [PATCH 069/129] Beautified SLIP macros. --- platform/c128/contiki-main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/c128/contiki-main.c b/platform/c128/contiki-main.c index a6eef0176..940601e9b 100644 --- a/platform/c128/contiki-main.c +++ b/platform/c128/contiki-main.c @@ -41,12 +41,12 @@ #if WITH_SLIP #define DRIVER_PROCESS &slip_process, -#define SLIP_INIT slip_arch_init(0); -#define SLIP_POLL slip_arch_poll(); +#define SLIP_INIT() slip_arch_init(0) +#define SLIP_POLL() slip_arch_poll() #else /* WITH_SLIP */ #define DRIVER_PROCESS ðernet_process, -#define SLIP_INIT -#define SLIP_POLL +#define SLIP_INIT() +#define SLIP_POLL() #endif /* WITH_SLIP */ #if WITH_GUI @@ -95,7 +95,7 @@ main(void) config_read("contiki.cfg"); - SLIP_INIT + SLIP_INIT(); process_init(); procinit_init(); @@ -109,7 +109,7 @@ main(void) etimer_request_poll(); - SLIP_POLL + SLIP_POLL(); } } /*-----------------------------------------------------------------------------------*/ From 7f3fcbd8e7b3f1c4d8d7c7aa2a40128e0cc20ddd Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sat, 18 Mar 2017 14:19:36 +0100 Subject: [PATCH 070/129] Made it somewhat more obvious that this is SLIP-only. --- cpu/6502/net/slip_arch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu/6502/net/slip_arch.c b/cpu/6502/net/slip_arch.c index 53450805a..8ca846800 100644 --- a/cpu/6502/net/slip_arch.c +++ b/cpu/6502/net/slip_arch.c @@ -42,15 +42,14 @@ #include "dev/slip.h" +#if WITH_SLIP /*---------------------------------------------------------------------------*/ void slip_arch_init(unsigned long ubr) { unsigned err; -#if WITH_SLIP err = ser_install(STATIC_DRIVER); -#endif /* WITH_SLIP */ if(err == SER_ERR_OK) { err = ser_open((struct ser_params *)config.slip); if(err == SER_ERR_OK) @@ -82,3 +81,4 @@ slip_arch_poll(void) slip_input_byte(c); } /*---------------------------------------------------------------------------*/ +#endif /* WITH_SLIP */ From 739b901e0dcac6570839ce66099fe1c001ade0cd Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 18 Mar 2017 14:01:10 +0000 Subject: [PATCH 071/129] Add missing variable declaration #1972 removed the declaration of `i` from various locations. In one of those locations it is still needed. This commit puts it back --- apps/webserver/httpd-cgi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/webserver/httpd-cgi.c b/apps/webserver/httpd-cgi.c index 0cd474f9b..5ccba151e 100644 --- a/apps/webserver/httpd-cgi.c +++ b/apps/webserver/httpd-cgi.c @@ -252,8 +252,9 @@ extern uip_ds6_netif_t uip_ds6_if; static unsigned short make_addresses(void *p) { -uint8_t j=0; -uint16_t numprinted; + uint8_t i, j = 0; + uint16_t numprinted; + numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh); for (i=0; i Date: Tue, 21 Mar 2017 13:12:39 +0100 Subject: [PATCH 072/129] native-border-router: fix for disappearing timer 'uip_ds6_timer_periodic' When UIP_ND6_SEND_NS is enabled, I've noticed that unreachable neighbours still remains in REACHABLE state even if lifetime (nbr->reachable) expired. During network init 'tcpip_process' is scheduling 'uip_ds6_timer_periodic' is to tick every 100ms and make necessary expirations. When MAC addres is received from slip-radio (from 'etimer_process' context), network is "reinitialized" and timer 'uip_ds6_timer_periodic' is set again with wrong process. --- examples/ipv6/native-border-router/border-router.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/ipv6/native-border-router/border-router.c b/examples/ipv6/native-border-router/border-router.c index fe8d7fbf5..63674db50 100644 --- a/examples/ipv6/native-border-router/border-router.c +++ b/examples/ipv6/native-border-router/border-router.c @@ -247,8 +247,10 @@ border_router_set_mac(const uint8_t *data) /* is this ok - should instead remove all addresses and add them back again - a bit messy... ?*/ + PROCESS_CONTEXT_BEGIN(&tcpip_process); uip_ds6_init(); rpl_init(); + PROCESS_CONTEXT_END(&tcpip_process); mac_set = 1; } From 432f12e156332a6155b124d28f967440657b832c Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 23 Feb 2017 22:03:28 +0100 Subject: [PATCH 073/129] Several changes to fix bugs and harden mqtt code. 1. The PT_MQTT_WAIT_SEND() macro has several issues: - It does not check the return value from process_post(), which sometimes returns an error code. See next issue. - Each time the macro is called, is posts an event to itself. The idea seems to be that the event should be absorbed by the macro itself, so when the macro terminates there is NOT a net growth of the event queue. This does not work. The reason is that the PROCESS_WAIT_EVENT() sometimes absorbs a broadcast event instead of its own event, and then the number of events in the event queue increases. This leads to event explosions and overflow in the event queue. - The macro cannot call PT_EXIT(). This will expand to a return statement, causing a return from the function calling the macro (mqtt_process), rather then exiting the protothread (which was probably the intention). Protothreads have lexical scope... Fixes: 1) Check return value from process_post() 2) Loop until the event posted to itself is absorbed (rather than just absorbing the next event) 3) Replace PT_EXIT() with PT_INIT() (doesn't really make a difference, could probably just be removed). 2. Change order of the checks in the protothread-calling loops in mqtt_process(). Reason: When a protothread has been cleared by PT_MQTT_WAIT_SEND(), it will not return a value, so checking against PT_EXITED does not make sense. 3. PT_MQTT_WRITE_BYTES() should initialize conn->out_write_pos to 0. When PT_MQTT_WRITE_BYTES() does not finish (due to TCP disconnect for instance), it may leave conn->out_write_pos with a non-zero value. Next time PT_MQTT_WRITE_BYTES() is called, it will take data from the wrong place. 4. Put MQTT_CONN_STATE_ABORT_IMMEDIATE before MQTT_CONN_STATE_NOT_CONNECTED in the enum list, so that the check if(conn->state > MQTT_CONN_STATE_NOT_CONNECTED) in mqtt_connect() fails when in state MQTT_CONN_STATE_ABORT_IMMEDIATE. Otherwise, it will deadlock and not reattempt connections while in this state. --- apps/mqtt/mqtt.c | 43 ++++++++++++++++++++++++------------------- apps/mqtt/mqtt.h | 2 +- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/apps/mqtt/mqtt.c b/apps/mqtt/mqtt.c index 0be8e83bc..0a803c761 100644 --- a/apps/mqtt/mqtt.c +++ b/apps/mqtt/mqtt.c @@ -130,6 +130,7 @@ typedef enum { /*---------------------------------------------------------------------------*/ /* Protothread send macros */ #define PT_MQTT_WRITE_BYTES(conn, data, len) \ + conn->out_write_pos = 0; \ while(write_bytes(conn, data, len)) { \ PT_WAIT_UNTIL(pt, (conn)->out_buffer_sent); \ } @@ -147,15 +148,19 @@ typedef enum { */ #define PT_MQTT_WAIT_SEND() \ do { \ - process_post(PROCESS_CURRENT(), mqtt_continue_send_event, NULL); \ - PROCESS_WAIT_EVENT(); \ - if(ev == mqtt_abort_now_event) { \ - conn->state = MQTT_CONN_STATE_ABORT_IMMEDIATE; \ - PT_EXIT(&conn->out_proto_thread); \ - process_post(PROCESS_CURRENT(), ev, data); \ - } else if(ev >= mqtt_event_min && ev <= mqtt_event_max) { \ - process_post(PROCESS_CURRENT(), ev, data); \ - } \ + if (PROCESS_ERR_OK == \ + process_post(PROCESS_CURRENT(), mqtt_continue_send_event, NULL)) { \ + do { \ + PROCESS_WAIT_EVENT(); \ + if(ev == mqtt_abort_now_event) { \ + conn->state = MQTT_CONN_STATE_ABORT_IMMEDIATE; \ + PT_INIT(&conn->out_proto_thread); \ + process_post(PROCESS_CURRENT(), ev, data); \ + } else if(ev >= mqtt_event_min && ev <= mqtt_event_max) { \ + process_post(PROCESS_CURRENT(), ev, data); \ + } \ + } while (ev != mqtt_continue_send_event); \ + } \ } while(0) /*---------------------------------------------------------------------------*/ static process_event_t mqtt_do_connect_tcp_event; @@ -1188,8 +1193,8 @@ PROCESS_THREAD(mqtt_process, ev, data) if(conn->state == MQTT_CONN_STATE_SENDING_MQTT_DISCONNECT) { if(conn->out_buffer_sent == 1) { PT_INIT(&conn->out_proto_thread); - while(disconnect_pt(&conn->out_proto_thread, conn) < PT_EXITED && - conn->state != MQTT_CONN_STATE_ABORT_IMMEDIATE) { + while(conn->state != MQTT_CONN_STATE_ABORT_IMMEDIATE && + disconnect_pt(&conn->out_proto_thread, conn) < PT_EXITED) { PT_MQTT_WAIT_SEND(); } abort_connection(conn); @@ -1206,8 +1211,8 @@ PROCESS_THREAD(mqtt_process, ev, data) if(conn->out_buffer_sent == 1 && conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) { PT_INIT(&conn->out_proto_thread); - while(pingreq_pt(&conn->out_proto_thread, conn) < PT_EXITED && - conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) { + while(conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER && + pingreq_pt(&conn->out_proto_thread, conn) < PT_EXITED) { PT_MQTT_WAIT_SEND(); } } @@ -1219,8 +1224,8 @@ PROCESS_THREAD(mqtt_process, ev, data) if(conn->out_buffer_sent == 1 && conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) { PT_INIT(&conn->out_proto_thread); - while(subscribe_pt(&conn->out_proto_thread, conn) < PT_EXITED && - conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) { + while(conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER && + subscribe_pt(&conn->out_proto_thread, conn) < PT_EXITED) { PT_MQTT_WAIT_SEND(); } } @@ -1232,8 +1237,8 @@ PROCESS_THREAD(mqtt_process, ev, data) if(conn->out_buffer_sent == 1 && conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) { PT_INIT(&conn->out_proto_thread); - while(unsubscribe_pt(&conn->out_proto_thread, conn) < PT_EXITED && - conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) { + while(conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER && + unsubscribe_pt(&conn->out_proto_thread, conn) < PT_EXITED) { PT_MQTT_WAIT_SEND(); } } @@ -1245,8 +1250,8 @@ PROCESS_THREAD(mqtt_process, ev, data) if(conn->out_buffer_sent == 1 && conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) { PT_INIT(&conn->out_proto_thread); - while(publish_pt(&conn->out_proto_thread, conn) < PT_EXITED && - conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) { + while(conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER && + publish_pt(&conn->out_proto_thread, conn) < PT_EXITED) { PT_MQTT_WAIT_SEND(); } } diff --git a/apps/mqtt/mqtt.h b/apps/mqtt/mqtt.h index 4b27fa30c..1802b6c31 100644 --- a/apps/mqtt/mqtt.h +++ b/apps/mqtt/mqtt.h @@ -196,6 +196,7 @@ typedef enum { MQTT_CONN_STATE_ERROR, MQTT_CONN_STATE_DNS_ERROR, MQTT_CONN_STATE_DISCONNECTING, + MQTT_CONN_STATE_ABORT_IMMEDIATE, MQTT_CONN_STATE_NOT_CONNECTED, MQTT_CONN_STATE_DNS_LOOKUP, @@ -204,7 +205,6 @@ typedef enum { MQTT_CONN_STATE_CONNECTING_TO_BROKER, MQTT_CONN_STATE_CONNECTED_TO_BROKER, MQTT_CONN_STATE_SENDING_MQTT_DISCONNECT, - MQTT_CONN_STATE_ABORT_IMMEDIATE, } mqtt_conn_state_t; /*---------------------------------------------------------------------------*/ struct mqtt_string { From 34fa3890548cec66b67aa5ec797bc9850b3ebe61 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Wed, 22 Mar 2017 13:15:58 +0100 Subject: [PATCH 074/129] Whitespace change to force new travis-check. modified: apps/mqtt/mqtt.h --- apps/mqtt/mqtt.h | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/mqtt/mqtt.h b/apps/mqtt/mqtt.h index 1802b6c31..bc6ac3bba 100644 --- a/apps/mqtt/mqtt.h +++ b/apps/mqtt/mqtt.h @@ -197,7 +197,6 @@ typedef enum { MQTT_CONN_STATE_DNS_ERROR, MQTT_CONN_STATE_DISCONNECTING, MQTT_CONN_STATE_ABORT_IMMEDIATE, - MQTT_CONN_STATE_NOT_CONNECTED, MQTT_CONN_STATE_DNS_LOOKUP, MQTT_CONN_STATE_TCP_CONNECTING, From c932ff45a3b9ba20ccbff44a19f4e32be3f6554b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Wed, 7 Dec 2016 17:09:52 +0100 Subject: [PATCH 075/129] er-coap: run uncrustify-fix-style.sh Clean style before modifying. --- apps/er-coap/er-coap-engine.c | 6 +++--- apps/er-coap/er-coap-observe.c | 4 ++-- apps/er-coap/er-coap.c | 4 ++-- apps/er-coap/er-coap.h | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/er-coap/er-coap-engine.c b/apps/er-coap/er-coap-engine.c index 2f58eda94..872de013a 100644 --- a/apps/er-coap/er-coap-engine.c +++ b/apps/er-coap/er-coap-engine.c @@ -256,12 +256,12 @@ coap_receive(void) transaction = NULL; #if COAP_OBSERVE_CLIENT - /* if observe notification */ + /* if observe notification */ if((message->type == COAP_TYPE_CON || message->type == COAP_TYPE_NON) - && IS_OPTION(message, COAP_OPTION_OBSERVE)) { + && IS_OPTION(message, COAP_OPTION_OBSERVE)) { PRINTF("Observe [%u]\n", message->observe); coap_handle_notification(&UIP_IP_BUF->srcipaddr, UIP_UDP_BUF->srcport, - message); + message); } #endif /* COAP_OBSERVE_CLIENT */ } /* request or response */ diff --git a/apps/er-coap/er-coap-observe.c b/apps/er-coap/er-coap-observe.c index 35ab2ff74..3f3dc34ec 100644 --- a/apps/er-coap/er-coap-observe.c +++ b/apps/er-coap/er-coap-observe.c @@ -266,7 +266,7 @@ coap_observe_handler(resource_t *resource, void *request, void *response) { coap_packet_t *const coap_req = (coap_packet_t *)request; coap_packet_t *const coap_res = (coap_packet_t *)response; - coap_observer_t * obs; + coap_observer_t *obs; if(coap_req->code == COAP_GET && coap_res->code < 128) { /* GET request and response without error code */ if(IS_OPTION(coap_req, COAP_OPTION_OBSERVE)) { @@ -274,7 +274,7 @@ coap_observe_handler(resource_t *resource, void *request, void *response) obs = add_observer(&UIP_IP_BUF->srcipaddr, UIP_UDP_BUF->srcport, coap_req->token, coap_req->token_len, coap_req->uri_path, coap_req->uri_path_len); - if(obs) { + if(obs) { coap_set_header_observe(coap_res, (obs->obs_counter)++); /* * Following payload is for demonstration purposes only. diff --git a/apps/er-coap/er-coap.c b/apps/er-coap/er-coap.c index 597d24a11..3c71ff6f9 100644 --- a/apps/er-coap/er-coap.c +++ b/apps/er-coap/er-coap.c @@ -178,7 +178,7 @@ coap_serialize_array_option(unsigned int number, unsigned int current_number, size_t i = 0; PRINTF("ARRAY type %u, len %zu, full [%.*s]\n", number, length, - (int)length, array); + (int)length, array); if(split_char != '\0') { int j; @@ -602,7 +602,7 @@ coap_parse_message(void *packet, uint8_t *data, uint16_t data_len) coap_pkt->uri_host = (char *)current_option; coap_pkt->uri_host_len = option_length; PRINTF("Uri-Host [%.*s]\n", (int)coap_pkt->uri_host_len, - coap_pkt->uri_host); + coap_pkt->uri_host); break; case COAP_OPTION_URI_PORT: coap_pkt->uri_port = coap_parse_int_option(current_option, diff --git a/apps/er-coap/er-coap.h b/apps/er-coap/er-coap.h index ccac6d76e..015d5ee04 100644 --- a/apps/er-coap/er-coap.h +++ b/apps/er-coap/er-coap.h @@ -61,8 +61,8 @@ (REST_MAX_CHUNK_SIZE < 128 ? 64 : \ (REST_MAX_CHUNK_SIZE < 256 ? 128 : \ (REST_MAX_CHUNK_SIZE < 512 ? 256 : \ - (REST_MAX_CHUNK_SIZE < 1024 ? 512 : \ - (REST_MAX_CHUNK_SIZE < 2048 ? 1024 : 2048))))))) + (REST_MAX_CHUNK_SIZE < 1024 ? 512 : \ + (REST_MAX_CHUNK_SIZE < 2048 ? 1024 : 2048))))))) #endif /* COAP_MAX_BLOCK_SIZE */ /* direct access into the buffer */ @@ -135,7 +135,7 @@ typedef struct { /* option format serialization */ #define COAP_SERIALIZE_INT_OPTION(number, field, text) \ if(IS_OPTION(coap_pkt, number)) { \ - PRINTF(text " [%u]\n", (unsigned int)coap_pkt->field); \ + PRINTF(text " [%u]\n", (unsigned int)coap_pkt->field); \ option += coap_serialize_int_option(number, current_number, option, coap_pkt->field); \ current_number = number; \ } @@ -167,7 +167,7 @@ typedef struct { uint32_t block = coap_pkt->field##_num << 4; \ if(coap_pkt->field##_more) { block |= 0x8; } \ block |= 0xF & coap_log_2(coap_pkt->field##_size / 16); \ - PRINTF(text " encoded: 0x%lX\n", (unsigned long)block); \ + PRINTF(text " encoded: 0x%lX\n", (unsigned long)block); \ option += coap_serialize_int_option(number, current_number, option, block); \ current_number = number; \ } From f70adde9a917ffcf3c0f6c0071e3d9c06856bfb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 13 Dec 2016 16:01:16 +0100 Subject: [PATCH 076/129] er-coap-observe-client: missing 'addr' parameter --- apps/er-coap/er-coap-observe-client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/er-coap/er-coap-observe-client.h b/apps/er-coap/er-coap-observe-client.h index d0ece32c0..dfb511620 100644 --- a/apps/er-coap/er-coap-observe-client.h +++ b/apps/er-coap/er-coap-observe-client.h @@ -107,7 +107,7 @@ int coap_obs_remove_observee_by_token(uip_ipaddr_t *addr, uint16_t port, int coap_obs_remove_observee_by_url(uip_ipaddr_t *addr, uint16_t port, const char *url); -void coap_handle_notification(uip_ipaddr_t *, uint16_t port, +void coap_handle_notification(uip_ipaddr_t *addr, uint16_t port, coap_packet_t *notification); coap_observee_t *coap_obs_request_registration(uip_ipaddr_t *addr, From 9e5aed5df6554be3afda2e8fae9cb10bfe33d6b1 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Sat, 21 Jan 2017 16:37:37 +0100 Subject: [PATCH 077/129] Support for changing PANID and channel from project-conf.h modified: cpu/avr/radio/rf230bb/rf230bb.c modified: platform/avr-rss2/contiki-conf.h modified: platform/avr-rss2/contiki-main.c --- cpu/avr/radio/rf230bb/rf230bb.c | 15 +++++++++++++++ platform/avr-rss2/contiki-conf.h | 4 ---- platform/avr-rss2/contiki-main.c | 15 ++++++++++++--- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index cbe8160ef..565c118d5 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -1291,6 +1291,21 @@ rf230_listen_channel(uint8_t c) radio_set_trx_state(RX_ON); } /*---------------------------------------------------------------------------*/ + +unsigned +rf230_get_panid(void) +{ + unsigned pan; + uint8_t byte; + + byte = hal_register_read(RG_PAN_ID_1); + pan = byte; + byte = hal_register_read(RG_PAN_ID_0); + pan = (pan << 8) + byte; + + return pan; +} + void rf230_set_pan_addr(unsigned pan, unsigned addr, diff --git a/platform/avr-rss2/contiki-conf.h b/platform/avr-rss2/contiki-conf.h index 3e1f5dfc2..e69a0a637 100644 --- a/platform/avr-rss2/contiki-conf.h +++ b/platform/avr-rss2/contiki-conf.h @@ -78,10 +78,6 @@ #define NETSTACK_CONF_RADIO rf230_driver #endif -#ifndef CHANNEL_802_15_4 -#define CHANNEL_802_15_4 26 -#endif - /* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */ #ifndef RF230_CONF_AUTOACK #define RF230_CONF_AUTOACK 1 diff --git a/platform/avr-rss2/contiki-main.c b/platform/avr-rss2/contiki-main.c index f220a168a..a872d0cd5 100644 --- a/platform/avr-rss2/contiki-main.c +++ b/platform/avr-rss2/contiki-main.c @@ -314,8 +314,18 @@ initialize(void) memcpy(&uip_lladdr.addr, &addr.u8, sizeof(linkaddr_t)); #endif +#ifdef IEEE802154_CONF_PANID + rf230_set_pan_addr(IEEE802154_CONF_PANID, params_get_panaddr(), (uint8_t *)&addr.u8); +#else rf230_set_pan_addr(params_get_panid(), params_get_panaddr(), (uint8_t *)&addr.u8); +#endif + +#ifdef CHANNEL_CONF_802_15_4 + rf230_set_channel(CHANNEL_CONF_802_15_4); +#else rf230_set_channel(params_get_channel()); +#endif + rf230_set_txpower(params_get_txpower()); #if NETSTACK_CONF_WITH_IPV6 @@ -339,8 +349,8 @@ initialize(void) NETSTACK_NETWORK.init(); #if ANNOUNCE_BOOT - PRINTA("MAC=%s, RDC=%s, NETWORK=%s, channel=%-u, check-rate-Hz=%-u, tx-power=%-u\n", NETSTACK_MAC.name, - NETSTACK_RDC.name, NETSTACK_NETWORK.name, rf230_get_channel(), + PRINTA("PAN=0x%X, XMAC=%s, RDC=%s, NETWORK=%s, channel=%-u, check-rate-Hz=%-u, tx-power=%-u\n", rf230_get_panid(), + NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name, rf230_get_channel(), CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1 : NETSTACK_RDC.channel_check_interval()), rf230_get_txpower()); #if UIP_CONF_IPV6_RPL @@ -349,7 +359,6 @@ initialize(void) #if UIP_CONF_ROUTER PRINTA("Routing Enabled\n"); #endif - #endif /* ANNOUNCE_BOOT */ #if NETSTACK_CONF_WITH_IPV6 || NETSTACK_CONF_WITH_IPV4 From fa6c52633fcbca7467fe6b38e61a23bad3a60fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Sj=C3=B6din?= Date: Fri, 28 Oct 2016 01:04:05 +0200 Subject: [PATCH 078/129] Use RS232_BAUDRATE to define baudrate from projekt config file. Removed serial initialization from contiki-main.c. It seems to be too soon. --- platform/avr-rss2/contiki-conf.h | 5 +++++ platform/avr-rss2/contiki-main.c | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/platform/avr-rss2/contiki-conf.h b/platform/avr-rss2/contiki-conf.h index e69a0a637..2d3ee1031 100644 --- a/platform/avr-rss2/contiki-conf.h +++ b/platform/avr-rss2/contiki-conf.h @@ -106,6 +106,11 @@ void clock_adjust_ticks(clock_time_t howmany); #define AVR_CONF_USE32KCRYSTAL 1 #define SLIP_PORT RS232_PORT_0 +/* Default baud rare on RS232 port */ +#ifndef RS232_BAUDRATE +#define RS232_BAUDRATE USART_BAUD_38400 +#endif + /* Pre-allocated memory for loadable modules heap space (in bytes)*/ /* Default is 4096. Currently used only when elfloader is present. Not tested on Raven */ /* #define MMEM_CONF_SIZE 256 */ diff --git a/platform/avr-rss2/contiki-main.c b/platform/avr-rss2/contiki-main.c index a872d0cd5..907576d43 100644 --- a/platform/avr-rss2/contiki-main.c +++ b/platform/avr-rss2/contiki-main.c @@ -71,7 +71,6 @@ #include "contiki-lib.h" #include "dev/rs232.h" -#include "dev/serial-line.h" #include "dev/slip.h" #if AVR_WEBSERVER @@ -186,9 +185,8 @@ initialize(void) watchdog_init(); watchdog_start(); leds_init(); - serial_line_init(); - rs232_init(RS232_PORT_0, USART_BAUD_38400, USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8); + rs232_init(RS232_PORT_0, RS232_BAUDRATE, USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8); rs232_redirect_stdout(RS232_PORT_0); #if 0 @@ -198,8 +196,6 @@ initialize(void) //UBRR0L = 3; UBRR0H = 0; UCSR0A = (1 << U2X0); // 500k 0% #endif - rs232_set_input(RS232_PORT_0, serial_line_input_byte); - clock_init(); if(MCUSR & (1 << PORF)) { From 29914b5a1fdfb487c6a6facb104599520c567bea Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Mon, 23 Jan 2017 22:18:54 +0100 Subject: [PATCH 079/129] =?UTF-8?q?Fixing=20input=20serial=20line=20initia?= =?UTF-8?q?lization=20pointed=20by=20Peter=20Sj=C3=B6din/KTH=20For=20avr-r?= =?UTF-8?q?ss2=20platform?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/avr-rss2/README.md | 8 -------- platform/avr-rss2/contiki-main.c | 5 +++++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/platform/avr-rss2/README.md b/platform/avr-rss2/README.md index 05d448fc6..2f92a64c4 100644 --- a/platform/avr-rss2/README.md +++ b/platform/avr-rss2/README.md @@ -110,14 +110,6 @@ Tested applications and examples * `examples/powertrace` * `example-shell` -Note that the shell example needs file `symbols.c` to be added to project also seems like -in `core/dev/serial-line.c` the function `process_poll` must be replaced with `process_post`: - - /* Wake up consumer process */ - - process_poll(&serial_line_process); - + process_post(&serial_line_process, 0, 0); - - Platform tutorial applications ----------------------------- Example to read out various sensors, leds, serial numbers, and so on: diff --git a/platform/avr-rss2/contiki-main.c b/platform/avr-rss2/contiki-main.c index 907576d43..ad7af6d11 100644 --- a/platform/avr-rss2/contiki-main.c +++ b/platform/avr-rss2/contiki-main.c @@ -71,6 +71,7 @@ #include "contiki-lib.h" #include "dev/rs232.h" +#include "dev/serial-line.h" #include "dev/slip.h" #if AVR_WEBSERVER @@ -267,6 +268,10 @@ initialize(void) process_start(&etimer_process, NULL); ctimer_init(); + /* After process start */ + serial_line_init(); + rs232_set_input(RS232_PORT_0, serial_line_input_byte); + /* Start radio and radio receive process */ NETSTACK_RADIO.init(); From e09bdc0c07eeae0e765b1e5c16717e51dd8ea6f3 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Sat, 18 Mar 2017 14:13:47 +0100 Subject: [PATCH 080/129] Increasing route table from 4 to 20 modified: platform/avr-rss2/examples/ipv6/mqtt-demo/project-conf.h --- platform/avr-rss2/contiki-conf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/avr-rss2/contiki-conf.h b/platform/avr-rss2/contiki-conf.h index 2d3ee1031..8b365671a 100644 --- a/platform/avr-rss2/contiki-conf.h +++ b/platform/avr-rss2/contiki-conf.h @@ -274,7 +274,7 @@ typedef unsigned short uip_stats_t; #define NBR_TABLE_CONF_MAX_NEIGHBORS 20 #define UIP_CONF_DS6_DEFRT_NBU 2 #define UIP_CONF_DS6_PREFIX_NBU 3 -#define UIP_CONF_MAX_ROUTES 4 +#define UIP_CONF_MAX_ROUTES 20 #define UIP_CONF_DS6_ADDR_NBU 3 #define UIP_CONF_DS6_MADDR_NBU 0 #define UIP_CONF_DS6_AADDR_NBU 0 From c0239b41c92c7efdf216069880d66cd3e664abbc Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Sun, 19 Mar 2017 21:14:31 +0100 Subject: [PATCH 081/129] Cleand-up _CONF for ROUTES, NEIGHBOR and BUFFER_SIZE modified: platform/avr-rss2/contiki-conf.h --- platform/avr-rss2/contiki-conf.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/platform/avr-rss2/contiki-conf.h b/platform/avr-rss2/contiki-conf.h index 8b365671a..b379319b6 100644 --- a/platform/avr-rss2/contiki-conf.h +++ b/platform/avr-rss2/contiki-conf.h @@ -165,6 +165,16 @@ typedef unsigned short uip_stats_t; #define RDC_CONF_MCU_SLEEP 1 #if NETSTACK_CONF_WITH_IPV6 + +#ifndef NBR_TABLE_CONF_MAX_NEIGHBORS +#define NBR_TABLE_CONF_MAX_NEIGHBORS 20 +#endif +#ifndef UIP_CONF_MAX_ROUTES +#define UIP_CONF_MAX_ROUTES 20 +#endif +#ifndef UIP_CONF_BUFFER_SIZE +#define UIP_CONF_BUFFER_SIZE 1280 +#endif #define LINKADDR_CONF_SIZE 8 #define UIP_CONF_ICMP6 1 #define UIP_CONF_UDP 1 @@ -230,16 +240,15 @@ typedef unsigned short uip_stats_t; /* from previous GETs, causing decreased throughput, retransmissions, and timeouts. Increase to study this. */ /* ACKs to other ports become interleaved with computation-intensive GETs, so ACKs are particularly missed. */ /* Increasing the number of packet receive buffers in RAM helps to keep ACKs from being lost */ + #define UIP_CONF_MAX_CONNECTIONS 4 /* 2 bytes per TCP listening port */ #define UIP_CONF_MAX_LISTENPORTS 4 /* 25 bytes per UDP connection */ #define UIP_CONF_UDP_CONNS 10 /* See uip-ds6.h */ -#define NBR_TABLE_CONF_MAX_NEIGHBORS 20 #define UIP_CONF_DS6_DEFRT_NBU 2 #define UIP_CONF_DS6_PREFIX_NBU 3 -#define UIP_CONF_MAX_ROUTES 20 #define UIP_CONF_DS6_ADDR_NBU 3 #define UIP_CONF_DS6_MADDR_NBU 0 #define UIP_CONF_DS6_AADDR_NBU 0 @@ -271,10 +280,8 @@ typedef unsigned short uip_stats_t; #define UIP_CONF_MAX_CONNECTIONS 2 #define UIP_CONF_MAX_LISTENPORTS 4 #define UIP_CONF_UDP_CONNS 5 -#define NBR_TABLE_CONF_MAX_NEIGHBORS 20 #define UIP_CONF_DS6_DEFRT_NBU 2 #define UIP_CONF_DS6_PREFIX_NBU 3 -#define UIP_CONF_MAX_ROUTES 20 #define UIP_CONF_DS6_ADDR_NBU 3 #define UIP_CONF_DS6_MADDR_NBU 0 #define UIP_CONF_DS6_AADDR_NBU 0 @@ -300,10 +307,8 @@ typedef unsigned short uip_stats_t; #define UIP_CONF_MAX_CONNECTIONS 2 #define UIP_CONF_MAX_LISTENPORTS 4 #define UIP_CONF_UDP_CONNS 5 -#define NBR_TABLE_CONF_MAX_NEIGHBORS 4 #define UIP_CONF_DS6_DEFRT_NBU 2 #define UIP_CONF_DS6_PREFIX_NBU 3 -#define UIP_CONF_MAX_ROUTES 4 #define UIP_CONF_DS6_ADDR_NBU 3 #define UIP_CONF_DS6_MADDR_NBU 0 #define UIP_CONF_DS6_AADDR_NBU 0 @@ -333,7 +338,6 @@ typedef unsigned short uip_stats_t; /* For slow slip connections, to prevent buffer overruns */ /* #define UIP_CONF_RECEIVE_WINDOW 300 */ #undef UIP_CONF_FWCACHE_SIZE -#define UIP_CONF_BUFFER_SIZE 600 /* DHCPv4 packets by ip64 module */ #define UIP_CONF_FWCACHE_SIZE 30 #define UIP_CONF_BROADCAST 1 #define UIP_ARCH_IPCHKSUM 1 From bf8e77ea4e316e5d7988dcaf3a587169f40b3c51 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Fri, 24 Mar 2017 17:07:35 +0100 Subject: [PATCH 082/129] Added missing prototype modified: cpu/avr/radio/rf230bb/rf230bb.h --- cpu/avr/radio/rf230bb/rf230bb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cpu/avr/radio/rf230bb/rf230bb.h b/cpu/avr/radio/rf230bb/rf230bb.h index c441e09ab..15f5b6438 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.h +++ b/cpu/avr/radio/rf230bb/rf230bb.h @@ -215,6 +215,7 @@ void rf230_set_channel(uint8_t channel); void rf230_listen_channel(uint8_t channel); uint8_t rf230_get_channel(void); void rf230_set_pan_addr(unsigned pan,unsigned addr,const uint8_t ieee_addr[8]); +unsigned rf230_get_panid(void); void rf230_set_txpower(uint8_t power); uint8_t rf230_get_txpower(void); void rf230_set_rpc(uint8_t rpc); From e77dba152d3aa4664d6d3e50f24b212d607dc9cc Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Fri, 24 Mar 2017 17:29:50 +0100 Subject: [PATCH 083/129] Removing avr-rss2 private sniffer app. Better use examples/sensniff. --- platform/avr-rss2/apps/sniffer/Makefile | 11 -- platform/avr-rss2/apps/sniffer/README.md | 29 ----- platform/avr-rss2/apps/sniffer/project-conf.h | 51 --------- .../apps/sniffer/sniffer-example-coap.pcapng | 0 platform/avr-rss2/apps/sniffer/sniffer.c | 67 ------------ platform/avr-rss2/apps/sniffer/stub-rdc.c | 100 ------------------ 6 files changed, 258 deletions(-) delete mode 100644 platform/avr-rss2/apps/sniffer/Makefile delete mode 100644 platform/avr-rss2/apps/sniffer/README.md delete mode 100644 platform/avr-rss2/apps/sniffer/project-conf.h delete mode 100644 platform/avr-rss2/apps/sniffer/sniffer-example-coap.pcapng delete mode 100644 platform/avr-rss2/apps/sniffer/sniffer.c delete mode 100644 platform/avr-rss2/apps/sniffer/stub-rdc.c diff --git a/platform/avr-rss2/apps/sniffer/Makefile b/platform/avr-rss2/apps/sniffer/Makefile deleted file mode 100644 index 63412a817..000000000 --- a/platform/avr-rss2/apps/sniffer/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -DEFINES+=PROJECT_CONF_H=\"project-conf.h\" -PROJECT_SOURCEFILES += stub-rdc.c - -CONTIKI_PROJECT = sniffer - -all: $(CONTIKI_PROJECT) - -CONTIKI = ../../../.. - -CONTIKI_WITH_RIME = 1 -include $(CONTIKI)/Makefile.include diff --git a/platform/avr-rss2/apps/sniffer/README.md b/platform/avr-rss2/apps/sniffer/README.md deleted file mode 100644 index b9332893b..000000000 --- a/platform/avr-rss2/apps/sniffer/README.md +++ /dev/null @@ -1,29 +0,0 @@ -Sniffer application mote side -============================= -This put the radio in sniff mode and should capure all traffic used -on the set channel. - -Default channel ---------------- -26 - -Bulld ------ -make TARGET=avr-rss2 - -Default serial port speed -------------------------- -38400 bps - -More info & uasage ------------------- -Look in the host directory - -Contiki support ---------------- -The code promisc for support is needed. This also adds the sensniff -format. - -References ----------- -https://github.com/g-oikonomou/sensniff diff --git a/platform/avr-rss2/apps/sniffer/project-conf.h b/platform/avr-rss2/apps/sniffer/project-conf.h deleted file mode 100644 index d56b19e7d..000000000 --- a/platform/avr-rss2/apps/sniffer/project-conf.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2010, Loughborough University - Computer Science - * 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 Institute 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 INSTITUTE 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 INSTITUTE 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. - * - * This file is part of the Contiki operating system. - */ - -/** - * \file - * Project specific configuration defines for the sniffer example. - * - * \author - * George Oikonomou - - * Robert Olsson - - */ - -#ifndef PROJECT_CONF_H_ -#define PROJECT_CONF_H_ - - -#define NETSTACK_CONF_MAC nullmac_driver -/* Can see other channels. Interesting. */ -/* #define NETSTACK_CONF_MAC csma_driver */ -#define NETSTACK_CONF_RDC stub_rdc_driver - - -#endif /* PROJECT_CONF_H_ */ diff --git a/platform/avr-rss2/apps/sniffer/sniffer-example-coap.pcapng b/platform/avr-rss2/apps/sniffer/sniffer-example-coap.pcapng deleted file mode 100644 index e69de29bb..000000000 diff --git a/platform/avr-rss2/apps/sniffer/sniffer.c b/platform/avr-rss2/apps/sniffer/sniffer.c deleted file mode 100644 index be572bce1..000000000 --- a/platform/avr-rss2/apps/sniffer/sniffer.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 Institute 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 INSTITUTE 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 INSTITUTE 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. - * - * This file is part of the Contiki operating system. - * - */ - -/* - Author: Robert Olsson -*/ - -#include "contiki.h" -#include "net/rime/rime.h" -#include "random.h" -#include "dev/button-sensor.h" -#include "dev/leds.h" -#include -/*---------------------------------------------------------------------------*/ - -PROCESS(sniffer_process, "Sniffer process"); -AUTOSTART_PROCESSES(&sniffer_process); - -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(sniffer_process, ev, data) -{ - PROCESS_BEGIN(); - - /* - To get rf230bb radio in sniff mode we need to have radio in RX_ON. - The promisc commands fixes this for us. No need to set PAN and - address or MAC to zero is this case. Se Atmel datasheet. There is - a chance other radios works the same way. - */ - - rf230_set_promiscuous_mode(1); - - printf("Sniffer started\n"); - - while(1) { - PROCESS_YIELD(); - } - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/avr-rss2/apps/sniffer/stub-rdc.c b/platform/avr-rss2/apps/sniffer/stub-rdc.c deleted file mode 100644 index a4db0710d..000000000 --- a/platform/avr-rss2/apps/sniffer/stub-rdc.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2010, Loughborough University - Computer Science - * 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 Institute 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 INSTITUTE 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 INSTITUTE 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. - * - * This file is part of the Contiki operating system. - */ - -/** - * \file - * Definition of a fake RDC driver to be used with passive - * examples. The sniffer will never send packets and it will never - * push incoming packets up the stack. We do this by defining this - * driver as our RDC. We then drop everything - * - * \author - * George Oikonomou - - */ - -#include "net/mac/mac.h" -#include "net/mac/rdc.h" -/*---------------------------------------------------------------------------*/ -static void -send(mac_callback_t sent, void *ptr) -{ - if(sent) { - sent(ptr, MAC_TX_OK, 1); - } -} -/*---------------------------------------------------------------------------*/ -static void -send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *list) -{ - if(sent) { - sent(ptr, MAC_TX_OK, 1); - } -} -/*---------------------------------------------------------------------------*/ -static void -input(void) -{ -} -/*---------------------------------------------------------------------------*/ -static int -on(void) -{ - return 1; -} -/*---------------------------------------------------------------------------*/ -static int -off(int keep_radio_on) -{ - return keep_radio_on; -} -/*---------------------------------------------------------------------------*/ -static unsigned short -cca(void) -{ - return 0; -} -/*---------------------------------------------------------------------------*/ -static void -init(void) -{ -} -/*---------------------------------------------------------------------------*/ -const struct rdc_driver stub_rdc_driver = { - "stub-rdc", - init, - send, - send_list, - input, - on, - off, - cca, -}; -/*---------------------------------------------------------------------------*/ From 3829dd2f209a619a71521c37dc271f1a02087d8d Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Fri, 24 Mar 2017 17:37:37 +0100 Subject: [PATCH 084/129] Leds toggle added modified: platform/avr-rss2/dev/leds.c --- platform/avr-rss2/dev/leds.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platform/avr-rss2/dev/leds.c b/platform/avr-rss2/dev/leds.c index c59f9d09f..ec228f804 100644 --- a/platform/avr-rss2/dev/leds.c +++ b/platform/avr-rss2/dev/leds.c @@ -33,6 +33,12 @@ leds_off(unsigned char ledv) void leds_toggle(unsigned char ledv) { + if(ledv & LEDS_YELLOW) { + PORTE ^= (1 << LED_YELLOW); + } + if(ledv & LEDS_RED) { + PORTE ^= (1 << LED_RED); + } } void leds_invert(unsigned char ledv) From 94defe6ba29c6ea270c4f0e8342506ffcd5f6fe2 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Tue, 28 Mar 2017 18:53:56 +0200 Subject: [PATCH 085/129] Updates for Atmel RF233 radio in AtMega256rfr2 including register update for MAC symbol counter. Basic functions for get/set-value parameter setting added. SPI radios needs to be tested. modified: cpu/avr/radio/rf230bb/atmega256rfr2_registermap.h modified: cpu/avr/radio/rf230bb/rf230bb.c --- .../radio/rf230bb/atmega256rfr2_registermap.h | 170 ++++++++++++--- cpu/avr/radio/rf230bb/rf230bb.c | 197 +++++++++++++++++- 2 files changed, 338 insertions(+), 29 deletions(-) diff --git a/cpu/avr/radio/rf230bb/atmega256rfr2_registermap.h b/cpu/avr/radio/rf230bb/atmega256rfr2_registermap.h index 1baf1a3ac..151513a25 100644 --- a/cpu/avr/radio/rf230bb/atmega256rfr2_registermap.h +++ b/cpu/avr/radio/rf230bb/atmega256rfr2_registermap.h @@ -41,6 +41,120 @@ * Registers can be read with a macro, but the args for subregisters don't expand properly so the actual address * is used with explicit _SFR_MEM8 in the subregister read/write routines. */ + + +/* Symbol Counter */ +#define RG_SCCNTHH (0xE4) /* SCCNTHH7-0 */ +#define RG_SCCNTHL (0xE3) /* SCCNTHL7-0 */ +#define RG_SCCNTLH (0xE2) /* SCCNTLH7-0 */ +#define RG_SCCNTLL (0xE1) /* SCCNTLL7-0 */ + +/* Counter control register 0 */ +#define RG_SCCR0 (0xdc) +#define SR_SCCR0 0xdc, 0xff, 0 +#define SR_SCCR0_SCRES 0xdc, 0x80, 7 /* Counter Sync. */ +#define SR_SCCR0_SCMBTS 0xdc, 0x40, 6 /* Manual Beacon timestamp */ +#define SR_SCCR0_SCEN 0xdc, 0x20, 5 /* Counter enable */ +#define SR_SCCR0_SCCKSEL 0xdc, 0x10, 4 /* Counter clock source */ +#define SR_SCCR0_SCTSE 0xdc, 0x08, 3 /* Auto timstamp Beacon, SFD */ +#define SR_SCCR0_SCMP3 0xdc, 0x04, 2 /* Compare 3 counter mode sel. */ +#define SR_SCCR0_SCMP2 0xdc, 0x02, 1 /* Compare 2 counter mode sel. */ +#define SR_SCCR0_SCMP1 0xdc, 0x01, 0 /* Compare 1 counter mode sel. */ + +/* Counter control register 1 */ +#define RG_SCCR1 (0xdd) +#define SR_SCCR1 0xdd, 0xff, 0 +#define SR_SCCR1_SCBTSM 0xdd, 0x20, 5 /* Disable beacon timestamp */ +#define SR_SCCR1_CLKDIV 0xdd, 0x1c, 2 /* CLKDIV */ +#define SR_SCCR1_CLK0 0xdd, 0x10, 4 /* CLK0 */ +#define SR_SCCR1_CLK1 0xdd, 0x08, 3 /* CLK1 */ +#define SR_SCCR1_CLK2 0xdd, 0x04, 2 /* CLK2 */ +#define SR_SCCR1_EECLK 0xdd, 0x02, 1 /* */ +#define SR_SCCR1_SCENBO 0xdd, 0x01, 0 /* Backoff Slot Counter Enable */ + +/* Prescaler for symbol counter */ +#define SCCKDIV_62_5k 0 +#define SCCKDIV_125k 1 +#define SCCKDIV_250k 2 +#define SCCKDIV_500k 3 +#define SCCKDIV_1M 4 +#define SCCKDIV_2M 5 +#define SCCKDIV_4M 6 + +/* Counter status register 1 */ +#define RG_SCSR (0xde) +#define SR_SCSR 0xde, 0xff, 0 +#define SR_SCBSY 0xde, 0x01, 0 /* Symbol counter busy */ + +/* Counter ISR */ +#define RG_SCIRQS (0xe0) +#define SR_SCIRQS 0xe0, 0xff, 0 +#define SR_SCIRQS_IRQSB0 0xe0, 0x10, 4 /* Backoff */ +#define SR_SCIRQS_IRQSOF 0xe0, 0x08, 3 /* Counter overflow */ +#define SR_SCIRQS_IRQSCP3 0xe0, 0x04, 2 /* Compare 3 counter */ +#define SR_SCIRQS_IRQSCP2 0xe0, 0x02, 1 /* Compare 2 counter */ +#define SR_SCIRQS_IRQSCP1 0xe0, 0x01, 0 /* Compare 1 counter */ + +/* Counter IRQ mask */ +#define RG_SCIRQM (0xdf) +#define SR_SCIRQM 0xdf, 0xff, 0 +#define SR_SCIRQM_IRQMB0 0xdf, 0x10, 4 /* Backoff mask */ +#define SR_SCIRQM_IRQMOF 0xdf, 0x08, 3 /* Counter overflow mask */ +#define SR_SCIRQM_IRQMCP3 0xdf, 0x04, 2 /* Compare 3 counter mask */ +#define SR_SCIRQM_IRQMCP2 0xdf, 0x02, 1 /* Compare 2 counter mask */ +#define SR_SCIRQM_IRQMCP1 0xdf, 0x01, 0 /* Compare 1 counter mask */ + +/* Timestamp SFD */ +#define RG_SCTSRHH 0xFC /* SCTSRHH7-0 */ +#define RG_SCTSRHL 0xFB /* SCTSRHL7-0 */ +#define RG_SCTSRLH 0xFA /* SCTSRLH7-0 */ +#define RG_SCTSRLL 0xF9 /* SCTSRLL7-0 */ + +/* Beacon Timestamp */ +#define RG_SCBTSRHH (0xE8) /* SCBTSRHH7-0 */ +#define RG_SCBTSRHL (0xE7) /* SCBTSRHL7-0 */ +#define RG_SCBTSRLH (0xE6) /* SCBTSRLH7-0 */ +#define RG_SCBTSRLL (0xE5) /* SCBTSRLL7-0 */ + +/* Output Compare 1 */ +#define RG_SCOCR1HH (0xF8) /* SCOCR1HH7-0 */ +#define RG_SCOCR1HL (0xF7) /* SCOCR1HL7-0 */ +#define RG_SCOCR1LH (0xF6) /* SCOCR1LH7-0 */ +#define RG_SCOCR1LL (0xF5) /* SCOCR1LL7-0 */ + +/* Output Compare 2 */ +#define RG_SCOCR2HH (0xF4) /* SCOCR2HH7-0 */ +#define RG_SCOCR2HL (0xF3) /* SCOCR2HL7-0 */ +#define RG_SCOCR2LH (0xF2) /* SCOCR2LH7-0 */ +#define RG_SCOCR2LL (0xF1) /* SCOCR2LL7-0 */ + +/* Output Compare 3 */ +#define RG_SCOCR3HH (0xF0) /* SCOCR3HH7-0 */ +#define RG_SCOCR3HL (0xEF) /* SCOCR3HL7-0 */ +#define RG_SCOCR3LH (0xEE) /* SCOCR3LH7-0 */ +#define RG_SCOCR3LL (0xED) /* SCOCR3LL7-0 */ + +/* Transmit Frame Timestamp */ +#define RG_SCTSTRHH (0xFC) /* SCTSTRHH7-0 */ +#define RG_SCTSTRHL (0xFB) /* SCTSTRHL7-0 */ +#define RG_SCTSTRLH (0xFA) /* SCTSTRLH7-0 */ +#define RG_SCTSTRLL (0xF9) /* SCTSTRLL7-0 */ + +/* +Interrupt Status +#define RG_SCIRQS (0xE0) Res2 Res1 Res0 IRQSBO IRQSOF IRQSCP3 IRQSCP2 IRQSCP1 page 173 +Interrupt Mask +#define RG_SCIRQM (0xDF) Res2 Res1 Res0 IRQMBO IRQMOF IRQMCP3 IRQMCP2 IRQMCP1 page 174 +Counter status +#define RG_SCSR (0xDE) Res6 Res5 Res4 Res3 Res2 Res1 Res0 SCBSY page 173 +Counter Control 1 +#define RG_SCCR1 (0xDD) Res6 Res5 SCBTSM SCCKDIV2 SCCKDIV1 SCCKDIV0 SCEECLK SCENBO page 172 +Counter Control 0 +#define RG_SCCR0 (0xDC) SCRES SCMBTS SCEN SCCKSEL SCTSE SCCMP3 SCCMP2 SCCMP1 page 171 +Counter Compare Source +#define RG_SCCSR (0xDB) Res1 Res0 SCCS31 SCCS30 SCCS21 SCCS20 SCCS11 SCCS10 page 161 +*/ + #define RG_TRX_STATUS TRX_STATUS #define SR_TRX_STATUS 0x141, 0x1f, 0 #define SR_TRX_CMD 0x142, 0x1f, 0 @@ -48,9 +162,35 @@ #define SR_TX_PWR 0x145, 0x0f, 0 #define RG_VERSION_NUM VERSION_NUM #define RG_MAN_ID_0 MAN_ID_0 -#define RG_IRQ_MASK IRQ_MASK +#define RG_IRQ_MASK (0x14e) +/** Access parameters for sub-register IRQ_MASK in register @ref RG_IRQ_MASK */ +#define SR_IRQ_MASK 0x14e, 0xff, 0 +/** Offset for register IRQ_STATUS */ +#define RG_IRQ_STATUS (0x14f) +#define SR_IRQ_STATUS 0x14f, 0xff, 0 +/** Awake Interrupt Status */ +#define SR_IRQ_AWAKE 0x14f, 0x80, 7 +/** TX_END Interrupt Status */ +#define SR_IRQ_TX_END 0x14f, 0x40, 6 +/** Address Match */ +#define SR_IRQ_AMI 0x14f, 0x20, 5 +/** End of ED Measurement Interrupt Status */ +#define SR_CCA_ED_DONE 0x14f, 0x10, 4 +/** Access parameters for sub-register IRQ_3_TRX_END in register @ref RG_IRQ_STATUS */ +#define SR_IRQ_3_TRX_END 0x14f, 0x08, 3 +/** Access parameters for sub-register IRQ_2_RX_START in register @ref RG_IRQ_STATUS */ +#define SR_IRQ_2_RX_START 0x14f, 0x04, 2 +/** Access parameters for sub-register IRQ_1_PLL_UNLOCK in register @ref RG_IRQ_STATUS */ +#define SR_IRQ_1_PLL_UNLOCK 0x14f, 0x02, 1 +/** Access parameters for sub-register IRQ_0_PLL_LOCK in register @ref RG_IRQ_STATUS */ +#define RG_XAH_CTRL_1 (0x157) +#define SR_AACK_PROM_MODE 0x157, 0x02, 1 + + +#define SR_IRQ_0_PLL_LOCK 0x14f, 0x01, 0 #define SR_MAX_FRAME_RETRIES 0x16C, 0xf0, 4 #define SR_TX_AUTO_CRC_ON 0x144, 0x20, 5 +#define SR_PLL_FLT 0x144, 0x10, 4 #define SR_TRAC_STATUS 0x142, 0xe0, 5 #define SR_CHANNEL 0x148, 0x1f, 0 #define SR_CCA_MODE 0x148, 0x60, 5 @@ -67,7 +207,7 @@ #define RG_IEEE_ADDR_5 IEEE_ADDR_5 #define RG_IEEE_ADDR_6 IEEE_ADDR_6 #define RG_IEEE_ADDR_7 IEEE_ADDR_7 -//#define SR_ED_LEVEL 0x147, 0xff, 0 +/* #define SR_ED_LEVEL 0x147, 0xff, 0 */ #define RG_PHY_ED_LEVEL PHY_ED_LEVEL #define RG_RX_SYN RX_SYN #define SR_RSSI 0x146, 0x1f, 0 @@ -81,12 +221,13 @@ #define RG_CSMA_BE CSMA_BE #define RG_CSMA_SEED_0 CSMA_SEED_0 #define RG_PHY_RSSI PHY_RSSI -//#define SR_CCA_CS_THRES 0x149, 0xf0, 4 +#define SR_CCA_CS_THRES 0x149, 0xf0, 4 #define SR_CCA_ED_THRES 0x149, 0x0f, 0 #define SR_CCA_DONE 0x141, 0x80, 7 #define SR_CCA_STATUS 0x141, 0x40, 6 #define SR_AACK_SET_PD 0x16e, 0x20, 5 -#define SR_CSMA_SEED_1 0x16e, 0x10, 4 +#define SR_CSMA_SEED_1 0x16e, 0x03, 0 +#define SR_AACK_DIS_ACK 0x16e, 0x10, 4 /* RF230 register assignments, for reference */ #if 1 @@ -216,27 +357,6 @@ ///** Access parameters for sub-register CCA_ED_THRES in register @ref RG_CCA_THRES */ //#define SR_CCA_ED_THRES 0x09, 0x0f, 0 ///** Offset for register IRQ_MASK */ -//#define RG_IRQ_MASK (0x0e) -///** Access parameters for sub-register IRQ_MASK in register @ref RG_IRQ_MASK */ -//#define SR_IRQ_MASK 0x0e, 0xff, 0 -///** Offset for register IRQ_STATUS */ -//#define RG_IRQ_STATUS (0x0f) -///** Access parameters for sub-register IRQ_7_BAT_LOW in register @ref RG_IRQ_STATUS */ -//#define SR_IRQ_7_BAT_LOW 0x0f, 0x80, 7 -///** Access parameters for sub-register IRQ_6_TRX_UR in register @ref RG_IRQ_STATUS */ -//#define SR_IRQ_6_TRX_UR 0x0f, 0x40, 6 -///** Access parameters for sub-register IRQ_5 in register @ref RG_IRQ_STATUS */ -//#define SR_IRQ_5 0x0f, 0x20, 5 -///** Access parameters for sub-register IRQ_4 in register @ref RG_IRQ_STATUS */ -//#define SR_IRQ_4 0x0f, 0x10, 4 -///** Access parameters for sub-register IRQ_3_TRX_END in register @ref RG_IRQ_STATUS */ -//#define SR_IRQ_3_TRX_END 0x0f, 0x08, 3 -///** Access parameters for sub-register IRQ_2_RX_START in register @ref RG_IRQ_STATUS */ -//#define SR_IRQ_2_RX_START 0x0f, 0x04, 2 -///** Access parameters for sub-register IRQ_1_PLL_UNLOCK in register @ref RG_IRQ_STATUS */ -//#define SR_IRQ_1_PLL_UNLOCK 0x0f, 0x02, 1 -///** Access parameters for sub-register IRQ_0_PLL_LOCK in register @ref RG_IRQ_STATUS */ -//#define SR_IRQ_0_PLL_LOCK 0x0f, 0x01, 0 ///** Offset for register VREG_CTRL */ //#define RG_VREG_CTRL (0x10) ///** Access parameters for sub-register AVREG_EXT in register @ref RG_VREG_CTRL */ diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index cbe8160ef..fcc198e31 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -94,6 +94,9 @@ static bool is_promiscuous; #endif +/* Poll mode disabled by default */ +uint8_t poll_mode = 0; + /* RF230_CONF_FRAME_RETRIES is 1 plus the number written to the hardware. */ /* Valid range 1-16, zero disables extended mode. */ #ifndef RF230_CONF_FRAME_RETRIES @@ -201,6 +204,8 @@ extern uint8_t debugflowsize,debugflow[DEBUGFLOWSIZE]; #define DEBUGFLOW(c) #endif +static radio_status_t radio_set_trx_state(uint8_t new_state); + /* XXX hack: these will be made as Chameleon packet attributes */ #if RF230_CONF_TIMESTAMPS rtimer_clock_t rf230_time_of_arrival, rf230_time_of_departure; @@ -254,17 +259,186 @@ static int rf230_cca(void); uint8_t rf230_last_correlation,rf230_last_rssi,rf230_smallest_rssi; +static void +set_poll_mode(bool enable) +{ + poll_mode = enable; + if(poll_mode) { + rf230_set_rpc(0x0); /* Disbable all RPC features */ + radio_set_trx_state(RX_ON); + hal_subregister_write(SR_IRQ_MASK, RF230_SUPPORTED_INTERRUPT_MASK); + /* hal_register_write(RG_IRQ_MASK, 0xFF); */ + } else { + /* Initialize and enable interrupts */ + rf230_set_rpc(0xFF); /* Enable all RPC features. Only XRFR2 radios */ + radio_set_trx_state(RX_AACK_ON); + } +} + +static bool +get_poll_mode(void) +{ + return poll_mode; +} + +void +set_frame_filtering(bool i) +{ + if(i) + hal_subregister_write(SR_AACK_PROM_MODE, 0); + else { + hal_subregister_write(SR_AACK_PROM_MODE, 1); + } +} + +static bool +get_frame_filtering(void) +{ + int i = hal_subregister_read(SR_AACK_PROM_MODE); + if(i) + return 0; + return 1; +} + +void +set_auto_ack(bool i) +{ + if(i) + hal_subregister_write(SR_AACK_DIS_ACK, 0); + else + hal_subregister_write(SR_AACK_DIS_ACK, 1); +} + +static bool +get_auto_ack(void) +{ + int i = hal_subregister_read(SR_AACK_DIS_ACK); + if(i) + return 0; + return 1; +} /*---------------------------------------------------------------------------*/ static radio_result_t get_value(radio_param_t param, radio_value_t *value) { - return RADIO_RESULT_NOT_SUPPORTED; + if(!value) { + return RADIO_RESULT_INVALID_VALUE; + } + + switch(param) { + case RADIO_PARAM_POWER_MODE: + /* *value = (REG(RFCORE_XREG_RXENABLE) && RFCORE_XREG_RXENABLE_RXENMASK) == 0 )? + RADIO_POWER_MODE_OFF : RADIO_POWER_MODE_ON; */ + return RADIO_RESULT_OK; + + case RADIO_PARAM_TX_MODE: + return RADIO_RESULT_OK; + + case RADIO_PARAM_CHANNEL: + *value = (radio_value_t)rf230_get_channel(); + return RADIO_RESULT_OK; + case RADIO_PARAM_PAN_ID: + /* *value = get_pan_id(); */ + return RADIO_RESULT_OK; + case RADIO_PARAM_16BIT_ADDR: + /* *value = get_short_addr(); */ + return RADIO_RESULT_OK; + case RADIO_PARAM_RX_MODE: + *value = 0; + if(get_frame_filtering()) { + *value |= RADIO_RX_MODE_ADDRESS_FILTER; + } + if(get_auto_ack()) { + *value |= RADIO_RX_MODE_AUTOACK; + } + if(get_poll_mode()) { + *value |= RADIO_RX_MODE_POLL_MODE; + } + return RADIO_RESULT_OK; + case RADIO_PARAM_TXPOWER: + *value = rf230_get_txpower(); + return RADIO_RESULT_OK; + case RADIO_PARAM_CCA_THRESHOLD: + /* *value = get_cca_threshold(); */ + return RADIO_RESULT_OK; + case RADIO_PARAM_RSSI: + *value = rf230_get_raw_rssi(); + return RADIO_RESULT_OK; + case RADIO_CONST_CHANNEL_MIN: + *value = RF230_MIN_CHANNEL; + return RADIO_RESULT_OK; + case RADIO_CONST_CHANNEL_MAX: + *value = RF230_MAX_CHANNEL;; + return RADIO_RESULT_OK; + case RADIO_CONST_TXPOWER_MIN: + *value = TX_PWR_MIN; + return RADIO_RESULT_OK; + case RADIO_CONST_TXPOWER_MAX: + *value = TX_PWR_MAX; + return RADIO_RESULT_OK; + default: + return RADIO_RESULT_NOT_SUPPORTED; + } } /*---------------------------------------------------------------------------*/ static radio_result_t set_value(radio_param_t param, radio_value_t value) { - return RADIO_RESULT_NOT_SUPPORTED; + switch(param) { + case RADIO_PARAM_POWER_MODE: + if(value == RADIO_POWER_MODE_ON) { + rf230_on(); + return RADIO_RESULT_OK; + } + if(value == RADIO_POWER_MODE_OFF) { + rf230_off(); + return RADIO_RESULT_OK; + } + return RADIO_RESULT_INVALID_VALUE; + + case RADIO_PARAM_CHANNEL: + + if(value < RF230_MIN_CHANNEL || + value > RF230_MAX_CHANNEL) { + return RADIO_RESULT_INVALID_VALUE; + } + + rf230_set_channel(value); + return RADIO_RESULT_OK; + + case RADIO_PARAM_TX_MODE: + return RADIO_RESULT_OK; + + case RADIO_PARAM_PAN_ID: + /* set_pan_id(value & 0xffff); */ + return RADIO_RESULT_OK; + case RADIO_PARAM_16BIT_ADDR: + /* set_short_addr(value & 0xffff); */ + return RADIO_RESULT_OK; + case RADIO_PARAM_RX_MODE: + + if(value & ~(RADIO_RX_MODE_ADDRESS_FILTER | RADIO_RX_MODE_POLL_MODE | + RADIO_RX_MODE_AUTOACK)) { + return RADIO_RESULT_INVALID_VALUE; + } + set_frame_filtering((value & RADIO_RX_MODE_ADDRESS_FILTER) != 0); + set_auto_ack((value & RADIO_RX_MODE_AUTOACK) != 0); + set_poll_mode((value & RADIO_RX_MODE_POLL_MODE) != 0); + return RADIO_RESULT_OK; + + case RADIO_PARAM_TXPOWER: + if(value < TX_PWR_MIN || value > TX_PWR_MAX) { + return RADIO_RESULT_INVALID_VALUE; + } + rf230_set_txpower(value); + return RADIO_RESULT_OK; + + case RADIO_PARAM_CCA_THRESHOLD: + /* set_cca_threshold(value); */ + return RADIO_RESULT_OK; + default: + return RADIO_RESULT_NOT_SUPPORTED; + } } /*---------------------------------------------------------------------------*/ static radio_result_t @@ -347,7 +521,7 @@ hal_rx_frame_t rxframe[RF230_CONF_RX_BUFFERS]; * \retval STATE_TRANSITION The radio transceiver's state machine is in * transition between two states. */ -//static uint8_t + uint8_t radio_get_trx_state(void) { @@ -878,7 +1052,7 @@ void rf230_warm_reset(void) { DDRB &= ~(1<<7); #endif - hal_register_write(RG_IRQ_MASK, RF230_SUPPORTED_INTERRUPT_MASK); + hal_subregister_write(SR_IRQ_MASK, RF230_SUPPORTED_INTERRUPT_MASK); /* Set up number of automatic retries 0-15 * (0 implies PLL_ON sends instead of the extended TX_ARET mode */ @@ -1291,6 +1465,21 @@ rf230_listen_channel(uint8_t c) radio_set_trx_state(RX_ON); } /*---------------------------------------------------------------------------*/ + +unsigned +rf230_get_panid(void) +{ + unsigned pan; + uint8_t byte; + + byte = hal_register_read(RG_PAN_ID_1); + pan = byte; + byte = hal_register_read(RG_PAN_ID_0); + pan = (pan << 8) + byte; + + return pan; +} + void rf230_set_pan_addr(unsigned pan, unsigned addr, From 55daec98dcb6ca24be108bceb294e0c2a1b30f28 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Tue, 28 Mar 2017 22:16:50 +0200 Subject: [PATCH 086/129] Added missing registers in modified: cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h --- cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h b/cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h index b28ed0ec0..64b068579 100644 --- a/cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h +++ b/cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h @@ -83,7 +83,10 @@ #define SR_CCA_DONE 0x141, 0x80, 7 #define SR_CCA_STATUS 0x141, 0x40, 6 #define SR_AACK_SET_PD 0x16e, 0x20, 5 +#define SR_AACK_DIS_ACK 0x16e, 0x10, 4 +#define RG_XAH_CTRL_1 (0x157) +#define SR_AACK_PROM_MODE 0x157, 0x02, 1 /* RF230 register assignments, for reference */ #if 0 From d6128852b2a2c749a9102894a4e40fd1390e724f Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Wed, 29 Mar 2017 11:32:39 +0200 Subject: [PATCH 087/129] Added missing register definitions in at86rf230_registermap.h modified: cpu/avr/radio/rf230bb/at86rf230_registermap.h --- cpu/avr/radio/rf230bb/at86rf230_registermap.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpu/avr/radio/rf230bb/at86rf230_registermap.h b/cpu/avr/radio/rf230bb/at86rf230_registermap.h index 1ca9d5130..b5c500315 100644 --- a/cpu/avr/radio/rf230bb/at86rf230_registermap.h +++ b/cpu/avr/radio/rf230bb/at86rf230_registermap.h @@ -236,6 +236,7 @@ #define RG_RX_SYN 0x15 /** Offset for register XAH_CTRL_1 */ #define RG_XAH_CTRL_1 0x17 +#define SR_AACK_PROM_MODE 0x17, 0x02, 1 /** Access parameters for sub-register XTAL_MODE in register @ref RG_XOSC_CTRL */ #define SR_XTAL_MODE 0x12, 0xf0, 4 /** Access parameters for sub-register XTAL_TRIM in register @ref RG_XOSC_CTRL */ @@ -340,6 +341,7 @@ #define SR_CSMA_SEED_0 0x2d, 0xff, 0 /** Offset for register CSMA_SEED_1 */ #define RG_CSMA_SEED_1 (0x2e) +#define SR_AACK_DIS_ACK 0x2e, 0x10, 4 /** Offset for register CSMA_BE */ #define RG_CSMA_BE 0x2f /** Access parameters for sub-register MIN_BE in register @ref RG_CSMA_SEED_1 */ From 399150b1428d49a36afbb74ca07f9d01c12e9e9b Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Thu, 30 Mar 2017 15:24:19 +0200 Subject: [PATCH 088/129] Minor spell fix in ANNOUNCE_BOOT modified: platform/avr-rss2/contiki-main.c --- platform/avr-rss2/contiki-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/avr-rss2/contiki-main.c b/platform/avr-rss2/contiki-main.c index ad7af6d11..2b5cf3b07 100644 --- a/platform/avr-rss2/contiki-main.c +++ b/platform/avr-rss2/contiki-main.c @@ -350,7 +350,7 @@ initialize(void) NETSTACK_NETWORK.init(); #if ANNOUNCE_BOOT - PRINTA("PAN=0x%X, XMAC=%s, RDC=%s, NETWORK=%s, channel=%-u, check-rate-Hz=%-u, tx-power=%-u\n", rf230_get_panid(), + PRINTA("PAN=0x%X, MAC=%s, RDC=%s, NETWORK=%s, channel=%-u, check-rate-Hz=%-u, tx-power=%-u\n", rf230_get_panid(), NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name, rf230_get_channel(), CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1 : NETSTACK_RDC.channel_check_interval()), rf230_get_txpower()); From a30364189a610058c4915516220ebb4682025d94 Mon Sep 17 00:00:00 2001 From: alexstanoev Date: Fri, 31 Mar 2017 16:44:11 +0100 Subject: [PATCH 089/129] Zero out httpd_state before deallocating When a connection is aborted by the HTTP server while it's still being processed it is possible to hit a null pointer dereference issue by jumping back to a protothread (outputpt) after its httpd_state has been freed. This can be triggered by sending a POST to any form in the CC26xx web demo server using Firefox. This patch prevents that by zeroing out httpd_state structs before freeing them, thus also clearing the httpd_state->outputpt field. Tested using Firefox 55.0a1 on a CC2650 LaunchPad. --- examples/cc26xx/cc26xx-web-demo/httpd-simple.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/cc26xx/cc26xx-web-demo/httpd-simple.c b/examples/cc26xx/cc26xx-web-demo/httpd-simple.c index 9800bbc48..e23e78efe 100644 --- a/examples/cc26xx/cc26xx-web-demo/httpd-simple.c +++ b/examples/cc26xx/cc26xx-web-demo/httpd-simple.c @@ -1268,9 +1268,7 @@ appcall(void *state) if(uip_closed() || uip_aborted() || uip_timedout()) { if(s != NULL) { - s->script = NULL; - s->blen = 0; - s->tmp_buf_len = 0; + memset(s, 0, sizeof(struct httpd_state)); memb_free(&conns, s); } } else if(uip_connected()) { @@ -1291,7 +1289,7 @@ appcall(void *state) if(uip_poll()) { if(timer_expired(&s->timer)) { uip_abort(); - s->script = NULL; + memset(s, 0, sizeof(struct httpd_state)); memb_free(&conns, s); } } else { From f15b86158bead763ea1824eb2e7f55eeec5ba71e Mon Sep 17 00:00:00 2001 From: Alexandru-Ioan Pop Date: Sun, 12 Mar 2017 20:59:00 +0000 Subject: [PATCH 090/129] Check broker IP conversion. Adjust state machine accordingly The result of converting the IP address of the broker wasn't checked. As a result, the pointer was left uninitialised and the IPv6 address used for connecting was some random data. The function now returns an error. Before connect_to_broker is called, mqtt_register is executed, which memsets conn to 0, making its state 0 (MQTT_CONN_STATE_ERROR). In order to recover from this error state, the extra check was added in the MQTT_CLIENT_STATE_NEWCONFIG state. This was discovered using [CodeSonar](https://www.grammatech.com/products/codesonar) --- apps/mqtt/mqtt.c | 4 +++- examples/cc26xx/cc26xx-web-demo/mqtt-client.c | 15 ++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/mqtt/mqtt.c b/apps/mqtt/mqtt.c index 0be8e83bc..5ef4cbca3 100644 --- a/apps/mqtt/mqtt.c +++ b/apps/mqtt/mqtt.c @@ -1333,7 +1333,9 @@ mqtt_connect(struct mqtt_connection *conn, char *host, uint16_t port, conn->connect_vhdr_flags |= MQTT_VHDR_CLEAN_SESSION_FLAG; /* convert the string IPv6 address to a numeric IPv6 address */ - uiplib_ip6addrconv(host, &ip6addr); + if(uiplib_ip6addrconv(host, &ip6addr) == 0) { + return MQTT_STATUS_ERROR; + } uip_ipaddr_copy(&(conn->server_ip), ipaddr); diff --git a/examples/cc26xx/cc26xx-web-demo/mqtt-client.c b/examples/cc26xx/cc26xx-web-demo/mqtt-client.c index cf60d6c63..e45378264 100644 --- a/examples/cc26xx/cc26xx-web-demo/mqtt-client.c +++ b/examples/cc26xx/cc26xx-web-demo/mqtt-client.c @@ -698,10 +698,15 @@ static void connect_to_broker(void) { /* Connect to MQTT server */ - mqtt_connect(&conn, conf->broker_ip, conf->broker_port, - conf->pub_interval * 3); + mqtt_status_t conn_attempt_result = mqtt_connect(&conn, conf->broker_ip, + conf->broker_port, + conf->pub_interval * 3); - state = MQTT_CLIENT_STATE_CONNECTING; + if(conn_attempt_result == MQTT_STATUS_OK) { + state = MQTT_CLIENT_STATE_CONNECTING; + } else { + state = MQTT_CLIENT_STATE_CONFIG_ERROR; + } } /*---------------------------------------------------------------------------*/ static void @@ -827,8 +832,8 @@ state_machine(void) } break; case MQTT_CLIENT_STATE_NEWCONFIG: - /* Only update config after we have disconnected */ - if(conn.state == MQTT_CONN_STATE_NOT_CONNECTED) { + /* Only update config after we have disconnected or in the case of an error */ + if(conn.state == MQTT_CONN_STATE_NOT_CONNECTED || conn.state == MQTT_CONN_STATE_ERROR) { update_config(); DBG("New config\n"); From 093550ecbf56f757577fda6f9400425d33f9a29d Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Fri, 31 Mar 2017 18:38:27 +0200 Subject: [PATCH 091/129] Update for Atmel radio part II modified: cpu/avr/radio/rf230bb/halbb.c modified: cpu/avr/radio/rf230bb/rf230bb.c --- cpu/avr/radio/rf230bb/halbb.c | 4 +- cpu/avr/radio/rf230bb/rf230bb.c | 92 ++++++++++++++++++++++----------- 2 files changed, 65 insertions(+), 31 deletions(-) diff --git a/cpu/avr/radio/rf230bb/halbb.c b/cpu/avr/radio/rf230bb/halbb.c index 243e11c03..c146998d4 100644 --- a/cpu/avr/radio/rf230bb/halbb.c +++ b/cpu/avr/radio/rf230bb/halbb.c @@ -81,10 +81,10 @@ extern uint8_t debugflowsize,debugflow[DEBUGFLOWSIZE]; #include "at86rf230_registermap.h" #endif +extern void get_last_rx_packet_timestamp(void); /*============================ VARIABLES =====================================*/ volatile extern signed char rf230_last_rssi; - /*============================ CALLBACKS =====================================*/ @@ -668,7 +668,7 @@ ISR(TRX24_RX_START_vect) #if !RF230_CONF_AUTOACK rf230_last_rssi = 3 * hal_subregister_read(SR_RSSI); #endif - + get_last_rx_packet_timestamp(); } /* PLL has locked, either from a transition out of TRX_OFF or a channel change while on */ diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index fcc198e31..2abe6b911 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -146,6 +146,8 @@ uint8_t ack_pending,ack_seqnum; #warning RF230 Untested Configuration! #endif +rtimer_clock_t last_rx_packet_timestamp; + struct timestamp { uint16_t time; uint8_t authority_level; @@ -317,6 +319,44 @@ get_auto_ack(void) return 0; return 1; } + +uint16_t +rf230_get_panid(void) +{ + unsigned pan; + uint8_t byte; + + byte = hal_register_read(RG_PAN_ID_1); + pan = byte; + byte = hal_register_read(RG_PAN_ID_0); + pan = (pan << 8) + byte; + + return pan; +} + +void +rf230_set_panid(uint16_t pan) +{ + hal_register_write(RG_PAN_ID_1, (pan >> 8)); + hal_register_write(RG_PAN_ID_0, (pan & 0xFF)); +} + +uint16_t +rf230_get_short_addr(void) +{ + unsigned char a0, a1; + a0 = hal_register_read(RG_SHORT_ADDR_0); + a1 = hal_register_read(RG_SHORT_ADDR_1); + return (a1 << 8) | a0; +} + +void +rf230_set_short_addr(uint16_t addr) +{ + hal_register_write(RG_SHORT_ADDR_0, (addr & 0xFF)); + hal_register_write(RG_SHORT_ADDR_1, (addr >> 8)); +} + /*---------------------------------------------------------------------------*/ static radio_result_t get_value(radio_param_t param, radio_value_t *value) @@ -338,10 +378,10 @@ get_value(radio_param_t param, radio_value_t *value) *value = (radio_value_t)rf230_get_channel(); return RADIO_RESULT_OK; case RADIO_PARAM_PAN_ID: - /* *value = get_pan_id(); */ + *value = rf230_get_panid(); return RADIO_RESULT_OK; case RADIO_PARAM_16BIT_ADDR: - /* *value = get_short_addr(); */ + *value = rf230_get_short_addr(); return RADIO_RESULT_OK; case RADIO_PARAM_RX_MODE: *value = 0; @@ -410,10 +450,11 @@ set_value(radio_param_t param, radio_value_t value) return RADIO_RESULT_OK; case RADIO_PARAM_PAN_ID: - /* set_pan_id(value & 0xffff); */ + rf230_set_panid(value & 0xffff); return RADIO_RESULT_OK; + case RADIO_PARAM_16BIT_ADDR: - /* set_short_addr(value & 0xffff); */ + rf230_set_short_addr(value & 0xffff); return RADIO_RESULT_OK; case RADIO_PARAM_RX_MODE: @@ -444,6 +485,14 @@ set_value(radio_param_t param, radio_value_t value) static radio_result_t get_object(radio_param_t param, void *dest, size_t size) { + if(param == RADIO_PARAM_LAST_PACKET_TIMESTAMP) { + if(size != sizeof(rtimer_clock_t) || !dest) { + return RADIO_RESULT_INVALID_VALUE; + } + *(rtimer_clock_t *)dest = last_rx_packet_timestamp; + + return RADIO_RESULT_OK; + } return RADIO_RESULT_NOT_SUPPORTED; } /*---------------------------------------------------------------------------*/ @@ -1466,38 +1515,15 @@ rf230_listen_channel(uint8_t c) } /*---------------------------------------------------------------------------*/ -unsigned -rf230_get_panid(void) -{ - unsigned pan; - uint8_t byte; - - byte = hal_register_read(RG_PAN_ID_1); - pan = byte; - byte = hal_register_read(RG_PAN_ID_0); - pan = (pan << 8) + byte; - - return pan; -} - void rf230_set_pan_addr(unsigned pan, unsigned addr, const uint8_t ieee_addr[8]) -//rf230_set_pan_addr(uint16_t pan,uint16_t addr,uint8_t *ieee_addr) { PRINTF("rf230: PAN=%x Short Addr=%x\n",pan,addr); - uint8_t abyte; - abyte = pan & 0xFF; - hal_register_write(RG_PAN_ID_0,abyte); - abyte = (pan >> 8*1) & 0xFF; - hal_register_write(RG_PAN_ID_1, abyte); - - abyte = addr & 0xFF; - hal_register_write(RG_SHORT_ADDR_0, abyte); - abyte = (addr >> 8*1) & 0xFF; - hal_register_write(RG_SHORT_ADDR_1, abyte); + rf230_set_panid(pan); + rf230_set_short_addr(addr); if (ieee_addr != NULL) { PRINTF("MAC=%x",*ieee_addr); @@ -1519,6 +1545,14 @@ rf230_set_pan_addr(unsigned pan, PRINTF("\n"); } } + +/* From ISR context */ +void +get_last_rx_packet_timestamp(void) +{ + last_rx_packet_timestamp = RTIMER_NOW(); +} + /*---------------------------------------------------------------------------*/ /* * Interrupt leaves frame intact in FIFO. From 417f32c65d77e8af6259a012cf66bb4289c1425a Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Fri, 31 Mar 2017 19:14:31 +0200 Subject: [PATCH 092/129] Adding sensniff support for Atmel via avr-rss2 platform --- examples/sensniff/README.md | 1 + examples/sensniff/avr-rss2/avr-rss2-io.h | 43 ++++++++++++++++++++++++ examples/sensniff/avr-rss2/target-conf.h | 39 +++++++++++++++++++++ platform/avr-rss2/README.md | 1 + 4 files changed, 84 insertions(+) create mode 100644 examples/sensniff/avr-rss2/avr-rss2-io.h create mode 100644 examples/sensniff/avr-rss2/target-conf.h diff --git a/examples/sensniff/README.md b/examples/sensniff/README.md index 646111391..3fe1df7dd 100644 --- a/examples/sensniff/README.md +++ b/examples/sensniff/README.md @@ -49,6 +49,7 @@ The following radios have been tested: * CC2538 * CC2530/CC2531 * CC1200 +* RF233 Once you have the radio sorted out, you also need to configure character I/O. The firmware captures wireless frames and streams them over a serial line to diff --git a/examples/sensniff/avr-rss2/avr-rss2-io.h b/examples/sensniff/avr-rss2/avr-rss2-io.h new file mode 100644 index 000000000..b92467511 --- /dev/null +++ b/examples/sensniff/avr-rss2/avr-rss2-io.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016, 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. + */ +/*---------------------------------------------------------------------------*/ +#ifndef AVR_RSS2_IO_H_ +#define AVR_RSS2_IO_H_ +/*---------------------------------------------------------------------------*/ +#include "contiki-conf.h" +#include "dev/rs232.h" + +#define sensniff_io_byte_out(b) rs232_send(0, b) +#define sensniff_io_flush() +#define sensniff_io_set_input(b) rs232_set_input(RS232_PORT_0, b) +/*---------------------------------------------------------------------------*/ +#endif /* AVR_RSS2_IO_H_ */ +/*---------------------------------------------------------------------------*/ diff --git a/examples/sensniff/avr-rss2/target-conf.h b/examples/sensniff/avr-rss2/target-conf.h new file mode 100644 index 000000000..c524b7c6e --- /dev/null +++ b/examples/sensniff/avr-rss2/target-conf.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2016, 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. + */ +/*---------------------------------------------------------------------------*/ +#ifndef TARGET_CONF_H_ +#define TARGET_CONF_H_ +/*---------------------------------------------------------------------------*/ +#define SENSNIFF_IO_DRIVER_H "avr-rss2/avr-rss2-io.h" +#define RS232_BAUDRATE USART_BAUD_500000 +/*---------------------------------------------------------------------------*/ +#endif /* TARGET_CONF_H_ */ +/*---------------------------------------------------------------------------*/ diff --git a/platform/avr-rss2/README.md b/platform/avr-rss2/README.md index 05d448fc6..89f7bbf50 100644 --- a/platform/avr-rss2/README.md +++ b/platform/avr-rss2/README.md @@ -108,6 +108,7 @@ Tested applications and examples * `rime` * `ipv6/multicast` * `examples/powertrace` +* `examples/sensniff` use 500kBAUD * `example-shell` Note that the shell example needs file `symbols.c` to be added to project also seems like From f564e6bb5fe778ed21e559296c34709d79874382 Mon Sep 17 00:00:00 2001 From: tarakanov Date: Sun, 2 Apr 2017 13:14:09 +0500 Subject: [PATCH 093/129] Correct SPI pins --- platform/srf06-cc26xx/sensortag/cc2650/board.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/srf06-cc26xx/sensortag/cc2650/board.h b/platform/srf06-cc26xx/sensortag/cc2650/board.h index 9f0a7abd3..68580d4ff 100644 --- a/platform/srf06-cc26xx/sensortag/cc2650/board.h +++ b/platform/srf06-cc26xx/sensortag/cc2650/board.h @@ -137,8 +137,12 @@ * Those values are not meant to be modified by the user * @{ */ +#define BOARD_IOID_SPI_SCK IOID_17 #define BOARD_IOID_SPI_MOSI IOID_19 #define BOARD_IOID_SPI_MISO IOID_18 +#define BOARD_SPI_SCK (1 << BOARD_IOID_SPI_SCK) +#define BOARD_SPI_MOSI (1 << BOARD_IOID_SPI_MOSI) +#define BOARD_SPI_MISO (1 << BOARD_IOID_SPI_MISO) /** @} */ /*---------------------------------------------------------------------------*/ /** From aed54573322f668333fbd66ffdf40fb893b37a8c Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Sun, 2 Apr 2017 11:32:52 +0200 Subject: [PATCH 094/129] Correct names for Atmel previous radio fixes plus static declarations. --- cpu/avr/radio/rf230bb/halbb.c | 4 ++-- cpu/avr/radio/rf230bb/rf230bb.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cpu/avr/radio/rf230bb/halbb.c b/cpu/avr/radio/rf230bb/halbb.c index c146998d4..1a85dfd1f 100644 --- a/cpu/avr/radio/rf230bb/halbb.c +++ b/cpu/avr/radio/rf230bb/halbb.c @@ -81,7 +81,7 @@ extern uint8_t debugflowsize,debugflow[DEBUGFLOWSIZE]; #include "at86rf230_registermap.h" #endif -extern void get_last_rx_packet_timestamp(void); +extern void rf230_get_last_rx_packet_timestamp(void); /*============================ VARIABLES =====================================*/ volatile extern signed char rf230_last_rssi; @@ -668,7 +668,7 @@ ISR(TRX24_RX_START_vect) #if !RF230_CONF_AUTOACK rf230_last_rssi = 3 * hal_subregister_read(SR_RSSI); #endif - get_last_rx_packet_timestamp(); + rf230_get_last_rx_packet_timestamp(); } /* PLL has locked, either from a transition out of TRX_OFF or a channel change while on */ diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index 2abe6b911..4fa9a44b4 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -146,7 +146,7 @@ uint8_t ack_pending,ack_seqnum; #warning RF230 Untested Configuration! #endif -rtimer_clock_t last_rx_packet_timestamp; +static rtimer_clock_t rf230_last_rx_packet_timestamp; struct timestamp { uint16_t time; @@ -283,7 +283,7 @@ get_poll_mode(void) return poll_mode; } -void +static void set_frame_filtering(bool i) { if(i) @@ -302,7 +302,7 @@ get_frame_filtering(void) return 1; } -void +static void set_auto_ack(bool i) { if(i) @@ -334,14 +334,14 @@ rf230_get_panid(void) return pan; } -void +static void rf230_set_panid(uint16_t pan) { hal_register_write(RG_PAN_ID_1, (pan >> 8)); hal_register_write(RG_PAN_ID_0, (pan & 0xFF)); } -uint16_t +static uint16_t rf230_get_short_addr(void) { unsigned char a0, a1; @@ -350,7 +350,7 @@ rf230_get_short_addr(void) return (a1 << 8) | a0; } -void +static void rf230_set_short_addr(uint16_t addr) { hal_register_write(RG_SHORT_ADDR_0, (addr & 0xFF)); @@ -489,7 +489,7 @@ get_object(radio_param_t param, void *dest, size_t size) if(size != sizeof(rtimer_clock_t) || !dest) { return RADIO_RESULT_INVALID_VALUE; } - *(rtimer_clock_t *)dest = last_rx_packet_timestamp; + *(rtimer_clock_t *)dest = rf230_last_rx_packet_timestamp; return RADIO_RESULT_OK; } @@ -1548,9 +1548,9 @@ rf230_set_pan_addr(unsigned pan, /* From ISR context */ void -get_last_rx_packet_timestamp(void) +rf230_get_last_rx_packet_timestamp(void) { - last_rx_packet_timestamp = RTIMER_NOW(); + rf230_last_rx_packet_timestamp = RTIMER_NOW(); } /*---------------------------------------------------------------------------*/ From 22b262ce73587c8cee431856e170584a62f70f90 Mon Sep 17 00:00:00 2001 From: chenek Date: Mon, 13 Feb 2017 09:37:34 +0100 Subject: [PATCH 095/129] Add ADC example to cc26xx-web-demo --- .../cc26xx/cc26xx-web-demo/cc26xx-web-demo.c | 73 ++++++++++++++++++- .../cc26xx/cc26xx-web-demo/cc26xx-web-demo.h | 8 ++ examples/cc26xx/cc26xx-web-demo/coap-server.c | 2 + .../cc26xx/cc26xx-web-demo/project-conf.h | 7 ++ .../cc26xx-web-demo/resources/res-sensors.c | 12 +++ 5 files changed, 101 insertions(+), 1 deletion(-) diff --git a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c index a363c31d5..02af7f946 100644 --- a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c +++ b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c @@ -55,9 +55,13 @@ #include #include #include + +#include "ti-lib.h" + /*---------------------------------------------------------------------------*/ PROCESS_NAME(cetic_6lbr_client_process); PROCESS(cc26xx_web_demo_process, "CC26XX Web Demo"); +PROCESS(adc_process, "ADC process"); /*---------------------------------------------------------------------------*/ /* * Update sensor readings in a staggered fashion every SENSOR_READING_PERIOD @@ -84,6 +88,9 @@ static struct uip_icmp6_echo_reply_notification echo_reply_notification; static struct etimer echo_request_timer; int def_rt_rssi = 0; #endif + +static uint16_t single_adc_sample; + /*---------------------------------------------------------------------------*/ process_event_t cc26xx_web_demo_publish_event; process_event_t cc26xx_web_demo_config_loaded_event; @@ -110,6 +117,9 @@ DEMO_SENSOR(batmon_temp, CC26XX_WEB_DEMO_SENSOR_BATMON_TEMP, DEMO_SENSOR(batmon_volt, CC26XX_WEB_DEMO_SENSOR_BATMON_VOLT, "Battery Volt", "battery-volt", "batmon_volt", CC26XX_WEB_DEMO_UNIT_VOLT); +DEMO_SENSOR(adc_dio23, CC26XX_WEB_DEMO_SENSOR_ADC_DIO23, + "ADC DIO23", "adc-dio23", "adc_dio23", + CC26XX_WEB_DEMO_UNIT_VOLT); /* Sensortag sensors */ #if BOARD_SENSORTAG @@ -467,6 +477,20 @@ get_batmon_reading(void *data) ctimer_set(&batmon_timer, next, get_batmon_reading, NULL); } /*---------------------------------------------------------------------------*/ +static void +get_adc_reading(void *data) +{ + int value; + char *buf; + + if(adc_dio23_reading.publish) { + value = single_adc_sample; + buf = adc_dio23_reading.converted; + memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN); + snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d", (value * 4300) >> 12); + } +} +/*---------------------------------------------------------------------------*/ #if BOARD_SENSORTAG /*---------------------------------------------------------------------------*/ static void @@ -825,6 +849,7 @@ init_sensors(void) list_add(sensor_list, &batmon_temp_reading); list_add(sensor_list, &batmon_volt_reading); + list_add(sensor_list, &adc_dio23_reading); SENSORS_ACTIVATE(batmon_sensor); #if BOARD_SENSORTAG @@ -864,6 +889,7 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data) /* Start all other (enabled) processes first */ process_start(&httpd_simple_process, NULL); + #if CC26XX_WEB_DEMO_COAP_SERVER process_start(&coap_server_process, NULL); #endif @@ -880,13 +906,17 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data) process_start(&net_uart_process, NULL); #endif +#if CC26XX_WEB_DEMO_ADC_DEMO + process_start(&adc_process, NULL); +#endif + /* * Now that processes have set their own config default values, set our * own defaults and restore saved config from flash... */ cc26xx_web_demo_config.sensors_bitmap = 0xFFFFFFFF; /* all on by default */ cc26xx_web_demo_config.def_rt_ping_interval = - CC26XX_WEB_DEMO_DEFAULT_RSSI_MEAS_INTERVAL; + CC26XX_WEB_DEMO_DEFAULT_RSSI_MEAS_INTERVAL; load_config(); /* @@ -966,6 +996,47 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data) PROCESS_END(); } + +PROCESS_THREAD(adc_process, ev, data) +{ + PROCESS_BEGIN(); + static struct etimer et_adc; + etimer_set(&et_adc, CLOCK_SECOND * 5); + while(1) { + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_adc)); + /* intialisation of ADC */ + ti_lib_aon_wuc_aux_wakeup_event(AONWUC_AUX_WAKEUP); + while(!(ti_lib_aon_wuc_power_status_get() & AONWUC_AUX_POWER_ON)) { + } + + /* Enable clock for ADC digital and analog interface (not currently enabled in driver) */ + /* Enable clocks */ + ti_lib_aux_wuc_clock_enable(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK); + while(ti_lib_aux_wuc_clock_status(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK) != AUX_WUC_CLOCK_READY) { + } + + /* Connect AUX IO7 (DIO23, but also DP2 on XDS110) as analog input. */ + ti_lib_aux_adc_select_input(ADC_COMPB_IN_AUXIO7); + + /* Set up ADC range */ + /* AUXADC_REF_FIXED = nominally 4.3 V */ + ti_lib_aux_adc_enable_sync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL); + + /* Trigger ADC converting */ + ti_lib_aux_adc_gen_manual_trigger(); + + /* reading adc value */ + single_adc_sample = ti_lib_aux_adc_read_fifo(); + + /* shut the adc down */ + ti_lib_aux_adc_disable(); + + get_adc_reading(NULL); + + etimer_reset(&et_adc); + } + PROCESS_END(); +} /*---------------------------------------------------------------------------*/ /** * @} diff --git a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h index 14bf3150c..b740a5d4c 100644 --- a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h +++ b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h @@ -79,6 +79,13 @@ #else #define CC26XX_WEB_DEMO_NET_UART 1 #endif + +#ifdef CC26XX_WEB_DEMO_CONF_ADC_DEMO +#define CC26XX_WEB_DEMO_ADC_DEMO CC26XX_WEB_DEMO_CONF_ADC_DEMO +#else +#define CC26XX_WEB_DEMO_ADC_DEMO 0 +#endif + /*---------------------------------------------------------------------------*/ /* Active probing of RSSI from our preferred parent */ #if (CC26XX_WEB_DEMO_COAP_SERVER || CC26XX_WEB_DEMO_MQTT_CLIENT) @@ -146,6 +153,7 @@ #define CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_X 12 #define CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_Y 13 #define CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_Z 14 +#define CC26XX_WEB_DEMO_SENSOR_ADC_DIO23 15 /*---------------------------------------------------------------------------*/ extern process_event_t cc26xx_web_demo_publish_event; extern process_event_t cc26xx_web_demo_config_loaded_event; diff --git a/examples/cc26xx/cc26xx-web-demo/coap-server.c b/examples/cc26xx/cc26xx-web-demo/coap-server.c index 518065f6e..957e8adae 100644 --- a/examples/cc26xx/cc26xx-web-demo/coap-server.c +++ b/examples/cc26xx/cc26xx-web-demo/coap-server.c @@ -50,6 +50,7 @@ extern resource_t res_leds; extern resource_t res_batmon_temp; extern resource_t res_batmon_volt; +extern resource_t res_adc_dio23; extern resource_t res_device_sw; extern resource_t res_device_hw; @@ -133,6 +134,7 @@ PROCESS_THREAD(coap_server_process, ev, data) rest_activate_resource(&res_batmon_temp, "sen/batmon/temp"); rest_activate_resource(&res_batmon_volt, "sen/batmon/voltage"); + rest_activate_resource(&res_adc_dio23, "sen/adc/dio23"); rest_activate_resource(&res_device_hw, "dev/mdl/hw"); rest_activate_resource(&res_device_sw, "dev/mdl/sw"); diff --git a/examples/cc26xx/cc26xx-web-demo/project-conf.h b/examples/cc26xx/cc26xx-web-demo/project-conf.h index adf2f1427..1d2355006 100644 --- a/examples/cc26xx/cc26xx-web-demo/project-conf.h +++ b/examples/cc26xx/cc26xx-web-demo/project-conf.h @@ -41,6 +41,13 @@ #define CC26XX_WEB_DEMO_CONF_6LBR_CLIENT 1 #define CC26XX_WEB_DEMO_CONF_COAP_SERVER 1 #define CC26XX_WEB_DEMO_CONF_NET_UART 1 +/* + * ADC sensor functionality. To test this, an external voltage source should be + * connected to DIO23 + * Enable/Disable DIO23 ADC reading by setting CC26XX_WEB_DEMO_CONF_ADC_DEMO + */ +#define CC26XX_WEB_DEMO_CONF_ADC_DEMO 0 + /*---------------------------------------------------------------------------*/ /* Enable the ROM bootloader */ #define ROM_BOOTLOADER_ENABLE 1 diff --git a/examples/cc26xx/cc26xx-web-demo/resources/res-sensors.c b/examples/cc26xx/cc26xx-web-demo/resources/res-sensors.c index 277c29c05..f5cfad79e 100644 --- a/examples/cc26xx/cc26xx-web-demo/resources/res-sensors.c +++ b/examples/cc26xx/cc26xx-web-demo/resources/res-sensors.c @@ -111,12 +111,24 @@ res_get_handler_batmon_volt(void *request, void *response, uint8_t *buffer, buffer, preferred_size, offset); } /*---------------------------------------------------------------------------*/ +static void +res_get_handler_adc_dio23(void *request, void *response, uint8_t *buffer, + uint16_t preferred_size, int32_t *offset) +{ + res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_ADC_DIO23, request, response, + buffer, preferred_size, offset); +} +/*---------------------------------------------------------------------------*/ RESOURCE(res_batmon_temp, "title=\"Battery Temp\";rt=\"C\"", res_get_handler_batmon_temp, NULL, NULL, NULL); /*---------------------------------------------------------------------------*/ RESOURCE(res_batmon_volt, "title=\"Battery Voltage\";rt=\"mV\"", res_get_handler_batmon_volt, NULL, NULL, NULL); /*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ +RESOURCE(res_adc_dio23, "title=\"ADC DIO23\";rt=\"mV\"", + res_get_handler_adc_dio23, NULL, NULL, NULL); +/*---------------------------------------------------------------------------*/ #if BOARD_SENSORTAG /*---------------------------------------------------------------------------*/ /* MPU resources and handler: Accelerometer and Gyro */ From 474dc33e122195f62e598a7e020c722b9009a2b4 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 18 Mar 2017 14:36:18 +0000 Subject: [PATCH 096/129] Wrap web demo ADC functionality inside #if blocks --- .../cc26xx/cc26xx-web-demo/cc26xx-web-demo.c | 19 ++++++++++++++++--- examples/cc26xx/cc26xx-web-demo/coap-server.c | 9 ++++++++- .../cc26xx-web-demo/resources/res-sensors.c | 17 ++++++++++------- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c index 02af7f946..1b80801a6 100644 --- a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c +++ b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c @@ -61,7 +61,6 @@ /*---------------------------------------------------------------------------*/ PROCESS_NAME(cetic_6lbr_client_process); PROCESS(cc26xx_web_demo_process, "CC26XX Web Demo"); -PROCESS(adc_process, "ADC process"); /*---------------------------------------------------------------------------*/ /* * Update sensor readings in a staggered fashion every SENSOR_READING_PERIOD @@ -88,9 +87,13 @@ static struct uip_icmp6_echo_reply_notification echo_reply_notification; static struct etimer echo_request_timer; int def_rt_rssi = 0; #endif +/*---------------------------------------------------------------------------*/ +#if CC26XX_WEB_DEMO_ADC_DEMO +PROCESS(adc_process, "ADC process"); static uint16_t single_adc_sample; - +static struct etimer et_adc; +#endif /*---------------------------------------------------------------------------*/ process_event_t cc26xx_web_demo_publish_event; process_event_t cc26xx_web_demo_config_loaded_event; @@ -117,9 +120,12 @@ DEMO_SENSOR(batmon_temp, CC26XX_WEB_DEMO_SENSOR_BATMON_TEMP, DEMO_SENSOR(batmon_volt, CC26XX_WEB_DEMO_SENSOR_BATMON_VOLT, "Battery Volt", "battery-volt", "batmon_volt", CC26XX_WEB_DEMO_UNIT_VOLT); + +#if CC26XX_WEB_DEMO_ADC_DEMO DEMO_SENSOR(adc_dio23, CC26XX_WEB_DEMO_SENSOR_ADC_DIO23, "ADC DIO23", "adc-dio23", "adc_dio23", CC26XX_WEB_DEMO_UNIT_VOLT); +#endif /* Sensortag sensors */ #if BOARD_SENSORTAG @@ -477,6 +483,7 @@ get_batmon_reading(void *data) ctimer_set(&batmon_timer, next, get_batmon_reading, NULL); } /*---------------------------------------------------------------------------*/ +#if CC26XX_WEB_DEMO_ADC_DEMO static void get_adc_reading(void *data) { @@ -490,6 +497,7 @@ get_adc_reading(void *data) snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d", (value * 4300) >> 12); } } +#endif /*---------------------------------------------------------------------------*/ #if BOARD_SENSORTAG /*---------------------------------------------------------------------------*/ @@ -849,7 +857,11 @@ init_sensors(void) list_add(sensor_list, &batmon_temp_reading); list_add(sensor_list, &batmon_volt_reading); + +#if CC26XX_WEB_DEMO_ADC_DEMO list_add(sensor_list, &adc_dio23_reading); +#endif + SENSORS_ACTIVATE(batmon_sensor); #if BOARD_SENSORTAG @@ -997,10 +1009,10 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data) PROCESS_END(); } +#if CC26XX_WEB_DEMO_ADC_DEMO PROCESS_THREAD(adc_process, ev, data) { PROCESS_BEGIN(); - static struct etimer et_adc; etimer_set(&et_adc, CLOCK_SECOND * 5); while(1) { PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_adc)); @@ -1037,6 +1049,7 @@ PROCESS_THREAD(adc_process, ev, data) } PROCESS_END(); } +#endif /*---------------------------------------------------------------------------*/ /** * @} diff --git a/examples/cc26xx/cc26xx-web-demo/coap-server.c b/examples/cc26xx/cc26xx-web-demo/coap-server.c index 957e8adae..8897eb23f 100644 --- a/examples/cc26xx/cc26xx-web-demo/coap-server.c +++ b/examples/cc26xx/cc26xx-web-demo/coap-server.c @@ -40,6 +40,7 @@ #include "rest-engine.h" #include "board-peripherals.h" #include "rf-core/rf-ble.h" +#include "cc26xx-web-demo.h" #include #include @@ -50,7 +51,6 @@ extern resource_t res_leds; extern resource_t res_batmon_temp; extern resource_t res_batmon_volt; -extern resource_t res_adc_dio23; extern resource_t res_device_sw; extern resource_t res_device_hw; @@ -86,6 +86,10 @@ extern resource_t res_mpu_gyro_z; extern resource_t res_toggle_orange; extern resource_t res_toggle_yellow; #endif + +#if CC26XX_WEB_DEMO_ADC_DEMO +extern resource_t res_adc_dio23; +#endif /*---------------------------------------------------------------------------*/ const char *coap_server_not_found_msg = "Resource not found"; const char *coap_server_supported_msg = "Supported:" @@ -134,7 +138,10 @@ PROCESS_THREAD(coap_server_process, ev, data) rest_activate_resource(&res_batmon_temp, "sen/batmon/temp"); rest_activate_resource(&res_batmon_volt, "sen/batmon/voltage"); + +#if CC26XX_WEB_DEMO_ADC_DEMO rest_activate_resource(&res_adc_dio23, "sen/adc/dio23"); +#endif rest_activate_resource(&res_device_hw, "dev/mdl/hw"); rest_activate_resource(&res_device_sw, "dev/mdl/sw"); diff --git a/examples/cc26xx/cc26xx-web-demo/resources/res-sensors.c b/examples/cc26xx/cc26xx-web-demo/resources/res-sensors.c index f5cfad79e..f3fd7bd26 100644 --- a/examples/cc26xx/cc26xx-web-demo/resources/res-sensors.c +++ b/examples/cc26xx/cc26xx-web-demo/resources/res-sensors.c @@ -111,6 +111,14 @@ res_get_handler_batmon_volt(void *request, void *response, uint8_t *buffer, buffer, preferred_size, offset); } /*---------------------------------------------------------------------------*/ +RESOURCE(res_batmon_temp, "title=\"Battery Temp\";rt=\"C\"", + res_get_handler_batmon_temp, NULL, NULL, NULL); +/*---------------------------------------------------------------------------*/ +RESOURCE(res_batmon_volt, "title=\"Battery Voltage\";rt=\"mV\"", + res_get_handler_batmon_volt, NULL, NULL, NULL); +/*---------------------------------------------------------------------------*/ +#if CC26XX_WEB_DEMO_ADC_DEMO +/*---------------------------------------------------------------------------*/ static void res_get_handler_adc_dio23(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) @@ -119,16 +127,11 @@ res_get_handler_adc_dio23(void *request, void *response, uint8_t *buffer, buffer, preferred_size, offset); } /*---------------------------------------------------------------------------*/ -RESOURCE(res_batmon_temp, "title=\"Battery Temp\";rt=\"C\"", - res_get_handler_batmon_temp, NULL, NULL, NULL); -/*---------------------------------------------------------------------------*/ -RESOURCE(res_batmon_volt, "title=\"Battery Voltage\";rt=\"mV\"", - res_get_handler_batmon_volt, NULL, NULL, NULL); -/*---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------*/ RESOURCE(res_adc_dio23, "title=\"ADC DIO23\";rt=\"mV\"", res_get_handler_adc_dio23, NULL, NULL, NULL); /*---------------------------------------------------------------------------*/ +#endif +/*---------------------------------------------------------------------------*/ #if BOARD_SENSORTAG /*---------------------------------------------------------------------------*/ /* MPU resources and handler: Accelerometer and Gyro */ From e823ead4b0af94b12b3cf5ffae7ea4ca4bc0628f Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 18 Mar 2017 14:36:35 +0000 Subject: [PATCH 097/129] Tidy up web demo ADC code style --- .../cc26xx/cc26xx-web-demo/cc26xx-web-demo.c | 35 +++++++++++-------- .../cc26xx/cc26xx-web-demo/cc26xx-web-demo.h | 1 - .../cc26xx/cc26xx-web-demo/project-conf.h | 2 +- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c index 1b80801a6..e14991d04 100644 --- a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c +++ b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c @@ -57,7 +57,6 @@ #include #include "ti-lib.h" - /*---------------------------------------------------------------------------*/ PROCESS_NAME(cetic_6lbr_client_process); PROCESS(cc26xx_web_demo_process, "CC26XX Web Demo"); @@ -1008,45 +1007,53 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data) PROCESS_END(); } - +/*---------------------------------------------------------------------------*/ #if CC26XX_WEB_DEMO_ADC_DEMO PROCESS_THREAD(adc_process, ev, data) { PROCESS_BEGIN(); + etimer_set(&et_adc, CLOCK_SECOND * 5); + while(1) { + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_adc)); + /* intialisation of ADC */ ti_lib_aon_wuc_aux_wakeup_event(AONWUC_AUX_WAKEUP); - while(!(ti_lib_aon_wuc_power_status_get() & AONWUC_AUX_POWER_ON)) { - } + while(!(ti_lib_aon_wuc_power_status_get() & AONWUC_AUX_POWER_ON)); - /* Enable clock for ADC digital and analog interface (not currently enabled in driver) */ - /* Enable clocks */ - ti_lib_aux_wuc_clock_enable(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK); - while(ti_lib_aux_wuc_clock_status(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK) != AUX_WUC_CLOCK_READY) { - } + /* + * Enable clock for ADC digital and analog interface (not currently enabled + * in driver) + */ + ti_lib_aux_wuc_clock_enable(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | + AUX_WUC_SMPH_CLOCK); + while(ti_lib_aux_wuc_clock_status(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | + AUX_WUC_SMPH_CLOCK) + != AUX_WUC_CLOCK_READY); /* Connect AUX IO7 (DIO23, but also DP2 on XDS110) as analog input. */ ti_lib_aux_adc_select_input(ADC_COMPB_IN_AUXIO7); - /* Set up ADC range */ - /* AUXADC_REF_FIXED = nominally 4.3 V */ - ti_lib_aux_adc_enable_sync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL); + /* Set up ADC range, AUXADC_REF_FIXED = nominally 4.3 V */ + ti_lib_aux_adc_enable_sync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, + AUXADC_TRIGGER_MANUAL); /* Trigger ADC converting */ ti_lib_aux_adc_gen_manual_trigger(); - /* reading adc value */ + /* Read value */ single_adc_sample = ti_lib_aux_adc_read_fifo(); - /* shut the adc down */ + /* Shut the adc down */ ti_lib_aux_adc_disable(); get_adc_reading(NULL); etimer_reset(&et_adc); } + PROCESS_END(); } #endif diff --git a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h index b740a5d4c..e40cd1864 100644 --- a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h +++ b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h @@ -85,7 +85,6 @@ #else #define CC26XX_WEB_DEMO_ADC_DEMO 0 #endif - /*---------------------------------------------------------------------------*/ /* Active probing of RSSI from our preferred parent */ #if (CC26XX_WEB_DEMO_COAP_SERVER || CC26XX_WEB_DEMO_MQTT_CLIENT) diff --git a/examples/cc26xx/cc26xx-web-demo/project-conf.h b/examples/cc26xx/cc26xx-web-demo/project-conf.h index 1d2355006..67b0971c7 100644 --- a/examples/cc26xx/cc26xx-web-demo/project-conf.h +++ b/examples/cc26xx/cc26xx-web-demo/project-conf.h @@ -41,13 +41,13 @@ #define CC26XX_WEB_DEMO_CONF_6LBR_CLIENT 1 #define CC26XX_WEB_DEMO_CONF_COAP_SERVER 1 #define CC26XX_WEB_DEMO_CONF_NET_UART 1 + /* * ADC sensor functionality. To test this, an external voltage source should be * connected to DIO23 * Enable/Disable DIO23 ADC reading by setting CC26XX_WEB_DEMO_CONF_ADC_DEMO */ #define CC26XX_WEB_DEMO_CONF_ADC_DEMO 0 - /*---------------------------------------------------------------------------*/ /* Enable the ROM bootloader */ #define ROM_BOOTLOADER_ENABLE 1 From b7b23b712f35c4d5d2d4cdb860c81f02889bfe7e Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 7 Feb 2017 23:11:36 +0100 Subject: [PATCH 098/129] RPL: fix indentation (rpl-icmp6.c) --- core/net/rpl/rpl-icmp6.c | 310 +++++++++++++++++++-------------------- 1 file changed, 155 insertions(+), 155 deletions(-) diff --git a/core/net/rpl/rpl-icmp6.c b/core/net/rpl/rpl-icmp6.c index 733b4e6a4..7763cb18d 100644 --- a/core/net/rpl/rpl-icmp6.c +++ b/core/net/rpl/rpl-icmp6.c @@ -79,7 +79,7 @@ static void dao_input(void); static void dao_ack_input(void); static void dao_output_target_seq(rpl_parent_t *parent, uip_ipaddr_t *prefix, - uint8_t lifetime, uint8_t seq_no); + uint8_t lifetime, uint8_t seq_no); /* some debug callbacks useful when debugging RPL networks */ #ifdef RPL_DEBUG_DIO_INPUT @@ -158,8 +158,8 @@ get_global_addr(uip_ipaddr_t *addr) static uint32_t get32(uint8_t *buffer, int pos) { - return (uint32_t)buffer[pos] << 24 | (uint32_t)buffer[pos + 1] << 16 | - (uint32_t)buffer[pos + 2] << 8 | buffer[pos + 3]; + return ((uint32_t)buffer[pos] << 24 | (uint32_t)buffer[pos + 1] << 16 | + (uint32_t)buffer[pos + 2] << 8 | buffer[pos + 3]); } /*---------------------------------------------------------------------------*/ static void @@ -202,7 +202,7 @@ rpl_icmp6_update_nbr_table(uip_ipaddr_t *from, nbr_table_reason_t reason, void * } return nbr; - } +} /*---------------------------------------------------------------------------*/ static void dis_input(void) @@ -238,7 +238,7 @@ dis_input(void) PRINTF("RPL: Unicast DIS, reply to sender\n"); dio_output(instance, &UIP_IP_BUF->srcipaddr); } - /* } */ + /* } */ } } } @@ -355,103 +355,103 @@ dio_input(void) PRINTF("RPL: DIO option %u, length: %u\n", subopt_type, len - 2); switch(subopt_type) { - case RPL_OPTION_DAG_METRIC_CONTAINER: - if(len < 6) { - PRINTF("RPL: Invalid DAG MC, len = %d\n", len); - RPL_STAT(rpl_stats.malformed_msgs++); - goto discard; - } - dio.mc.type = buffer[i + 2]; - dio.mc.flags = buffer[i + 3] << 1; - dio.mc.flags |= buffer[i + 4] >> 7; - dio.mc.aggr = (buffer[i + 4] >> 4) & 0x3; - dio.mc.prec = buffer[i + 4] & 0xf; - dio.mc.length = buffer[i + 5]; + case RPL_OPTION_DAG_METRIC_CONTAINER: + if(len < 6) { + PRINTF("RPL: Invalid DAG MC, len = %d\n", len); + RPL_STAT(rpl_stats.malformed_msgs++); + goto discard; + } + dio.mc.type = buffer[i + 2]; + dio.mc.flags = buffer[i + 3] << 1; + dio.mc.flags |= buffer[i + 4] >> 7; + dio.mc.aggr = (buffer[i + 4] >> 4) & 0x3; + dio.mc.prec = buffer[i + 4] & 0xf; + dio.mc.length = buffer[i + 5]; - if(dio.mc.type == RPL_DAG_MC_NONE) { - /* No metric container: do nothing */ - } else if(dio.mc.type == RPL_DAG_MC_ETX) { - dio.mc.obj.etx = get16(buffer, i + 6); + if(dio.mc.type == RPL_DAG_MC_NONE) { + /* No metric container: do nothing */ + } else if(dio.mc.type == RPL_DAG_MC_ETX) { + dio.mc.obj.etx = get16(buffer, i + 6); - PRINTF("RPL: DAG MC: type %u, flags %u, aggr %u, prec %u, length %u, ETX %u\n", - (unsigned)dio.mc.type, - (unsigned)dio.mc.flags, - (unsigned)dio.mc.aggr, - (unsigned)dio.mc.prec, - (unsigned)dio.mc.length, - (unsigned)dio.mc.obj.etx); - } else if(dio.mc.type == RPL_DAG_MC_ENERGY) { - dio.mc.obj.energy.flags = buffer[i + 6]; - dio.mc.obj.energy.energy_est = buffer[i + 7]; - } else { - PRINTF("RPL: Unhandled DAG MC type: %u\n", (unsigned)dio.mc.type); - goto discard; - } - break; - case RPL_OPTION_ROUTE_INFO: - if(len < 9) { - PRINTF("RPL: Invalid destination prefix option, len = %d\n", len); - RPL_STAT(rpl_stats.malformed_msgs++); - goto discard; - } + PRINTF("RPL: DAG MC: type %u, flags %u, aggr %u, prec %u, length %u, ETX %u\n", + (unsigned)dio.mc.type, + (unsigned)dio.mc.flags, + (unsigned)dio.mc.aggr, + (unsigned)dio.mc.prec, + (unsigned)dio.mc.length, + (unsigned)dio.mc.obj.etx); + } else if(dio.mc.type == RPL_DAG_MC_ENERGY) { + dio.mc.obj.energy.flags = buffer[i + 6]; + dio.mc.obj.energy.energy_est = buffer[i + 7]; + } else { + PRINTF("RPL: Unhandled DAG MC type: %u\n", (unsigned)dio.mc.type); + goto discard; + } + break; + case RPL_OPTION_ROUTE_INFO: + if(len < 9) { + PRINTF("RPL: Invalid destination prefix option, len = %d\n", len); + RPL_STAT(rpl_stats.malformed_msgs++); + goto discard; + } - /* The flags field includes the preference value. */ - dio.destination_prefix.length = buffer[i + 2]; - dio.destination_prefix.flags = buffer[i + 3]; - dio.destination_prefix.lifetime = get32(buffer, i + 4); + /* The flags field includes the preference value. */ + dio.destination_prefix.length = buffer[i + 2]; + dio.destination_prefix.flags = buffer[i + 3]; + dio.destination_prefix.lifetime = get32(buffer, i + 4); - if(((dio.destination_prefix.length + 7) / 8) + 8 <= len && - dio.destination_prefix.length <= 128) { - PRINTF("RPL: Copying destination prefix\n"); - memcpy(&dio.destination_prefix.prefix, &buffer[i + 8], - (dio.destination_prefix.length + 7) / 8); - } else { - PRINTF("RPL: Invalid route info option, len = %d\n", len); - RPL_STAT(rpl_stats.malformed_msgs++); - goto discard; - } + if(((dio.destination_prefix.length + 7) / 8) + 8 <= len && + dio.destination_prefix.length <= 128) { + PRINTF("RPL: Copying destination prefix\n"); + memcpy(&dio.destination_prefix.prefix, &buffer[i + 8], + (dio.destination_prefix.length + 7) / 8); + } else { + PRINTF("RPL: Invalid route info option, len = %d\n", len); + RPL_STAT(rpl_stats.malformed_msgs++); + goto discard; + } - break; - case RPL_OPTION_DAG_CONF: - if(len != 16) { - PRINTF("RPL: Invalid DAG configuration option, len = %d\n", len); - RPL_STAT(rpl_stats.malformed_msgs++); - goto discard; - } + break; + case RPL_OPTION_DAG_CONF: + if(len != 16) { + PRINTF("RPL: Invalid DAG configuration option, len = %d\n", len); + RPL_STAT(rpl_stats.malformed_msgs++); + goto discard; + } - /* Path control field not yet implemented - at i + 2 */ - dio.dag_intdoubl = buffer[i + 3]; - dio.dag_intmin = buffer[i + 4]; - dio.dag_redund = buffer[i + 5]; - dio.dag_max_rankinc = get16(buffer, i + 6); - dio.dag_min_hoprankinc = get16(buffer, i + 8); - dio.ocp = get16(buffer, i + 10); - /* buffer + 12 is reserved */ - dio.default_lifetime = buffer[i + 13]; - dio.lifetime_unit = get16(buffer, i + 14); - PRINTF("RPL: DAG conf:dbl=%d, min=%d red=%d maxinc=%d mininc=%d ocp=%d d_l=%u l_u=%u\n", - dio.dag_intdoubl, dio.dag_intmin, dio.dag_redund, - dio.dag_max_rankinc, dio.dag_min_hoprankinc, dio.ocp, - dio.default_lifetime, dio.lifetime_unit); - break; - case RPL_OPTION_PREFIX_INFO: - if(len != 32) { - PRINTF("RPL: Invalid DAG prefix info, len != 32\n"); - RPL_STAT(rpl_stats.malformed_msgs++); - goto discard; - } - dio.prefix_info.length = buffer[i + 2]; - dio.prefix_info.flags = buffer[i + 3]; - /* valid lifetime is ingnored for now - at i + 4 */ - /* preferred lifetime stored in lifetime */ - dio.prefix_info.lifetime = get32(buffer, i + 8); - /* 32-bit reserved at i + 12 */ - PRINTF("RPL: Copying prefix information\n"); - memcpy(&dio.prefix_info.prefix, &buffer[i + 16], 16); - break; - default: - PRINTF("RPL: Unsupported suboption type in DIO: %u\n", - (unsigned)subopt_type); + /* Path control field not yet implemented - at i + 2 */ + dio.dag_intdoubl = buffer[i + 3]; + dio.dag_intmin = buffer[i + 4]; + dio.dag_redund = buffer[i + 5]; + dio.dag_max_rankinc = get16(buffer, i + 6); + dio.dag_min_hoprankinc = get16(buffer, i + 8); + dio.ocp = get16(buffer, i + 10); + /* buffer + 12 is reserved */ + dio.default_lifetime = buffer[i + 13]; + dio.lifetime_unit = get16(buffer, i + 14); + PRINTF("RPL: DAG conf:dbl=%d, min=%d red=%d maxinc=%d mininc=%d ocp=%d d_l=%u l_u=%u\n", + dio.dag_intdoubl, dio.dag_intmin, dio.dag_redund, + dio.dag_max_rankinc, dio.dag_min_hoprankinc, dio.ocp, + dio.default_lifetime, dio.lifetime_unit); + break; + case RPL_OPTION_PREFIX_INFO: + if(len != 32) { + PRINTF("RPL: Invalid DAG prefix info, len != 32\n"); + RPL_STAT(rpl_stats.malformed_msgs++); + goto discard; + } + dio.prefix_info.length = buffer[i + 2]; + dio.prefix_info.flags = buffer[i + 3]; + /* valid lifetime is ingnored for now - at i + 4 */ + /* preferred lifetime stored in lifetime */ + dio.prefix_info.lifetime = get32(buffer, i + 8); + /* 32-bit reserved at i + 12 */ + PRINTF("RPL: Copying prefix information\n"); + memcpy(&dio.prefix_info.prefix, &buffer[i + 16], 16); + break; + default: + PRINTF("RPL: Unsupported suboption type in DIO: %u\n", + (unsigned)subopt_type); } } @@ -461,7 +461,7 @@ dio_input(void) rpl_process_dio(&from, &dio); - discard: +discard: uip_clear_buf(); } /*---------------------------------------------------------------------------*/ @@ -546,7 +546,7 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr) buffer[pos++] = instance->mc.obj.energy.energy_est; } else { PRINTF("RPL: Unable to send DIO because of unhandled DAG MC type %u\n", - (unsigned)instance->mc.type); + (unsigned)instance->mc.type); return; } } @@ -600,7 +600,7 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr) } #endif /* DEBUG_PRINT */ PRINTF("RPL: Sending unicast-DIO with rank %u to ", - (unsigned)dag->rank); + (unsigned)dag->rank); PRINT6ADDR(uc_addr); PRINTF("\n"); uip_icmp6_send(uc_addr, ICMP6_RPL, RPL_CODE_DIO, pos); @@ -608,12 +608,12 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr) /* Unicast requests get unicast replies! */ if(uc_addr == NULL) { PRINTF("RPL: Sending a multicast-DIO with rank %u\n", - (unsigned)instance->current_dag->rank); + (unsigned)instance->current_dag->rank); uip_create_linklocal_rplnodes_mcast(&addr); uip_icmp6_send(&addr, ICMP6_RPL, RPL_CODE_DIO, pos); } else { PRINTF("RPL: Sending unicast-DIO with rank %u to ", - (unsigned)instance->current_dag->rank); + (unsigned)instance->current_dag->rank); PRINT6ADDR(uc_addr); PRINTF("\n"); uip_icmp6_send(uc_addr, ICMP6_RPL, RPL_CODE_DIO, pos); @@ -636,8 +636,8 @@ dao_input_storing(void) uint8_t flags; uint8_t subopt_type; /* - uint8_t pathcontrol; - uint8_t pathsequence; + uint8_t pathcontrol; + uint8_t pathsequence; */ uip_ipaddr_t prefix; uip_ds6_route_t *rep; @@ -683,11 +683,11 @@ dao_input_storing(void) } learned_from = uip_is_addr_mcast(&dao_sender_addr) ? - RPL_ROUTE_FROM_MULTICAST_DAO : RPL_ROUTE_FROM_UNICAST_DAO; + RPL_ROUTE_FROM_MULTICAST_DAO : RPL_ROUTE_FROM_UNICAST_DAO; /* Destination Advertisement Object */ PRINTF("RPL: Received a (%s) DAO with sequence number %u from ", - learned_from == RPL_ROUTE_FROM_UNICAST_DAO? "unicast": "multicast", sequence); + learned_from == RPL_ROUTE_FROM_UNICAST_DAO? "unicast": "multicast", sequence); PRINT6ADDR(&dao_sender_addr); PRINTF("\n"); @@ -699,7 +699,7 @@ dao_input_storing(void) if(parent != NULL && DAG_RANK(parent->rank, instance) < DAG_RANK(dag->rank, instance)) { PRINTF("RPL: Loop detected when receiving a unicast DAO from a node with a lower rank! (%u < %u)\n", - DAG_RANK(parent->rank, instance), DAG_RANK(dag->rank, instance)); + DAG_RANK(parent->rank, instance), DAG_RANK(dag->rank, instance)); parent->rank = INFINITE_RANK; parent->flags |= RPL_PARENT_FLAG_UPDATED; return; @@ -725,24 +725,24 @@ dao_input_storing(void) } switch(subopt_type) { - case RPL_OPTION_TARGET: - /* Handle the target option. */ - prefixlen = buffer[i + 3]; - memset(&prefix, 0, sizeof(prefix)); - memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT); - break; - case RPL_OPTION_TRANSIT: - /* The path sequence and control are ignored. */ - /* pathcontrol = buffer[i + 3]; - pathsequence = buffer[i + 4];*/ - lifetime = buffer[i + 5]; - /* The parent address is also ignored. */ - break; + case RPL_OPTION_TARGET: + /* Handle the target option. */ + prefixlen = buffer[i + 3]; + memset(&prefix, 0, sizeof(prefix)); + memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT); + break; + case RPL_OPTION_TRANSIT: + /* The path sequence and control are ignored. */ + /* pathcontrol = buffer[i + 3]; + pathsequence = buffer[i + 4];*/ + lifetime = buffer[i + 5]; + /* The parent address is also ignored. */ + break; } } PRINTF("RPL: DAO lifetime: %u, prefix length: %u prefix: ", - (unsigned)lifetime, (unsigned)prefixlen); + (unsigned)lifetime, (unsigned)prefixlen); PRINT6ADDR(&prefix); PRINTF("\n"); @@ -781,7 +781,7 @@ dao_input_storing(void) out_seq = prepare_for_dao_fwd(sequence, rep); PRINTF("RPL: Forwarding No-path DAO to parent - out_seq:%d", - out_seq); + out_seq); PRINT6ADDR(rpl_get_parent_ipaddr(dag->preferred_parent)); PRINTF("\n"); @@ -813,8 +813,8 @@ dao_input_storing(void) if(flags & RPL_DAO_K_FLAG) { /* signal the failure to add the node */ dao_ack_output(instance, &dao_sender_addr, sequence, - is_root ? RPL_DAO_ACK_UNABLE_TO_ADD_ROUTE_AT_ROOT : - RPL_DAO_ACK_UNABLE_TO_ACCEPT); + is_root ? RPL_DAO_ACK_UNABLE_TO_ADD_ROUTE_AT_ROOT : + RPL_DAO_ACK_UNABLE_TO_ACCEPT); } return; } @@ -826,8 +826,8 @@ dao_input_storing(void) if(flags & RPL_DAO_K_FLAG) { /* signal the failure to add the node */ dao_ack_output(instance, &dao_sender_addr, sequence, - is_root ? RPL_DAO_ACK_UNABLE_TO_ADD_ROUTE_AT_ROOT : - RPL_DAO_ACK_UNABLE_TO_ACCEPT); + is_root ? RPL_DAO_ACK_UNABLE_TO_ADD_ROUTE_AT_ROOT : + RPL_DAO_ACK_UNABLE_TO_ACCEPT); } return; } @@ -852,7 +852,7 @@ fwd_dao: */ if((!RPL_ROUTE_IS_DAO_PENDING(rep) && rep->state.dao_seqno_in == sequence) || - dag->rank == ROOT_RANK(instance)) { + dag->rank == ROOT_RANK(instance)) { should_ack = 1; } } @@ -948,26 +948,26 @@ dao_input_nonstoring(void) } switch(subopt_type) { - case RPL_OPTION_TARGET: - /* Handle the target option. */ - prefixlen = buffer[i + 3]; - memset(&prefix, 0, sizeof(prefix)); - memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT); - break; - case RPL_OPTION_TRANSIT: - /* The path sequence and control are ignored. */ - /* pathcontrol = buffer[i + 3]; - pathsequence = buffer[i + 4];*/ - lifetime = buffer[i + 5]; - if(len >= 20) { - memcpy(&dao_parent_addr, buffer + i + 6, 16); - } - break; + case RPL_OPTION_TARGET: + /* Handle the target option. */ + prefixlen = buffer[i + 3]; + memset(&prefix, 0, sizeof(prefix)); + memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT); + break; + case RPL_OPTION_TRANSIT: + /* The path sequence and control are ignored. */ + /* pathcontrol = buffer[i + 3]; + pathsequence = buffer[i + 4];*/ + lifetime = buffer[i + 5]; + if(len >= 20) { + memcpy(&dao_parent_addr, buffer + i + 6, 16); + } + break; } } PRINTF("RPL: DAO lifetime: %u, prefix length: %u prefix: ", - (unsigned)lifetime, (unsigned)prefixlen); + (unsigned)lifetime, (unsigned)prefixlen); PRINT6ADDR(&prefix); PRINTF(", parent: "); PRINT6ADDR(&dao_parent_addr); @@ -987,7 +987,7 @@ dao_input_nonstoring(void) PRINTF("RPL: Sending DAO ACK\n"); uip_clear_buf(); dao_ack_output(instance, &dao_sender_addr, sequence, - RPL_DAO_ACK_UNCONDITIONAL_ACCEPT); + RPL_DAO_ACK_UNCONDITIONAL_ACCEPT); } #endif /* RPL_WITH_NON_STORING */ } @@ -1017,7 +1017,7 @@ dao_input(void) dao_input_nonstoring(); } - discard: +discard: uip_clear_buf(); } /*---------------------------------------------------------------------------*/ @@ -1059,7 +1059,7 @@ handle_dao_retransmission(void *ptr) } PRINTF("RPL: will retransmit DAO - seq:%d trans:%d\n", instance->my_dao_seqno, - instance->my_dao_transmissions); + instance->my_dao_transmissions); if(get_global_addr(&prefix) == 0) { return; @@ -1068,11 +1068,11 @@ handle_dao_retransmission(void *ptr) ctimer_set(&instance->dao_retransmit_timer, RPL_DAO_RETRANSMISSION_TIMEOUT / 2 + (random_rand() % (RPL_DAO_RETRANSMISSION_TIMEOUT / 2)), - handle_dao_retransmission, parent); + handle_dao_retransmission, parent); instance->my_dao_transmissions++; dao_output_target_seq(parent, &prefix, - instance->default_lifetime, instance->my_dao_seqno); + instance->default_lifetime, instance->my_dao_seqno); } #endif /* RPL_WITH_DAO_ACK */ /*---------------------------------------------------------------------------*/ @@ -1103,11 +1103,11 @@ dao_output(rpl_parent_t *parent, uint8_t lifetime) instance->my_dao_seqno = dao_sequence; instance->my_dao_transmissions = 1; ctimer_set(&instance->dao_retransmit_timer, RPL_DAO_RETRANSMISSION_TIMEOUT, - handle_dao_retransmission, parent); + handle_dao_retransmission, parent); } #else - /* We know that we have tried to register so now we are assuming - that we have a down-link - unless this is a zero lifetime one */ + /* We know that we have tried to register so now we are assuming + that we have a down-link - unless this is a zero lifetime one */ parent->dag->instance->has_downward_route = lifetime != RPL_ZERO_LIFETIME; #endif /* RPL_WITH_DAO_ACK */ @@ -1123,7 +1123,7 @@ dao_output_target(rpl_parent_t *parent, uip_ipaddr_t *prefix, uint8_t lifetime) /*---------------------------------------------------------------------------*/ static void dao_output_target_seq(rpl_parent_t *parent, uip_ipaddr_t *prefix, - uint8_t lifetime, uint8_t seq_no) + uint8_t lifetime, uint8_t seq_no) { rpl_dag_t *dag; rpl_instance_t *instance; @@ -1223,7 +1223,7 @@ dao_output_target_seq(rpl_parent_t *parent, uip_ipaddr_t *prefix, } PRINTF("RPL: Sending a %sDAO with sequence number %u, lifetime %u, prefix ", - lifetime == RPL_ZERO_LIFETIME ? "No-Path " : "", seq_no, lifetime); + lifetime == RPL_ZERO_LIFETIME ? "No-Path " : "", seq_no, lifetime); PRINT6ADDR(prefix); PRINTF(" to "); @@ -1273,8 +1273,8 @@ dao_ack_input(void) } PRINTF("RPL: Received a DAO %s with sequence number %d (%d) and status %d from ", - status < 128 ? "ACK" : "NACK", - sequence, instance->my_dao_seqno, status); + status < 128 ? "ACK" : "NACK", + sequence, instance->my_dao_seqno, status); PRINT6ADDR(&UIP_IP_BUF->srcipaddr); PRINTF("\n"); @@ -1333,7 +1333,7 @@ dao_ack_input(void) /*---------------------------------------------------------------------------*/ void dao_ack_output(rpl_instance_t *instance, uip_ipaddr_t *dest, uint8_t sequence, - uint8_t status) + uint8_t status) { #if RPL_WITH_DAO_ACK unsigned char *buffer; From 3559402781e65909585cfdb973562ab826c686a3 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 7 Feb 2017 23:55:01 +0100 Subject: [PATCH 099/129] RPL: add regression test for multicast This test aims to reproduce the issue #2031: https://github.com/contiki-os/contiki/issues/2031 Test nodes are built from the code under example/ipv6/multicast with WITH_SMRF=1 and WITH_DAO_ACK=1. If the simulation runs through for one hour, the test is regarded as success. Otherwise, when it crashes, the test fails. --- regression-tests/12-rpl/11-rpl-multicast.csc | 263 +++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100644 regression-tests/12-rpl/11-rpl-multicast.csc diff --git a/regression-tests/12-rpl/11-rpl-multicast.csc b/regression-tests/12-rpl/11-rpl-multicast.csc new file mode 100644 index 000000000..cd985d9d1 --- /dev/null +++ b/regression-tests/12-rpl/11-rpl-multicast.csc @@ -0,0 +1,263 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/collect-view + [APPS_DIR]/powertracker + [APPS_DIR]/radiologger-headless + + My simulation + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype442 + Cooja Mote Type #1 + [CONTIKI_DIR]/examples/ipv6/multicast/root.c + make clean TARGET=cooja + make DEFINES=RPL_CONF_WITH_DAO_ACK=1,UIP_MCAST6_CONF_ENGINE=UIP_MCAST6_ENGINE_SMRF root.cooja TARGET=cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype774 + Cooja Mote Type #2 + [CONTIKI_DIR]/examples/ipv6/multicast/sink.c + make clean TARGET=cooja + make DEFINES=RPL_CONF_WITH_DAO_ACK=1,UIP_MCAST6_CONF_ENGINE=UIP_MCAST6_ENGINE_SMRF sink.cooja TARGET=cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype224 + Cooja Mote Type #3 + [CONTIKI_DIR]/examples/ipv6/multicast/intermediate.c + make clean TARGET=cooja + make DEFINES=RPL_CONF_WITH_DAO_ACK=1,UIP_MCAST6_CONF_ENGINE=UIP_MCAST6_ENGINE_SMRF intermediate.cooja TARGET=cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 85.56533190308505 + 53.562395364420965 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype442 + + + + org.contikios.cooja.interfaces.Position + 43.952924225580446 + 106.6875691603427 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype774 + + + + org.contikios.cooja.interfaces.Position + 64.1616459084996 + 81.13076965805963 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 3 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype224 + + + + org.contikios.cooja.plugins.SimControl + 280 + 2 + 160 + 400 + 0 + + + org.contikios.cooja.plugins.Visualizer + + true + org.contikios.cooja.plugins.skins.IDVisualizerSkin + org.contikios.cooja.plugins.skins.GridVisualizerSkin + org.contikios.cooja.plugins.skins.TrafficVisualizerSkin + org.contikios.cooja.plugins.skins.UDGMVisualizerSkin + 3.699424669235615 0.0 0.0 3.699424669235615 -45.57151591938098 -64.4098979798254 + + 400 + 1 + 400 + 1 + 1 + + + org.contikios.cooja.plugins.LogListener + + + + + + 1320 + 6 + 240 + 400 + 160 + + + org.contikios.cooja.plugins.TimeLine + + 0 + 1 + 2 + + + + 500.0 + + 1720 + 5 + 166 + 0 + 957 + + + org.contikios.cooja.plugins.Notes + + Enter notes here + true + + 1040 + 4 + 160 + 680 + 0 + + + org.contikios.cooja.plugins.RadioLogger + + 150 + + false + false + + + 500 + 3 + 300 + 710 + 30 + + + org.contikios.cooja.plugins.ScriptRunner + + + true + + 600 + 0 + 700 + 430 + 30 + + + From faeb71de008e227bd8d957ef218c0120c458dc98 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 7 Feb 2017 23:59:17 +0100 Subject: [PATCH 100/129] RPL: fix a bug accessing an uninitialized pointer This bug is uncovered when RPL_WITH_MULTICAST is enabled. --- core/net/rpl/rpl-icmp6.c | 43 ++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/core/net/rpl/rpl-icmp6.c b/core/net/rpl/rpl-icmp6.c index 7763cb18d..94361cf04 100644 --- a/core/net/rpl/rpl-icmp6.c +++ b/core/net/rpl/rpl-icmp6.c @@ -748,6 +748,11 @@ dao_input_storing(void) #if RPL_WITH_MULTICAST if(uip_is_addr_mcast_global(&prefix)) { + /* + * "rep" is used for a unicast route which we don't need now; so set NULL so + * that operations on "rep" will be skipped. + */ + rep = NULL; mcast_group = uip_mcast6_route_add(&prefix); if(mcast_group) { mcast_group->dag = dag; @@ -844,29 +849,33 @@ fwd_dao: int should_ack = 0; if(flags & RPL_DAO_K_FLAG) { - /* - * check if this route is already installed and we can ack now! - * not pending - and same seq-no means that we can ack. - * (e.g. the route is installed already so it will not take any - * more room that it already takes - so should be ok!) - */ - if((!RPL_ROUTE_IS_DAO_PENDING(rep) && - rep->state.dao_seqno_in == sequence) || - dag->rank == ROOT_RANK(instance)) { - should_ack = 1; + if(rep != NULL) { + /* + * check if this route is already installed and we can ack now! + * not pending - and same seq-no means that we can ack. + * (e.g. the route is installed already so it will not take any + * more room that it already takes - so should be ok!) + */ + if((!RPL_ROUTE_IS_DAO_PENDING(rep) && + rep->state.dao_seqno_in == sequence) || + dag->rank == ROOT_RANK(instance)) { + should_ack = 1; + } } } if(dag->preferred_parent != NULL && rpl_get_parent_ipaddr(dag->preferred_parent) != NULL) { uint8_t out_seq = 0; - /* if this is pending and we get the same seq no it is a retrans */ - if(RPL_ROUTE_IS_DAO_PENDING(rep) && - rep->state.dao_seqno_in == sequence) { - /* keep the same seq-no as before for parent also */ - out_seq = rep->state.dao_seqno_out; - } else { - out_seq = prepare_for_dao_fwd(sequence, rep); + if(rep != NULL) { + /* if this is pending and we get the same seq no it is a retrans */ + if(RPL_ROUTE_IS_DAO_PENDING(rep) && + rep->state.dao_seqno_in == sequence) { + /* keep the same seq-no as before for parent also */ + out_seq = rep->state.dao_seqno_out; + } else { + out_seq = prepare_for_dao_fwd(sequence, rep); + } } PRINTF("RPL: Forwarding DAO to parent "); From 51205eb809db3b50473a93e0a2162e443f56ef12 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 4 Apr 2017 14:12:35 +0200 Subject: [PATCH 101/129] TSCH readme: link to reference paper on implem and eval --- core/net/mac/tsch/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/net/mac/tsch/README.md b/core/net/mac/tsch/README.md index 143bc0482..49e78573b 100644 --- a/core/net/mac/tsch/README.md +++ b/core/net/mac/tsch/README.md @@ -13,7 +13,9 @@ It was developped by: * Beshr Al Nahas, SICS (now Chalmers University), beshr@chalmers.se, github user: [beshrns](https://github.com/beshrns) * Atis Elsts, Univ. Bristol, atis.elsts@bristol.ac.uk, github user: [atiselsts](https://github.com/atiselsts) -You can find an extensive evaluation of this implementation in our paper [*Orchestra: Robust Mesh Networks Through Autonomously Scheduled TSCH*](http://www.simonduquennoy.net/papers/duquennoy15orchestra.pdf), ACM SenSys'15. + +This implementation is presented in depth and evaluated in our paper: [*TSCH and 6TiSCH for Contiki: Challenges, Design and Evaluation*](http://www.simonduquennoy.net/papers/duquennoy17tsch.pdf), IEEE DCOSS'17. +The scheduler Orchestra is detailled in [*Orchestra: Robust Mesh Networks Through Autonomously Scheduled TSCH*](http://www.simonduquennoy.net/papers/duquennoy15orchestra.pdf), ACM SenSys'15. ## Features From a330f59b8edff790e005cb0508e1a957ace572f7 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 4 Apr 2017 14:14:42 +0200 Subject: [PATCH 102/129] TSCH readme: update with 802.15.4-2015 and 6TiSCH --- core/net/mac/tsch/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/net/mac/tsch/README.md b/core/net/mac/tsch/README.md index 49e78573b..91bd603ca 100644 --- a/core/net/mac/tsch/README.md +++ b/core/net/mac/tsch/README.md @@ -1,8 +1,8 @@ -# IEEE 802.15.4e TSCH (TimeSlotted Channel Hopping) +# IEEE 802.15.4-2015 TSCH and IETF 6TiSCH ## Overview -TSCH is a MAC layer of the [IEEE 802.15.4e-2012 amendment][ieee802.15.4e-2012], +Time Slotted Channel Hopping (TSCH) is a MAC layer of the [IEEE 802.15.4e-2012 amendment][ieee802.15.4e-2012], currently being integrated as part of the new IEEE 802.15.4-2015. [6TiSCH][ietf-6tisch-wg] is an IETF Working Group focused on IPv6 over TSCH. This is a Contiki implementation of TSCH and the 6TiSCH so-called "minimal configuration", @@ -29,7 +29,7 @@ This implementation includes: * Standard TSCH link selection and slot operation (10ms slots by default) * Standard TSCH synchronization, including with ACK/NACK time correction Information Element * Standard TSCH queues and CSMA-CA mechanism - * Standard TSCH security + * Standard TSCH and 6TiSCH security * Standard 6TiSCH TSCH-RPL interaction (6TiSCH Minimal Configuration and Minimal Schedule) * A scheduling API to add/remove slotframes and links * A system for logging from TSCH timeslot operation interrupt, with postponed printout From f6a2c4ea3f6dcc06af9acbd02c896e406aa4699a Mon Sep 17 00:00:00 2001 From: Atis Elsts Date: Wed, 5 Apr 2017 12:23:26 +0100 Subject: [PATCH 103/129] Fix HDC sensor reading conversion --- platform/srf06-cc26xx/sensortag/hdc-1000-sensor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/srf06-cc26xx/sensortag/hdc-1000-sensor.c b/platform/srf06-cc26xx/sensortag/hdc-1000-sensor.c index 8fdd6d847..b8da56fef 100644 --- a/platform/srf06-cc26xx/sensortag/hdc-1000-sensor.c +++ b/platform/srf06-cc26xx/sensortag/hdc-1000-sensor.c @@ -186,7 +186,7 @@ static void convert(float *temp, float *hum) { /* Convert temperature to degrees C */ - *temp = ((double)(int16_t)raw_temp / 65536) * 165 - 40; + *temp = ((double)raw_temp / 65536) * 165 - 40; /* Convert relative humidity to a %RH value */ *hum = ((double)raw_hum / 65536) * 100; From f83f0358552a56facc11e6ce8e9f9842012c22a2 Mon Sep 17 00:00:00 2001 From: Atis Elsts Date: Sat, 8 Apr 2017 15:02:52 +0100 Subject: [PATCH 104/129] Keep CoAP 'observe' option length <= 3 bytes --- apps/er-coap/er-coap-observe.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/er-coap/er-coap-observe.c b/apps/er-coap/er-coap-observe.c index 3f3dc34ec..311f08ac8 100644 --- a/apps/er-coap/er-coap-observe.c +++ b/apps/er-coap/er-coap-observe.c @@ -249,6 +249,8 @@ coap_notify_observers_sub(resource_t *resource, const char *subpath) if(notification->code < BAD_REQUEST_4_00) { coap_set_header_observe(notification, (obs->obs_counter)++); + /* mask out to keep the CoAP observe option length <= 3 bytes */ + obs->obs_counter &= 0xffffff; } coap_set_token(notification, obs->token, obs->token_len); @@ -276,6 +278,8 @@ coap_observe_handler(resource_t *resource, void *request, void *response) coap_req->uri_path, coap_req->uri_path_len); if(obs) { coap_set_header_observe(coap_res, (obs->obs_counter)++); + /* mask out to keep the CoAP observe option length <= 3 bytes */ + obs->obs_counter &= 0xffffff; /* * Following payload is for demonstration purposes only. * A subscription should return the same representation as a normal GET. From fa618ad86c68d7c24c8b5b0025d90812902b3853 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Mon, 10 Apr 2017 11:09:28 +0200 Subject: [PATCH 105/129] Adjusted cc65 compiler options to recent cc65 option handling change. --- cpu/6502/Makefile.6502 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/6502/Makefile.6502 b/cpu/6502/Makefile.6502 index 1ddf9599c..8721c6f73 100644 --- a/cpu/6502/Makefile.6502 +++ b/cpu/6502/Makefile.6502 @@ -67,7 +67,7 @@ AR = ar65 # The apps coming with Contiki run even on a 0x100 byte stack. ASFLAGS = -t $(TARGET) -CFLAGS += -t $(TARGET) -Or -W -unused-param +CFLAGS += -t $(TARGET) -Ors -W -unused-param LDFLAGS = -t $(TARGET) -m contiki-$(TARGET).map -D __STACKSIZE__=0x200 AROPTS = a From a08adccfd57beee7d86704a60f3219b9c2a49038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Sj=C3=B6din?= Date: Tue, 11 Apr 2017 17:19:43 +0200 Subject: [PATCH 106/129] Untabify mqtt.c --- apps/mqtt/mqtt.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/apps/mqtt/mqtt.c b/apps/mqtt/mqtt.c index 9cf372fe6..43fac9db4 100644 --- a/apps/mqtt/mqtt.c +++ b/apps/mqtt/mqtt.c @@ -130,7 +130,7 @@ typedef enum { /*---------------------------------------------------------------------------*/ /* Protothread send macros */ #define PT_MQTT_WRITE_BYTES(conn, data, len) \ - conn->out_write_pos = 0; \ + conn->out_write_pos = 0; \ while(write_bytes(conn, data, len)) { \ PT_WAIT_UNTIL(pt, (conn)->out_buffer_sent); \ } @@ -148,19 +148,19 @@ typedef enum { */ #define PT_MQTT_WAIT_SEND() \ do { \ - if (PROCESS_ERR_OK == \ + if (PROCESS_ERR_OK == \ process_post(PROCESS_CURRENT(), mqtt_continue_send_event, NULL)) { \ - do { \ - PROCESS_WAIT_EVENT(); \ - if(ev == mqtt_abort_now_event) { \ - conn->state = MQTT_CONN_STATE_ABORT_IMMEDIATE; \ - PT_INIT(&conn->out_proto_thread); \ - process_post(PROCESS_CURRENT(), ev, data); \ - } else if(ev >= mqtt_event_min && ev <= mqtt_event_max) { \ - process_post(PROCESS_CURRENT(), ev, data); \ - } \ - } while (ev != mqtt_continue_send_event); \ - } \ + do { \ + PROCESS_WAIT_EVENT(); \ + if(ev == mqtt_abort_now_event) { \ + conn->state = MQTT_CONN_STATE_ABORT_IMMEDIATE; \ + PT_INIT(&conn->out_proto_thread); \ + process_post(PROCESS_CURRENT(), ev, data); \ + } else if(ev >= mqtt_event_min && ev <= mqtt_event_max) { \ + process_post(PROCESS_CURRENT(), ev, data); \ + } \ + } while (ev != mqtt_continue_send_event); \ + } \ } while(0) /*---------------------------------------------------------------------------*/ static process_event_t mqtt_do_connect_tcp_event; @@ -1194,7 +1194,7 @@ PROCESS_THREAD(mqtt_process, ev, data) if(conn->out_buffer_sent == 1) { PT_INIT(&conn->out_proto_thread); while(conn->state != MQTT_CONN_STATE_ABORT_IMMEDIATE && - disconnect_pt(&conn->out_proto_thread, conn) < PT_EXITED) { + disconnect_pt(&conn->out_proto_thread, conn) < PT_EXITED) { PT_MQTT_WAIT_SEND(); } abort_connection(conn); @@ -1212,7 +1212,7 @@ PROCESS_THREAD(mqtt_process, ev, data) conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) { PT_INIT(&conn->out_proto_thread); while(conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER && - pingreq_pt(&conn->out_proto_thread, conn) < PT_EXITED) { + pingreq_pt(&conn->out_proto_thread, conn) < PT_EXITED) { PT_MQTT_WAIT_SEND(); } } @@ -1225,7 +1225,7 @@ PROCESS_THREAD(mqtt_process, ev, data) conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) { PT_INIT(&conn->out_proto_thread); while(conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER && - subscribe_pt(&conn->out_proto_thread, conn) < PT_EXITED) { + subscribe_pt(&conn->out_proto_thread, conn) < PT_EXITED) { PT_MQTT_WAIT_SEND(); } } @@ -1238,7 +1238,7 @@ PROCESS_THREAD(mqtt_process, ev, data) conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) { PT_INIT(&conn->out_proto_thread); while(conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER && - unsubscribe_pt(&conn->out_proto_thread, conn) < PT_EXITED) { + unsubscribe_pt(&conn->out_proto_thread, conn) < PT_EXITED) { PT_MQTT_WAIT_SEND(); } } @@ -1251,7 +1251,7 @@ PROCESS_THREAD(mqtt_process, ev, data) conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) { PT_INIT(&conn->out_proto_thread); while(conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER && - publish_pt(&conn->out_proto_thread, conn) < PT_EXITED) { + publish_pt(&conn->out_proto_thread, conn) < PT_EXITED) { PT_MQTT_WAIT_SEND(); } } From ae91d6b4b15a1e427476790477ef1e49a5864a23 Mon Sep 17 00:00:00 2001 From: Bernhard Hackl Date: Tue, 11 Apr 2017 06:27:55 -0700 Subject: [PATCH 107/129] Fix potentially unterminated strings --- core/net/ip/resolv.c | 10 +++++----- core/net/ipv6/websocket.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/net/ip/resolv.c b/core/net/ip/resolv.c index a0b40c32d..c7fb2e364 100644 --- a/core/net/ip/resolv.c +++ b/core/net/ip/resolv.c @@ -1094,7 +1094,7 @@ resolv_set_hostname(const char *hostname) /* Add the .local suffix if it isn't already there */ if(strlen(resolv_hostname) < 7 || strcasecmp(resolv_hostname + strlen(resolv_hostname) - 6, ".local") != 0) { - strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE); + strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE - strlen(resolv_hostname)); } PRINTF("resolver: hostname changed to \"%s\"\n", resolv_hostname); @@ -1248,8 +1248,8 @@ remove_trailing_dots(const char *name) { static char dns_name_without_dots[RESOLV_CONF_MAX_DOMAIN_NAME_SIZE + 1]; size_t len = strlen(name); - if(name[len - 1] == '.') { - strncpy(dns_name_without_dots, name, sizeof(dns_name_without_dots)); + if(len && name[len - 1] == '.') { + strncpy(dns_name_without_dots, name, RESOLV_CONF_MAX_DOMAIN_NAME_SIZE); while(len && (dns_name_without_dots[len - 1] == '.')) { dns_name_without_dots[--len] = 0; } @@ -1309,7 +1309,7 @@ resolv_query(const char *name) memset(nameptr, 0, sizeof(*nameptr)); - strncpy(nameptr->name, name, sizeof(nameptr->name)); + strncpy(nameptr->name, name, sizeof(nameptr->name) - 1); nameptr->state = STATE_NEW; nameptr->seqno = seqno; ++seqno; @@ -1479,7 +1479,7 @@ resolv_found(char *name, uip_ipaddr_t * ipaddr) } /* Re-add the .local suffix */ - strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE); + strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE - strlen(resolv_hostname)); start_name_collision_check(CLOCK_SECOND * 5); } else if(mdns_state == MDNS_STATE_READY) { diff --git a/core/net/ipv6/websocket.c b/core/net/ipv6/websocket.c index 92141c9c9..28f78896b 100644 --- a/core/net/ipv6/websocket.c +++ b/core/net/ipv6/websocket.c @@ -547,8 +547,8 @@ websocket_open(struct websocket *s, const char *url, websocket_callback c) { int ret; - char host[MAX_HOSTLEN]; - char path[MAX_PATHLEN]; + char host[MAX_HOSTLEN + 1] = {0}; + char path[MAX_PATHLEN + 1] = {0}; uint16_t port; uip_ipaddr_t addr; From 848f801460963ce24a39ad9f8abcb7945d346e65 Mon Sep 17 00:00:00 2001 From: Bernhard Hackl Date: Tue, 11 Apr 2017 05:25:18 -0700 Subject: [PATCH 108/129] Fix several uninitialized variables --- core/net/mac/frame802154.c | 2 +- core/net/rpl/rpl-icmp6.c | 1 + cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/net/mac/frame802154.c b/core/net/mac/frame802154.c index d5c55c4e8..9fa893c1d 100644 --- a/core/net/mac/frame802154.c +++ b/core/net/mac/frame802154.c @@ -205,7 +205,7 @@ frame802154_has_panid(frame802154_fcf_t *fcf, int *has_src_pan_id, int *has_dest int frame802154_check_dest_panid(frame802154_t *frame) { - int has_dest_panid; + int has_dest_panid = 0; if(frame == NULL) { return 0; diff --git a/core/net/rpl/rpl-icmp6.c b/core/net/rpl/rpl-icmp6.c index 733b4e6a4..390168aaf 100644 --- a/core/net/rpl/rpl-icmp6.c +++ b/core/net/rpl/rpl-icmp6.c @@ -652,6 +652,7 @@ dao_input_storing(void) prefixlen = 0; parent = NULL; + memset(&prefix, 0, sizeof(prefix)); uip_ipaddr_copy(&dao_sender_addr, &UIP_IP_BUF->srcipaddr); diff --git a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index 446f935d4..81382b204 100644 --- a/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -1587,7 +1587,7 @@ get_object(radio_param_t param, void *dest, size_t size) static radio_result_t set_object(radio_param_t param, const void *src, size_t size) { - radio_result_t rv; + radio_result_t rv = RADIO_RESULT_OK; int i; uint8_t *dst; rfc_CMD_IEEE_RX_t *cmd = (rfc_CMD_IEEE_RX_t *)cmd_ieee_rx_buf; From 58517dfcbde0467034f341bb77f3b9b5067ecfe5 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Mon, 24 Apr 2017 14:34:01 +0200 Subject: [PATCH 109/129] AES128 HW crypto engine support for Atmel radios modified: cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h modified: cpu/avr/radio/rf230bb/atmega256rfr2_registermap.h modified: cpu/avr/radio/rf230bb/rf230bb.c modified: cpu/avr/radio/rf230bb/rf230bb.h --- .../radio/rf230bb/atmega128rfa1_registermap.h | 18 ++ .../radio/rf230bb/atmega256rfr2_registermap.h | 15 ++ cpu/avr/radio/rf230bb/rf230bb.c | 180 ++++++++++++++++++ cpu/avr/radio/rf230bb/rf230bb.h | 4 + 4 files changed, 217 insertions(+) diff --git a/cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h b/cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h index 64b068579..9a8e82308 100644 --- a/cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h +++ b/cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h @@ -88,6 +88,24 @@ #define RG_XAH_CTRL_1 (0x157) #define SR_AACK_PROM_MODE 0x157, 0x02, 1 + +#define RG_AES_KEY (0x13F) +#define SR_AES_KEY 0x13F, 0xff, 0 +#define RG_AES_STATE (0x13E) +#define SR_AES_STATE 0x13E, 0xff, 0 +#define RG_AES_STATUS (0x13D) +#define SR_AES_STATUS 0x13D, 0xff, 0 +#define SR_AES_STATUS_DONE 0x13D, 0x01, 0 +#define SR_AES_STATUS_ERR 0x13D, 0x80, 7 +#define RG_AES_CNTRL (0x13C) +#define SR_AES_CNTRL 0x13C, 0xff, 0 +#define SR_AES_CNTRL_IM 0x13C, 0x04, 2 +#define SR_AES_CNTRL_DIR 0x13C, 0x08, 3 +#define SR_AES_CNTRL_MODE 0x13C, 0x20, 5 +#define SR_AES_CNTRL_REQUEST 0x13C, 0x80, 7 + +#define SR_IRQ_MASK 0x14e, 0xff, 0 + /* RF230 register assignments, for reference */ #if 0 #define HAVE_REGISTER_MAP (1) diff --git a/cpu/avr/radio/rf230bb/atmega256rfr2_registermap.h b/cpu/avr/radio/rf230bb/atmega256rfr2_registermap.h index 151513a25..1e8ed54e3 100644 --- a/cpu/avr/radio/rf230bb/atmega256rfr2_registermap.h +++ b/cpu/avr/radio/rf230bb/atmega256rfr2_registermap.h @@ -229,6 +229,21 @@ Counter Compare Source #define SR_CSMA_SEED_1 0x16e, 0x03, 0 #define SR_AACK_DIS_ACK 0x16e, 0x10, 4 +#define RG_AES_KEY (0x13F) +#define SR_AES_KEY 0x13F, 0xff, 0 +#define RG_AES_STATE (0x13E) +#define SR_AES_STATE 0x13E, 0xff, 0 +#define RG_AES_STATUS (0x13D) +#define SR_AES_STATUS 0x13D, 0xff, 0 +#define SR_AES_STATUS_DONE 0x13D, 0x01, 0 +#define SR_AES_STATUS_ERR 0x13D, 0x80, 7 +#define RG_AES_CNTRL (0x13C) +#define SR_AES_CNTRL 0x13C, 0xff, 0 +#define SR_AES_CNTRL_IM 0x13C, 0x04, 2 +#define SR_AES_CNTRL_DIR 0x13C, 0x08, 3 +#define SR_AES_CNTRL_MODE 0x13C, 0x20, 5 +#define SR_AES_CNTRL_REQUEST 0x13C, 0x80, 7 + /* RF230 register assignments, for reference */ #if 1 //#define HAVE_REGISTER_MAP (1) diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index 4fa9a44b4..ce29b70af 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -46,6 +46,7 @@ #if defined(__AVR__) #include +#include //_delay_us has the potential to use floating point which brings the 256 byte clz table into RAM //#include @@ -2075,4 +2076,183 @@ void rf230_start_sneeze(void) { // while (hal_register_read(0x0f)!=1) {continue;} //wait for pll lock-hangs hal_register_write(0x02,0x02); //Set TRX_STATE to TX_START } + #endif + +#ifdef AES_128_HW_CONF +#define IEEE_VECT 0 + +extern unsigned char aes_key[16]; +extern unsigned char aes_p[]; +extern unsigned char aes_c[]; +extern unsigned char aes_s[]; +extern unsigned char tmp[16]; + +/* + After PWR_SAVE sleep key is lost. We'll lock en/decyption to avoid + not to forced in to sleep while doing crypto. Also the key is hold + be the user so AES block should be reentrant. Encode/Docode och 128bit + (16 bytes) is promised to be less than 24us. + Note! Radio must be on to use the HW crypto engine. --ro +*/ + +static void +rf230_aes_write_key(unsigned char *key) +{ + uint8_t i; + for(i = 0; i < 16; i++) { + hal_subregister_write(SR_AES_KEY, key[i]); + } +} +static void +rf230_aes_read_key(unsigned char *key) +{ + uint8_t i; + for(i = 0; i < 16; i++) { + key[i] = hal_subregister_read(SR_AES_KEY); + } +} +static void +rf230_aes_write_state(unsigned char *state) +{ + uint8_t i; + for(i = 0; i < 16; i++) { + hal_subregister_write(SR_AES_STATE, state[i]); + } +} +static void +rf230_aes_read_state(unsigned char *state) +{ + uint8_t i; + for(i = 0; i < 16; i++) { + state[i] = hal_subregister_read(SR_AES_STATE); + } +} + +static int +crypt(void) +{ + uint8_t status; + + hal_subregister_write(SR_AES_CNTRL_REQUEST, 1); /* Kick */ + + do { + watchdog_periodic(); + status = hal_subregister_read(SR_AES_STATUS); + } while(status == 0); + + if (hal_subregister_read(SR_AES_STATUS_ERR)) { + PRINTF("AES ERR\n"); + return 0; + } + if (hal_subregister_read(SR_AES_STATUS_DONE)) { + PRINTF("AES DONE\n"); + return 1; + } + return 0; /* Unknown */ +} + +int +rf230_aes_encrypt_cbc(unsigned char *key, unsigned char *plain, int len, unsigned char *mic) +{ + uint8_t i; + uint8_t sreg; + int res; + + sreg = SREG; + cli(); + rf230_aes_write_key(key); + hal_subregister_write(SR_AES_CNTRL_MODE, 0); /* AES_MODE=0 -> ECB for 1:st block*/ + hal_subregister_write(SR_AES_CNTRL_DIR, 0); /* AES_DIR=0 -> encryption */ + + /* write string to encrypt into buffer */ + for(i = 0; i < 16; i++) { + AES_STATE = plain[i] ^ IEEE_VECT; + } + res = crypt(); + if(!res) + goto out; + + len -= 16; + /* Swiitch Mode */ + hal_subregister_write(SR_AES_CNTRL_MODE, 1); /* AES_MODE=1 -> CBC */ + hal_subregister_write(SR_AES_CNTRL_DIR, 0); /* AES_DIR=0 -> encryption */ + + while(len > 0) { + rf230_aes_write_state(plain); + res = crypt(); + if(!res) + goto out; + + len -= 16; + } + /* Read and retrun cipher */ + rf230_aes_read_state(mic); + +out: + SREG = sreg; + return res; +} + +/* Electonic Code Block */ +int +rf230_aes_encrypt_ebc(unsigned char *key, unsigned char *plain, unsigned char *cipher) +{ + int res; + uint8_t sreg; + + sreg = SREG; + cli(); + rf230_aes_write_key(key); + hal_subregister_write(SR_AES_CNTRL_MODE, 0); /* AES_MODE=0 -> ECB for 1:st block*/ + hal_subregister_write(SR_AES_CNTRL_DIR, 0); /* AES_DIR=0 -> encryption */ + rf230_aes_write_state(plain); /* write string to encrypt into buffer */ + res = crypt(); + if(!res) + goto out; + rf230_aes_read_state(cipher); /* Read and return cipher */ + +out: + SREG = sreg; + return res; +} + +int +rf230_aes_decrypt_ebc(unsigned char *key, unsigned char *cipher, unsigned char *plain) +{ + int res; + uint8_t sreg; + /* + Dummy encryption of 0 w. original key + to get last round key to be used decrytion + */ + + sreg = SREG; + cli(); + + rf230_aes_write_key(key); + hal_subregister_write(SR_AES_CNTRL_MODE, 0); /* AES_MODE=0 -> ECB for 1:st block*/ + hal_subregister_write(SR_AES_CNTRL_DIR, 0); /* AES_DIR=0 -> encryption */ + memset(tmp, 0, sizeof(tmp)); /* Setup for last round */ + rf230_aes_write_state(tmp); + res = crypt(); + if(!res) + goto out; + + rf230_aes_read_key(tmp);/* Save the last round key */ + /* And use as decrytion key */ + rf230_aes_write_key(tmp); + hal_subregister_write(SR_AES_CNTRL_MODE, 0); /* AES_MODE=0 -> ECB for 1:st block*/ + hal_subregister_write(SR_AES_CNTRL_DIR, 1); /* AES_DIR=1 -> decryption */ + /* Write string to decrypt into buffer */ + rf230_aes_write_state(cipher); + res = crypt(); + if(!res) + goto out; + rf230_aes_read_state(plain); /* Read plaintext into string */ + +out: + SREG = sreg; + return res; +} +#endif /* AES_128_HW_CONF */ diff --git a/cpu/avr/radio/rf230bb/rf230bb.h b/cpu/avr/radio/rf230bb/rf230bb.h index 15f5b6438..a6414d4fc 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.h +++ b/cpu/avr/radio/rf230bb/rf230bb.h @@ -227,6 +227,10 @@ bool rf230_is_ready_to_send(); extern uint8_t rf230_last_correlation,rf230_last_rssi,rf230_smallest_rssi; uint8_t rf230_get_raw_rssi(void); +int rf230_aes_encrypt_ebc(unsigned char *key, unsigned char *plain, unsigned char *cipher); +int rf230_aes_decrypt_ebc(unsigned char *key, unsigned char *cipher, unsigned char *plain); +int rf230_aes_decrypt_ebc(unsigned char *key, unsigned char *cipher, unsigned char *plain); + #define rf230_rssi rf230_get_raw_rssi From e9aed001bce4efaafd21f1908ddfe9e5cfa1cbc4 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Mon, 24 Apr 2017 14:40:33 +0200 Subject: [PATCH 110/129] Example project for Atmel radio AES128 cryto engine --- .../avr-rss2/AES128HW_test/AES128HW_test.c | 107 ++++++++++++++++++ examples/avr-rss2/AES128HW_test/Makefile | 18 +++ examples/avr-rss2/AES128HW_test/README.md | 24 ++++ .../avr-rss2/AES128HW_test/project-conf.h | 47 ++++++++ 4 files changed, 196 insertions(+) create mode 100644 examples/avr-rss2/AES128HW_test/AES128HW_test.c create mode 100644 examples/avr-rss2/AES128HW_test/Makefile create mode 100644 examples/avr-rss2/AES128HW_test/README.md create mode 100644 examples/avr-rss2/AES128HW_test/project-conf.h diff --git a/examples/avr-rss2/AES128HW_test/AES128HW_test.c b/examples/avr-rss2/AES128HW_test/AES128HW_test.c new file mode 100644 index 000000000..da7935838 --- /dev/null +++ b/examples/avr-rss2/AES128HW_test/AES128HW_test.c @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2015, Copyright Robert Olsson + * 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 Institute 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 INSTITUTE 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 INSTITUTE 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. + * + * This file is part of the Contiki operating system. + * + * Author : Robert Olsson + * roolss@kth.se & robert@radio-sensors.com + * Created : 2017-04-22 + */ + +/** + * \file + * A simple AES128 crypto emmgine test for Atmel radios + */ + +#include "contiki.h" +#include "dev/radio.h" +#include "net/netstack.h" +#include "sys/etimer.h" +#include +#include +#include +#include "rf230bb.h" + +PROCESS(aes_crypto_process, "AES HW crypto process"); +AUTOSTART_PROCESSES(&aes_crypto_process); + +unsigned char aes_key[16] = "abcdefghijklmnop"; +unsigned char aes_p[128]; +unsigned char aes_c[128]; +unsigned char aes_s[128]; +unsigned char tmp[16]; +uint8_t i; +int res; + +PROCESS_THREAD(aes_crypto_process, ev, data) +{ + PROCESS_BEGIN(); + + /* AES engine on */ + NETSTACK_RADIO.on(); + + strcpy((char *)aes_s, "Teststring______"); + + for(i = 0; i < 16; i++) { + printf("%02X", aes_s[i]); + } + printf(" Uncrypted \n"); + + res = rf230_aes_encrypt_ebc(aes_key, aes_s, aes_c); + if(!res) { + printf("ERR encryption\n"); + exit(0); + } + for(i = 0; i < 16; i++) { + printf("%02X", aes_c[i]); + } + printf(" AES-128 EBC Crypted\n"); + + res = rf230_aes_decrypt_ebc(aes_key, aes_c, aes_p); + if(!res) { + printf("ERR decryption\n"); + exit(0); + } + for(i = 0; i < 16; i++) { + printf("%02X", aes_p[i]); + } + printf(" Decrypted \n"); + + res = rf230_aes_encrypt_cbc(aes_key, aes_s, sizeof(aes_s), aes_c); + if(!res) { + printf("ERR encryption\n"); + exit(0); + } + for(i = 0; i < 16; i++) { + printf("%02X", aes_c[i]); + } + printf(" AES-128 MIC\n"); + + PROCESS_END(); +} + diff --git a/examples/avr-rss2/AES128HW_test/Makefile b/examples/avr-rss2/AES128HW_test/Makefile new file mode 100644 index 000000000..44c80fb3b --- /dev/null +++ b/examples/avr-rss2/AES128HW_test/Makefile @@ -0,0 +1,18 @@ +CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" +CONTIKI_PROJECT = AES128HW_test +all: $(CONTIKI_PROJECT) + +# We use floating vars. Add library. +PRINTF_LIB_FLT = -Wl,-u,vfprintf -lprintf_flt -lm +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min +PRINTF_LIB = $(PRINTF_LIB_FLT) +CLIBS = $(PRINTF_LIB) + +CUSTOM_RULE_LINK = 1 +%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a + $(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ $(CLIBS) + +CONTIKI_WITH_RIME = 1 + +CONTIKI = ../../.. +include $(CONTIKI)/Makefile.include diff --git a/examples/avr-rss2/AES128HW_test/README.md b/examples/avr-rss2/AES128HW_test/README.md new file mode 100644 index 000000000..ebcaaa7fb --- /dev/null +++ b/examples/avr-rss2/AES128HW_test/README.md @@ -0,0 +1,24 @@ +AES128HW_test +============= + +Scope +----- +Simple demo to use the AES crypto engine in the Atmel radios. + +Build +----- +make TARGET=avr-rss2 + +Program output +-------------- +*******Booting Contiki-3.x-3252-g0783591******* +I2C: AT24MAC +MAC address 7d:c2: +PAN=0xABCD, MAC=nullmac, RDC=nullrdc, NETWORK=Rime, channel=26, check-rate-Hz=128, tx-power=0 +Routing Enabled + +54657374737472696E675F5F5F5F5F5F Uncrypted +6FDE14E8F9453C6714B7B45B24876CBF AES-128 EBC Crypted +54657374737472696E675F5F5F5F5F5F Decrypted +215C9836DCDB443F15AFED576E9F7F72 AES-128 MIC + diff --git a/examples/avr-rss2/AES128HW_test/project-conf.h b/examples/avr-rss2/AES128HW_test/project-conf.h new file mode 100644 index 000000000..5ae870b6f --- /dev/null +++ b/examples/avr-rss2/AES128HW_test/project-conf.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2015, Copyright Robert Olsson / Radio Sensors AB + * 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 Institute 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 INSTITUTE 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 INSTITUTE 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. + * + * This file is part of the Contiki operating system. + * + * + * Author : Robert Olsson robert@radio-sensors.com + * Created : 2017-04-22 + */ + +/** + * \file + * Project specific configuration defines for example + * + */ + +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ + +#define AES_128_HW_CONF 1 + +#endif /* PROJECT_CONF_H_ */ From c2560498b6a3e18a2dc492376fd3b8cf19ae30a8 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Fri, 5 May 2017 12:55:03 +0200 Subject: [PATCH 111/129] Atmel radio; Support for RADIO_PARAM_CCA_THRESHOLD added --- cpu/avr/radio/rf230bb/rf230bb.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index 4fa9a44b4..7d81e237b 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -357,6 +357,35 @@ rf230_set_short_addr(uint16_t addr) hal_register_write(RG_SHORT_ADDR_1, (addr >> 8)); } +#define RSSI_BASE_VAL (-90) + +/* Returns the current CCA threshold in dBm */ +static radio_value_t +rf230_get_cca_threshold() +{ + radio_value_t cca_thresh = 0; + + cca_thresh = hal_subregister_read(SR_CCA_ED_THRES); + cca_thresh = RSSI_BASE_VAL + 2 * cca_thresh; + return cca_thresh; +} + +/* Sets the CCA threshold in dBm */ +static radio_value_t +rf230_set_cca_threshold(radio_value_t cca_thresh) +{ + + if(cca_thresh > -60) /* RSSI_BASE_VAL - 2 * 0xF */ + cca_thresh = -60; + + cca_thresh = (RSSI_BASE_VAL - cca_thresh)/2; + if(cca_thresh < 0) + cca_thresh = - cca_thresh; + + hal_subregister_write(SR_CCA_ED_THRES, cca_thresh); + return cca_thresh; +} + /*---------------------------------------------------------------------------*/ static radio_result_t get_value(radio_param_t param, radio_value_t *value) @@ -399,7 +428,7 @@ get_value(radio_param_t param, radio_value_t *value) *value = rf230_get_txpower(); return RADIO_RESULT_OK; case RADIO_PARAM_CCA_THRESHOLD: - /* *value = get_cca_threshold(); */ + *value = rf230_get_cca_threshold(); return RADIO_RESULT_OK; case RADIO_PARAM_RSSI: *value = rf230_get_raw_rssi(); @@ -475,7 +504,7 @@ set_value(radio_param_t param, radio_value_t value) return RADIO_RESULT_OK; case RADIO_PARAM_CCA_THRESHOLD: - /* set_cca_threshold(value); */ + rf230_set_cca_threshold(value); return RADIO_RESULT_OK; default: return RADIO_RESULT_NOT_SUPPORTED; From 22975df423d45841e89d83786f0a810fb22a8b2a Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Fri, 5 May 2017 12:57:18 +0200 Subject: [PATCH 112/129] examples/rf_environment for rf CCA (non-intrusive) monitoring added --- examples/rf_environment/Makefile | 20 +++ examples/rf_environment/README.md | 12 ++ examples/rf_environment/project-conf.h | 11 ++ examples/rf_environment/rf_environment.c | 195 +++++++++++++++++++++++ 4 files changed, 238 insertions(+) create mode 100644 examples/rf_environment/Makefile create mode 100644 examples/rf_environment/README.md create mode 100644 examples/rf_environment/project-conf.h create mode 100644 examples/rf_environment/rf_environment.c diff --git a/examples/rf_environment/Makefile b/examples/rf_environment/Makefile new file mode 100644 index 000000000..75bf368af --- /dev/null +++ b/examples/rf_environment/Makefile @@ -0,0 +1,20 @@ +CONTIKI_PROJECT=rf_environment +all: $(CONTIKI_PROJECT) + +DEFINES+=PROJECT_CONF_H=\"project-conf.h\" + +# We use floating vars. Add library. +PRINTF_LIB_FLT = -Wl,-u,vfprintf -lprintf_flt -lm +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min +PRINTF_LIB = $(PRINTF_LIB_FLT) +CLIBS = $(PRINTF_LIB) + + +CUSTOM_RULE_LINK = 1 +%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a + $(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ $(CLIBS) + + +CONTIKI=../../ +include $(CONTIKI)/Makefile.include + diff --git a/examples/rf_environment/README.md b/examples/rf_environment/README.md new file mode 100644 index 000000000..89b1495bd --- /dev/null +++ b/examples/rf_environment/README.md @@ -0,0 +1,12 @@ +Non-intrusive monitoring of the RF-environment +============================================== + + +rf_environment runs clear channel assessment (CCA) test for over +all 802.15.4 channels and reports stats per channel. The CCA test +is run for different CCA thresholds from -60 to -190 dBm. CCA is a +non-destructive for the rf-environment it's just listens. + +Best and worst channel is printed as average rf activity. + +Originally developed for the Atmel avr-rss2 platform. diff --git a/examples/rf_environment/project-conf.h b/examples/rf_environment/project-conf.h new file mode 100644 index 000000000..2f7691f16 --- /dev/null +++ b/examples/rf_environment/project-conf.h @@ -0,0 +1,11 @@ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ + +#define NETSTACK_CONF_RDC nullrdc_driver +#define NETSTACK_CONF_MAC nullmac_driver +#define NETSTACK_CONF_FRAMER framer_802154 +#define NETSTACK_CONF_RADIO rf230_driver + +#define RS232_BAUDRATE USART_BAUD_38400 + +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/rf_environment/rf_environment.c b/examples/rf_environment/rf_environment.c new file mode 100644 index 000000000..44f151a1a --- /dev/null +++ b/examples/rf_environment/rf_environment.c @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2016, Robert Olsson KTH Royal Institute of Technology + * COS/Kista Stockholm roolss@kth.se + * + * 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. + */ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" +#include "dev/radio.h" +#include "net/netstack.h" +#include "net/packetbuf.h" +#include "sys/process.h" +#include "sys/etimer.h" +#include +#include "dev/leds.h" + +#include +#include +#include + +#define SAMPLES 1000 + +#define DEBUG 1 +#if DEBUG +#define PRINTF(...) printf(__VA_ARGS__) +#else +#define PRINTF(...) +#endif + +PROCESS(rf_scan_process, "rf_scan process"); +AUTOSTART_PROCESSES(&rf_scan_process); + +/* + rf_environment runs clear channel assessment (CCA) test for over + all 802.15.4 channels and reports stats per channel. The CCA test + is run for different CCA thresholds from -60 to -190 dBm. CCA is a + non-destructive for the rf-environment it's just listens. + + Best and worst channel is printed as average rf activity. + + Originally developed for the Atmel avr-rss2 platform. + + */ + +static struct etimer et; +static int cca[27], cca_thresh, chan, i, j, k; +static uint16_t best, best_sum; +static uint16_t worst, worst_sum; +static double ave; + +static radio_value_t +get_chan(void) +{ + radio_value_t chan; + if(NETSTACK_RADIO.get_value(RADIO_PARAM_CHANNEL, &chan) == + RADIO_RESULT_OK) { + return chan; + } + return 0; +} +static void +set_chan(uint8_t chan) +{ + if(NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, chan) == + RADIO_RESULT_OK) { + } +} +static radio_value_t +get_chan_min(void) +{ + radio_value_t chan; + if(NETSTACK_RADIO.get_value(RADIO_CONST_CHANNEL_MIN, &chan) == + RADIO_RESULT_OK) { + return chan; + } + return 0; +} +static radio_value_t +get_chan_max(void) +{ + radio_value_t chan; + + if(NETSTACK_RADIO.get_value(RADIO_CONST_CHANNEL_MAX, &chan) == + RADIO_RESULT_OK) { + return chan; + } + return 0; +} +static radio_value_t +get_cca_thresh(void) +{ + radio_value_t cca; + + if(NETSTACK_RADIO.get_value(RADIO_PARAM_CCA_THRESHOLD, &cca) == + RADIO_RESULT_OK) { + return cca; + } + return 0; +} +static radio_value_t +set_cca_thresh(radio_value_t thresh) +{ + if(NETSTACK_RADIO.set_value(RADIO_PARAM_CCA_THRESHOLD, thresh) == + RADIO_RESULT_OK) { + return RADIO_RESULT_OK; + } + return 0; +} +PROCESS_THREAD(rf_scan_process, ev, data) +{ + PROCESS_BEGIN(); + + leds_init(); + leds_on(LEDS_RED); + leds_on(LEDS_YELLOW); + + printf("Chan min=%d\n", get_chan_min()); + chan = get_chan(); + printf("Chan cur=%d\n", chan); + printf("Chan max=%d\n", get_chan_max()); + cca_thresh = get_cca_thresh(); + printf("Default CCA thresh=%d\n", cca_thresh); + + etimer_set(&et, CLOCK_SECOND / 2); + + while(1) { + + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); + + for(k = -90; k <= -60; k += 2) { + set_cca_thresh(k); + for(j = 11; j <= 26; j++) { + set_chan(j); + cca[j] = 0; +#ifdef CONTIKI_TARGET_AVR_RSS2 + watchdog_periodic(); +#endif + NETSTACK_RADIO.on(); + for(i = 0; i < SAMPLES; i++) { + cca[j] += NETSTACK_RADIO.channel_clear(); + } + NETSTACK_RADIO.off(); + } + printf("cca_thresh=%-3ddBm", get_cca_thresh()); + + worst = 0; + worst_sum = 0xFFFF; + best = 0; + best_sum = 0; + ave = 0; + + for(j = 11; j <= 26; j++) { + ave += cca[j]; + printf(" %3d", 100 - (100 * cca[j]) / SAMPLES); + if(cca[j] > best_sum) { + best_sum = cca[j]; + best = j; + } + if(cca[j] < worst_sum) { + worst_sum = cca[j]; + worst = j; + } + } + printf(" Best=%d Worst=%d Ave=%-5.2f\n", best, worst, 100 - (100 * (ave / 16) / SAMPLES)); + } + etimer_set(&et, CLOCK_SECOND / 2); + } + PROCESS_END(); +} From 91928592d09b98a1f1004530bb57081807766411 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Mon, 8 May 2017 13:11:22 +0200 Subject: [PATCH 113/129] Updated README for rf_environment example --- examples/rf_environment/README.md | 65 ++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/examples/rf_environment/README.md b/examples/rf_environment/README.md index 89b1495bd..9bdf1a907 100644 --- a/examples/rf_environment/README.md +++ b/examples/rf_environment/README.md @@ -1,12 +1,65 @@ Non-intrusive monitoring of the RF-environment ============================================== - -rf_environment runs clear channel assessment (CCA) test for over +rf_environment runs the clear channel assessment (CCA) test over all 802.15.4 channels and reports stats per channel. The CCA test -is run for different CCA thresholds from -60 to -190 dBm. CCA is a -non-destructive for the rf-environment it's just listens. - +is run for different CCA thresholds from -60dBm to -90dBm. CCA is +a non-destructive for the rf-environment as it's just listens. Best and worst channel is printed as average rf activity. +See example below from Uppsala Kungs-Vaksalagatan. 2017-05-08 +and Electrum Stockholm. Originally developed for the Atmel avr-rss2 +platform. -Originally developed for the Atmel avr-rss2 platform. +Probability for not passing a CCA check in percent per channel. +3-minute samples. Of course this just snapshots to illustrate +functionality + + + Chan: 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 + --------------------------------------------------------------------- +cca_thresh=-82dBm 0 0 7 0 1 2 2 0 0 0 0 6 30 5 0 1 Best=11 Worst=23 Ave=3.09 +cca_thresh=-80dBm 0 0 1 0 1 0 3 1 0 0 1 16 15 1 2 0 Best=11 Worst=22 Ave=2.31 +cca_thresh=-78dBm 0 0 4 10 0 2 2 2 1 2 0 12 23 4 1 1 Best=11 Worst=23 Ave=3.65 +cca_thresh=-76dBm 0 0 12 8 4 0 6 4 10 3 1 24 15 0 1 1 Best=11 Worst=22 Ave=5.37 +cca_thresh=-74dBm 0 1 1 2 1 0 4 1 2 1 2 10 16 22 5 1 Best=11 Worst=24 Ave=3.96 +cca_thresh=-72dBm 0 1 3 3 3 0 2 1 1 4 2 5 3 8 5 3 Best=11 Worst=24 Ave=2.26 +cca_thresh=-70dBm 0 0 5 3 3 3 1 5 9 26 60 77 53 35 27 8 Best=11 Worst=22 Ave=19.40 +cca_thresh=-68dBm 0 1 9 10 1 2 1 3 0 4 59 32 60 37 24 3 Best=11 Worst=23 Ave=14.89 +cca_thresh=-66dBm 0 2 3 2 1 2 2 1 5 15 50 64 77 49 16 5 Best=11 Worst=23 Ave=17.87 +cca_thresh=-64dBm 1 3 0 1 1 2 1 1 6 18 19 31 62 47 25 3 Best=13 Worst=23 Ave=13.35 +cca_thresh=-62dBm 0 0 3 6 2 5 2 0 23 43 37 25 18 32 27 25 Best=11 Worst=20 Ave=15.14 +cca_thresh=-60dBm 2 2 3 3 2 3 1 8 34 37 40 49 72 55 9 9 Best=17 Worst=23 Ave=20.17 +cca_thresh=-90dBm 0 1 11 10 4 8 2 1 10 22 15 17 22 18 3 9 Best=11 Worst=20 Ave=9.06 +cca_thresh=-88dBm 0 0 17 37 2 3 2 5 12 18 24 43 13 28 6 3 Best=11 Worst=22 Ave=12.90 +cca_thresh=-86dBm 0 3 12 2 0 3 3 4 12 11 17 13 42 19 17 10 Best=11 Worst=23 Ave=10.05 +cca_thresh=-84dBm 0 0 3 3 0 3 2 4 12 11 14 13 23 9 11 15 Best=11 Worst=23 Ave=7.33 +cca_thresh=-82dBm 0 2 30 24 2 4 2 6 3 11 4 10 8 3 4 1 Best=11 Worst=13 Ave=6.66 +cca_thresh=-80dBm 0 1 9 3 0 1 6 6 15 0 0 8 11 4 3 3 Best=11 Worst=19 Ave=4.05 +cca_thresh=-78dBm 0 1 3 2 0 1 7 8 1 0 4 13 6 3 1 1 Best=11 Worst=22 Ave=2.79 +cca_thresh=-76dBm 0 0 1 7 1 8 11 10 21 1 2 10 28 3 0 1 Best=11 Worst=23 Ave=6.15 +cca_thresh=-74dBm 0 3 2 2 0 1 6 4 8 0 3 5 8 9 0 0 Best=11 Worst=24 Ave=2.77 +cca_thresh=-72dBm 0 0 0 3 1 2 2 2 1 1 3 7 11 9 1 1 Best=11 Worst=23 Ave=2.40 +cca_thresh=-70dBm 0 1 11 2 1 2 4 1 4 4 13 31 7 1 1 1 Best=11 Worst=22 Ave=4.69 +cca_thresh=-68dBm 0 0 13 26 1 5 7 8 3 1 1 20 43 7 1 0 Best=11 Worst=23 Ave=8.21 +cca_thresh=-66dBm 1 2 13 9 1 3 3 1 3 16 11 22 9 7 0 1 Best=25 Worst=22 Ave=5.79 +cca_thresh=-64dBm 0 1 6 2 1 2 2 0 3 8 4 8 14 1 4 1 Best=11 Worst=23 Ave=3.10 +cca_thresh=-62dBm 0 1 4 0 1 2 1 3 1 1 9 16 22 7 1 1 Best=11 Worst=23 Ave=3.91 +cca_thresh=-60dBm 0 1 2 0 1 0 1 1 15 33 4 5 26 2 0 0 Best=11 Worst=20 Ave=5.34 +cca_thresh=-90dBm 0 1 0 2 2 0 1 1 0 1 6 12 24 10 2 1 Best=11 Worst=23 Ave=3.64 +cca_thresh=-88dBm 0 0 0 2 0 1 0 2 0 2 2 9 10 0 0 1 Best=11 Worst=23 Ave=1.54 + + +Electrum Kista Stockolm (KTH/SICS etc) + +cca_thresh=-62dBm 2 17 26 2 2 1 14 18 17 4 9 6 5 31 47 2 Best=16 Worst=25 Ave=12.07 +cca_thresh=-60dBm 7 8 13 2 2 1 6 6 7 1 11 32 16 11 1 2 Best=16 Worst=22 Ave=7.54 +cca_thresh=-90dBm 1 9 13 3 2 1 31 32 10 2 2 12 7 10 1 2 Best=11 Worst=18 Ave=8.17 +cca_thresh=-88dBm 4 8 10 2 2 1 5 12 6 3 5 8 2 9 1 2 Best=16 Worst=18 Ave=4.45 +cca_thresh=-86dBm 11 9 10 2 2 1 5 16 21 2 5 5 2 3 1 4 Best=25 Worst=19 Ave=5.88 +cca_thresh=-84dBm 4 9 7 5 5 1 6 46 16 3 16 2 13 5 1 2 Best=25 Worst=18 Ave=8.38 +cca_thresh=-82dBm 15 9 14 2 2 1 7 22 14 1 15 2 10 10 1 19 Best=25 Worst=18 Ave=8.68 +cca_thresh=-80dBm 1 8 16 3 2 1 14 23 6 1 10 22 5 7 3 4 Best=11 Worst=18 Ave=7.38 +cca_thresh=-78dBm 16 9 25 3 3 1 9 8 12 2 7 2 3 2 1 2 Best=16 Worst=13 Ave=6.13 +cca_thresh=-76dBm 12 9 23 4 4 0 36 9 10 2 32 14 7 4 1 3 Best=16 Worst=17 Ave=10.13 +cca_thresh=-74dBm 8 24 9 8 5 0 16 6 10 2 3 31 27 18 1 3 Best=16 Worst=22 Ave=10.32 +cca_thresh=-72dBm 4 7 18 4 2 0 6 11 7 1 3 6 3 9 1 2 Best=16 Worst=13 Ave=4.80 From 404000505642942513b29cd39298b36d875bde5c Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Mon, 8 May 2017 14:25:59 +0200 Subject: [PATCH 114/129] Retrigger regression test modified: examples/rf_environment/README.md --- examples/rf_environment/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/rf_environment/README.md b/examples/rf_environment/README.md index 9bdf1a907..152a6acf6 100644 --- a/examples/rf_environment/README.md +++ b/examples/rf_environment/README.md @@ -48,7 +48,6 @@ cca_thresh=-60dBm 0 1 2 0 1 0 1 1 15 33 4 5 26 2 0 cca_thresh=-90dBm 0 1 0 2 2 0 1 1 0 1 6 12 24 10 2 1 Best=11 Worst=23 Ave=3.64 cca_thresh=-88dBm 0 0 0 2 0 1 0 2 0 2 2 9 10 0 0 1 Best=11 Worst=23 Ave=1.54 - Electrum Kista Stockolm (KTH/SICS etc) cca_thresh=-62dBm 2 17 26 2 2 1 14 18 17 4 9 6 5 31 47 2 Best=16 Worst=25 Ave=12.07 From 9ed56b148572d11199540ea493c8337d6990e9eb Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Tue, 9 May 2017 08:48:11 +0100 Subject: [PATCH 115/129] Fix Doxygen PPA location --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7f92c751c..803bbcff2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ before_script: ## Install doxygen - if [ ${BUILD_CATEGORY:-0} = doxygen ] ; then - sudo add-apt-repository ppa:libreoffice/libreoffice-4-4 -y && sudo apt-get -qq update && + sudo add-apt-repository ppa:libreoffice/ppa -y && sudo apt-get -qq update && sudo apt-get --no-install-suggests --no-install-recommends -qq install doxygen && doxygen --version ; fi From 71167f0ba6e6629c3c23c84a2d18102374d8e402 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Tue, 9 May 2017 15:26:14 +0200 Subject: [PATCH 116/129] Retrigger PR after Doxigen fix --- examples/rf_environment/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/rf_environment/README.md b/examples/rf_environment/README.md index 152a6acf6..0485d33d1 100644 --- a/examples/rf_environment/README.md +++ b/examples/rf_environment/README.md @@ -14,7 +14,6 @@ Probability for not passing a CCA check in percent per channel. 3-minute samples. Of course this just snapshots to illustrate functionality - Chan: 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 --------------------------------------------------------------------- cca_thresh=-82dBm 0 0 7 0 1 2 2 0 0 0 0 6 30 5 0 1 Best=11 Worst=23 Ave=3.09 From ef9b00103e501a841ab2812d7ce7d59e54522901 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Thu, 11 May 2017 14:20:12 +0200 Subject: [PATCH 117/129] Optimizing channel table size for CCA in rf_environment example modified: examples/rf_environment/rf_environment.c --- examples/rf_environment/rf_environment.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/rf_environment/rf_environment.c b/examples/rf_environment/rf_environment.c index 44f151a1a..2d587fe0b 100644 --- a/examples/rf_environment/rf_environment.c +++ b/examples/rf_environment/rf_environment.c @@ -69,7 +69,7 @@ AUTOSTART_PROCESSES(&rf_scan_process); */ static struct etimer et; -static int cca[27], cca_thresh, chan, i, j, k; +static int cca[16], cca_thresh, chan, i, j, k; static uint16_t best, best_sum; static uint16_t worst, worst_sum; static double ave; @@ -155,8 +155,8 @@ PROCESS_THREAD(rf_scan_process, ev, data) for(k = -90; k <= -60; k += 2) { set_cca_thresh(k); - for(j = 11; j <= 26; j++) { - set_chan(j); + for(j = 0; j < 16; j++) { + set_chan(j+11); cca[j] = 0; #ifdef CONTIKI_TARGET_AVR_RSS2 watchdog_periodic(); @@ -175,7 +175,7 @@ PROCESS_THREAD(rf_scan_process, ev, data) best_sum = 0; ave = 0; - for(j = 11; j <= 26; j++) { + for(j = 0; j < 16; j++) { ave += cca[j]; printf(" %3d", 100 - (100 * cca[j]) / SAMPLES); if(cca[j] > best_sum) { @@ -187,7 +187,7 @@ PROCESS_THREAD(rf_scan_process, ev, data) worst = j; } } - printf(" Best=%d Worst=%d Ave=%-5.2f\n", best, worst, 100 - (100 * (ave / 16) / SAMPLES)); + printf(" Best=%d Worst=%d Ave=%-5.2f\n", (best+11) , (worst+11), 100 - (100 * (ave / 16) / SAMPLES)); } etimer_set(&et, CLOCK_SECOND / 2); } From 18cfaf7fa223bd36c039b58d1a5ee10f6aabf16a Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Fri, 19 May 2017 09:28:46 +0200 Subject: [PATCH 118/129] Reformat of table text for README modified: examples/rf_environment/README.md --- examples/rf_environment/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/rf_environment/README.md b/examples/rf_environment/README.md index 0485d33d1..7d33c7178 100644 --- a/examples/rf_environment/README.md +++ b/examples/rf_environment/README.md @@ -14,6 +14,7 @@ Probability for not passing a CCA check in percent per channel. 3-minute samples. Of course this just snapshots to illustrate functionality +
              Chan:  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26
              ---------------------------------------------------------------------
 cca_thresh=-82dBm   0   0   7   0   1   2   2   0   0   0   0   6  30   5   0   1 Best=11 Worst=23 Ave=3.09 
@@ -61,3 +62,5 @@ cca_thresh=-78dBm  16   9  25   3   3   1   9   8  12   2   7   2   3   2   1
 cca_thresh=-76dBm  12   9  23   4   4   0  36   9  10   2  32  14   7   4   1   3 Best=16 Worst=17 Ave=10.13
 cca_thresh=-74dBm   8  24   9   8   5   0  16   6  10   2   3  31  27  18   1   3 Best=16 Worst=22 Ave=10.32
 cca_thresh=-72dBm   4   7  18   4   2   0   6  11   7   1   3   6   3   9   1   2 Best=16 Worst=13 Ave=4.80 
+
+
\ No newline at end of file From b4ef18b2fa7861c2286628457f51e74bfd2d440f Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Tue, 23 May 2017 21:07:59 +0200 Subject: [PATCH 119/129] Keep cca scan function separated modified: examples/rf_environment/rf_environment.c --- examples/rf_environment/rf_environment.c | 34 +++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/examples/rf_environment/rf_environment.c b/examples/rf_environment/rf_environment.c index 2d587fe0b..fc7be6f4e 100644 --- a/examples/rf_environment/rf_environment.c +++ b/examples/rf_environment/rf_environment.c @@ -132,6 +132,25 @@ set_cca_thresh(radio_value_t thresh) } return 0; } + +void +do_all_chan_cca(int *cca, int try) +{ + int j; + for(j = 0; j < 16; j++) { + set_chan(j+11); + cca[j] = 0; +#ifdef CONTIKI_TARGET_AVR_RSS2 + watchdog_periodic(); +#endif + NETSTACK_RADIO.on(); + for(i = 0; i < try; i++) { + cca[j] += NETSTACK_RADIO.channel_clear(); + } + NETSTACK_RADIO.off(); + } +} + PROCESS_THREAD(rf_scan_process, ev, data) { PROCESS_BEGIN(); @@ -155,18 +174,9 @@ PROCESS_THREAD(rf_scan_process, ev, data) for(k = -90; k <= -60; k += 2) { set_cca_thresh(k); - for(j = 0; j < 16; j++) { - set_chan(j+11); - cca[j] = 0; -#ifdef CONTIKI_TARGET_AVR_RSS2 - watchdog_periodic(); -#endif - NETSTACK_RADIO.on(); - for(i = 0; i < SAMPLES; i++) { - cca[j] += NETSTACK_RADIO.channel_clear(); - } - NETSTACK_RADIO.off(); - } + + do_all_chan_cca(cca, SAMPLES); + printf("cca_thresh=%-3ddBm", get_cca_thresh()); worst = 0; From bb90d50ba19a76cf0fc04c83b1fa358a6b9c284f Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Thu, 1 Jun 2017 17:30:30 +0200 Subject: [PATCH 120/129] RADIO_PARAM_POWER_MODE for Atmel radio modified: cpu/avr/radio/rf230bb/rf230bb.c modified: cpu/avr/radio/rf230bb/rf230bb.h --- cpu/avr/radio/rf230bb/rf230bb.c | 9 ++------- cpu/avr/radio/rf230bb/rf230bb.h | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index 7d81e237b..6506cb086 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -396,13 +396,10 @@ get_value(radio_param_t param, radio_value_t *value) switch(param) { case RADIO_PARAM_POWER_MODE: - /* *value = (REG(RFCORE_XREG_RXENABLE) && RFCORE_XREG_RXENABLE_RXENMASK) == 0 )? - RADIO_POWER_MODE_OFF : RADIO_POWER_MODE_ON; */ + *value = rf230_is_sleeping() ? RADIO_POWER_MODE_OFF : RADIO_POWER_MODE_ON; return RADIO_RESULT_OK; - case RADIO_PARAM_TX_MODE: return RADIO_RESULT_OK; - case RADIO_PARAM_CHANNEL: *value = (radio_value_t)rf230_get_channel(); return RADIO_RESULT_OK; @@ -613,8 +610,7 @@ radio_get_trx_state(void) * states. * \retval false The radio transceiver is not sleeping. */ -#if 0 -static bool radio_is_sleeping(void) +static bool rf230_is_sleeping(void) { bool sleeping = false; @@ -626,7 +622,6 @@ static bool radio_is_sleeping(void) return sleeping; } -#endif /*----------------------------------------------------------------------------*/ /** \brief This function will reset the state machine (to TRX_OFF) from any of * its states, except for the SLEEP state. diff --git a/cpu/avr/radio/rf230bb/rf230bb.h b/cpu/avr/radio/rf230bb/rf230bb.h index 15f5b6438..42b8265fc 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.h +++ b/cpu/avr/radio/rf230bb/rf230bb.h @@ -223,7 +223,7 @@ uint8_t rf230_get_rpc(void); void rf230_set_promiscuous_mode(bool isPromiscuous); bool rf230_is_ready_to_send(); - +static bool rf230_is_sleeping(void); extern uint8_t rf230_last_correlation,rf230_last_rssi,rf230_smallest_rssi; uint8_t rf230_get_raw_rssi(void); From bb5d5546cec0bff774edd46cf3337ac9a6ca231a Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Fri, 2 Jun 2017 08:42:43 +0200 Subject: [PATCH 121/129] Atmel radio bug fix when setting tx-power. Spotted by Voravit Tanyingyong --- cpu/avr/radio/rf230bb/rf230bb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index 6506cb086..0f11bd627 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -494,7 +494,8 @@ set_value(radio_param_t param, radio_value_t value) return RADIO_RESULT_OK; case RADIO_PARAM_TXPOWER: - if(value < TX_PWR_MIN || value > TX_PWR_MAX) { + /* MIN = 15, MAX = 0 */ + if(value > TX_PWR_MIN || value < TX_PWR_MAX) { return RADIO_RESULT_INVALID_VALUE; } rf230_set_txpower(value); From 6b78ee9a4e995fa3b7913145d47e0b61d74c482a Mon Sep 17 00:00:00 2001 From: alexstanoev Date: Sun, 23 Apr 2017 17:06:32 +0100 Subject: [PATCH 122/129] MQTT: Validate broker IP and escape quotes when displaying This commit implements address validation for the broker address in the MQTT configuration page. Additionally, the Type ID, Org ID, Auth Token, Command Type and Event Type ID fields have quotes escaped (" -> ") to prevent XSS issues when displaying user-sourced input. --- .../cc26xx/cc26xx-web-demo/httpd-simple.c | 40 +++++++++++++++++-- examples/cc26xx/cc26xx-web-demo/mqtt-client.c | 12 +++++- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/examples/cc26xx/cc26xx-web-demo/httpd-simple.c b/examples/cc26xx/cc26xx-web-demo/httpd-simple.c index e23e78efe..168294088 100644 --- a/examples/cc26xx/cc26xx-web-demo/httpd-simple.c +++ b/examples/cc26xx/cc26xx-web-demo/httpd-simple.c @@ -137,6 +137,10 @@ PROCESS(httpd_simple_process, "CC26XX Web Server"); #define REQUEST_TYPE_GET 1 #define REQUEST_TYPE_POST 2 /*---------------------------------------------------------------------------*/ +/* Temporary buffer for holding escaped HTML used by html_escape_quotes */ +#define HTML_ESCAPED_BUFFER_SIZE 128 +static char html_escaped_buf[HTML_ESCAPED_BUFFER_SIZE]; +/*---------------------------------------------------------------------------*/ static const char *NOT_FOUND = "" "
" "

404 - file not found

" @@ -305,6 +309,30 @@ url_unescape(const char *src, size_t srclen, char *dst, size_t dstlen) return i == srclen; } /*---------------------------------------------------------------------------*/ +static char* +html_escape_quotes(const char *src) +{ + memset(html_escaped_buf, 0, HTML_ESCAPED_BUFFER_SIZE); + size_t dstpos = 0; + for(size_t i = 0; i < HTML_ESCAPED_BUFFER_SIZE; i++) { + if(src[i] == '\0') { + break; + } else if(src[i] == '"') { + if(dstpos + 6 > HTML_ESCAPED_BUFFER_SIZE) { + break; + } + + strcpy(&html_escaped_buf[dstpos], """); + dstpos += 6; + } else { + html_escaped_buf[dstpos++] = src[i]; + } + } + + html_escaped_buf[HTML_ESCAPED_BUFFER_SIZE - 1] = '\0'; + return html_escaped_buf; +} +/*---------------------------------------------------------------------------*/ void httpd_simple_register_post_handler(httpd_simple_post_handler_t *h) { @@ -675,7 +703,8 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s)) config_div_right)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "value=\"%s\" ", - cc26xx_web_demo_config.mqtt_config.type_id)); + html_escape_quotes( + cc26xx_web_demo_config.mqtt_config.type_id))); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "name=\"type_id\">%s", config_div_close)); @@ -687,7 +716,8 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s)) config_div_right)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "value=\"%s\" ", - cc26xx_web_demo_config.mqtt_config.org_id)); + html_escape_quotes( + cc26xx_web_demo_config.mqtt_config.org_id))); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "name=\"org_id\">%s", config_div_close)); @@ -711,7 +741,8 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s)) config_div_right)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "value=\"%s\" ", - cc26xx_web_demo_config.mqtt_config.cmd_type)); + html_escape_quotes( + cc26xx_web_demo_config.mqtt_config.cmd_type))); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "name=\"cmd_type\">%s", config_div_close)); @@ -724,7 +755,8 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s)) config_div_right)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "value=\"%s\" ", - cc26xx_web_demo_config.mqtt_config.event_type_id)); + html_escape_quotes( + cc26xx_web_demo_config.mqtt_config.event_type_id))); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "name=\"event_type_id\">%s", config_div_close)); diff --git a/examples/cc26xx/cc26xx-web-demo/mqtt-client.c b/examples/cc26xx/cc26xx-web-demo/mqtt-client.c index e45378264..c54b856fb 100644 --- a/examples/cc26xx/cc26xx-web-demo/mqtt-client.c +++ b/examples/cc26xx/cc26xx-web-demo/mqtt-client.c @@ -64,6 +64,9 @@ */ static const char *broker_ip = "0064:ff9b:0000:0000:0000:0000:b8ac:7cbd"; /*---------------------------------------------------------------------------*/ +#define ADDRESS_CONVERSION_OK 1 +#define ADDRESS_CONVERSION_ERROR 0 +/*---------------------------------------------------------------------------*/ /* * A timeout used when waiting for something to happen (e.g. to connect or to * disconnect) @@ -356,7 +359,14 @@ ip_addr_post_handler(char *key, int key_len, char *val, int val_len) return HTTPD_SIMPLE_POST_HANDLER_UNKNOWN; } - if(val_len > MQTT_CLIENT_CONFIG_IP_ADDR_STR_LEN) { + /* + * uiplib_ip6addrconv will immediately start writing into the supplied buffer + * even if it subsequently fails. Thus, pass an intermediate buffer + */ + uip_ip6addr_t tmp_addr; + + if(val_len > MQTT_CLIENT_CONFIG_IP_ADDR_STR_LEN + || uiplib_ip6addrconv(val, &tmp_addr) != ADDRESS_CONVERSION_OK) { /* Ours but bad value */ rv = HTTPD_SIMPLE_POST_HANDLER_ERROR; } else { From c558e1a55903bb27e478a2f178510741ee76b727 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Fri, 2 Jun 2017 23:02:54 +0100 Subject: [PATCH 123/129] Revert "Validate MQTT broker IP and escape quotes when displaying" --- .../cc26xx/cc26xx-web-demo/httpd-simple.c | 40 ++----------------- examples/cc26xx/cc26xx-web-demo/mqtt-client.c | 12 +----- 2 files changed, 5 insertions(+), 47 deletions(-) diff --git a/examples/cc26xx/cc26xx-web-demo/httpd-simple.c b/examples/cc26xx/cc26xx-web-demo/httpd-simple.c index 168294088..e23e78efe 100644 --- a/examples/cc26xx/cc26xx-web-demo/httpd-simple.c +++ b/examples/cc26xx/cc26xx-web-demo/httpd-simple.c @@ -137,10 +137,6 @@ PROCESS(httpd_simple_process, "CC26XX Web Server"); #define REQUEST_TYPE_GET 1 #define REQUEST_TYPE_POST 2 /*---------------------------------------------------------------------------*/ -/* Temporary buffer for holding escaped HTML used by html_escape_quotes */ -#define HTML_ESCAPED_BUFFER_SIZE 128 -static char html_escaped_buf[HTML_ESCAPED_BUFFER_SIZE]; -/*---------------------------------------------------------------------------*/ static const char *NOT_FOUND = "" "
" "

404 - file not found

" @@ -309,30 +305,6 @@ url_unescape(const char *src, size_t srclen, char *dst, size_t dstlen) return i == srclen; } /*---------------------------------------------------------------------------*/ -static char* -html_escape_quotes(const char *src) -{ - memset(html_escaped_buf, 0, HTML_ESCAPED_BUFFER_SIZE); - size_t dstpos = 0; - for(size_t i = 0; i < HTML_ESCAPED_BUFFER_SIZE; i++) { - if(src[i] == '\0') { - break; - } else if(src[i] == '"') { - if(dstpos + 6 > HTML_ESCAPED_BUFFER_SIZE) { - break; - } - - strcpy(&html_escaped_buf[dstpos], """); - dstpos += 6; - } else { - html_escaped_buf[dstpos++] = src[i]; - } - } - - html_escaped_buf[HTML_ESCAPED_BUFFER_SIZE - 1] = '\0'; - return html_escaped_buf; -} -/*---------------------------------------------------------------------------*/ void httpd_simple_register_post_handler(httpd_simple_post_handler_t *h) { @@ -703,8 +675,7 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s)) config_div_right)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "value=\"%s\" ", - html_escape_quotes( - cc26xx_web_demo_config.mqtt_config.type_id))); + cc26xx_web_demo_config.mqtt_config.type_id)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "name=\"type_id\">%s", config_div_close)); @@ -716,8 +687,7 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s)) config_div_right)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "value=\"%s\" ", - html_escape_quotes( - cc26xx_web_demo_config.mqtt_config.org_id))); + cc26xx_web_demo_config.mqtt_config.org_id)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "name=\"org_id\">%s", config_div_close)); @@ -741,8 +711,7 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s)) config_div_right)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "value=\"%s\" ", - html_escape_quotes( - cc26xx_web_demo_config.mqtt_config.cmd_type))); + cc26xx_web_demo_config.mqtt_config.cmd_type)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "name=\"cmd_type\">%s", config_div_close)); @@ -755,8 +724,7 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s)) config_div_right)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "value=\"%s\" ", - html_escape_quotes( - cc26xx_web_demo_config.mqtt_config.event_type_id))); + cc26xx_web_demo_config.mqtt_config.event_type_id)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "name=\"event_type_id\">%s", config_div_close)); diff --git a/examples/cc26xx/cc26xx-web-demo/mqtt-client.c b/examples/cc26xx/cc26xx-web-demo/mqtt-client.c index c54b856fb..e45378264 100644 --- a/examples/cc26xx/cc26xx-web-demo/mqtt-client.c +++ b/examples/cc26xx/cc26xx-web-demo/mqtt-client.c @@ -64,9 +64,6 @@ */ static const char *broker_ip = "0064:ff9b:0000:0000:0000:0000:b8ac:7cbd"; /*---------------------------------------------------------------------------*/ -#define ADDRESS_CONVERSION_OK 1 -#define ADDRESS_CONVERSION_ERROR 0 -/*---------------------------------------------------------------------------*/ /* * A timeout used when waiting for something to happen (e.g. to connect or to * disconnect) @@ -359,14 +356,7 @@ ip_addr_post_handler(char *key, int key_len, char *val, int val_len) return HTTPD_SIMPLE_POST_HANDLER_UNKNOWN; } - /* - * uiplib_ip6addrconv will immediately start writing into the supplied buffer - * even if it subsequently fails. Thus, pass an intermediate buffer - */ - uip_ip6addr_t tmp_addr; - - if(val_len > MQTT_CLIENT_CONFIG_IP_ADDR_STR_LEN - || uiplib_ip6addrconv(val, &tmp_addr) != ADDRESS_CONVERSION_OK) { + if(val_len > MQTT_CLIENT_CONFIG_IP_ADDR_STR_LEN) { /* Ours but bad value */ rv = HTTPD_SIMPLE_POST_HANDLER_ERROR; } else { From 3a53d96526b193c541cd5f5c1a6213405cc9791f Mon Sep 17 00:00:00 2001 From: alexstanoev Date: Sat, 6 May 2017 00:07:16 +0100 Subject: [PATCH 124/129] Validate MQTT broker IP and escape quotes when displaying This commit implements address validation for the broker address in the MQTT configuration page of the CC26XX web demo example. Additionally, the Type ID, Org ID, Auth Token, Command Type and Event Type ID fields have quotes escaped (" -> ") to prevent XSS/broken page issues when displaying user-sourced input in HTML input fields. --- .../cc26xx/cc26xx-web-demo/httpd-simple.c | 45 +++++++++++++++++-- examples/cc26xx/cc26xx-web-demo/mqtt-client.c | 12 ++++- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/examples/cc26xx/cc26xx-web-demo/httpd-simple.c b/examples/cc26xx/cc26xx-web-demo/httpd-simple.c index e23e78efe..17f62f0d7 100644 --- a/examples/cc26xx/cc26xx-web-demo/httpd-simple.c +++ b/examples/cc26xx/cc26xx-web-demo/httpd-simple.c @@ -137,6 +137,10 @@ PROCESS(httpd_simple_process, "CC26XX Web Server"); #define REQUEST_TYPE_GET 1 #define REQUEST_TYPE_POST 2 /*---------------------------------------------------------------------------*/ +/* Temporary buffer for holding escaped HTML used by html_escape_quotes */ +#define HTML_ESCAPED_BUFFER_SIZE 128 +static char html_escaped_buf[HTML_ESCAPED_BUFFER_SIZE]; +/*---------------------------------------------------------------------------*/ static const char *NOT_FOUND = "" "
" "

404 - file not found

" @@ -305,6 +309,31 @@ url_unescape(const char *src, size_t srclen, char *dst, size_t dstlen) return i == srclen; } /*---------------------------------------------------------------------------*/ +static char* +html_escape_quotes(const char *src, size_t srclen) +{ + size_t srcpos, dstpos; + memset(html_escaped_buf, 0, HTML_ESCAPED_BUFFER_SIZE); + for(srcpos = dstpos = 0; + srcpos < srclen && dstpos < HTML_ESCAPED_BUFFER_SIZE - 1; srcpos++) { + if(src[srcpos] == '\0') { + break; + } else if(src[srcpos] == '"') { + if(dstpos + 7 > HTML_ESCAPED_BUFFER_SIZE) { + break; + } + + strcpy(&html_escaped_buf[dstpos], """); + dstpos += 6; + } else { + html_escaped_buf[dstpos++] = src[srcpos]; + } + } + + html_escaped_buf[HTML_ESCAPED_BUFFER_SIZE - 1] = '\0'; + return html_escaped_buf; +} +/*---------------------------------------------------------------------------*/ void httpd_simple_register_post_handler(httpd_simple_post_handler_t *h) { @@ -675,7 +704,9 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s)) config_div_right)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "value=\"%s\" ", - cc26xx_web_demo_config.mqtt_config.type_id)); + html_escape_quotes( + cc26xx_web_demo_config.mqtt_config.type_id, + MQTT_CLIENT_CONFIG_TYPE_ID_LEN))); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "name=\"type_id\">%s", config_div_close)); @@ -687,7 +718,9 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s)) config_div_right)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "value=\"%s\" ", - cc26xx_web_demo_config.mqtt_config.org_id)); + html_escape_quotes( + cc26xx_web_demo_config.mqtt_config.org_id, + MQTT_CLIENT_CONFIG_ORG_ID_LEN))); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "name=\"org_id\">%s", config_div_close)); @@ -711,7 +744,9 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s)) config_div_right)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "value=\"%s\" ", - cc26xx_web_demo_config.mqtt_config.cmd_type)); + html_escape_quotes( + cc26xx_web_demo_config.mqtt_config.cmd_type, + MQTT_CLIENT_CONFIG_CMD_TYPE_LEN))); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "name=\"cmd_type\">%s", config_div_close)); @@ -724,7 +759,9 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s)) config_div_right)); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "value=\"%s\" ", - cc26xx_web_demo_config.mqtt_config.event_type_id)); + html_escape_quotes( + cc26xx_web_demo_config.mqtt_config.event_type_id, + MQTT_CLIENT_CONFIG_EVENT_TYPE_ID_LEN))); PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "name=\"event_type_id\">%s", config_div_close)); diff --git a/examples/cc26xx/cc26xx-web-demo/mqtt-client.c b/examples/cc26xx/cc26xx-web-demo/mqtt-client.c index e45378264..d3f3c0207 100644 --- a/examples/cc26xx/cc26xx-web-demo/mqtt-client.c +++ b/examples/cc26xx/cc26xx-web-demo/mqtt-client.c @@ -64,6 +64,9 @@ */ static const char *broker_ip = "0064:ff9b:0000:0000:0000:0000:b8ac:7cbd"; /*---------------------------------------------------------------------------*/ +#define ADDRESS_CONVERSION_OK 1 +#define ADDRESS_CONVERSION_ERROR 0 +/*---------------------------------------------------------------------------*/ /* * A timeout used when waiting for something to happen (e.g. to connect or to * disconnect) @@ -350,13 +353,20 @@ ip_addr_post_handler(char *key, int key_len, char *val, int val_len) { int rv = HTTPD_SIMPLE_POST_HANDLER_UNKNOWN; + /* + * uiplib_ip6addrconv will immediately start writing into the supplied buffer + * even if it subsequently fails. Thus, pass an intermediate buffer + */ + uip_ip6addr_t tmp_addr; + if(key_len != strlen("broker_ip") || strncasecmp(key, "broker_ip", strlen("broker_ip")) != 0) { /* Not ours */ return HTTPD_SIMPLE_POST_HANDLER_UNKNOWN; } - if(val_len > MQTT_CLIENT_CONFIG_IP_ADDR_STR_LEN) { + if(val_len > MQTT_CLIENT_CONFIG_IP_ADDR_STR_LEN + || uiplib_ip6addrconv(val, &tmp_addr) != ADDRESS_CONVERSION_OK) { /* Ours but bad value */ rv = HTTPD_SIMPLE_POST_HANDLER_ERROR; } else { From 576ca6457fa758eec8e8c6f6be9c6c520d9d3d39 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Thu, 1 Jun 2017 17:33:34 +0200 Subject: [PATCH 125/129] Added boundary checks when parsing CoAP packets. Thanks to Stephan Zeisberg for reporting this issue. --- apps/er-coap/er-coap.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/er-coap/er-coap.c b/apps/er-coap/er-coap.c index 3c71ff6f9..435a22ae4 100644 --- a/apps/er-coap/er-coap.c +++ b/apps/er-coap/er-coap.c @@ -529,8 +529,21 @@ coap_parse_message(void *packet, uint8_t *data, uint16_t data_len) ++current_option; } + if(current_option + option_length > data + data_len) { + /* Malformed CoAP - out of bounds */ + PRINTF("BAD REQUEST: options outside data packet: %u > %u\n", + (unsigned)(current_option + option_length - data), data_len); + return BAD_REQUEST_4_00; + } + option_number += option_delta; + if(option_number > COAP_OPTION_SIZE1) { + /* Malformed CoAP - out of bounds */ + PRINTF("BAD REQUEST: option number too large: %u\n", option_number); + return BAD_REQUEST_4_00; + } + PRINTF("OPTION %u (delta %u, len %zu): ", option_number, option_delta, option_length); From e97f3bca269d92375c617ccd96574f5f28523558 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Fri, 16 Jun 2017 10:48:52 +0200 Subject: [PATCH 126/129] Fix misspelled copyright for AES128HW_test pointed out by Nicolas Tsiftes --- examples/avr-rss2/AES128HW_test/AES128HW_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/avr-rss2/AES128HW_test/AES128HW_test.c b/examples/avr-rss2/AES128HW_test/AES128HW_test.c index da7935838..00de029ee 100644 --- a/examples/avr-rss2/AES128HW_test/AES128HW_test.c +++ b/examples/avr-rss2/AES128HW_test/AES128HW_test.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Copyright Robert Olsson + * Copyright (c) 2017, Robert Olsson * All rights reserved. * * Redistribution and use in source and binary forms, with or without From 5c0094cbd66e17398ab4cda972b5fc89e1926656 Mon Sep 17 00:00:00 2001 From: Andreas Urke Date: Sat, 17 Jun 2017 23:32:04 +0200 Subject: [PATCH 127/129] Minor cleanup to RPL debug output --- core/net/rpl/rpl-dag-root.c | 13 ++++++------- core/net/rpl/rpl-dag.c | 8 ++++---- core/net/rpl/rpl-ext-header.c | 8 ++++---- core/net/rpl/rpl-icmp6.c | 10 +++++----- core/net/rpl/rpl-nbr-policy.c | 10 +++++----- core/net/rpl/rpl.c | 10 +++++----- 6 files changed, 29 insertions(+), 30 deletions(-) diff --git a/core/net/rpl/rpl-dag-root.c b/core/net/rpl/rpl-dag-root.c index 57a10ef80..af87f6b9a 100644 --- a/core/net/rpl/rpl-dag-root.c +++ b/core/net/rpl/rpl-dag-root.c @@ -99,13 +99,12 @@ create_dag_callback(void *ptr) rpl_dag_t *dag; dag = rpl_get_any_dag(); -#if DEBUG - printf("Found a network we did not create\n"); - printf("version %d grounded %d preference %d used %d joined %d rank %d\n", + + PRINTF("RPL: Found a network we did not create\n"); + PRINTF("RPL: version %d grounded %d preference %d used %d joined %d rank %d\n", dag->version, dag->grounded, dag->preference, dag->used, dag->joined, dag->rank); -#endif /* DEBUG */ /* We found a RPL network that we did not create so we just join it without becoming root. But if the network has an infinite @@ -223,14 +222,14 @@ rpl_dag_root_init_dag_immediately(void) uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); rpl_set_prefix(dag, &prefix, 64); - PRINTF("rpl_dag_root_init_dag: created a new RPL dag\n"); + PRINTF("RPL: rpl_dag_root_init_dag: created a new RPL dag\n"); return 0; } else { - PRINTF("rpl_dag_root_init_dag: failed to create a new RPL DAG\n"); + PRINTF("RPL: rpl_dag_root_init_dag: failed to create a new RPL DAG\n"); return -1; } } else { - PRINTF("rpl_dag_root_init_dag: failed to create a new RPL DAG, no preferred IP address found\n"); + PRINTF("RPL: rpl_dag_root_init_dag: failed to create a new RPL DAG, no preferred IP address found\n"); return -2; } } diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index b1694239c..329943950 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -525,10 +525,10 @@ rpl_set_prefix(rpl_dag_t *dag, uip_ipaddr_t *prefix, unsigned len) /* Autoconfigure an address if this node does not already have an address with this prefix. Otherwise, update the prefix */ if(last_len == 0) { - PRINTF("rpl_set_prefix - prefix NULL\n"); + PRINTF("RPL: rpl_set_prefix - prefix NULL\n"); check_prefix(NULL, &dag->prefix_info); } else { - PRINTF("rpl_set_prefix - prefix NON-NULL\n"); + PRINTF("RPL: rpl_set_prefix - prefix NON-NULL\n"); check_prefix(&last_prefix, &dag->prefix_info); } return 1; @@ -983,7 +983,7 @@ rpl_move_parent(rpl_dag_t *dag_src, rpl_dag_t *dag_dst, rpl_parent_t *parent) PRINTF("RPL: Removing default route "); PRINT6ADDR(rpl_get_parent_ipaddr(parent)); PRINTF("\n"); - PRINTF("rpl_move_parent\n"); + PRINTF("RPL: rpl_move_parent\n"); uip_ds6_defrt_rm(dag_src->instance->def_route); dag_src->instance->def_route = NULL; } @@ -1546,7 +1546,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio) /* The DIO comes from a valid DAG, we can refresh its lifetime */ dag->lifetime = (1UL << (instance->dio_intmin + instance->dio_intdoubl)) * RPL_DAG_LIFETIME / 1000; - PRINTF("Set dag "); + PRINTF("RPL: Set dag "); PRINT6ADDR(&dag->dag_id); PRINTF(" lifetime to %ld\n", dag->lifetime); diff --git a/core/net/rpl/rpl-ext-header.c b/core/net/rpl/rpl-ext-header.c index 1dd0850a2..83c13ea46 100644 --- a/core/net/rpl/rpl-ext-header.c +++ b/core/net/rpl/rpl-ext-header.c @@ -507,10 +507,10 @@ update_hbh_header(void) if((UIP_EXT_HDR_OPT_RPL_BUF->flags & RPL_HDR_OPT_DOWN)) { if(uip_ds6_route_lookup(&UIP_IP_BUF->destipaddr) == NULL) { UIP_EXT_HDR_OPT_RPL_BUF->flags |= RPL_HDR_OPT_FWD_ERR; - PRINTF("RPL forwarding error\n"); + PRINTF("RPL: RPL forwarding error\n"); /* We should send back the packet to the originating parent, but it is not feasible yet, so we send a No-Path DAO instead */ - PRINTF("RPL generate No-Path DAO\n"); + PRINTF("RPL: RPL generate No-Path DAO\n"); parent = rpl_get_parent((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER)); if(parent != NULL) { dao_output_target(parent, &UIP_IP_BUF->destipaddr, RPL_ZERO_LIFETIME); @@ -526,11 +526,11 @@ update_hbh_header(void) /* No route was found, so this packet will go towards the RPL root. If so, we should not set the down flag. */ UIP_EXT_HDR_OPT_RPL_BUF->flags &= ~RPL_HDR_OPT_DOWN; - PRINTF("RPL option going up\n"); + PRINTF("RPL: RPL option going up\n"); } else { /* A DAO route was found so we set the down flag. */ UIP_EXT_HDR_OPT_RPL_BUF->flags |= RPL_HDR_OPT_DOWN; - PRINTF("RPL option going down\n"); + PRINTF("RPL: RPL option going down\n"); } } } diff --git a/core/net/rpl/rpl-icmp6.c b/core/net/rpl/rpl-icmp6.c index 6aff7249c..b812ba4d8 100644 --- a/core/net/rpl/rpl-icmp6.c +++ b/core/net/rpl/rpl-icmp6.c @@ -1151,30 +1151,30 @@ dao_output_target_seq(rpl_parent_t *parent, uip_ipaddr_t *prefix, } if(parent == NULL) { - PRINTF("RPL dao_output_target error parent NULL\n"); + PRINTF("RPL: dao_output_target error parent NULL\n"); return; } parent_ipaddr = rpl_get_parent_ipaddr(parent); if(parent_ipaddr == NULL) { - PRINTF("RPL dao_output_target error parent IP address NULL\n"); + PRINTF("RPL: dao_output_target error parent IP address NULL\n"); return; } dag = parent->dag; if(dag == NULL) { - PRINTF("RPL dao_output_target error dag NULL\n"); + PRINTF("RPL: dao_output_target error dag NULL\n"); return; } instance = dag->instance; if(instance == NULL) { - PRINTF("RPL dao_output_target error instance NULL\n"); + PRINTF("RPL: dao_output_target error instance NULL\n"); return; } if(prefix == NULL) { - PRINTF("RPL dao_output_target error prefix NULL\n"); + PRINTF("RPL: dao_output_target error prefix NULL\n"); return; } #ifdef RPL_DEBUG_DAO_OUTPUT diff --git a/core/net/rpl/rpl-nbr-policy.c b/core/net/rpl/rpl-nbr-policy.c index d10de973e..4f506f8bc 100644 --- a/core/net/rpl/rpl-nbr-policy.c +++ b/core/net/rpl/rpl-nbr-policy.c @@ -177,7 +177,7 @@ find_removable_dis(uip_ipaddr_t *from) if(num_free > 0) { /* there are free entries (e.g. unsused by RPL and ND6) but since it is used by other modules we can not pick these entries for removal. */ - PRINTF("Num-free > 0 = %d - Other for RPL/ND6 unused NBR entry exists .", + PRINTF("NBR-POLICY: Num-free > 0 = %d - Other for RPL/ND6 unused NBR entry exists .", num_free); } if(num_children < MAX_CHILDREN) { @@ -195,20 +195,20 @@ find_removable_dio(uip_ipaddr_t *from, rpl_dio_t *dio) instance = rpl_get_instance(dio->instance_id); if(instance == NULL || instance->current_dag == NULL) { - PRINTF("Did not find instance id: %d\n", dio->instance_id); + PRINTF("NBR-POLICY: Did not find instance id: %d\n", dio->instance_id); return NULL; } /* Add the new neighbor only if it is better than the worst parent. */ if(dio->rank + instance->min_hoprankinc < worst_rank - instance->min_hoprankinc / 2) { /* Found *great* neighbor - add! */ - PRINTF("Found better neighbor %d < %d - add to cache...\n", + PRINTF("NBR-POLICY: Found better neighbor %d < %d - add to cache...\n", dio->rank, worst_rank); return worst_rank_nbr; } - PRINTF("Found worse neighbor with new %d and old %d - NOT add to cache.\n", + PRINTF("NBR-POLICY: Found worse neighbor with new %d and old %d - NOT add to cache.\n", dio->rank, worst_rank); return NULL; } @@ -229,7 +229,7 @@ find_removable_dao(uip_ipaddr_t *from, rpl_instance_t *instance) /* Check if this DAO sender is not yet neighbor and there is already too many children. */ if(num_children >= max) { - PRINTF("Can not add another child - already at max.\n"); + PRINTF("NBR-POLICY: Can not add another child - already at max.\n"); return NULL; } /* remove the worst ranked nbr */ diff --git a/core/net/rpl/rpl.c b/core/net/rpl/rpl.c index 15dcb6e5a..b7553d251 100644 --- a/core/net/rpl/rpl.c +++ b/core/net/rpl/rpl.c @@ -91,13 +91,13 @@ rpl_set_mode(enum rpl_mode m) PRINTF("RPL: switching to feather mode\n"); if(default_instance != NULL) { - PRINTF("rpl_set_mode: RPL sending DAO with zero lifetime\n"); + PRINTF("RPL: rpl_set_mode: RPL sending DAO with zero lifetime\n"); if(default_instance->current_dag != NULL) { dao_output(default_instance->current_dag->preferred_parent, RPL_ZERO_LIFETIME); } rpl_cancel_dao(default_instance); } else { - PRINTF("rpl_set_mode: no default instance\n"); + PRINTF("RPL: rpl_set_mode: no default instance\n"); } mode = m; @@ -143,7 +143,7 @@ rpl_purge_routes(void) uip_ipaddr_copy(&prefix, &r->ipaddr); uip_ds6_route_rm(r); r = uip_ds6_route_head(); - PRINTF("No more routes to "); + PRINTF("RPL: No more routes to "); PRINT6ADDR(&prefix); dag = default_instance->current_dag; /* Propagate this information with a No-Path DAO to preferred parent if we are not a RPL Root */ @@ -313,7 +313,7 @@ rpl_purge_dags(void) if(instance->dag_table[i].used) { if(instance->dag_table[i].lifetime == 0) { if(!instance->dag_table[i].joined) { - PRINTF("Removing dag "); + PRINTF("RPL: Removing dag "); PRINT6ADDR(&instance->dag_table[i].dag_id); PRINTF("\n"); rpl_free_dag(&instance->dag_table[i]); @@ -331,7 +331,7 @@ void rpl_init(void) { uip_ipaddr_t rplmaddr; - PRINTF("RPL started\n"); + PRINTF("RPL: RPL started\n"); default_instance = NULL; rpl_dag_init(); From a986ecf7c3e061c1a12d58a708189fbccda76b25 Mon Sep 17 00:00:00 2001 From: Andreas Urke Date: Thu, 22 Jun 2017 15:52:43 +0200 Subject: [PATCH 128/129] Remove minor duplicates in RPL printouts --- core/net/rpl/rpl-ext-header.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/net/rpl/rpl-ext-header.c b/core/net/rpl/rpl-ext-header.c index 83c13ea46..7ae62b8f2 100644 --- a/core/net/rpl/rpl-ext-header.c +++ b/core/net/rpl/rpl-ext-header.c @@ -507,10 +507,10 @@ update_hbh_header(void) if((UIP_EXT_HDR_OPT_RPL_BUF->flags & RPL_HDR_OPT_DOWN)) { if(uip_ds6_route_lookup(&UIP_IP_BUF->destipaddr) == NULL) { UIP_EXT_HDR_OPT_RPL_BUF->flags |= RPL_HDR_OPT_FWD_ERR; - PRINTF("RPL: RPL forwarding error\n"); + PRINTF("RPL: Forwarding error\n"); /* We should send back the packet to the originating parent, but it is not feasible yet, so we send a No-Path DAO instead */ - PRINTF("RPL: RPL generate No-Path DAO\n"); + PRINTF("RPL: Generate No-Path DAO\n"); parent = rpl_get_parent((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER)); if(parent != NULL) { dao_output_target(parent, &UIP_IP_BUF->destipaddr, RPL_ZERO_LIFETIME); @@ -526,11 +526,11 @@ update_hbh_header(void) /* No route was found, so this packet will go towards the RPL root. If so, we should not set the down flag. */ UIP_EXT_HDR_OPT_RPL_BUF->flags &= ~RPL_HDR_OPT_DOWN; - PRINTF("RPL: RPL option going up\n"); + PRINTF("RPL: Option going up\n"); } else { /* A DAO route was found so we set the down flag. */ UIP_EXT_HDR_OPT_RPL_BUF->flags |= RPL_HDR_OPT_DOWN; - PRINTF("RPL: RPL option going down\n"); + PRINTF("RPL: Option going down\n"); } } } From 770bbfc6f66f8966e2c1797704aa061df49817c8 Mon Sep 17 00:00:00 2001 From: Andreas Urke Date: Fri, 30 Jun 2017 02:50:24 +0200 Subject: [PATCH 129/129] Allow UART TX or RX to not be configured --- cpu/cc26xx-cc13xx/dev/cc26xx-uart.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/cpu/cc26xx-cc13xx/dev/cc26xx-uart.c b/cpu/cc26xx-cc13xx/dev/cc26xx-uart.c index 140a5d203..f31104686 100644 --- a/cpu/cc26xx-cc13xx/dev/cc26xx-uart.c +++ b/cpu/cc26xx-cc13xx/dev/cc26xx-uart.c @@ -65,10 +65,20 @@ static int (*input_handler)(unsigned char c); /*---------------------------------------------------------------------------*/ static bool -usable(void) +usable_rx(void) { if(BOARD_IOID_UART_RX == IOID_UNUSED || - BOARD_IOID_UART_TX == IOID_UNUSED || + CC26XX_UART_CONF_ENABLE == 0) { + return false; + } + + return true; +} +/*---------------------------------------------------------------------------*/ +static bool +usable_tx(void) +{ + if(BOARD_IOID_UART_TX == IOID_UNUSED || CC26XX_UART_CONF_ENABLE == 0) { return false; } @@ -271,7 +281,7 @@ cc26xx_uart_init() bool interrupts_disabled; /* Return early if disabled by user conf or if ports are misconfigured */ - if(usable() == false) { + if(!usable_rx() && !usable_tx()) { return; } @@ -299,7 +309,7 @@ void cc26xx_uart_write_byte(uint8_t c) { /* Return early if disabled by user conf or if ports are misconfigured */ - if(usable() == false) { + if(usable_tx() == false) { return; } @@ -316,7 +326,7 @@ cc26xx_uart_set_input(int (*input)(unsigned char c)) input_handler = input; /* Return early if disabled by user conf or if ports are misconfigured */ - if(usable() == false) { + if(usable_rx() == false) { return; } @@ -348,7 +358,7 @@ uint8_t cc26xx_uart_busy(void) { /* Return early if disabled by user conf or if ports are misconfigured */ - if(usable() == false) { + if(usable_tx() == false) { return UART_IDLE; }