pub struct TrapConfig {
pub valid: bool,
pub level: u8,
pub port: u8,
pub pin: u8,
}
Expand description
Represents the configuration of a hardware trap.
A TrapConfig
structure holds information related to a trap configuration, including
the pin, port, level, and validity of the trap. The fields are packed into a 16-bit
integer with specific bitwise encoding. The layout of the 16-bit value is as follows:
Layout (16-bit integer):
0 8 15
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| pin | port|l| |v|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Where:
v
(bit 15) represents the validity of the trap configuration (1
for valid,0
for invalid).l
(bit 8) represents the level of the trap (0
or1
).port
(bits 5 to 7) represents the port number (3 bits, value range from 0 to 7).pin
(bits 0 to 4) represents the pin number (5 bits, value range from 0 to 31).
§Type Implementation:
TrapConfig
can be created from a 16-bit integer using theFrom<u16>
trait, and it can be converted back to a 16-bit integer using theInto<u16>
trait.
The packing and unpacking logic allows easy conversion between the TrapConfig
struct
and a single 16-bit integer, which is useful for hardware register manipulation.
Fields§
§valid: bool
Whether the trap configuration is valid (1 bit).
level: u8
The level of the trap (1 bit, 0 or 1).
port: u8
The port number (3 bits, value range: 0-7).
pin: u8
The pin number (5 bits, value range: 0-31).
Trait Implementations§
Source§impl Clone for TrapConfig
impl Clone for TrapConfig
Source§fn clone(&self) -> TrapConfig
fn clone(&self) -> TrapConfig
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for TrapConfig
impl Debug for TrapConfig
Source§impl Default for TrapConfig
impl Default for TrapConfig
Source§impl<'de> Deserialize<'de> for TrapConfig
impl<'de> Deserialize<'de> for TrapConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Into<u16> for TrapConfig
impl Into<u16> for TrapConfig
Source§impl Serialize for TrapConfig
impl Serialize for TrapConfig
impl Copy for TrapConfig
Auto Trait Implementations§
impl Freeze for TrapConfig
impl RefUnwindSafe for TrapConfig
impl Send for TrapConfig
impl Sync for TrapConfig
impl Unpin for TrapConfig
impl UnwindSafe for TrapConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more