|
15 | 15 | */ |
16 | 16 | #include <string.h> |
17 | 17 | #if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT) |
| 18 | + |
18 | 19 | #include "platform/arm_hal_interrupt.h" |
19 | 20 | #include "nanostack/platform/arm_hal_phy.h" |
20 | 21 | #include "ns_types.h" |
|
30 | 31 | #include "Thread.h" |
31 | 32 | #include "mbed_wait_api.h" |
32 | 33 | #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 |
33 | 45 |
|
34 | 46 | using namespace mbed; |
35 | 47 | using namespace rtos; |
@@ -276,7 +288,11 @@ static void rf_calculate_symbol_rate(uint32_t baudrate, phy_modulation_e modulat |
276 | 288 |
|
277 | 289 | static uint32_t rf_get_timestamp(void) |
278 | 290 | { |
| 291 | +#ifdef S2LP_USE_CHRONO |
| 292 | + return (uint32_t)rf->tx_timer.elapsed_time().count(); |
| 293 | +#else |
279 | 294 | return (uint32_t)rf->tx_timer.read_us(); |
| 295 | +#endif |
280 | 296 | } |
281 | 297 |
|
282 | 298 | static void rf_update_tx_active_time(void) |
@@ -866,7 +882,11 @@ static void rf_cca_timer_stop(void) |
866 | 882 |
|
867 | 883 | static void rf_cca_timer_start(uint32_t slots) |
868 | 884 | { |
| 885 | +#ifdef S2LP_USE_CHRONO |
| 886 | + rf->cca_timer.attach(rf_cca_timer_signal, microseconds(slots)); |
| 887 | +#else |
869 | 888 | rf->cca_timer.attach_us(rf_cca_timer_signal, slots); |
| 889 | +#endif |
870 | 890 | TEST_CSMA_STARTED |
871 | 891 | } |
872 | 892 |
|
@@ -903,7 +923,11 @@ static void rf_backup_timer_stop(void) |
903 | 923 |
|
904 | 924 | static void rf_backup_timer_start(uint32_t slots) |
905 | 925 | { |
| 926 | +#ifdef S2LP_USE_CHRONO |
| 927 | + rf->backup_timer.attach(rf_backup_timer_signal, microseconds(slots)); |
| 928 | +#else |
906 | 929 | rf->backup_timer.attach_us(rf_backup_timer_signal, slots); |
| 930 | +#endif |
907 | 931 | } |
908 | 932 |
|
909 | 933 | 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) |
1177 | 1201 | { |
1178 | 1202 | // Shutdown |
1179 | 1203 | rf->SDN = 1; |
1180 | | - ThisThread::sleep_for(10); |
| 1204 | + ThisThread::sleep_for(S2LP_TIME_10MS); |
1181 | 1205 | // Wake up |
1182 | 1206 | rf->SDN = 0; |
1183 | | - ThisThread::sleep_for(10); |
| 1207 | + ThisThread::sleep_for(S2LP_TIME_10MS); |
1184 | 1208 | } |
1185 | 1209 |
|
1186 | 1210 | static void rf_init(void) |
|
0 commit comments