Struct avr_oxide::util::datatypes::BitField

source ·
#[repr(C)]
pub struct BitField(/* private fields */);
Expand description

Helper newtype to represent a packed bitfield structure.

Implementations§

source§

impl BitField

Configuration of various translation/usability options for the serial port device.

OptionEffect
flush_on_eolAutomatically flush when an end-of-line is transmitted
cr_to_crlfTranslate sent CRs to CRLF
lf_to_crlfTranslate sent LFs to CRLF
interactiveThis is an interactive terminal, reading from the device will automatically flush the transmit buffer first
echoEcho all characters received back on the transmit line. If interactive is set, will also flush after each.
blocking_readCalls to read() should block until data is available
read_to_eolBlocking read()s will immediately return when a CR or LF (‘\r’ or ‘\n’) is received
read_to_eotBlocking read()s will immediately return when an EOT character is received
source

pub fn set_flush_on_eol(&mut self, flag: bool)

Indicate that the device should automatically flush when an end-of-line (CR or LF) character is sent is sent.

source

pub fn flush_on_eol(self) -> bool

True iff the device should automatically flush when an LF character is sent.

source

pub fn set_cr_to_crlf(&mut self, flag: bool)

Indicate that CR should be translated to CRLF automatically

source

pub fn cr_to_crlf(&self) -> bool

True iff the device should automatically translate CR to CRLF.

source

pub fn set_lf_to_crlf(&mut self, flag: bool)

Indicate that LF should be translated to CRLF automatically

source

pub fn lf_to_crlf(&self) -> bool

True iff the device should automatically translate LF to CRLF.

source

pub fn set_interactive(&mut self, flag: bool)

Indicate that this is an interactive terminal. Effects:

  • A call to read() will automatically flush the transmit buffer
source

pub fn interactive(&self) -> bool

True iff this is an interative terminal

source

pub fn set_echo(&mut self, flag: bool)

Indicate that we should echo received characters back. If the device is also set to interactive, then we will flush() after each echoed character as well.

source

pub fn echo(&self) -> bool

True iff we should echo everything we receive back on transmit

source

pub fn set_blocking_read(&mut self, flag: bool)

Indicate that calls to read() should block until data is available

source

pub fn blocking_read(&self) -> bool

True iff read()s should block until data is available

source

pub fn set_read_to_eol(&mut self, flag: bool)

Stop blocking read()s as soon as a linefeed (\n) is received

source

pub fn read_to_eol(&self) -> bool

True iff blocking reads will complete when a linefeed (\n) is received

source

pub fn set_read_to_eot(&mut self, flag: bool)

Stop blocking read()s as soon as an EOT is received

source

pub fn read_to_eot(&self) -> bool

True iff blocking reads will complete when an EOT is received

source

pub fn disable_translations(&mut self)

Clear all settings that result in the data being translated in any way (e.g. CR to CRLF type translations.) Use this to ensure a serial port is ‘clean’ for sending/receiving binary data.

source§

impl BitField

source

pub const fn with_initial(vals: u8) -> Self

Create a BitField initialised to the given values (big-endian)

source

pub fn with_bits_set(bits: &[BitIndex]) -> Self

Create a BitField where all bits are clear except the ones passed in the initialisation array.

source

pub const fn all_clr() -> Self

An instance of BitField with all bits cleared

source

pub const fn all_set() -> Self

An instance of BitField with all bits set

Trait Implementations§

source§

impl BitAnd<u8> for BitField

§

type Output = u8

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: u8) -> Self::Output

Performs the & operation. Read more
source§

impl BitFieldAccess for BitField

source§

fn read_byte(&self) -> u8

source§

fn write_byte(&mut self, val: u8)

source§

fn is_set(&self, bit: BitIndex) -> bool

True IFF the bit at the given index is set
source§

fn is_all_set<B: BitMaskable + Copy>(&self, bits: B) -> bool

True IFF all the bits at the given index/range are set
source§

fn is_any_set<B: BitMaskable + Copy>(&self, bits: B) -> bool

True IFF any of the bits at the given index/range are set
source§

fn is_all_clr<B: BitMaskable + Copy>(&self, bits: B) -> bool

True IFF none of the bits at the given index/range are set
source§

fn is_clr(&self, bit: BitIndex) -> bool

True IFF the bit at the given index is clear
source§

fn set_isolated<B: BitMaskable + Copy>(&mut self, _isotoken: Isolated, bits: B)

Set the bit(s) at the given index/range
source§

fn set<B: BitMaskable + Copy>(&mut self, bits: B)

Set the bit(s) at the given index/range
source§

fn set_all(&mut self)

Set all bits of the bitmask to 1
source§

fn clr_all(&mut self)

Set all bits of the bitmask to 0
source§

fn exc_set<B: BitMaskable + Copy>(&mut self, bits: B)

Set the bit(s) at the given index/range and clear all others
source§

fn clr_isolated<B: BitMaskable + Copy>(&mut self, _isotoken: Isolated, bits: B)

Clear the bit(s) at the given index/range
source§

fn clr<B: BitMaskable + Copy>(&mut self, bits: B)

Clear the bit at the given index
source§

fn exc_clr<B: BitMaskable + Copy>(&mut self, bits: B)

Clear the bit at the given index and set all others
source§

fn set_or_clr<B: BitMaskable + Copy>(&mut self, bits: B, set: bool)

Set or clear the bit(s) at the given index/range depending on the set parameter (true = set the bit, false = clear it.)
source§

fn set_to<B: BitMaskable + Copy>(&mut self, bits: B, value: u8)

Set the bit(s) at the given index/range to the bitwise value given.
source§

fn set_to_isolated<B: BitMaskable + Copy>( &mut self, _isotoken: Isolated, bits: B, value: u8 )

Set the bit(s) at the given index/range to the bitwise value given.
source§

fn get_val<B: BitMaskable + Copy>(&self, bits: B) -> u8

Return the bit(s) at the given index/range as a binary value.
source§

impl BitOr<u8> for BitField

§

type Output = u8

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: u8) -> Self::Output

Performs the | operation. Read more
source§

impl Clone for BitField

source§

fn clone(&self) -> BitField

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 Debug for BitField

source§

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

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

impl PartialEq for BitField

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for BitField

source§

impl Eq for BitField

source§

impl StructuralPartialEq for BitField

Auto Trait Implementations§

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> 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.