Skip to content

Commit 1a4f35f

Browse files
edmontcarlescufi
authored andcommitted
[nrf fromlist] drivers: nrf5: fixes for the CSL Receiver
Introduce fixes for making the CSL Receiver to properly schedule the reception window. Signed-off-by: Eduardo Montoya <[email protected]>
1 parent a64e96d commit 1a4f35f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

drivers/ieee802154/ieee802154_nrf5.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ static struct nrf5_802154_data nrf5_data;
6969

7070
#define DRX_SLOT_PH 0 /* Placeholder delayed reception window ID */
7171
#define DRX_SLOT_RX 1 /* Actual delayed reception window ID */
72-
#define PH_DURATION 10 /* Duration of the placeholder window, in microseconds */
72+
#define PH_DURATION 10 /* Duration of the placeholder window, in microseconds */
73+
/* When scheduling the actual delayed reception window an adjustment of
74+
* 800 us is required to match the CSL tranmission timing for unknown
75+
* reasons. This is a temporary workaround until the root cause is found.
76+
*/
77+
#define DRX_ADJUST 800
7378

7479
#if defined(CONFIG_IEEE802154_NRF5_UICR_EUI64_ENABLE)
7580
#if defined(CONFIG_SOC_NRF5340_CPUAPP)
@@ -795,7 +800,7 @@ static void nrf5_config_csl_period(uint16_t period)
795800

796801
static void nrf5_schedule_rx(uint8_t channel, uint32_t start, uint32_t duration)
797802
{
798-
nrf5_receive_at(start, duration, channel, DRX_SLOT_RX);
803+
nrf5_receive_at(start - DRX_ADJUST, duration, channel, DRX_SLOT_RX);
799804

800805
/* The placeholder reception window is rescheduled for the next period */
801806
nrf_802154_receive_at_cancel(DRX_SLOT_PH);
@@ -928,22 +933,23 @@ static int nrf5_configure(const struct device *dev,
928933

929934
/* nRF5 radio driver callbacks */
930935

931-
void nrf_802154_received_timestamp_raw(uint8_t *data, int8_t power, uint8_t lqi,
932-
uint32_t time)
936+
void nrf_802154_received_timestamp_raw(uint8_t *data, int8_t power, uint8_t lqi, uint32_t time)
933937
{
934938
for (uint32_t i = 0; i < ARRAY_SIZE(nrf5_data.rx_frames); i++) {
935939
if (nrf5_data.rx_frames[i].psdu != NULL) {
936940
continue;
937941
}
938942

939943
nrf5_data.rx_frames[i].psdu = data;
940-
nrf5_data.rx_frames[i].time = time;
941944
nrf5_data.rx_frames[i].rssi = power;
942945
nrf5_data.rx_frames[i].lqi = lqi;
943946

947+
#if !defined(CONFIG_NRF_802154_SER_HOST) && defined(CONFIG_NET_PKT_TIMESTAMP)
948+
nrf5_data.rx_frames[i].time = nrf_802154_first_symbol_timestamp_get(time, data[0]);
949+
#endif
950+
944951
if (data[ACK_REQUEST_BYTE] & ACK_REQUEST_BIT) {
945-
nrf5_data.rx_frames[i].ack_fpb =
946-
nrf5_data.last_frame_ack_fpb;
952+
nrf5_data.rx_frames[i].ack_fpb = nrf5_data.last_frame_ack_fpb;
947953
} else {
948954
nrf5_data.rx_frames[i].ack_fpb = false;
949955
}

0 commit comments

Comments
 (0)