Reg

Struct Reg 

Source
pub struct Reg<T: Copy, A: Access> { /* private fields */ }
Expand description

Generic register structure. T refers to the data type of the register. Alternatively, A corresponds to the access level (e.g., read-only, read-write…).

§Note

This structure assumes that it points to a valid peripheral register. If so, it is safe to read from or write to the register. However, keep in mind that read-modify-write operations may lead to wrong behavior.

Implementations§

Source§

impl<T: Copy, A: Access> Reg<T, A>

Source

pub const unsafe fn new(ptr: *mut T) -> Self

Creates a new register from a pointer.

§Safety

The pointer must be valid and must be correctly aligned.

Source

pub const fn get_ptr(self) -> *mut T

Returns a pointer to the register.

Source§

impl<T: Copy, A: Read> Reg<T, A>

Source

pub fn read(self) -> T

Performs a volatile read of the peripheral register with no side effects.

§Note

If you want to perform a read-modify-write operation, use Reg::modify instead.

Source§

impl<T: Copy, A: Write> Reg<T, A>

Source

pub fn write(self, val: T)

Performs a volatile write of the peripheral register.

§Note

If you want to perform a read-modify-write operation, use Reg::modify instead.

Source§

impl<T: Copy, A: Read + Write> Reg<T, A>

Source

pub fn modify<R>(self, f: impl FnOnce(&mut T) -> R) -> R

It modifies the value of the register according to a given function f. After writing the new value to the register, it returns the value returned by f.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source§

impl<A: Read> Reg<u8, A>

Source

pub fn read_bit(self, n: usize) -> bool

Reads the nth bit of the register.

Source

pub fn read_bits(self, start: usize, end: usize) -> u8

Reads a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<u8, A>

Source

pub fn clear_bit(self, n: usize)

Clears the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn set_bit(self, n: usize)

Sets the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn write_bits(self, start: usize, end: usize, val: u8)

Writes a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read> Reg<u16, A>

Source

pub fn read_bit(self, n: usize) -> bool

Reads the nth bit of the register.

Source

pub fn read_bits(self, start: usize, end: usize) -> u16

Reads a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<u16, A>

Source

pub fn clear_bit(self, n: usize)

Clears the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn set_bit(self, n: usize)

Sets the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn write_bits(self, start: usize, end: usize, val: u16)

Writes a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read> Reg<u32, A>

Source

pub fn read_bit(self, n: usize) -> bool

Reads the nth bit of the register.

Source

pub fn read_bits(self, start: usize, end: usize) -> u32

Reads a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<u32, A>

Source

pub fn clear_bit(self, n: usize)

Clears the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn set_bit(self, n: usize)

Sets the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn write_bits(self, start: usize, end: usize, val: u32)

Writes a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read> Reg<u64, A>

Source

pub fn read_bit(self, n: usize) -> bool

Reads the nth bit of the register.

Source

pub fn read_bits(self, start: usize, end: usize) -> u64

Reads a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<u64, A>

Source

pub fn clear_bit(self, n: usize)

Clears the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn set_bit(self, n: usize)

Sets the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn write_bits(self, start: usize, end: usize, val: u64)

Writes a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read> Reg<u128, A>

Source

pub fn read_bit(self, n: usize) -> bool

Reads the nth bit of the register.

Source

pub fn read_bits(self, start: usize, end: usize) -> u128

Reads a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<u128, A>

Source

pub fn clear_bit(self, n: usize)

Clears the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn set_bit(self, n: usize)

Sets the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn write_bits(self, start: usize, end: usize, val: u128)

Writes a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read> Reg<usize, A>

Source

pub fn read_bit(self, n: usize) -> bool

Reads the nth bit of the register.

Source

pub fn read_bits(self, start: usize, end: usize) -> usize

Reads a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<usize, A>

Source

pub fn clear_bit(self, n: usize)

Clears the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn set_bit(self, n: usize)

Sets the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn write_bits(self, start: usize, end: usize, val: usize)

Writes a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read> Reg<i8, A>

Source

pub fn read_bit(self, n: usize) -> bool

Reads the nth bit of the register.

Source

