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
use drone_core::reg::{RawBits, RawValue};
use reg::{Value, PERIPHERAL_ALIAS_BASE};
const BASE: usize = 0x4002_2000;
define_reg! {
name => Acr => AcrBits,
desc => "Flash access control register.",
addr => BASE + 0x00,
alias => PERIPHERAL_ALIAS_BASE,
}
#[repr(u32)]
pub enum AcrWaitStates {
Zero = 0b000,
One = 0b001,
Two = 0b010,
}
pub trait AcrBits<T>: RawBits<Acr, T> {
fn prefetch_enable(&mut self, enable: bool) -> &mut Self {
self.write(4, enable)
}
fn half_cycle(&mut self, enable: bool) -> &mut Self {
self.write(3, enable)
}
}
impl Value<Acr> {
pub fn latency(&mut self, wait_states: AcrWaitStates) -> &mut Value<Acr> {
self.write_bits(wait_states as u32, 3, 0)
}
}