lpc55s6x_hal/traits.rs
1// TODO: is this renaming confusing?
2// Using the name as is is not so nice
3// `wg` is for "Rust Embedded Working Group (WG)"
4// TODO: this pulls in the not-very-well-organised
5// entire library, in particular not just traits and types.
6// Would be worth being more explicit.
7pub use embedded_hal as wg;
8
9// TODO: Add more as needed,
10// - internal
11// - specific (CASPER, PUF, etc.)
12// - experiments
13// - etc.
14//
15// Idea is to try and have (peripheral) drivers implement
16// a well-designed trait.
17
18// pub use flash;
19
20pub mod reg_proxy {
21 /// Implemented for registers that `RegProxy` can proxy
22 ///
23 /// Use the `reg!` macro to implement this trait for a register from a crate
24 /// generated by svd2rust.
25 ///
26 /// Safety: The pointer returned by `get` must be valid for the duration of the program.
27 pub unsafe trait Reg {
28 /// The type that `RegProxy` should derefence to
29 ///
30 /// If only one instance of the register exists, this should be `Self`.
31 /// If the same type in the svd2rust API is used to represent registers at
32 /// multiple memory locations, this trait must be implemented for a type
33 /// that represents a specific register at a specific location, and `Target`
34 /// must be the common type.
35 type Target;
36
37 /// Return a pointer to the memory location of the register
38 fn get() -> *const Self::Target;
39 }
40
41 pub unsafe trait RegCluster {
42 /// The type that `RegProxy` should derefence to
43 ///
44 /// If only one instance of the register exists, this should be `Self`.
45 /// If the same type in the svd2rust API is used to represent registers at
46 /// multiple memory locations, this trait must be implemented for a type
47 /// that represents a specific register at a specific location, and `Target`
48 /// must be the common type.
49 type Target;
50
51 /// Return a pointer to the memory location of the register
52 fn get() -> *const [Self::Target];
53 }
54
55}