Skip to content

Commit 877436c

Browse files
author
Abbas Bracken Ziad
committed
Replace calls to deprecated functions in the Timer API
1 parent 2f87d59 commit 877436c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

connectivity/drivers/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAT86RF215.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ static const phy_device_channel_page_s phy_channel_pages[] = {
164164
{ CHANNEL_PAGE_0, NULL}
165165
};
166166

167+
using namespace std::chrono_literals;
168+
167169
using namespace mbed;
168170
using namespace rtos;
169171

@@ -196,7 +198,7 @@ static Se2435Pins *se2435_pa_pins = NULL;
196198

197199
static uint32_t rf_get_timestamp(void)
198200
{
199-
return (uint32_t)rf->tx_timer.read_us();
201+
return (uint32_t)rf->tx_timer.elapsed_time().count();
200202
}
201203

202204
static void rf_lock(void)
@@ -564,17 +566,17 @@ static int8_t rf_start_csma_ca(uint8_t *data_ptr, uint16_t data_length, uint8_t
564566
mac_tx_handle = tx_handle;
565567

566568
if (tx_time) {
567-
uint32_t backoff_time = tx_time - rf_get_timestamp();
569+
std::chrono::microseconds backoff_time(tx_time - rf_get_timestamp());
568570
// Max. time to TX can be 65ms, otherwise time has passed already -> send immediately
569-
if (backoff_time <= 65000) {
570-
rf->cca_timer.attach_us(rf_csma_ca_timer_signal, backoff_time);
571+
if (backoff_time <= 65ms) {
572+
rf->cca_timer.attach(rf_csma_ca_timer_signal, backoff_time);
571573
TEST_CSMA_STARTED
572574
rf_unlock();
573575
return 0;
574576
}
575577
}
576578
// Short timeout to start CCA immediately.
577-
rf->cca_timer.attach_us(rf_csma_ca_timer_signal, 1);
579+
rf->cca_timer.attach(rf_csma_ca_timer_signal, 1us);
578580
TEST_CSMA_STARTED
579581
rf_unlock();
580582
return 0;
@@ -607,12 +609,12 @@ static void rf_handle_cca_ed_done(void)
607609
if (cca_prepare_status == PHY_RESTART_CSMA) {
608610
device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_OK, 0, 0);
609611
if (tx_time) {
610-
uint32_t backoff_time = tx_time - rf_get_timestamp();
612+
std::chrono::microseconds backoff_time(tx_time - rf_get_timestamp());
611613
// Max. time to TX can be 65ms, otherwise time has passed already -> send immediately
612-
if (backoff_time > 65000) {
613-
backoff_time = 1;
614+
if (backoff_time > 65ms) {
615+
backoff_time = 1us;
614616
}
615-
rf->cca_timer.attach_us(rf_csma_ca_timer_signal, backoff_time);
617+
rf->cca_timer.attach(rf_csma_ca_timer_signal, backoff_time);
616618
TEST_CSMA_STARTED
617619
}
618620
return;
@@ -994,7 +996,7 @@ static uint32_t rf_backup_timer_start(uint16_t bytes, uint32_t time_us)
994996
time_us = (uint32_t)(8000000 / phy_current_config.datarate) * bytes + PACKET_PROCESSING_TIME;
995997
}
996998
// Using cal_timer as backup timer
997-
rf->cal_timer.attach_us(rf_backup_timer_signal, time_us);
999+
rf->cal_timer.attach(rf_backup_timer_signal, std::chrono::microseconds(time_us));
9981000

9991001
return (rf_get_timestamp() + time_us);
10001002
}

0 commit comments

Comments
 (0)