amebazii::types::image::pt

Struct TrapConfig

Source
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 or 1).
  • 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 the From<u16> trait, and it can be converted back to a 16-bit integer using the Into<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

Source§

fn clone(&self) -> TrapConfig

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TrapConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TrapConfig

Source§

fn default() -> Self

Returns a default TrapConfig with all fields set to 0 or false.

Source§

impl<'de> Deserialize<'de> for TrapConfig

Source§

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 From<u16> for TrapConfig

Source§

fn from(value: u16) -> Self

Converts a 16-bit integer to a TrapConfig by unpacking the respective bits according to the layout described above.

§Arguments:
  • value: The 16-bit integer to convert into a TrapConfig.
§Returns:

A TrapConfig where each field is populated based on the respective bits in the 16-bit integer.

Source§

impl Into<u16> for TrapConfig

Source§

fn into(self) -> u16

Converts a TrapConfig back into a 16-bit integer by packing the fields into their respective bit positions.

§Returns:

A 16-bit integer representing the packed values of the TrapConfig fields.

Source§

impl Serialize for TrapConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for TrapConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,