Skip to content

Commit 1215a3a

Browse files
author
Arto Kinnunen
committed
Merge commit 'f43b5b3761db0cc431d42f621b366ab16387b2db' into nanostack-as_subtree
* commit 'f43b5b3761db0cc431d42f621b366ab16387b2db': Squashed 'connectivity/drivers/802.15.4_RF/stm-s2lp-rf-driver/' changes from 9441d65aab..063b1af74e
2 parents ca5d054 + f43b5b3 commit 1215a3a

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

connectivity/drivers/802.15.4_RF/stm-s2lp-rf-driver/source/NanostackRfPhys2lp.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#include <string.h>
1717
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)
18+
1819
#include "platform/arm_hal_interrupt.h"
1920
#include "nanostack/platform/arm_hal_phy.h"
2021
#include "ns_types.h"
@@ -30,6 +31,17 @@
3031
#include "Thread.h"
3132
#include "mbed_wait_api.h"
3233
#include "platform/mbed_error.h"
34+
#include "platform/mbed_version.h"
35+
36+
#if (MBED_VERSION > MBED_ENCODE_VERSION(6, 0, 0))
37+
/* Mbed OS 6.0 introduces support for chrono time management */
38+
using namespace std::chrono;
39+
#define S2LP_USE_CHRONO
40+
#define S2LP_TIME_50US 50us
41+
#define S2LP_TIME_10MS 10ms
42+
#else
43+
#define S2LP_TIME_10MS 10
44+
#endif
3345

3446
using namespace mbed;
3547
using namespace rtos;
@@ -276,7 +288,11 @@ static void rf_calculate_symbol_rate(uint32_t baudrate, phy_modulation_e modulat
276288

277289
static uint32_t rf_get_timestamp(void)
278290
{
291+
#ifdef S2LP_USE_CHRONO
292+
return (uint32_t)rf->tx_timer.elapsed_time().count();
293+
#else
279294
return (uint32_t)rf->tx_timer.read_us();
295+
#endif
280296
}
281297

282298
static void rf_update_tx_active_time(void)
@@ -866,7 +882,11 @@ static void rf_cca_timer_stop(void)
866882

867883
static void rf_cca_timer_start(uint32_t slots)
868884
{
885+
#ifdef S2LP_USE_CHRONO
886+
rf->cca_timer.attach(rf_cca_timer_signal, microseconds(slots));
887+
#else
869888
rf->cca_timer.attach_us(rf_cca_timer_signal, slots);
889+
#endif
870890
TEST_CSMA_STARTED
871891
}
872892

@@ -903,7 +923,11 @@ static void rf_backup_timer_stop(void)
903923

904924
static void rf_backup_timer_start(uint32_t slots)
905925
{
926+
#ifdef S2LP_USE_CHRONO
927+
rf->backup_timer.attach(rf_backup_timer_signal, microseconds(slots));
928+
#else
906929
rf->backup_timer.attach_us(rf_backup_timer_signal, slots);
930+
#endif
907931
}
908932

909933
static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_handle, data_protocol_e data_protocol)
@@ -1177,10 +1201,10 @@ static void rf_reset(void)
11771201
{
11781202
// Shutdown
11791203
rf->SDN = 1;
1180-
ThisThread::sleep_for(10);
1204+
ThisThread::sleep_for(S2LP_TIME_10MS);
11811205
// Wake up
11821206
rf->SDN = 0;
1183-
ThisThread::sleep_for(10);
1207+
ThisThread::sleep_for(S2LP_TIME_10MS);
11841208
}
11851209

11861210
static void rf_init(void)
@@ -1328,7 +1352,7 @@ NanostackRfPhys2lp::NanostackRfPhys2lp(PinName spi_sdi, PinName spi_sdo, PinName
13281352
#ifdef AT24MAC
13291353
_mac(i2c_sda, i2c_scl),
13301354
#endif //AT24MAC
1331-
_mac_addr(), _rf(NULL), _mac_set(false),
1355+
_mac_addr(), _rf(NULL), _test_pins(NULL), _mac_set(false),
13321356
_spi_sdi(spi_sdi), _spi_sdo(spi_sdo), _spi_sclk(spi_sclk), _spi_cs(spi_cs), _spi_sdn(spi_sdn),
13331357
_spi_gpio0(spi_gpio0), _spi_gpio1(spi_gpio1), _spi_gpio2(spi_gpio2), _spi_gpio3(spi_gpio3)
13341358
{

0 commit comments

Comments
 (0)