Struct FieldValues

Source
pub struct FieldValues<R: RegisterValue, T = ()> { /* private fields */ }
Expand description

Some fields’ values read from or to be written to a register

§Created by:

  • Combining (with |) fields values generated by the [periph!], [register!] or [field_type!] macros.
  • Reg::fields or Value&Fields: read some fields from the register.
  • Default or FieldValues::empty: no fields’ values.

§Used with:

These field values can be combined together with |.

§Example

use peripherals::{register, FieldValues, Fields, Value};

register! {
    Register: u8 = 0b1001 {
        BIT1: 0 = struct Bit1(bool);
        BIT2: 1 = struct Bit2(bool);
        TWO_BITS: 2..3 = struct TwoBits(u8);
    }
}

// Obtain it with the `empty` method or by combining field values
let empty = FieldValues::<Register>::empty();
assert_eq!(empty.bits(), 0b0000);
assert_eq!(empty.fields(), Fields::<Register>::empty());
let bits_12 = Bit1(false) | Bit2(true);
assert_eq!(bits_12.bits(), 0b0010);
assert_eq!(bits_12.fields(), Register::BIT1 | Register::BIT2);
let values = Bit1(true) | TwoBits(0b01);
assert_eq!(values.bits(), 0b0101);
assert_eq!(values.fields(), Register::BIT1 | Register::TWO_BITS);

// Use it to modify values
let mut value = Value::<Register>::reset();
assert_eq!(value.value(), 0b1001);
value |= bits_12;
assert_eq!(value.value(), 0b1010);
value |= values;
assert_eq!(value.value(), 0b0111);

Implementations§

Source§

impl<R: RegisterValue, T> FieldValues<R, T>

Source

pub fn bits(self) -> R::Int

Get the raw bits to set

Source

pub fn mask(self) -> R::Int

Get the raw mask

Source

pub fn fields(self) -> Fields<R, T>

Get the fields specified in this value

Source

pub unsafe fn from_raw(bits: R::Int, mask: R::Int) -> FieldValues<R, T>

Build from raw bits and mask

§Safety

You must ensure the value and mask are valid for the fields of the associated register.

Source

pub fn empty() -> FieldValues<R, T>

No fields’ values (doesn’t change anything when used to modify a register)

Trait Implementations§

Source§

impl<R: RegisterValue, T, U> BitAnd<T> for FieldValues<R, U>
where T: Either<U> + Into<Fields<R>>,

Source§

type Output = FieldValues<R, <T as Either<U>>::Output>

The resulting type after applying the & operator.
Source§

fn bitand(self, other: T) -> Self::Output

Performs the & operation. Read more
Source§

impl<R: RegisterValue, T, U> BitAndAssign<T> for FieldValues<R, U>
where T: Either<U, Output = U> + Into<Fields<R>>,

Source§

fn bitand_assign(&mut self, other: T)

Performs the &= operation. Read more
Source§

impl<R: RegisterValue, T, U> BitOr<T> for FieldValues<R, U>
where T: Both<U> + Into<FieldValues<R>>,

Source§

type Output = FieldValues<R, <T as Both<U>>::Output>

The resulting type after applying the | operator.
Source§

fn bitor(self, other: T) -> Self::Output

Performs the | operation. Read more
Source§

impl<R: RegisterValue, T, U> BitOrAssign<T> for FieldValues<R, U>
where T: Both<U, Output = U> + Into<FieldValues<R>>,

Source§

fn bitor_assign(&mut self, other: T)

Performs the |= operation. Read more
Source§

impl<R: RegisterValue, T, U> BitXor<T> for FieldValues<R, U>
where T: Either<U, Output = Toggle> + Into<Fields<R>>,

Source§

type Output = FieldValues<R, U>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: T) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<R: RegisterValue, T, U> BitXorAssign<T> for FieldValues<R, U>
where T: Either<U, Output = Toggle> + Into<Fields<R>>,

Source§

fn bitxor_assign(&mut self, other: T)

Performs the ^= operation. Read more
Source§

impl<R: RegisterValue, T> Clone for FieldValues<R, T>

Source§

fn clone(&self) -> FieldValues<R, T>

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<R: RegisterValue, T> Debug for FieldValues<R, T>

Source§

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

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

impl<R: RegisterValue, T> Default for FieldValues<R, T>

Source§

fn default() -> FieldValues<R, T>

Returns the “default value” for a type. Read more
Source§

impl From<CfgFlag> for FieldValues<CONFIG, Toggle>

Source§

fn from(value: CfgFlag) -> FieldValues<CONFIG, Toggle>

Converts to this type from the input type.
Source§

impl From<Data> for FieldValues<BUFFER>

