mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/dose: calculate timeout based on symbol rate
A fixed timeout is either too long for high symbol rates or too short for low symbol rates. To fix this, calculate the timeout based on the symbol rate. For this, the old 5ms timeout is equivalent to 58 bytes being transmitted at 115200 baud (8 data bit + start & stop bit). I rounded this to 50 bytes which should yield 4340 µs.
This commit is contained in:
parent
dde4772aa4
commit
3399a6476a
@ -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
|
||||
|
@ -599,10 +599,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;
|
||||
}
|
||||
|
@ -128,12 +128,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
|
||||
/** @} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user