Skip to content

[mbed-os-5.15] Nanostack release v12.5.0 #13559

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

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 @@ -20,60 +20,107 @@
#include "at24mac.h"
#include "PinNames.h"

#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_I2C && defined(MBED_CONF_RTOS_PRESENT)
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_I2C && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)

#include "NanostackRfPhy.h"

// Uncomment to use testing gpios attached to TX/RX processes
// #define TEST_GPIOS_ENABLED

// Arduino pin defaults for convenience
#if !defined(ATMEL_SPI_MOSI)
#define ATMEL_SPI_MOSI D11
#if defined(MBED_CONF_ATMEL_RF_SPI_MOSI)
#define ATMEL_SPI_MOSI MBED_CONF_ATMEL_RF_SPI_MOSI
#else
#define ATMEL_SPI_MOSI D11
#endif
#if !defined(ATMEL_SPI_MISO)
#define ATMEL_SPI_MISO D12

#if defined(MBED_CONF_ATMEL_RF_SPI_MISO)
#define ATMEL_SPI_MISO MBED_CONF_ATMEL_RF_SPI_MISO
#else
#define ATMEL_SPI_MISO D12
#endif
#if !defined(ATMEL_SPI_SCLK)
#define ATMEL_SPI_SCLK D13

#if defined(MBED_CONF_ATMEL_RF_SPI_SCLK)
#define ATMEL_SPI_SCLK MBED_CONF_ATMEL_RF_SPI_SCLK
#else
#define ATMEL_SPI_SCLK D13
#endif
#if !defined(ATMEL_SPI_CS)
#define ATMEL_SPI_CS D10

#if defined(MBED_CONF_ATMEL_RF_SPI_CS)
#define ATMEL_SPI_CS MBED_CONF_ATMEL_RF_SPI_CS
#else
#define ATMEL_SPI_CS D10
#endif
#if !defined(ATMEL_SPI_RST)
#define ATMEL_SPI_RST D5

#if defined(MBED_CONF_ATMEL_RF_SPI_RST)
#define ATMEL_SPI_RST MBED_CONF_ATMEL_RF_SPI_RST
#else
#define ATMEL_SPI_RST D5
#endif
#if !defined(ATMEL_SPI_SLP)
#define ATMEL_SPI_SLP D7

#if defined(MBED_CONF_ATMEL_RF_SPI_SLP)
#define ATMEL_SPI_SLP MBED_CONF_ATMEL_RF_SPI_SLP
#else
#define ATMEL_SPI_SLP D7
#endif
#if !defined(ATMEL_SPI_IRQ)
#define ATMEL_SPI_IRQ D9

#if defined(MBED_CONF_ATMEL_RF_SPI_IRQ)
#define ATMEL_SPI_IRQ MBED_CONF_ATMEL_RF_SPI_IRQ
#else
#define ATMEL_SPI_IRQ D9
#endif
#if !defined(ATMEL_I2C_SDA)
#define ATMEL_I2C_SDA D14

#if defined(MBED_CONF_ATMEL_RF_I2C_SDA)
#define ATMEL_I2C_SDA MBED_CONF_ATMEL_RF_I2C_SDA
#else
#define ATMEL_I2C_SDA D14
#endif
#if !defined(ATMEL_I2C_SCL)
#define ATMEL_I2C_SCL D15

#if defined(MBED_CONF_ATMEL_RF_I2C_SCL)
#define ATMEL_I2C_SCL MBED_CONF_ATMEL_RF_I2C_SCL
#else
#define ATMEL_I2C_SCL D15
#endif
#if !defined(TEST_PIN_TX)
#define TEST_PIN_TX D6

#if defined(MBED_CONF_ATMEL_RF_TEST_PIN_TX)
#define TEST_PIN_TX MBED_CONF_ATMEL_RF_TEST_PIN_TX
#else
#define TEST_PIN_TX D6
#endif
#if !defined(TEST_PIN_RX)
#define TEST_PIN_RX D3

#if defined(MBED_CONF_ATMEL_RF_TEST_PIN_RX)
#define TEST_PIN_RX MBED_CONF_ATMEL_RF_TEST_PIN_RX
#else
#define TEST_PIN_RX D3
#endif
#if !defined(TEST_PIN_CSMA)
#define TEST_PIN_CSMA D4

#if defined(MBED_CONF_ATMEL_RF_TEST_PIN_CSMA)
#define TEST_PIN_CSMA MBED_CONF_ATMEL_RF_TEST_PIN_CSMA
#else
#define TEST_PIN_CSMA D4
#endif
#if !defined(TEST_PIN_SPARE_1)

#if defined(MBED_CONF_ATMEL_RF_TEST_PIN_SPARE_1)
#define TEST_PIN_SPARE_1 MBED_CONF_ATMEL_RF_TEST_PIN_SPARE_1
#else
#define TEST_PIN_SPARE_1 D2
#endif
#if !defined(TEST_PIN_SPARE_2)

