lpc55_hal/peripherals/
casper.rs

1use crate::{peripherals::syscon, raw, typestates::init_state};
2
3crate::wrap_stateful_peripheral!(Casper, CASPER);
4
5impl<State> Casper<State> {
6    pub fn enabled(mut self, syscon: &mut syscon::Syscon) -> Casper<init_state::Enabled> {
7        syscon.enable_clock(&mut self.raw);
8        syscon.reset(&mut self.raw);
9        Casper {
10            raw: self.raw,
11            _state: init_state::Enabled(()),
12        }
13    }
14
15    pub fn disabled(mut self, syscon: &mut syscon::Syscon) -> Casper<init_state::Disabled> {
16        syscon.disable_clock(&mut self.raw);
17        Casper {
18            raw: self.raw,
19            _state: init_state::Disabled,
20        }
21    }
22}
23
24pub enum Operations {
25    /// Walking 1 or more of J loop, doing r=a*b using 64x64=128
26    Mul6464NoSum = 0x01,
27    /// Walking 1 or more of J loop, doing c,r=r+a*b using 64x64=128, but assume inner j loop
28    Mul6464Sum = 0x02,
29    /// Walking 1 or more of J loop, doing c,r=r+a*b using 64x64=128, but sum all of w.
30    Mul6464FullSum = 0x03,
31    /// Walking 1 or more of J loop, doing c,r[-1]=r+a*b using 64x64=128, but skip 1st write
32    Mul6464Reduce = 0x04,
33    /// Walking add with off_AB, and in/out off_RES doing c,r=r+a+c using 64+64=65
34    Add64 = 0x08,
35    /// Walking subtract with off_AB, and in/out off_RES doing r=r-a uding 64-64=64,
36    /// with last borrow implicit if any
37    Sub64 = 0x09,
38    /// Walking add to self with off_RES doing c,r=r+r+c using 64+64=65
39    Double64 = 0x0A,
40    /// Walking XOR with off_AB, and in/out off_RES doing r=r^a using 64^64=64
41    Xor64 = 0x0B,
42    /// Walking shift left doing r1,r=(b*D)|r1, where D is 2^amt and is loaded
43    /// by app (off_CD not used)
44    ShiftLeft32 = 0x10,
45    /// Walking shift right doing r,r1=(b*D)|r1, where D is 2^(32-amt) and is loaded
46    /// by app (off_CD not used) and off_RES starts at MSW
47    ShiftRight32 = 0x11,
48    /// Copy from ABoff to resoff, 64b at a time
49    Copy = 0x14,
50    /// Copy and mask from ABoff to resoff, 64b at a time
51    Remask = 0x15,
52    /// Compare two arrays, running all the way to the end
53    Compare = 0x16,
54    /// Compare two arrays, stopping on 1st !=^
55    CompareFast = 0x17,
56}