Skip to content

Commit f397e9b

Browse files
edmontcarlescufi
authored andcommitted
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 b945d7a commit f397e9b

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
@@ -61,7 +61,12 @@ static struct nrf5_802154_data nrf5_data;
6161

6262
#define DRX_SLOT_PH 0 /* Placeholder delayed reception window ID */
6363
#define DRX_SLOT_RX 1 /* Actual delayed reception window ID */
64-
#define PH_DURATION 10 /* Duration of the placeholder window, in microseconds */
64+
#define PH_DURATION 10 /* Duration of the placeholder window, in microseconds */
65+
/* When scheduling the actual delayed reception window an adjustment of
66+
* 800 us is required to match the CSL tranmission timing for unknown
67+
* reasons. This is a temporary workaround until the root cause is found.
68+
*/
69+
#define DRX_ADJUST 800
6570

6671
#if defined(CONFIG_IEEE802154_NRF5_UICR_EUI64_ENABLE)
6772
#if defined(CONFIG_SOC_NRF5340_CPUAPP)
@@ -755,7 +760,7 @@ static void nrf5_config_csl_period(uint16_t period)
755760

756761
static void nrf5_schedule_rx(uint8_t channel, uint32_t start, uint32_t duration)
757762
{
758-
nrf5_receive_at(start, duration, channel, DRX_SLOT_RX);
763+
nrf5_receive_at(start - DRX_ADJUST, duration, channel, DRX_SLOT_RX);
759764

760765
/* The placeholder reception window is rescheduled for the next period */
761766
nrf_802154_receive_at_cancel(DRX_SLOT_PH);
@@ -888,22 +893,23 @@ static int nrf5_configure(const struct device *dev,
888893

889894
/* nRF5 radio driver callbacks */
890895

891-
void nrf_802154_received_timestamp_raw(uint8_t *data, int8_t power, uint8_t lqi,
892-
uint32_t time)
896+
void nrf_802154_received_timestamp_raw(uint8_t *data, int8_t power, uint8_t lqi, uint32_t time)
893897
{
894898
for (uint32_t i = 0; i < ARRAY_SIZE(nrf5_data.rx_frames); i++) {
895899
if (nrf5_data.rx_frames[i].psdu != NULL) {
896900
continue;
897901
}
898902

899903
nrf5_data.rx_frames[i].psdu = data;
900-
nrf5_data.rx_frames[i].time = time;
901904
nrf5_data.rx_frames[i].rssi = power;
902905
nrf5_data.rx_frames[i].lqi = lqi;
903906

907+
#if !defined(CONFIG_NRF_802154_SER_HOST) && defined(CONFIG_NET_PKT_TIMESTAMP)
908+
nrf5_data.rx_frames[i].time = nrf_802154_first_symbol_timestamp_get(time, data[0]);
909+
#endif
910+
904911
if (data[ACK_REQUEST_BYTE] & ACK_REQUEST_BIT) {
905-
nrf5_data.rx_frames[i].ack_fpb =
906-
nrf5_data.last_frame_ack_fpb;
912+
nrf5_data.rx_frames[i].ack_fpb = nrf5_data.last_frame_ack_fpb;
907913
} else {
908914
nrf5_data.rx_frames[i].ack_fpb = false;
909915
}

0 commit comments

Comments
 (0)