mirror of
https://github.com/espressif/openthread.git
synced 2026-10-01 21:37:39 +00:00
[spi-hdlc-adapter] enhance the retry logic when slave is busy (#2647)
This commit changes the `spi-hdlc-adapter` retry logic when the slave is busy (it refuses a transmission). There are three levels, initially the retries happen almost immediately, then up to certain number of attempts at a fast rate and finally it drops to a slow rate. This change helps with the average delay of spinel message exchange between NCP and host (connected using an SPI interface).
This commit is contained in:
committed by
Jonathan Hui
parent
ecd28458ec
commit
bd4cc2689b
@@ -92,6 +92,13 @@
|
|||||||
|
|
||||||
#define SPI_POLL_PERIOD_MSEC (MSEC_PER_SEC/30)
|
#define SPI_POLL_PERIOD_MSEC (MSEC_PER_SEC/30)
|
||||||
|
|
||||||
|
#define IMMEDIATE_RETRY_COUNT 5
|
||||||
|
#define FAST_RETRY_COUNT 15
|
||||||
|
|
||||||
|
#define IMMEDIATE_RETRY_TIMEOUT_MSEC 1
|
||||||
|
#define FAST_RETRY_TIMEOUT_MSEC 10
|
||||||
|
#define SLOW_RETRY_TIMEOUT_MSEC 33
|
||||||
|
|
||||||
#define GPIO_INT_ASSERT_STATE 0 // I̅N̅T̅ is asserted low
|
#define GPIO_INT_ASSERT_STATE 0 // I̅N̅T̅ is asserted low
|
||||||
#define GPIO_RES_ASSERT_STATE 0 // R̅E̅S̅ is asserted low
|
#define GPIO_RES_ASSERT_STATE 0 // R̅E̅S̅ is asserted low
|
||||||
|
|
||||||
@@ -1866,13 +1873,29 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (sSpiTxRefusedCount)
|
if (sSpiTxRefusedCount)
|
||||||
{
|
{
|
||||||
|
int min_timeout = 0;
|
||||||
|
|
||||||
// We are being rate-limited by the slave. This is
|
// We are being rate-limited by the slave. This is
|
||||||
// fairly normal behavior. We poll because we
|
// fairly normal behavior. Based on number of times
|
||||||
// won't get an interrupt unless the slave happens
|
// slave has refused a transmission, we apply a
|
||||||
// to be trying to send us something.
|
// minimum timeout.
|
||||||
if (timeout_ms < SPI_POLL_PERIOD_MSEC)
|
|
||||||
|
if (sSpiTxRefusedCount < IMMEDIATE_RETRY_COUNT)
|
||||||
{
|
{
|
||||||
timeout_ms = SPI_POLL_PERIOD_MSEC;
|
min_timeout = IMMEDIATE_RETRY_TIMEOUT_MSEC;
|
||||||
|
}
|
||||||
|
else if (sSpiTxRefusedCount < FAST_RETRY_COUNT)
|
||||||
|
{
|
||||||
|
min_timeout = FAST_RETRY_TIMEOUT_MSEC;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
min_timeout = SLOW_RETRY_TIMEOUT_MSEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeout_ms < min_timeout)
|
||||||
|
{
|
||||||
|
timeout_ms = min_timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( sSpiTxIsReady
|
if ( sSpiTxIsReady
|
||||||
|
|||||||
Reference in New Issue
Block a user