Source§

fn from(value: Data) -> FieldValues<BUFFER>

Converts to this type from the input type.
Source§

impl From<Data> for FieldValues<BigRegister>

Source§

fn from(value: Data) -> FieldValues<BigRegister>

Converts to this type from the input type.
Source§

impl From<Enum> for FieldValues<Register>

Source§

fn from(value: Enum) -> FieldValues<Register>

Converts to this type from the input type.
Source§

impl From<Enum> for FieldValues<Register>

Source§

fn from(value: Enum) -> FieldValues<Register>

Converts to this type from the input type.
Source§

impl From<Enum> for FieldValues<RegisterName>

Source§

fn from(value: Enum) -> FieldValues<RegisterName>

Converts to this type from the input type.
Source§

impl From<EnumAll> for FieldValues<RegisterAll>

all: on everything

Source§

fn from(value: EnumAll) -> FieldValues<RegisterAll>

Converts to this type from the input type.
Source§

impl From<EnumAll> for FieldValues<RegisterAll>

all: on everything

Source§

fn from(value: EnumAll) -> FieldValues<RegisterAll>

Converts to this type from the input type.
Source§

impl From<EnumField> for FieldValues<RegisterField>

Source§

fn from(value: EnumField) -> FieldValues<RegisterField>

Converts to this type from the input type.
Source§

impl From<EnumField> for FieldValues<RegisterField>

Source§

fn from(value: EnumField) -> FieldValues<RegisterField>

Converts to this type from the input type.
Source§

impl From<EnumImpl> for FieldValues<RegisterImpl>

impl: only on impls

Source§

fn from(value: EnumImpl) -> FieldValues<RegisterImpl>

Converts to this type from the input type.
Source§

impl From<EnumImpl> for FieldValues<RegisterImpl>

impl: only on impls

Source§

fn from(value: EnumImpl) -> FieldValues<RegisterImpl>

Converts to this type from the input type.
Source§

impl From<EnumType> for FieldValues<RegisterType>

Source§

fn from(value: EnumType) -> FieldValues<RegisterType>

Converts to this type from the input type.
Source§

impl From<EnumType> for FieldValues<RegisterType>

Source§

fn from(value: EnumType) -> FieldValues<RegisterType>

Converts to this type from the input type.
Source§

impl From<Extern> for FieldValues<Register>

Source§

fn from(value: Extern) -> FieldValues<Register>

Converts to this type from the input type.
Source§

impl From<ExternAll> for FieldValues<RegisterAll>

all: on everything

Source§

fn from(value: ExternAll) -> FieldValues<RegisterAll>

Converts to this type from the input type.
Source§

impl From<ExternField> for FieldValues<RegisterField>

Source§

fn from(value: ExternField) -> FieldValues<RegisterField>

Converts to this type from the input type.
Source§

impl From<ExternImpl> for FieldValues<RegisterImpl>

impl: only on impls

Source§

fn from(value: ExternImpl) -> FieldValues<RegisterImpl>

Converts to this type from the input type.
Source§

impl From<ExternType> for FieldValues<RegisterType>

Source§

fn from(value: ExternType) -> FieldValues<RegisterType>

Converts to this type from the input type.
Source§

impl From<Mode> for FieldValues<BigRegister>

Source§

fn from(value: Mode) -> FieldValues<BigRegister>

Converts to this type from the input type.
Source§

impl From<Mode> for FieldValues<CONFIG>

Source§

fn from(value: Mode) -> FieldValues<CONFIG>

Converts to this type from the input type.
Source§

impl From<Newtype> for FieldValues<Register, Toggle>

Source§

fn from(value: Newtype) -> FieldValues<Register, Toggle>

Converts to this type from the input type.
Source§

impl From<Newtype> for FieldValues<Register, Toggle>

Source§

fn from(value: Newtype) -> FieldValues<Register, Toggle>

Converts to this type from the input type.
Source§

impl From<Newtype> for FieldValues<RegisterName, Toggle>

Source§

fn from(value: Newtype) -> FieldValues<RegisterName, Toggle>

Converts to this type from the input type.
Source§

impl From<NewtypeAll> for FieldValues<RegisterAll, Toggle>

all: on everything

Source§

fn from(value: NewtypeAll) -> FieldValues<RegisterAll, Toggle>

Converts to this type from the input type.
Source§

impl From<NewtypeAll> for FieldValues<RegisterAll, Toggle>

all: on everything

Source§

fn from(value: NewtypeAll) -> FieldValues<RegisterAll, Toggle>

Converts to this type from the input type.
Source§

impl From<NewtypeField> for FieldValues<RegisterField, Toggle>

Source§

