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
orValue
&
Fields
: read some fields from the register.Default
orFieldValues::empty
: no fields’ values.
§Used with:
Reg::modify
orValue
|
FieldValues
: change the value of the specified fields.
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>
impl<R: RegisterValue, T> FieldValues<R, T>
Sourcepub unsafe fn from_raw(bits: R::Int, mask: R::Int) -> FieldValues<R, T>
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.
Sourcepub fn empty() -> FieldValues<R, T>
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>
impl<R: RegisterValue, T, U> BitAnd<T> for FieldValues<R, U>
Source§impl<R: RegisterValue, T, U> BitAndAssign<T> for FieldValues<R, U>
impl<R: RegisterValue, T, U> BitAndAssign<T> for FieldValues<R, U>
Source§fn bitand_assign(&mut self, other: T)
fn bitand_assign(&mut self, other: T)
Performs the
&=
operation. Read moreSource§impl<R: RegisterValue, T, U> BitOr<T> for FieldValues<R, U>where
T: Both<U> + Into<FieldValues<R>>,
impl<R: RegisterValue, T, U> BitOr<T> for FieldValues<R, U>where
T: Both<U> + Into<FieldValues<R>>,
Source§impl<R: RegisterValue, T, U> BitOrAssign<T> for FieldValues<R, U>where
T: Both<U, Output = U> + Into<FieldValues<R>>,
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)
fn bitor_assign(&mut self, other: T)
Performs the
|=
operation. Read moreSource§impl<R: RegisterValue, T, U> BitXor<T> for FieldValues<R, U>
impl<R: RegisterValue, T, U> BitXor<T> for FieldValues<R, U>
Source§impl<R: RegisterValue, T, U> BitXorAssign<T> for FieldValues<R, U>
impl<R: RegisterValue, T, U> BitXorAssign<T> for FieldValues<R, U>
Source§fn bitxor_assign(&mut self, other: T)
fn bitxor_assign(&mut self, other: T)
Performs the
^=
operation. Read moreSource§impl<R: RegisterValue, T> Clone for FieldValues<R, T>
impl<R: RegisterValue, T> Clone for FieldValues<R, T>
Source§fn clone(&self) -> FieldValues<R, T>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<R: RegisterValue, T> Debug for FieldValues<R, T>
impl<R: RegisterValue, T> Debug for FieldValues<R, T>
Source§impl<R: RegisterValue, T> Default for FieldValues<R, T>
impl<R: RegisterValue, T> Default for FieldValues<R, T>
Source§fn default() -> FieldValues<R, T>
fn default() -> FieldValues<R, T>
Returns the “default value” for a type. Read more
Source§impl From<Data> for FieldValues<BigRegister>
impl From<Data> for FieldValues<BigRegister>
Source§fn from(value: Data) -> FieldValues<BigRegister>
fn from(value: Data) -> FieldValues<BigRegister>
Converts to this type from the input type.
Source§impl From<Enum> for FieldValues<RegisterName>
impl From<Enum> for FieldValues<RegisterName>
Source§fn from(value: Enum) -> FieldValues<RegisterName>
fn from(value: Enum) -> FieldValues<RegisterName>
Converts to this type from the input type.
Source§impl From<EnumAll> for FieldValues<RegisterAll>
all
: on everything
impl From<EnumAll> for FieldValues<RegisterAll>
all
: on everything
Source§fn from(value: EnumAll) -> FieldValues<RegisterAll>
fn from(value: EnumAll) -> FieldValues<RegisterAll>
Converts to this type from the input type.
Source§impl From<EnumAll> for FieldValues<RegisterAll>
all
: on everything
impl From<EnumAll> for FieldValues<RegisterAll>
all
: on everything
Source§fn from(value: EnumAll) -> FieldValues<RegisterAll>
fn from(value: EnumAll) -> FieldValues<RegisterAll>
Converts to this type from the input type.
Source§impl From<EnumField> for FieldValues<RegisterField>
impl From<EnumField> for FieldValues<RegisterField>
Source§fn from(value: EnumField) -> FieldValues<RegisterField>
fn from(value: EnumField) -> FieldValues<RegisterField>
Converts to this type from the input type.
Source§impl From<EnumField> for FieldValues<RegisterField>
impl From<EnumField> for FieldValues<RegisterField>
Source§fn from(value: EnumField) -> FieldValues<RegisterField>
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
impl From<EnumImpl> for FieldValues<RegisterImpl>
impl
: only on impls
Source§fn from(value: EnumImpl) -> FieldValues<RegisterImpl>
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
impl From<EnumImpl> for FieldValues<RegisterImpl>
impl
: only on impls
Source§fn from(value: EnumImpl) -> FieldValues<RegisterImpl>
fn from(value: EnumImpl) -> FieldValues<RegisterImpl>
Converts to this type from the input type.
Source§impl From<EnumType> for FieldValues<RegisterType>
impl From<EnumType> for FieldValues<RegisterType>
Source§fn from(value: EnumType) -> FieldValues<RegisterType>
fn from(value: EnumType) -> FieldValues<RegisterType>
Converts to this type from the input type.
Source§impl From<EnumType> for FieldValues<RegisterType>
impl From<EnumType> for FieldValues<RegisterType>
Source§fn from(value: EnumType) -> FieldValues<RegisterType>
fn from(value: EnumType) -> FieldValues<RegisterType>
Converts to this type from the input type.
Source§impl From<ExternAll> for FieldValues<RegisterAll>
all
: on everything
impl From<ExternAll> for FieldValues<RegisterAll>
all
: on everything
Source§fn from(value: ExternAll) -> FieldValues<RegisterAll>
fn from(value: ExternAll) -> FieldValues<RegisterAll>
Converts to this type from the input type.
Source§impl From<ExternField> for FieldValues<RegisterField>
impl From<ExternField> for FieldValues<RegisterField>
Source§fn from(value: ExternField) -> FieldValues<RegisterField>
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
impl From<ExternImpl> for FieldValues<RegisterImpl>
impl
: only on impls
Source§fn from(value: ExternImpl) -> FieldValues<RegisterImpl>
fn from(value: ExternImpl) -> FieldValues<RegisterImpl>
Converts to this type from the input type.
Source§impl From<ExternType> for FieldValues<RegisterType>
impl From<ExternType> for FieldValues<RegisterType>
Source§fn from(value: ExternType) -> FieldValues<RegisterType>
fn from(value: ExternType) -> FieldValues<RegisterType>
Converts to this type from the input type.
Source§impl From<Mode> for FieldValues<BigRegister>
impl From<Mode> for FieldValues<BigRegister>
Source§fn from(value: Mode) -> FieldValues<BigRegister>
fn from(value: Mode) -> FieldValues<BigRegister>
Converts to this type from the input type.
Source§impl From<Newtype> for FieldValues<RegisterName, Toggle>
impl From<Newtype> for FieldValues<RegisterName, Toggle>
Source§fn from(value: Newtype) -> FieldValues<RegisterName, Toggle>
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
impl From<NewtypeAll> for FieldValues<RegisterAll, Toggle>
all
: on everything
Source§fn from(value: NewtypeAll) -> FieldValues<RegisterAll, Toggle>
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
impl From<NewtypeAll> for FieldValues<RegisterAll, Toggle>
all
: on everything
Source§fn from(value: NewtypeAll) -> FieldValues<RegisterAll, Toggle>
fn from(value: NewtypeAll) -> FieldValues<RegisterAll, Toggle>
Converts to this type from the input type.
Source§impl From<NewtypeField> for FieldValues<RegisterField, Toggle>
impl From<NewtypeField> for FieldValues<RegisterField, Toggle>
Source§fn from(value: NewtypeField) -> FieldValues<RegisterField, Toggle>
fn from(value: NewtypeField) -> FieldValues<RegisterField, Toggle>
Converts to this type from the input type.
Source§impl From<NewtypeField> for FieldValues<RegisterField, Toggle>
impl From<NewtypeField> for FieldValues<RegisterField, Toggle>
Source§fn from(value: NewtypeField) -> FieldValues<RegisterField, Toggle>
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
impl From<NewtypeImpl> for FieldValues<RegisterImpl, Toggle>
impl
: only on impls
Source§fn from(value: NewtypeImpl) -> FieldValues<RegisterImpl, Toggle>
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
impl From<NewtypeImpl> for FieldValues<RegisterImpl, Toggle>
impl
: only on impls
Source§fn from(value: NewtypeImpl) -> FieldValues<RegisterImpl, Toggle>
fn from(value: NewtypeImpl) -> FieldValues<RegisterImpl, Toggle>
Converts to this type from the input type.
Source§impl From<NewtypeType> for FieldValues<RegisterType, Toggle>
impl From<NewtypeType> for FieldValues<RegisterType, Toggle>
Source§fn from(value: NewtypeType) -> FieldValues<RegisterType, Toggle>
fn from(value: NewtypeType) -> FieldValues<RegisterType, Toggle>
Converts to this type from the input type.
Source§impl From<NewtypeType> for FieldValues<RegisterType, Toggle>
impl From<NewtypeType> for FieldValues<RegisterType, Toggle>
Source§fn from(value: NewtypeType) -> FieldValues<RegisterType, Toggle>
fn from(value: NewtypeType) -> FieldValues<RegisterType, Toggle>
Converts to this type from the input type.
Source§impl From<Small<Data>> for FieldValues<SmallRegister>
impl From<Small<Data>> for FieldValues<SmallRegister>
Source§fn from(value: Small<Data>) -> FieldValues<SmallRegister>
fn from(value: Small<Data>) -> FieldValues<SmallRegister>
Converts to this type from the input type.
Source§impl From<Small<Mode>> for FieldValues<SmallRegister>
impl From<Small<Mode>> for FieldValues<SmallRegister>
Source§fn from(value: Small<Mode>) -> FieldValues<SmallRegister>
fn from(value: Small<Mode>) -> FieldValues<SmallRegister>
Converts to this type from the input type.
Source§impl From<Small<State>> for FieldValues<SmallRegister, Toggle>
impl From<Small<State>> for FieldValues<SmallRegister, Toggle>
Source§fn from(value: Small<State>) -> FieldValues<SmallRegister, Toggle>
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>
impl From<Small<Status>> for FieldValues<SmallRegister, Toggle>
Source§fn from(value: Small<Status>) -> FieldValues<SmallRegister, Toggle>
fn from(value: Small<Status>) -> FieldValues<SmallRegister, Toggle>
Converts to this type from the input type.
Source§impl From<State> for FieldValues<BigRegister, Toggle>
impl From<State> for FieldValues<BigRegister, Toggle>
Source§fn from(value: State) -> FieldValues<BigRegister, Toggle>
fn from(value: State) -> FieldValues<BigRegister, Toggle>
Converts to this type from the input type.
Source§impl From<Status> for FieldValues<BigRegister, Toggle>
impl From<Status> for FieldValues<BigRegister, Toggle>
Source§fn from(value: Status) -> FieldValues<BigRegister, Toggle>
fn from(value: Status) -> FieldValues<BigRegister, Toggle>
Converts to this type from the input type.
Source§impl<R: RegisterValue, T: Into<FieldValues<R, Toggle>>> From<T> for FieldValues<R, ()>
impl<R: RegisterValue, T: Into<FieldValues<R, Toggle>>> From<T> for FieldValues<R, ()>
Source§fn from(bits: T) -> FieldValues<R, ()>
fn from(bits: T) -> FieldValues<R, ()>
Converts to this type from the input type.
Source§impl From<Type> for FieldValues<RegisterName>
impl From<Type> for FieldValues<RegisterName>
Source§fn from(value: Type) -> FieldValues<RegisterName>
fn from(value: Type) -> FieldValues<RegisterName>
Converts to this type from the input type.
Source§impl<R: RegisterValue, T> MayToggle for FieldValues<R, T>
impl<R: RegisterValue, T> MayToggle for FieldValues<R, T>
Source§impl<R: RegisterValue> Not for FieldValues<R, Toggle>
impl<R: RegisterValue> Not for FieldValues<R, Toggle>
Source§impl<R: RegisterValue, T: Into<FieldValues<R>> + Copy, U> PartialEq<T> for FieldValues<R, U>
impl<R: RegisterValue, T: Into<FieldValues<R>> + Copy, U> PartialEq<T> for FieldValues<R, U>
impl<R: RegisterValue, T> Copy for FieldValues<R, T>
impl<R: RegisterValue> Eq for FieldValues<R, ()>
impl<R: RegisterValue> Eq for FieldValues<R, Toggle>
Auto Trait Implementations§
impl<R, T> Freeze for FieldValues<R, T>
impl<R, T> RefUnwindSafe for FieldValues<R, T>
impl<R, T> Send for FieldValues<R, T>
impl<R, T> Sync for FieldValues<R, T>
impl<R, T> Unpin for FieldValues<R, T>
impl<R, T> UnwindSafe for FieldValues<R, T>
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