Skip to content

Better delay description #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 8, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ pub fn bkpt() {

/// Blocks the program for *at least* `n` instruction cycles
///
/// This is implemented in assembly so its execution time is the same regardless of the optimization
/// level.
/// This is implemented in assembly so its execution time is independent of the optimization
/// level, however it is dependent on the specific architecture and core configuration.
///
/// NOTE that the delay can take much longer if interrupts are serviced during its execution.
/// NOTE that the delay can take much longer if interrupts are serviced during its execution
/// and the execution time may wary with other factors. This delay is mainly useful for simple
/// timer-less initialisation of peripherals iff accurate timing is not essential. In any other
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// timer-less initialisation of peripherals iff accurate timing is not essential. In any other
/// timer-less initialization of peripherals if accurate timing is not essential. In any other

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, the iff is intended. I'm fine with changing the spelling to AE.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe expand it to "if and only if" then? iff tends to confuse people.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I've never met anyone who was confused about that but sure, why not.

/// case please use more accurate methods to cause a delay.
#[inline]
pub fn delay(_n: u32) {
// NOTE(divide by 4) is easier to compute than `/ 3` is it's just a shift (`>> 2`).
// NOTE(divide by 4) is easier to compute than `/ 3` because it's just a shift (`>> 2`).
match () {
#[cfg(all(cortex_m, feature = "inline-asm"))]
() => unsafe {
Expand Down