-
Notifications
You must be signed in to change notification settings - Fork 100
Conversation
/// Read ten millisecond calibration value from hardware | ||
pub fn tenms() -> Option<u32> { | ||
let calib = reg::SYSTICK.calib.tenms(); | ||
if calib == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or
match reg::SYSTICK.calib.tenms() {
0 => None,
val => Some(val)
}
Nice, I like using enums this way. |
I feel that "fallback" is a bit misleading concept. I want to set the systick clock to the exact time value that I know. There are two cases: either platform has the value for 10ms or not. It's also a bit more complicated as that reference value is only supported on reference clock, so in the end it's up to PT to initialise the systick clocking correctly (i.e. we don't even need to care about pre-defined constant). I'm fine if "calibrated" source goes away in that case. Systick is kind of reserved for zinc/os internals (scheduler), so it's not really that of user-facing api. |
} | ||
|
||
/// Read ten millisecond calibration value from hardware | ||
pub fn tenms() -> Option<u32> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bikeshed: perhaps ten_ms
would be a tad more readable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it even need to be public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends. For standalone applications (not using any rust-provided scheduler), it might be useful to check if there's any calibrated value. Is there any cost having it public?
A couple of notes above but otherwise LGTM. |
I feel that leaving I'll fix using your comments and push today/tomorrow. Thanks. |
@dpc I agree. |
r? |
Looks good to me. Thanks for your good work. |
@hacknbot: merge |
systick: Refactoring into ioreg
This change rewrites systick module a bit to use new ioreg macro, changes
systick::setup
a bit to eliminate "boolean trap", exposes tenms() to the user, so the user can read and manipulate it.