pub fn read_bits(self, start: usize, end: usize) -> i8

Reads a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<i8, A>

Source

pub fn clear_bit(self, n: usize)

Clears the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn set_bit(self, n: usize)

Sets the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn write_bits(self, start: usize, end: usize, val: i8)

Writes a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read> Reg<i16, A>

Source

pub fn read_bit(self, n: usize) -> bool

Reads the nth bit of the register.

Source

pub fn read_bits(self, start: usize, end: usize) -> i16

Reads a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<i16, A>

Source

pub fn clear_bit(self, n: usize)

Clears the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn set_bit(self, n: usize)

Sets the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn write_bits(self, start: usize, end: usize, val: i16)

Writes a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read> Reg<i32, A>

Source

pub fn read_bit(self, n: usize) -> bool

Reads the nth bit of the register.

Source

pub fn read_bits(self, start: usize, end: usize) -> i32

Reads a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<i32, A>

Source

pub fn clear_bit(self, n: usize)

Clears the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn set_bit(self, n: usize)

Sets the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn write_bits(self, start: usize, end: usize, val: i32)

Writes a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read> Reg<i64, A>

Source

pub fn read_bit(self, n: usize) -> bool

Reads the nth bit of the register.

Source

pub fn read_bits(self, start: usize, end: usize) -> i64

Reads a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<i64, A>

Source

pub fn clear_bit(self, n: usize)

Clears the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn set_bit(self, n: usize)

Sets the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn write_bits(self, start: usize, end: usize, val: i64)

Writes a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read> Reg<i128, A>

Source

pub fn read_bit(self, n: usize) -> bool

Reads the nth bit of the register.

Source

pub fn read_bits(self, start: usize, end: usize) -> i128

Reads a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<i128, A>

Source

pub fn clear_bit(self, n: usize)

Clears the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn set_bit(self, n: usize)

Sets the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn write_bits(self, start: usize, end: usize, val: i128)

Writes a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read> Reg<isize, A>

Source

pub fn read_bit(self, n: usize) -> bool

Reads the nth bit of the register.

Source

pub fn read_bits(self, start: usize, end: usize) -> isize

Reads a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<isize, A>

Source

pub fn clear_bit(self, n: usize)

Clears the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn set_bit(self, n: usize)

Sets the nth bit of the register.

§Note

It performs a non-atomic read-modify-write operation, which may lead to wrong behavior.

Source

pub fn write_bits(self, start: usize, end: usize, val: isize)

Writes a range of bits of the register specified by the start and end indexes, both included.

Source§

impl<A: Read + Write> Reg<u8, A>

Source

pub unsafe fn as_atomic<'a>(&self) -> &'a AtomicU8

Creates a new atomic reference to the register.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations for the whole lifetime 'a.
Source

pub unsafe fn atomic_clear_bit(&self, n: usize, order: Ordering)

Clears the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source

pub unsafe fn atomic_set_bit(&self, n: usize, order: Ordering)

Sets the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source§

impl<A: Read + Write> Reg<u16, A>

Source

pub unsafe fn as_atomic<'a>(&self) -> &'a AtomicU16

Creates a new atomic reference to the register.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations for the whole lifetime 'a.
Source

pub unsafe fn atomic_clear_bit(&self, n: usize, order: Ordering)

Clears the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source

pub unsafe fn atomic_set_bit(&self, n: usize, order: Ordering)

Sets the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source§

impl<A: Read + Write> Reg<u32, A>

Source

pub unsafe fn as_atomic<'a>(&self) -> &'a AtomicU32

Creates a new atomic reference to the register.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations for the whole lifetime 'a.
Source

pub unsafe fn atomic_clear_bit(&self, n: usize, order: Ordering)

Clears the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source

pub unsafe fn atomic_set_bit(&self, n: usize, order: Ordering)

Sets the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source§

impl<A: Read + Write> Reg<u64, A>

Source

pub unsafe fn as_atomic<'a>(&self) -> &'a AtomicU64

Creates a new atomic reference to the register.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations for the whole lifetime 'a.
Source

pub unsafe fn atomic_clear_bit(&self, n: usize, order: Ordering)

Clears the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source

pub unsafe fn atomic_set_bit(&self, n: usize, order: Ordering)

Sets the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source§

impl<A: Read + Write> Reg<usize, A>

Source

pub unsafe fn as_atomic<'a>(&self) -> &'a AtomicUsize

Creates a new atomic reference to the register.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations for the whole lifetime 'a.
Source

pub unsafe fn atomic_clear_bit(&self, n: usize, order: Ordering)

Clears the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source

pub unsafe fn atomic_set_bit(&self, n: usize, order: Ordering)

Sets the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source§

impl<A: Read + Write> Reg<i8, A>

Source

pub unsafe fn as_atomic<'a>(&self) -> &'a AtomicI8

Creates a new atomic reference to the register.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations for the whole lifetime 'a.
Source

pub unsafe fn atomic_clear_bit(&self, n: usize, order: Ordering)

Clears the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source

pub unsafe fn atomic_set_bit(&self, n: usize, order: Ordering)

Sets the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source§

impl<A: Read + Write> Reg<i16, A>

Source

pub unsafe fn as_atomic<'a>(&self) -> &'a AtomicI16

Creates a new atomic reference to the register.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations for the whole lifetime 'a.
Source

pub unsafe fn atomic_clear_bit(&self, n: usize, order: Ordering)

Clears the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source

pub unsafe fn atomic_set_bit(&self, n: usize, order: Ordering)

Sets the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source§

impl<A: Read + Write> Reg<i32, A>

Source

pub unsafe fn as_atomic<'a>(&self) -> &'a AtomicI32

Creates a new atomic reference to the register.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations for the whole lifetime 'a.
Source

pub unsafe fn atomic_clear_bit(&self, n: usize, order: Ordering)

Clears the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source

pub unsafe fn atomic_set_bit(&self, n: usize, order: Ordering)

Sets the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source§

impl<A: Read + Write> Reg<i64, A>

Source

pub unsafe fn as_atomic<'a>(&self) -> &'a AtomicI64

Creates a new atomic reference to the register.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations for the whole lifetime 'a.
Source

pub unsafe fn atomic_clear_bit(&self, n: usize, order: Ordering)

Clears the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source

pub unsafe fn atomic_set_bit(&self, n: usize, order: Ordering)

Sets the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source§

impl<A: Read + Write> Reg<isize, A>

Source

pub unsafe fn as_atomic<'a>(&self) -> &'a AtomicIsize

Creates a new atomic reference to the register.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations for the whole lifetime 'a.
Source

pub unsafe fn atomic_clear_bit(&self, n: usize, order: Ordering)

Clears the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.
Source

pub unsafe fn atomic_set_bit(&self, n: usize, order: Ordering)

Sets the nth bit of the register atomically.

§Safety
  • Register must be properly aligned for atomic operations.
  • The register must not be accessed through non-atomic operations until this function returns.

Trait Implementations§

Source§

impl<T: Clone + Copy, A: Clone + Access> Clone for Reg<T, A>

Source§

fn clone(&self) -> Reg<T, A>

Returns a duplicate 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<T: Debug + Copy, A: Debug + Access> Debug for Reg<T, A>

Source§

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

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

impl<T: PartialEq + Copy, A: PartialEq + Access> PartialEq for Reg<T, A>

Source§

fn eq(&self, other: &Reg<T, A>) -> 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<T: Copy + Copy, A: Copy + Access> Copy for Reg<T, A>

Source§

impl<T: Eq + Copy, A: Eq + Access> Eq for Reg<T, A>

Source§

impl<T: Copy + Send, A: Access> Send for Reg<T, A>

Source§

impl<T: Copy, A: Access> StructuralPartialEq for Reg<T, A>

Source§

impl<T: Copy + Sync, A: Access> Sync for Reg<T, A>

Auto Trait Implementations§

§

impl<T, A> Freeze for Reg<T, A>

§

impl<T, A> RefUnwindSafe for Reg<T, A>

§

impl<T, A> Unpin for Reg<T, A>
where A: Unpin,

§

impl<T, A> UnwindSafe for Reg<T, A>

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.