diff --git a/drivers/dose/Kconfig b/drivers/dose/Kconfig index feb2a42f3b..5eb1c8cbdb 100644 --- a/drivers/dose/Kconfig +++ b/drivers/dose/Kconfig @@ -13,11 +13,11 @@ menuconfig KCONFIG_USEMODULE_DOSE if KCONFIG_USEMODULE_DOSE -config DOSE_TIMEOUT_USEC - int "Transaction timeout in microseconds [us]" - default 5000 +config DOSE_TIMEOUT_BYTES + int "Transaction timeout in bytes" + default 50 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. endif # KCONFIG_USEMODULE_DOSE diff --git a/drivers/dose/dose.c b/drivers/dose/dose.c index dda81b31b6..470db77406 100644 --- a/drivers/dose/dose.c +++ b/drivers/dose/dose.c @@ -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 * transitions are triggered from another state transition setting up the * 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)) { 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.arg = ctx; } diff --git a/drivers/include/dose.h b/drivers/include/dose.h index abaa27ad29..5013e0e77a 100644 --- a/drivers/include/dose.h +++ b/drivers/include/dose.h @@ -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. */ -#ifndef CONFIG_DOSE_TIMEOUT_USEC -#define CONFIG_DOSE_TIMEOUT_USEC (5000) +#ifndef CONFIG_DOSE_TIMEOUT_BYTES +#define CONFIG_DOSE_TIMEOUT_BYTES (50) #endif /** @} */