1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! SysTick timer

use super::prelude::*;

reg! {
  [0xE000_E010] u32
  #[doc = "SysTick control and status register"]
  Ctrl
  #[doc = "SysTick control and status register"]
  CtrlValue
  RReg {} WReg {}
}

impl CtrlValue {
  /// Returns `true` if timer counted to `0` since last time this was read
  pub fn countflag(&self) -> bool {
    self.bit(16)
  }

  /// Clock source selection
  pub fn clksource(&self) -> bool {
    self.bit(2)
  }

  /// Clock source selection
  pub fn set_clksource(&mut self, value: bool) -> &mut Self {
    self.set_bit(2, value)
  }

  /// SysTick exception request enable
  pub fn tickint(&self) -> bool {
    self.bit(1)
  }

  /// SysTick exception request enable
  pub fn set_tickint(&mut self, value: bool) -> &mut Self {
    self.set_bit(1, value)
  }

  /// Counter enable
  pub fn enable(&self) -> bool {
    self.bit(0)
  }

  /// Counter enable
  pub fn set_enable(&mut self, value: bool) -> &mut Self {
    self.set_bit(0, value)
  }
}

reg! {
  [0xE000_E014] u32
  #[doc = "SysTick reload value register"]
  Load
  #[doc = "SysTick reload value register"]
  LoadValue
  RReg {} WReg {}
}

impl LoadValue {
  /// RELOAD value
  pub fn reload(&self) -> u32 {
    self.bits(0, 24)
  }

  /// RELOAD value
  pub fn set_reload(&mut self, value: u32) -> &mut Self {
    self.set_bits(0, 24, value)
  }
}