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

Commit

Permalink
Add function to get the current value of systick
Browse files Browse the repository at this point in the history
The k20 example app doesn't use an interrupt, so it needs the systick
value.
  • Loading branch information
bharrisau committed Jul 15, 2014
1 parent 8da190e commit eed6b97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/app_blink_k20.rs
Expand Up @@ -13,10 +13,10 @@ use zinc::hal::cortex_m4::systick;
/// Wait the given number of SysTick ticks
pub fn wait(ticks: u32) {
let mut n = ticks;
let mut t = systick::reg::SYSTICK.CURRENT();
let mut t = systick::get_current();
loop {
if systick::reg::SYSTICK.CURRENT() > t {
t = systick::reg::SYSTICK.CURRENT();
if systick::get_current() > t {
t = systick::get_current();
n -= 1;
if n == 0 {
break;
Expand Down
5 changes: 5 additions & 0 deletions src/hal/cortex_common/systick.rs
Expand Up @@ -56,6 +56,11 @@ pub fn disable_irq() {
reg::SYSTICK.set_CONTROL(reg::SYSTICK.CONTROL() & !0b010);
}

/// Gets the current systick value
pub fn get_current() -> u32 {
reg::SYSTICK.CURRENT()
}

mod reg {
use lib::volatile_cell::VolatileCell;

Expand Down

6 comments on commit eed6b97

@farcaller
Copy link
Member

Choose a reason for hiding this comment

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

r+

@hacknbot
Copy link
Contributor

Choose a reason for hiding this comment

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

saw approval from farcaller
at bharrisau@eed6b97

@hacknbot
Copy link
Contributor

Choose a reason for hiding this comment

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

merging bharrisau/zinc/cortex-commons = eed6b97 into auto

@hacknbot
Copy link
Contributor

Choose a reason for hiding this comment

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

bharrisau/zinc/cortex-commons = eed6b97 merged ok, testing candidate = 4556ab4

@hacknbot
Copy link
Contributor

Choose a reason for hiding this comment

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

@hacknbot
Copy link
Contributor

Choose a reason for hiding this comment

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

fast-forwarding master to auto = 4556ab4

Please sign in to comment.