pub struct ChipRevision {
pub major: u8,
pub minor: u8,
}Expand description
Represents the hardware revision.
The type supports converting between two separate u16-based representations:
- Combined: a
u16calculated asmajor * 100 + minor. The combined representation is more often used by ESP-IDF, and working with it involves integer division. Note that the combined representation assumes minor is less than 100. - Packed: a
u16with the major revision in the high byte and the minor revision in the low byte.
§Examples
use esp_hal::efuse::ChipRevision;
let rev = esp_hal::efuse::chip_revision();
println!("Chip revision: {}.{}", rev.major, rev.minor);
// You can compare against other ChipRevision objects
if rev < ChipRevision::from_combined(300) {
// You can print a debug representation
println!("Chip revision is too old: {:?}", rev);
}
if rev >= ChipRevision::from_packed(0x400) {
println!("Chip revision is too new: {:?}", rev);
}
// You can convert into two different numeric representations.
assert!(rev.packed() >= 0x300);
assert!(rev.combined() >= 300);Fields§
§major: u8The major revision number.
minor: u8The minor revision number.
Implementations§
Source§impl ChipRevision
impl ChipRevision
Sourcepub const fn from_combined(revision: u16) -> Self
pub const fn from_combined(revision: u16) -> Self
Creates a new ChipRevision from a combined revision value.
Sourcepub const fn combined(self) -> u16
pub const fn combined(self) -> u16
Returns the combined revision value as a u16.
The combined revision value is a u16 calculated as major * 100 + minor.
Sourcepub const fn from_packed(packed: u16) -> Self
pub const fn from_packed(packed: u16) -> Self
Creates a new ChipRevision from a packed revision value.
The packed revision value is a u16 with the major revision in the high byte and the minor
revision in the low byte.
Trait Implementations§
Source§impl Clone for ChipRevision
impl Clone for ChipRevision
Source§fn clone(&self) -> ChipRevision
fn clone(&self) -> ChipRevision
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ChipRevision
impl Debug for ChipRevision
Source§impl Hash for ChipRevision
impl Hash for ChipRevision
Source§impl Ord for ChipRevision
impl Ord for ChipRevision
Source§impl PartialEq for ChipRevision
impl PartialEq for ChipRevision
Source§impl PartialOrd for ChipRevision
impl PartialOrd for ChipRevision
impl Copy for ChipRevision
impl Eq for ChipRevision
impl StructuralPartialEq for ChipRevision
Auto Trait Implementations§
impl Freeze for ChipRevision
impl RefUnwindSafe for ChipRevision
impl Send for ChipRevision
impl Sync for ChipRevision
impl Unpin for ChipRevision
impl UnsafeUnpin for ChipRevision
impl UnwindSafe for ChipRevision
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)