1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #16768 from benpicco/drivers/dose-timeout_bytes

drivers/dose: calculate timeout based on symbol rate
This commit is contained in:
benpicco 2021-11-10 12:40:13 +01:00 committed by GitHub
commit 026d6cfba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -13,11 +13,11 @@ menuconfig KCONFIG_USEMODULE_DOSE
if KCONFIG_USEMODULE_DOSE if KCONFIG_USEMODULE_DOSE
config DOSE_TIMEOUT_USEC config DOSE_TIMEOUT_BYTES
int "Transaction timeout in microseconds [us]" int "Transaction timeout in bytes"
default 5000 default 50
help help
Timeout, in microseconds, to bring the driver back into idle state if Timeout, in bytes at the set baudrate, to bring the driver back into idle state if
the remote side died within a transaction. the remote side died within a transaction.
endif # KCONFIG_USEMODULE_DOSE endif # KCONFIG_USEMODULE_DOSE

View File

@ -662,10 +662,11 @@ void dose_setup(dose_t *ctx, const dose_params_t *params, uint8_t index)
* We have to ensure it is above the XTIMER_BACKOFF. Otherwise state * We have to ensure it is above the XTIMER_BACKOFF. Otherwise state
* transitions are triggered from another state transition setting up the * transitions are triggered from another state transition setting up the
* timeout. */ * timeout. */
ctx->timeout_base = CONFIG_DOSE_TIMEOUT_USEC; ctx->timeout_base = CONFIG_DOSE_TIMEOUT_BYTES * 10UL * US_PER_SEC / params->baudrate;
if (ctx->timeout_base < xtimer_usec_from_ticks(min_timeout)) { if (ctx->timeout_base < xtimer_usec_from_ticks(min_timeout)) {
ctx->timeout_base = xtimer_usec_from_ticks(min_timeout); ctx->timeout_base = xtimer_usec_from_ticks(min_timeout);
} }
DEBUG("dose timeout set to %" PRIu32 " µs\n", ctx->timeout_base);
ctx->timeout.callback = _isr_xtimer; ctx->timeout.callback = _isr_xtimer;
ctx->timeout.arg = ctx; ctx->timeout.arg = ctx;
} }

View File

@ -130,12 +130,12 @@ typedef enum {
* @{ * @{
*/ */
/** /**
* @brief Timeout that brings the driver back into idle state. * @brief Timeout that brings the driver back into idle state expressed as bytes.
* *
* Fallback to idle if the remote side died within a transaction. * Fallback to idle if the remote side died within a transaction.
*/ */
#ifndef CONFIG_DOSE_TIMEOUT_USEC #ifndef CONFIG_DOSE_TIMEOUT_BYTES
#define CONFIG_DOSE_TIMEOUT_USEC (5000) #define CONFIG_DOSE_TIMEOUT_BYTES (50)
#endif #endif
/** @} */ /** @} */