pub struct Reg<R, P> { /* private fields */ }
Expand description
Base struct for all registers
This is the struct that allows to read and write registers. It is created as part of the
peripheral struct generated by the [periph!
] macro. The type parameters indicate the actual
register and the peripheral it belongs to.
Implementations§
Source§impl<R: Register, P: Peripheral> Reg<R, P>
impl<R: Register, P: Peripheral> Reg<R, P>
Source§impl<R: ReadRegister, P: Peripheral> Reg<R, P>
impl<R: ReadRegister, P: Peripheral> Reg<R, P>
Sourcepub fn read(&self) -> Value<R::Value>
pub fn read(&self) -> Value<R::Value>
Read the current value of this register
This returns a Value
, which can be used to read fields or modified and written back.
Sourcepub fn field<T>(&self, field: Field<R::Value, T, R::Int>) -> T
pub fn field<T>(&self, field: Field<R::Value, T, R::Int>) -> T
Read the given field
Same as register.read().field(fields)
. See Value::field
for more details.
Sourcepub fn fields<F: Into<Fields<R::Value>> + MayToggle>(
&self,
fields: F,
) -> FieldValues<R::Value, F::Toggle>
pub fn fields<F: Into<Fields<R::Value>> + MayToggle>( &self, fields: F, ) -> FieldValues<R::Value, F::Toggle>
Read the given fields
Same as register.read() & fields
. See Value
for more details.
Sourcepub fn test<B: Into<FieldValues<R::Value>>>(&self, bits: B) -> bool
pub fn test<B: Into<FieldValues<R::Value>>>(&self, bits: B) -> bool
Test the value of the given fields
Same as register.read().test(bits)
. See Value::test
for more details.
Source§impl<R: WriteRegister, P: Peripheral> Reg<R, P>
impl<R: WriteRegister, P: Peripheral> Reg<R, P>
Source§impl<R: ReadRegister + WriteRegister, P: Peripheral> Reg<R, P>
impl<R: ReadRegister + WriteRegister, P: Peripheral> Reg<R, P>
Sourcepub fn modify<B: Into<FieldValues<R::Value>>>(&mut self, bits: B)
pub fn modify<B: Into<FieldValues<R::Value>>>(&mut self, bits: B)
Modify the given fields
This takes any field defined for this register by the [periph!
] macro. These fields can
also be combined with the |
operator.