Skip to content
This repository was archived by the owner on Jul 6, 2019. It is now read-only.

systick: Refactoring. #152

Merged
merged 1 commit into from
Aug 29, 2014
Merged

systick: Refactoring. #152

merged 1 commit into from
Aug 29, 2014

Conversation

dpc
Copy link
Contributor

@dpc dpc commented Aug 28, 2014

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.

/// Read ten millisecond calibration value from hardware
pub fn tenms() -> Option<u32> {
let calib = reg::SYSTICK.calib.tenms();
if calib == 0 {
Copy link
Contributor

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)
}

@bharrisau
Copy link
Contributor

Nice, I like using enums this way.

@farcaller
Copy link
Member

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> {
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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?

@bgamari
Copy link
Contributor

bgamari commented Aug 28, 2014

A couple of notes above but otherwise LGTM.

@dpc
Copy link
Contributor Author

dpc commented Aug 28, 2014

I feel that leaving ten_ms public, to let user potentially discover calibrated value if it wants it, and killing CalibrationMode is simplest solution that does not sacrifice simplicity.

I'll fix using your comments and push today/tomorrow. Thanks.

@bgamari
Copy link
Contributor

bgamari commented Aug 28, 2014

@dpc I agree. systick::setup(systick::tenms().or(fallback)) seems much clearer to me than yet another type.

@dpc
Copy link
Contributor Author

dpc commented Aug 29, 2014

r?

@bharrisau
Copy link
Contributor

Looks good to me. Thanks for your good work.

@bharrisau
Copy link
Contributor

@hacknbot: merge

bharrisau added a commit that referenced this pull request Aug 29, 2014
systick: Refactoring into ioreg
@bharrisau bharrisau merged commit 75e4deb into hackndev:master Aug 29, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants