Struct peripherals::Reg[][src]

pub struct Reg<R, P> { /* fields omitted */ }
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

impl<R: Register, P: Peripheral> Reg<R, P>[src]

pub fn ptr(&self) -> *const R::Int[src]

Get a raw pointer to the register

pub fn ptr_mut(&mut self) -> *mut R::Int[src]

Get a mutable raw pointer to the register

pub fn into_dyn(self) -> &'static mut DynReg<R>[src]

Erase peripheral information

This allows to choose at runtime which instance of a peripheral to use.

impl<R: ReadRegister, P: Peripheral> Reg<R, P>[src]

pub fn read(&self) -> Value<R::Value>[src]

Read the current value of this register

This returns a Value, which can be used to read fields or modified and written back.

pub fn field<T>(&self, field: Field<R::Value, T, R::Int>) -> T where
    R::Int: TryInto<T>,
    <R::Int as TryInto<T>>::Error: Debug
[src]

Read the given field

Same as register.read().field(fields). See Value::field for more details.

pub fn fields<F: Into<Fields<R::Value>> + MayToggle>(
    &self,
    fields: F
) -> FieldValues<R::Value, F::Toggle>
[src]

Read the given fields

Same as register.read() & fields. See Value for more details.

pub fn test<B: Into<FieldValues<R::Value>>>(&self, bits: B) -> bool[src]

Test the value of the given fields

Same as register.read().test(bits). See Value::test for more details.

impl<R: WriteRegister, P: Peripheral> Reg<R, P>[src]

pub fn write(&mut self, value: Value<R::Value>)[src]

Write a value to this register

This takes a Value, which can be read from a register or created with Default.

pub fn reset(&mut self)[src]

Reset this register

This set the register to the value it has right after a reset or a boot.

impl<R: ReadRegister + WriteRegister, P: Peripheral> Reg<R, P>[src]

pub fn modify<B: Into<FieldValues<R::Value>>>(&mut self, bits: B)[src]

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.

pub fn toggle<F: Into<Fields<R::Value, Toggle>>>(&mut self, fields: F)[src]

Toggle the given fields

This takes a toggleable field defined for this register by the periph! macro. These fields can also be combined with the | operator.

Trait Implementations

impl<R: Register, P: Peripheral> Debug for Reg<R, P>[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<R, P> Send for Reg<R, P> where
    P: Send,
    R: Send

impl<R, P> Sync for Reg<R, P> where
    P: Sync,
    R: Sync

impl<R, P> Unpin for Reg<R, P> where
    P: Unpin,
    R: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.