Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature-wisun] Nanostack release v12.8.1 #14164

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,24 @@
#include <Timer.h>
#include "Timeout.h"
#include "SPI.h"
#include "platform/mbed_version.h"

#define TRACE_GROUP "AtRF"

#if (MBED_VERSION > MBED_ENCODE_VERSION(6, 0, 0))
/* Mbed OS 6.0 introduces support for chrono time management */
using namespace std::chrono_literals;
#define ATMEL_RF_TIME_65MS 65ms
#define ATMEL_RF_TIME_1US 1us
#define ATMEL_RF_ATTACH(timer_ref, signal_ref, timeout_ref) timer_ref.attach(signal_ref, timeout_ref)
#define ATMEL_RF_DRIVER_CHRONO_SUPPORTED
#else
#define ATMEL_RF_TIME_65MS 65000
#define ATMEL_RF_TIME_1US 1

#define ATMEL_RF_ATTACH(timer_ref, signal_ref, timeout_ref) timer_ref.attach_us(signal_ref, timeout_ref)
#endif

#define RF_MTU_15_4_2011 127
#define RF_MTU_15_4G_2012 2047

Expand Down Expand Up @@ -196,7 +211,11 @@ static Se2435Pins *se2435_pa_pins = NULL;

static uint32_t rf_get_timestamp(void)
{
#ifdef ATMEL_RF_DRIVER_CHRONO_SUPPORTED
return (uint32_t)rf->tx_timer.elapsed_time().count();
#else
return (uint32_t)rf->tx_timer.read_us();
#endif
}

static void rf_lock(void)
Expand Down Expand Up @@ -485,7 +504,7 @@ static void rf_init_registers(rf_modules_e module)
// Set low frequency offset bit
rf_write_bbc_register_field(BBC_OFDMC, module, LFO, 0);
// Configure using bandwidth option
rf_configure_by_ofdm_bandwidth_option(4, 300000, module);
rf_configure_by_ofdm_bandwidth_option(phy_current_config.ofdm_option, phy_current_config.datarate, module);
// Set Gain control settings
rf_write_rf_register_field(RF_AGCC, module, AVGS, AVGS_8_SAMPLES);
rf_write_rf_register_field(RF_AGCC, module, AGCI, 0);
Expand Down Expand Up @@ -564,17 +583,21 @@ static int8_t rf_start_csma_ca(uint8_t *data_ptr, uint16_t data_length, uint8_t
mac_tx_handle = tx_handle;

if (tx_time) {
#ifdef ATMEL_RF_DRIVER_CHRONO_SUPPORTED
std::chrono::microseconds backoff_time(tx_time - rf_get_timestamp());
#else
uint32_t backoff_time = tx_time - rf_get_timestamp();
#endif
// Max. time to TX can be 65ms, otherwise time has passed already -> send immediately
if (backoff_time <= 65000) {
rf->cca_timer.attach_us(rf_csma_ca_timer_signal, backoff_time);
if (backoff_time <= ATMEL_RF_TIME_65MS) {
ATMEL_RF_ATTACH(rf->cca_timer, rf_csma_ca_timer_signal, backoff_time);
TEST_CSMA_STARTED
rf_unlock();
return 0;
}
}
// Short timeout to start CCA immediately.
rf->cca_timer.attach_us(rf_csma_ca_timer_signal, 1);
ATMEL_RF_ATTACH(rf->cca_timer, rf_csma_ca_timer_signal, ATMEL_RF_TIME_1US);
TEST_CSMA_STARTED
rf_unlock();
return 0;
Expand Down Expand Up @@ -607,12 +630,16 @@ static void rf_handle_cca_ed_done(void)
if (cca_prepare_status == PHY_RESTART_CSMA) {
device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_OK, 0, 0);
if (tx_time) {
#ifdef ATMEL_RF_DRIVER_CHRONO_SUPPORTED
std::chrono::microseconds backoff_time(tx_time - rf_get_timestamp());
#else
uint32_t backoff_time = tx_time - rf_get_timestamp();
#endif
// Max. time to TX can be 65ms, otherwise time has passed already -> send immediately
if (backoff_time > 65000) {
backoff_time = 1;
if (backoff_time > ATMEL_RF_TIME_65MS) {
backoff_time = ATMEL_RF_TIME_1US;
}
rf->cca_timer.attach_us(rf_csma_ca_timer_signal, backoff_time);
ATMEL_RF_ATTACH(rf->cca_timer, rf_csma_ca_timer_signal, backoff_time);
TEST_CSMA_STARTED
}
return;
Expand Down Expand Up @@ -994,7 +1021,11 @@ static uint32_t rf_backup_timer_start(uint16_t bytes, uint32_t time_us)
time_us = (uint32_t)(8000000 / phy_current_config.datarate) * bytes + PACKET_PROCESSING_TIME;
}
// Using cal_timer as backup timer
#ifdef ATMEL_RF_DRIVER_CHRONO_SUPPORTED
rf->cal_timer.attach(rf_backup_timer_signal, std::chrono::microseconds(time_us));
#else
rf->cal_timer.attach_us(rf_backup_timer_signal, time_us);
#endif

return (rf_get_timestamp() + time_us);
}
Expand Down
7 changes: 6 additions & 1 deletion features/frameworks/mbed-trace/mbed-trace/mbed_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ extern "C" {
#define MBED_CONF_MBED_TRACE_ENABLE 0
#endif

#ifndef MBED_CONF_MBED_TRACE_FEA_IPV6
#ifndef MBED_CONF_NANOSTACK_LIBSERVICE_PRESENT
/* if libservice presence is not configured, enable it by default */
#define MBED_CONF_NANOSTACK_LIBSERVICE_PRESENT 1
#endif

#if !defined(MBED_CONF_MBED_TRACE_FEA_IPV6) && MBED_CONF_NANOSTACK_LIBSERVICE_PRESENT
#define MBED_CONF_MBED_TRACE_FEA_IPV6 1
#endif

Expand Down
2 changes: 1 addition & 1 deletion features/frameworks/mbed-trace/source/mbed_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#undef MBED_CONF_MBED_TRACE_ENABLE
#endif
#define MBED_CONF_MBED_TRACE_ENABLE 1
#ifndef MBED_CONF_MBED_TRACE_FEA_IPV6
#if !defined(MBED_CONF_MBED_TRACE_FEA_IPV6) && MBED_CONF_NANOSTACK_LIBSERVICE_PRESENT
#define MBED_CONF_MBED_TRACE_FEA_IPV6 1
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
/*
* Copyright (c) 2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "CppUTest/CommandLineTestRunner.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
/*
* Copyright (c) 2016 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "CppUTest/TestHarness.h"
#include "test_ns_nvm_helper.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
/*
* Copyright (c) 2016 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <inttypes.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
/*
* Copyright (c) 2016 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TEST_NS_NVM_HELPER_H
#define TEST_NS_NVM_HELPER_H
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ void event_core_free_push(arm_event_storage_t *free)
timer_sys_event_free(free);
break;
case ARM_LIB_EVENT_USER:
// *INDENT-OFF*
// No need set state to UNQUEUED - we forget about it.
// *INDENT-ON*
default:
break;
}
Expand Down
Loading