Given that implementors must provide wait_until_nanos, could the less-granular functions be implemented in terms of the nanos wait (or, alternatively, in a "stepping down" fashion, i.e. seconds calls millis, millis calls micros, micros calls nanos? It should reduce the amount of logic that implementors have to do, and by extension reduce the likelihood of introducing bugs that way.
Time-wise, 2^64 nanoseconds is 584 years, so the reduced maximum time/duration (being 1e{3,6,9} longer in the future) shouldn't really be a problem, IMO.
I think the same holds for Timer::max_{micros, millis, seconds} and Timer::elapsed_{micros, millis, secs}. They all "do the same thing", just with a differing maximum value and resolution.
This will also place "being consistent" responsibility closer to the HAL: instead of every Alarm/Timer implementor being forced to do the math for converting to/from ticks correctly, and rounding in an expected way, this can be done by the HAL instead. If implementors choose to override any functions, they have a clear example of the expected behaviour in the HAL itself.
Given that implementors must provide
wait_until_nanos, could the less-granular functions be implemented in terms of thenanoswait (or, alternatively, in a "stepping down" fashion, i.e.secondscallsmillis,milliscallsmicros,microscallsnanos? It should reduce the amount of logic that implementors have to do, and by extension reduce the likelihood of introducing bugs that way.Time-wise, 2^64 nanoseconds is 584 years, so the reduced maximum time/duration (being
1e{3,6,9}longer in the future) shouldn't really be a problem, IMO.I think the same holds for
Timer::max_{micros, millis, seconds}andTimer::elapsed_{micros, millis, secs}. They all "do the same thing", just with a differing maximum value and resolution.This will also place "being consistent" responsibility closer to the HAL: instead of every
Alarm/Timerimplementor being forced to do the math for converting to/from ticks correctly, and rounding in an expected way, this can be done by the HAL instead. If implementors choose to override any functions, they have a clear example of the expected behaviour in the HAL itself.