use crate::lib_enum;
use crate::result::{Error, Result};
use super::{ExtCsd, ExtCsdIndex};
lib_enum! {
/// Represents the `MODE_CONFIG` field of the [ExtCsd] register.
ModeConfig: u8 {
default: Normal,
error: Error,
/// Normal operation mode, for compatibility.
Normal = 0x00,
/// FFU (Field Firmware Update) operation mode.
Ffu = 0x01,
/// Vendor specific operation mode.
Vendor = 0x10,
}
}
impl ExtCsd {
/// Gets the `MODE_CONFIG` field of the [ExtCsd] register.
pub const fn mode_config(&self) -> Result<ModeConfig> {
ModeConfig::from_raw(self.0[ExtCsdIndex::ModeConfig.into_inner()])
}
/// Sets the `MODE_CONFIG` field of the [ExtCsd] register.
pub fn set_mode_config(&mut self, val: ModeConfig) {
self.0[ExtCsdIndex::ModeConfig.into_inner()] = val.into_raw();
}
}