Skip to content

Commit d8420fb

Browse files
author
Arto Kinnunen
committed
802.15.4 STM S2LP driver update
Sync with master v1.0.5
1 parent a28e809 commit d8420fb

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ static bool rf_rx_filter(uint8_t *mac_header, uint8_t *mac_64bit_addr, uint8_t *
182182
static void rf_cca_timer_start(uint32_t slots);
183183

184184
static RFPins *rf;
185+
#ifdef TEST_GPIOS_ENABLED
185186
static TestPins_S2LP *test_pins;
187+
#endif
186188
static phy_device_driver_s device_driver;
187189
static int8_t rf_radio_driver_id = -1;
188190
static uint8_t *tx_data_ptr;
@@ -207,6 +209,7 @@ static uint8_t s2lp_short_address[2];
207209
static uint8_t s2lp_MAC[8];
208210
static rf_mode_e rf_mode = RF_MODE_NORMAL;
209211
static bool rf_update_config = false;
212+
static bool rf_update_cca_threshold = false;
210213
static uint16_t cur_packet_len = 0xffff;
211214
static uint32_t receiver_ready_timestamp;
212215
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
704707
rf_receive(rf_rx_channel);
705708
}
706709
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;
707717
default:
708718
break;
709719
}
@@ -752,9 +762,9 @@ static void rf_tx_sent_handler(void)
752762
TEST_TX_DONE
753763
rf_backup_timer_stop();
754764
rf_disable_interrupt(TX_DATA_SENT);
765+
rf_update_tx_active_time();
755766
if (rf_state != RF_TX_ACK) {
756767
tx_finnish_time = rf_get_timestamp();
757-
rf_update_tx_active_time();
758768
rf_state = RF_IDLE;
759769
rf_receive(rf_rx_channel);
760770
if (device_driver.phy_tx_done_cb) {
@@ -821,7 +831,6 @@ static void rf_cca_timer_interrupt(void)
821831
}
822832
rf_flush_tx_fifo();
823833
tx_finnish_time = rf_get_timestamp();
824-
rf_update_tx_active_time();
825834
if (device_driver.phy_tx_done_cb) {
826835
device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_FAIL, 0, 0);
827836
}
@@ -955,7 +964,6 @@ static void rf_handle_ack(uint8_t seq_number, uint8_t pending)
955964
phy_link_tx_status_e phy_status;
956965
if (tx_sequence == (uint16_t)seq_number) {
957966
tx_finnish_time = rf_get_timestamp();
958-
rf_update_tx_active_time();
959967
if (pending) {
960968
phy_status = PHY_LINK_TX_DONE_PENDING;
961969
} else {
@@ -1047,6 +1055,12 @@ static void rf_receive(uint8_t rx_channel)
10471055
rf_update_config = false;
10481056
rf_set_channel_configuration_registers();
10491057
}
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+
}
10501064
if (rx_channel != rf_rx_channel) {
10511065
rf_write_register(CHNUM, rx_channel * rf_channel_multiplier);
10521066
rf_rx_channel = rf_new_channel = rx_channel;
@@ -1280,7 +1294,9 @@ int8_t NanostackRfPhys2lp::rf_register()
12801294
}
12811295

12821296
rf = _rf;
1297+
#ifdef TEST_GPIOS_ENABLED
12831298
test_pins = _test_pins;
1299+
#endif
12841300

12851301
int8_t radio_id = rf_device_register(_mac_addr);
12861302
if (radio_id < 0) {

components/802.15.4_RF/stm-s2lp-rf-driver/source/rf_configuration.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void rf_conf_calculate_rx_filter_bandwidth_registers(uint32_t rx_bandwidth, uint
157157

158158
int16_t rf_conf_cca_threshold_percent_to_rssi(uint8_t percent)
159159
{
160-
uint8_t step = (MAX_RSSI_THRESHOLD-MIN_RSSI_THRESHOLD);
160+
uint8_t step = (MAX_RSSI_THRESHOLD - MIN_RSSI_THRESHOLD);
161161
return MIN_RSSI_THRESHOLD + (step * percent) / 100;
162162
}
163163

components/802.15.4_RF/stm-s2lp-rf-driver/stm-s2lp-rf-driver/NanostackRfPhys2lp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
#define S2LP_TEST_PIN_RX D5
6868
#endif
6969

70-
#if defined(TMBED_CONF_S2LP_TEST_PIN_CSMA)
71-
#define S2LP_TEST_PIN_CSMA TMBED_CONF_S2LP_TEST_PIN_CSMA
70+
#if defined(MBED_CONF_S2LP_TEST_PIN_CSMA)
71+
#define S2LP_TEST_PIN_CSMA MBED_CONF_S2LP_TEST_PIN_CSMA
7272
#else
7373
#define S2LP_TEST_PIN_CSMA D4
7474
#endif
@@ -80,7 +80,7 @@
8080
#endif
8181

8282
#if defined(MBED_CONF_S2LP_TEST_PIN_SPARE_2)
83-
#define S2LP_TEST_PIN_SPARE_2 DMBED_CONF_S2LP_TEST_PIN_SPARE_2
83+
#define S2LP_TEST_PIN_SPARE_2 MBED_CONF_S2LP_TEST_PIN_SPARE_2
8484
#else
8585
#define S2LP_TEST_PIN_SPARE_2 D8
8686
#endif

0 commit comments

Comments
 (0)