Embedded-hal: Timer countdown start contract for multiple calls

Created on 23 Oct 2018  路  1Comment  路  Source: rust-embedded/embedded-hal

The countdown trait states:

self.start(count); block!(self.wait()); MUST block for AT LEAST the time specified by count.

The effect of calling start a second time is unclear.

One interpretation is that the countdown restarts; consider a countdown that does not restart (possibly because cancel has not been called):

self.start(5);
nop;
self.start(10);
block!(self.wait());

The contract on self.start(10) would not hold. (This is true even if this were an upcounting timer and the final count were updated by self.start(10) , as the timer count has already increased.)

Most helpful comment

Thank you for opening this issue, @droogmic. I agree with your interpretation, and the timer restarting is certainly the most sensible actions for the uses cases that I've seen so far.

I'd like to leave this open for a while to see if there are any disagreements, but from my perspective, it seems the correct action is to update the documentation of CountDown::start to clearly state that the documented contract implies a restart.

>All comments

Thank you for opening this issue, @droogmic. I agree with your interpretation, and the timer restarting is certainly the most sensible actions for the uses cases that I've seen so far.

I'd like to leave this open for a while to see if there are any disagreements, but from my perspective, it seems the correct action is to update the documentation of CountDown::start to clearly state that the documented contract implies a restart.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hannobraun picture hannobraun  路  8Comments

dbrgn picture dbrgn  路  10Comments

mgottschlag picture mgottschlag  路  6Comments

japaric picture japaric  路  8Comments

austinglaser picture austinglaser  路  9Comments