Skip to content

Commit 0b95cfd

Browse files
Tryton77nordicjm
authored andcommitted
esb: Validation of retransmit delay parameter
Added checks for user provided retransmit delay. JIRA: NCSDK-32921 Signed-off-by: Michał Strządała <[email protected]>
1 parent b58d40e commit 0b95cfd

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

subsys/esb/esb.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ LOG_MODULE_REGISTER(esb, CONFIG_ESB_LOG_LEVEL);
4949
/* 4 Mb RX wait for acknowledgment time-out value. */
5050
#define RX_ACK_TIMEOUT_US_4MBPS 160
5151

52-
/* Minimum retransmit time */
52+
/* Minimum retransmit time for the worst case scenario = 435.
53+
* In general = wait_for_ack_timeout_us + ADDR_EVENT_LATENCY_US + ramp_up.
54+
*/
5355
#define RETRANSMIT_DELAY_MIN 435
5456

5557
/* Radio Tx ramp-up time in microseconds. */
@@ -1029,8 +1031,6 @@ static bool update_radio_parameters(void)
10291031
params_valid &= update_radio_protocol();
10301032
params_valid &= update_radio_crc();
10311033
update_rf_payload_format(esb_cfg.payload_length);
1032-
params_valid &=
1033-
(esb_cfg.retransmit_delay >= RETRANSMIT_DELAY_MIN);
10341034

10351035
return params_valid;
10361036
}
@@ -1899,7 +1899,17 @@ int esb_init(const struct esb_config *config)
18991899
memset(rx_pipe_info, 0, sizeof(rx_pipe_info));
19001900
memset(pids, 0, sizeof(pids));
19011901

1902-
update_radio_parameters();
1902+
if (!update_radio_parameters()) {
1903+
LOG_ERR("Failed to update radio parameters");
1904+
return -EINVAL;
1905+
}
1906+
1907+
if (esb_cfg.retransmit_delay < RETRANSMIT_DELAY_MIN) {
1908+
LOG_ERR("Configured retransmission delay is below the required minimum of %d us",
1909+
RETRANSMIT_DELAY_MIN);
1910+
1911+
return -EINVAL;
1912+
}
19031913

19041914
/* Configure radio address registers according to ESB default values */
19051915
nrf_radio_base0_set(NRF_RADIO, 0xE7E7E7E7);

0 commit comments

Comments
 (0)