Skip to content

Commit 5c515ed

Browse files
Zhenghuan Zhangliang4804
authored andcommitted
drivers: ieee802154: b9x: Update cca features and function.
- Update the CCA threshold. - Improve the CCA calculation method. Co-authored-by: Liang Zhong <liang.zhong@telink-semi.com> Signed-off-by: Zhenghuan Zhang <zhenghuan.zhang@telink-semi.com>
1 parent 2b01144 commit 5c515ed

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

drivers/ieee802154/Kconfig.b9x

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ config IEEE802154_B9X_SET_TXRX_DELAY_US
2525

2626
config IEEE802154_B9X_CCA_RSSI_THRESHOLD
2727
int "CCA procedure RSSI threshold"
28-
default -50
28+
default -70
2929
help
3030
CCA procedure returns true if the current RSSI value is less than
3131
this parameter.

drivers/ieee802154/ieee802154_b9x.c

+20-4
Original file line numberDiff line numberDiff line change
@@ -914,13 +914,29 @@ static enum ieee802154_hw_caps b9x_get_capabilities(const struct device *dev)
914914
static int b9x_cca(const struct device *dev)
915915
{
916916
ARG_UNUSED(dev);
917-
917+
signed char rssi_peak = -110;
918+
signed char rssi_cur = -110;
919+
signed int rssiSum = 0;
920+
signed int cnt = 1;
918921
unsigned int t1 = stimer_get_tick();
919922

923+
rf_set_rxmode();
924+
rssi_cur = rf_get_rssi();
925+
rssiSum += rssi_cur;
926+
920927
while (!clock_time_exceed(t1, B9X_CCA_TIME_MAX_US)) {
921-
if (rf_get_rssi() < CONFIG_IEEE802154_B9X_CCA_RSSI_THRESHOLD) {
922-
return 0;
923-
}
928+
rssi_cur = rf_get_rssi();
929+
rssiSum += rssi_cur;
930+
cnt++;
931+
}
932+
933+
rssi_peak = rssiSum/cnt;
934+
rf_set_tx_rx_off();
935+
936+
if (rssi_peak > CONFIG_IEEE802154_B9X_CCA_RSSI_THRESHOLD) {
937+
return -EBUSY;
938+
} else {
939+
return 0;
924940
}
925941

926942
return -EBUSY;

drivers/ieee802154/ieee802154_b9x.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#define B9X_TRX_LENGTH (256)
3535
#define B9X_RSSI_TO_LQI_SCALE (3)
3636
#define B9X_RSSI_TO_LQI_MIN (-87)
37-
#define B9X_CCA_TIME_MAX_US (200)
37+
#define B9X_CCA_TIME_MAX_US (120)
3838
#define B9X_LOGIC_CHANNEL_TO_PHYSICAL(p) (((p) - 10) * 5)
3939
#define B9X_MAC_KEYS_ITEMS (3)
4040
#ifndef IEEE802154_CRYPTO_LENGTH_AES_BLOCK

0 commit comments

Comments
 (0)