fn from(value: NewtypeField) -> FieldValues<RegisterField, Toggle>

Converts to this type from the input type.
Source§

impl From<NewtypeField> for FieldValues<RegisterField, Toggle>

Source§

fn from(value: NewtypeField) -> FieldValues<RegisterField, Toggle>

Converts to this type from the input type.
Source§

impl From<NewtypeImpl> for FieldValues<RegisterImpl, Toggle>

impl: only on impls

Source§

fn from(value: NewtypeImpl) -> FieldValues<RegisterImpl, Toggle>

Converts to this type from the input type.
Source§

impl From<NewtypeImpl> for FieldValues<RegisterImpl, Toggle>

impl: only on impls

Source§

fn from(value: NewtypeImpl) -> FieldValues<RegisterImpl, Toggle>

Converts to this type from the input type.
Source§

impl From<NewtypeType> for FieldValues<RegisterType, Toggle>

Source§

fn from(value: NewtypeType) -> FieldValues<RegisterType, Toggle>

Converts to this type from the input type.
Source§

impl From<NewtypeType> for FieldValues<RegisterType, Toggle>

Source§

fn from(value: NewtypeType) -> FieldValues<RegisterType, Toggle>

Converts to this type from the input type.
Source§

impl From<Small<Data>> for FieldValues<SmallRegister>

Source§

fn from(value: Small<Data>) -> FieldValues<SmallRegister>

Converts to this type from the input type.
Source§

impl From<Small<Mode>> for FieldValues<SmallRegister>

Source§

fn from(value: Small<Mode>) -> FieldValues<SmallRegister>

Converts to this type from the input type.
Source§

impl From<Small<State>> for FieldValues<SmallRegister, Toggle>

Source§

fn from(value: Small<State>) -> FieldValues<SmallRegister, Toggle>

Converts to this type from the input type.
Source§

impl From<Small<Status>> for FieldValues<SmallRegister, Toggle>

Source§

fn from(value: Small<Status>) -> FieldValues<SmallRegister, Toggle>

Converts to this type from the input type.
Source§

impl From<StatFlag> for FieldValues<STATUS, Toggle>

Source§

fn from(value: StatFlag) -> FieldValues<STATUS, Toggle>

Converts to this type from the input type.
Source§

impl From<State> for FieldValues<BigRegister, Toggle>

Source§

fn from(value: State) -> FieldValues<BigRegister, Toggle>

Converts to this type from the input type.
Source§

impl From<Status> for FieldValues<BigRegister, Toggle>

Source§

fn from(value: Status) -> FieldValues<BigRegister, Toggle>

Converts to this type from the input type.
Source§

impl From<Status> for FieldValues<STATUS>

Source§

fn from(value: Status) -> FieldValues<STATUS>

Converts to this type from the input type.
Source§

impl<R: RegisterValue, T: Into<FieldValues<R, Toggle>>> From<T> for FieldValues<R, ()>

Source§

fn from(bits: T) -> FieldValues<R, ()>

Converts to this type from the input type.
Source§

impl From<Type> for FieldValues<RegisterName>

Source§

fn from(value: Type) -> FieldValues<RegisterName>

Converts to this type from the input type.
Source§

impl<R: RegisterValue, T> MayToggle for FieldValues<R, T>

Source§

type Toggle = T

Toggle if it can be toggled, () otherwise
Source§

impl<R: RegisterValue> Not for FieldValues<R, Toggle>

Source§

type Output = FieldValues<R, Toggle>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self

Performs the unary ! operation. Read more
Source§

impl<R: RegisterValue, T: Into<FieldValues<R>> + Copy, U> PartialEq<T> for FieldValues<R, U>

Source§

fn eq(&self, other: &T) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<R: RegisterValue, T> Copy for FieldValues<R, T>

Source§

impl<R: RegisterValue> Eq for FieldValues<R, ()>

Source§

impl<R: RegisterValue> Eq for FieldValues<R, Toggle>

Auto Trait Implementations§

§

impl<R, T> Freeze for FieldValues<R, T>
where <R as RegisterValue>::Int: Freeze,

§

impl<R, T> RefUnwindSafe for FieldValues<R, T>

§

impl<R, T> Send for FieldValues<R, T>
where <R as RegisterValue>::Int: Send, R: Send, T: Send,

§

impl<R, T> Sync for FieldValues<R, T>
where <R as RegisterValue>::Int: Sync, R: Sync, T: Sync,

§

impl<R, T> Unpin for FieldValues<R, T>
where <R as RegisterValue>::Int: Unpin, R: Unpin, T: Unpin,

§

impl<R, T> UnwindSafe for FieldValues<R, T>

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, 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.