@@ -164,6 +164,8 @@ static const phy_device_channel_page_s phy_channel_pages[] = {
164
164
{ CHANNEL_PAGE_0, NULL }
165
165
};
166
166
167
+ using namespace std ::chrono_literals;
168
+
167
169
using namespace mbed ;
168
170
using namespace rtos ;
169
171
@@ -196,7 +198,7 @@ static Se2435Pins *se2435_pa_pins = NULL;
196
198
197
199
static uint32_t rf_get_timestamp (void )
198
200
{
199
- return (uint32_t )rf->tx_timer .read_us ();
201
+ return (uint32_t )rf->tx_timer .elapsed_time (). count ();
200
202
}
201
203
202
204
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
564
566
mac_tx_handle = tx_handle;
565
567
566
568
if (tx_time) {
567
- uint32_t backoff_time = tx_time - rf_get_timestamp ();
569
+ std::chrono::microseconds backoff_time ( tx_time - rf_get_timestamp () );
568
570
// 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);
571
573
TEST_CSMA_STARTED
572
574
rf_unlock ();
573
575
return 0 ;
574
576
}
575
577
}
576
578
// 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 );
578
580
TEST_CSMA_STARTED
579
581
rf_unlock ();
580
582
return 0 ;
@@ -607,12 +609,12 @@ static void rf_handle_cca_ed_done(void)
607
609
if (cca_prepare_status == PHY_RESTART_CSMA) {
608
610
device_driver.phy_tx_done_cb (rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_OK, 0 , 0 );
609
611
if (tx_time) {
610
- uint32_t backoff_time = tx_time - rf_get_timestamp ();
612
+ std::chrono::microseconds backoff_time ( tx_time - rf_get_timestamp () );
611
613
// 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 ;
614
616
}
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);
616
618
TEST_CSMA_STARTED
617
619
}
618
620
return ;
@@ -994,7 +996,7 @@ static uint32_t rf_backup_timer_start(uint16_t bytes, uint32_t time_us)
994
996
time_us = (uint32_t )(8000000 / phy_current_config.datarate ) * bytes + PACKET_PROCESSING_TIME;
995
997
}
996
998
// 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) );
998
1000
999
1001
return (rf_get_timestamp () + time_us);
1000
1002
}
0 commit comments