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
#![allow(non_snake_case)]
use tock_registers::registers::{ReadOnly, ReadWrite, WriteOnly};

#[repr(C)]
pub struct Sp804 {
    pub Timer1Load: ReadWrite<u32>,
    pub Timer1Value: ReadOnly<u32>,
    pub Timer1Control: ReadWrite<u32, Control::Register>,
    pub Timer1IntClr: WriteOnly<u32>,
    pub Timer1RIS: ReadOnly<u32>,
    pub Timer1MIS: ReadOnly<u32>,
    pub Timer1BGLoad: ReadWrite<u32>,
    _reserved1: u32,
    pub Timer2Load: ReadWrite<u32>,
    pub Timer2Value: ReadOnly<u32>,
    pub Timer2Control: ReadWrite<u32, Control::Register>,
    pub Timer2IntClr: WriteOnly<u32>,
    pub Timer2RIS: ReadOnly<u32>,
    pub Timer2MIS: ReadOnly<u32>,
    pub Timer2BGLoad: ReadWrite<u32>,
    _reserved2: u32,
}

tock_registers::register_bitfields! {u32,
    pub Control [
        /// Selects one-shot or wrapping counter mode
        OneShot OFFSET(0) NUMBITS(1) [
            Wrapping = 0,
            OneShot = 1
        ],

        /// Selects 16/32 bit counter operation
        TimerSize OFFSET(1) NUMBITS(1) [
            SixteenBits = 0,
            ThirtyTwoBits = 1
        ],

        /// Prescale bits
        TimerPre OFFSET(2) NUMBITS(2) [
            DivideBy1 = 0b00,
            DivideBy16 = 0b01,
            DivideBy256 = 0b10
        ],

        /// Interrupt enable bit
        IntEnable OFFSET(5) NUMBITS(1) [
            Disable = 0,
            Enable = 1
        ],

        /// Mode bit
        TimerMode OFFSET(6) NUMBITS(1) [
            FreeRunning = 0,
            Periodic = 1
        ],

        /// Enable bit
        TimerEn OFFSET(7) NUMBITS(1) [
            Disable = 0,
            Enable = 1
        ]
    ]
}