@@ -182,7 +182,9 @@ static bool rf_rx_filter(uint8_t *mac_header, uint8_t *mac_64bit_addr, uint8_t *
182
182
static void rf_cca_timer_start (uint32_t slots);
183
183
184
184
static RFPins *rf;
185
+ #ifdef TEST_GPIOS_ENABLED
185
186
static TestPins_S2LP *test_pins;
187
+ #endif
186
188
static phy_device_driver_s device_driver;
187
189
static int8_t rf_radio_driver_id = -1 ;
188
190
static uint8_t *tx_data_ptr;
@@ -207,6 +209,7 @@ static uint8_t s2lp_short_address[2];
207
209
static uint8_t s2lp_MAC[8 ];
208
210
static rf_mode_e rf_mode = RF_MODE_NORMAL;
209
211
static bool rf_update_config = false ;
212
+ static bool rf_update_cca_threshold = false ;
210
213
static uint16_t cur_packet_len = 0xffff ;
211
214
static uint32_t receiver_ready_timestamp;
212
215
static int16_t rssi_threshold = RSSI_THRESHOLD;
@@ -704,6 +707,13 @@ static int8_t rf_extension(phy_extension_type_e extension_type, uint8_t *data_pt
704
707
rf_receive (rf_rx_channel);
705
708
}
706
709
break ;
710
+ case PHY_EXTENSION_SET_CHANNEL_CCA_THRESHOLD:
711
+ if ((rssi_threshold != (int8_t )*data_ptr) && (rf_state != RF_RX_STARTED)) {
712
+ rssi_threshold = (int8_t )*data_ptr; // *NOPAD*
713
+ rf_update_cca_threshold = true ;
714
+ rf_receive (rf_rx_channel);
715
+ }
716
+ break ;
707
717
default :
708
718
break ;
709
719
}
@@ -752,9 +762,9 @@ static void rf_tx_sent_handler(void)
752
762
TEST_TX_DONE
753
763
rf_backup_timer_stop ();
754
764
rf_disable_interrupt (TX_DATA_SENT);
765
+ rf_update_tx_active_time ();
755
766
if (rf_state != RF_TX_ACK) {
756
767
tx_finnish_time = rf_get_timestamp ();
757
- rf_update_tx_active_time ();
758
768
rf_state = RF_IDLE;
759
769
rf_receive (rf_rx_channel);
760
770
if (device_driver.phy_tx_done_cb ) {
@@ -821,7 +831,6 @@ static void rf_cca_timer_interrupt(void)
821
831
}
822
832
rf_flush_tx_fifo ();
823
833
tx_finnish_time = rf_get_timestamp ();
824
- rf_update_tx_active_time ();
825
834
if (device_driver.phy_tx_done_cb ) {
826
835
device_driver.phy_tx_done_cb (rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_FAIL, 0 , 0 );
827
836
}
@@ -955,7 +964,6 @@ static void rf_handle_ack(uint8_t seq_number, uint8_t pending)
955
964
phy_link_tx_status_e phy_status;
956
965
if (tx_sequence == (uint16_t )seq_number) {
957
966
tx_finnish_time = rf_get_timestamp ();
958
- rf_update_tx_active_time ();
959
967
if (pending) {
960
968
phy_status = PHY_LINK_TX_DONE_PENDING;
961
969
} else {
@@ -1047,6 +1055,12 @@ static void rf_receive(uint8_t rx_channel)
1047
1055
rf_update_config = false ;
1048
1056
rf_set_channel_configuration_registers ();
1049
1057
}
1058
+ if (rf_update_cca_threshold == true ) {
1059
+ rf_update_cca_threshold = false ;
1060
+ uint8_t rssi_th;
1061
+ rf_conf_calculate_rssi_threshold_registers (rssi_threshold, &rssi_th);
1062
+ rf_write_register (RSSI_TH, rssi_th);
1063
+ }
1050
1064
if (rx_channel != rf_rx_channel) {
1051
1065
rf_write_register (CHNUM, rx_channel * rf_channel_multiplier);
1052
1066
rf_rx_channel = rf_new_channel = rx_channel;
@@ -1280,7 +1294,9 @@ int8_t NanostackRfPhys2lp::rf_register()
1280
1294
}
1281
1295
1282
1296
rf = _rf;
1297
+ #ifdef TEST_GPIOS_ENABLED
1283
1298
test_pins = _test_pins;
1299
+ #endif
1284
1300
1285
1301
int8_t radio_id = rf_device_register (_mac_addr);
1286
1302
if (radio_id < 0 ) {
0 commit comments