sdmmc-core 0.5.0

SD/MMC core data structures and algorithms
Documentation
use crate::lib_bitfield;
use crate::result::Result;

use super::{ExtCsd, ExtCsdIndex};

mod protection;

pub use protection::*;

lib_bitfield! {
    /// Represents the `BOOT_WP_STATUS` field of the [ExtCsd] register.
    BootWpStatus: u8,
    mask: 0xf,
    default: 0,
    {
        /// Indicates the boot protection status of `Boot Area 1`.
        b_area_2_wp: BootProtection, 3, 2;
        /// Indicates the boot protection status of `Boot Area 1`.
        b_area_1_wp: BootProtection, 1, 0;
    }
}

impl ExtCsd {
    /// Gets the `BOOT_WP_STATUS` field of the [ExtCsd] register.
    pub const fn boot_wp_status(&self) -> Result<BootWpStatus> {
        BootWpStatus::try_from_inner(self.0[ExtCsdIndex::BootWpStatus.into_inner()])
    }

    /// Sets the `BOOT_WP_STATUS` field of the [ExtCsd] register.
    pub(crate) fn set_boot_wp_status(&mut self, val: BootWpStatus) {
        self.0[ExtCsdIndex::BootWpStatus.into_inner()] = val.into_inner();
    }
}