#if defined(MBED_CONF_ATMEL_RF_TEST_PIN_SPARE_2)
#define TEST_PIN_SPARE_2 MBED_CONF_ATMEL_RF_TEST_PIN_SPARE_2
#else
#define TEST_PIN_SPARE_2 D8
#endif
#if !defined(SE2435L_CSD)
#define SE2435L_CSD D2

#if defined(MBED_CONF_ATMEL_RF_SE2435L_CSD)
#define SE2435L_CSD MBED_CONF_ATMEL_RF_SE2435L_CSD
#else
#define SE2435L_CSD D2
#endif
#if !defined(SE2435L_ANT_SEL)

#if defined(MBED_CONF_ATMEL_RF_SE2435L_ANT_SEL)
#define SE2435L_ANT_SEL MBED_CONF_ATMEL_RF_SE2435L_ANT_SEL
#else
#define SE2435L_ANT_SEL D8
#endif

Expand Down
64 changes: 64 additions & 0 deletions components/802.15.4_RF/atmel-rf-driver/mbed_lib.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,70 @@
{
"name": "atmel-rf",
"config": {
"SPI_MOSI": {
"help": "SPI_MOSI pin configured for SPI connection.",
"value": null
},
"SPI_MISO": {
"help": "SPI_MISO pin configured for SPI connection.",
"value": null
},
"SPI_SCLK": {
"help": "SPI_SCLK pin configured for SPI connection.",
"value": null
},
"SPI_CS": {
"help": "SPI_CS pin configured for SPI connection.",
"value": null
},
"SPI_RST": {
"help": "SPI_RST pin configured for SPI connection.",
"value": null
},
"SPI_SLP": {
"help": "SPI_SLP pin configured for SPI connection.",
"value": null
},
"SPI_IRQ": {
"help": "SPI_IRQ pin configured for SPI connection.",
"value": null
},
"I2C_SDA": {
"help": "I2C_SDA pin configured for I2C connection.",
"value": null
},
"I2C_SCL": {
"help": "I2C_SCL pin configured for I2C connection.",
"value": null
},
"TEST_PIN_TX": {
"help": "TEST_PIN_TX pin configured for TX.",
"value": null
},
"TEST_PIN_RX": {
"help": "TEST_PIN_RX pin configured for RX.",
"value": null
},
"TEST_PIN_CSMA": {
"help": "TEST_PIN_CSMA pin configured for CSMA.",
"value": null
},
"TEST_PIN_SPARE_1": {
"help": "TEST_PIN_SPARE_1.",
"value": null
},
"TEST_PIN_SPARE_2": {
"help": "TEST_PIN_SPARE_2.",
"value": null
},
"SE2435L_CSD": {
"help": "SE2435L_CSD pin configuration.",
"value": null
},
"SE2435L_ANT_SEL": {
"help": "SE2435L_ANT_SEL pin confuguration.",
"value": null
},
"full-spi-speed": {
"help": "Maximum SPI clock speed (Hz), as long as sufficient inter-byte spacing",
"value": 7500000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <string.h>

#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_I2C && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)

#include "ns_types.h"
#include "platform/arm_hal_interrupt.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@
#include "inttypes.h"
#include "Timeout.h"
#include "platform/mbed_error.h"
#include "platform/mbed_version.h"

#if (MBED_VERSION > MBED_ENCODE_VERSION(6, 0, 0))
/* Mbed OS 6.0 introduces support for chrono time management */
using namespace std::chrono;
#define ATMEL_RF_TIME_50US 50us
#define ATMEL_RF_TIME_2MS 2ms
#define ATMEL_RF_TIME_10MS 10ms
#define ATMEL_RF_ATTACH(timer_ref, signal_ref, timeout_ref) timer_ref.attach(signal_ref, timeout_ref)
#else
#define ATMEL_RF_TIME_50US 50
#define ATMEL_RF_TIME_2MS 2
#define ATMEL_RF_TIME_10MS 10
#define ATMEL_RF_ATTACH(timer_ref, signal_ref, timeout_ref) timer_ref.attach_us(signal_ref, timeout_ref)
#endif

#define TRACE_GROUP "AtRF"

Expand Down Expand Up @@ -345,7 +360,6 @@ static rf_trx_part_e rf_radio_type_read(void)
return ret_val;
}


/*
* \brief Function starts the ACK wait timeout.
*
Expand All @@ -356,9 +370,9 @@ static rf_trx_part_e rf_radio_type_read(void)
static void rf_if_ack_wait_timer_start(uint16_t slots)
{
#ifdef MBED_CONF_RTOS_PRESENT
rf->ack_timer.attach_us(rf_if_ack_timer_signal, slots * 50);
ATMEL_RF_ATTACH(rf->ack_timer, rf_if_ack_timer_signal, slots * ATMEL_RF_TIME_50US);
#else
rf->ack_timer.attach_us(rf_ack_wait_timer_interrupt, slots * 50);
ATMEL_RF_ATTACH(rf->ack_timer, rf_ack_wait_timer_interrupt, slots * ATMEL_RF_TIME_50US);
#endif
}

Expand All @@ -372,9 +386,9 @@ static void rf_if_ack_wait_timer_start(uint16_t slots)
static void rf_if_calibration_timer_start(uint32_t slots)
{
#ifdef MBED_CONF_RTOS_PRESENT
rf->cal_timer.attach_us(rf_if_cal_timer_signal, slots * 50);
ATMEL_RF_ATTACH(rf->cal_timer, rf_if_cal_timer_signal, slots * ATMEL_RF_TIME_50US);
#else
rf->cal_timer.attach_us(rf_calibration_timer_interrupt, slots * 50);
ATMEL_RF_ATTACH(rf->cal_timer, rf_calibration_timer_interrupt, slots * ATMEL_RF_TIME_50US);
#endif
}

Expand All @@ -388,9 +402,9 @@ static void rf_if_calibration_timer_start(uint32_t slots)
static void rf_if_cca_timer_start(uint32_t slots)
{
#ifdef MBED_CONF_RTOS_PRESENT
rf->cca_timer.attach_us(rf_if_cca_timer_signal, slots * 50);
ATMEL_RF_ATTACH(rf->cca_timer, rf_if_cca_timer_signal, slots * ATMEL_RF_TIME_50US);
#else
rf->cca_timer.attach_us(rf_cca_timer_interrupt, slots * 50);
ATMEL_RF_ATTACH(rf->cca_timer, rf_cca_timer_interrupt, slots * ATMEL_RF_TIME_50US);
#endif
}

Expand Down Expand Up @@ -519,14 +533,14 @@ static void rf_if_reset_radio(void)
#endif
rf->IRQ.rise(nullptr);
rf->RST = 1;
ThisThread::sleep_for(2);
ThisThread::sleep_for(ATMEL_RF_TIME_2MS);
rf->RST = 0;
ThisThread::sleep_for(10);
ThisThread::sleep_for(ATMEL_RF_TIME_10MS);
CS_RELEASE();
rf->SLP_TR = 0;
ThisThread::sleep_for(10);
ThisThread::sleep_for(ATMEL_RF_TIME_10MS);
rf->RST = 1;
ThisThread::sleep_for(10);
ThisThread::sleep_for(ATMEL_RF_TIME_10MS);

rf->IRQ.rise(&rf_if_interrupt_handler);
}
Expand Down
3 changes: 3 additions & 0 deletions components/802.15.4_RF/atmel-rf-driver/source/rfbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef RFBITS_H_
#define RFBITS_H_

#if DEVICE_SPI

#include "DigitalIn.h"
#include "DigitalOut.h"
#include "InterruptIn.h"
Expand Down Expand Up @@ -78,4 +80,5 @@ class Se2435Pins {
DigitalOut ANT_SEL;
};

#endif /* DEVICE_SPI */
#endif /* RFBITS_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
#include <string.h>
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)

#include "platform/arm_hal_interrupt.h"
#include "nanostack/platform/arm_hal_phy.h"
#include "ns_types.h"
Expand All @@ -30,6 +31,17 @@
#include "Thread.h"
#include "mbed_wait_api.h"
#include "platform/mbed_error.h"
#include "platform/mbed_version.h"

#if (MBED_VERSION > MBED_ENCODE_VERSION(6, 0, 0))
/* Mbed OS 6.0 introduces support for chrono time management */
using namespace std::chrono;
#define S2LP_USE_CHRONO
#define S2LP_TIME_50US 50us
#define S2LP_TIME_10MS 10ms
#else
#define S2LP_TIME_10MS 10
#endif

using namespace mbed;
using namespace rtos;
Expand Down Expand Up @@ -276,7 +288,11 @@ static void rf_calculate_symbol_rate(uint32_t baudrate, phy_modulation_e modulat

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

static void rf_update_tx_active_time(void)
Expand Down Expand Up @@ -866,7 +882,11 @@ static void rf_cca_timer_stop(void)

static void rf_cca_timer_start(uint32_t slots)
{
#ifdef S2LP_USE_CHRONO
rf->cca_timer.attach(rf_cca_timer_signal, microseconds(slots));
#else
rf->cca_timer.attach_us(rf_cca_timer_signal, slots);
#endif
TEST_CSMA_STARTED
}

Expand Down Expand Up @@ -903,7 +923,11 @@ static void rf_backup_timer_stop(void)

static void rf_backup_timer_start(uint32_t slots)
{
#ifdef S2LP_USE_CHRONO
rf->backup_timer.attach(rf_backup_timer_signal, microseconds(slots));
#else
rf->backup_timer.attach_us(rf_backup_timer_signal, slots);
#endif
}

static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_handle, data_protocol_e data_protocol)
Expand Down Expand Up @@ -1177,10 +1201,10 @@ static void rf_reset(void)
{
// Shutdown
rf->SDN = 1;
ThisThread::sleep_for(10);
ThisThread::sleep_for(S2LP_TIME_10MS);
// Wake up
rf->SDN = 0;
ThisThread::sleep_for(10);
ThisThread::sleep_for(S2LP_TIME_10MS);
}

static void rf_init(void)
Expand Down
Loading