use crate::lib_enum;
use crate::result::{Error, Result};
use super::{ExtCsd, ExtCsdIndex};
lib_enum! {
/// Represents the `POWER_OFF_NOTIFICATION` field of the [ExtCsd] register.
PowerOffNotification: u8 {
default: None,
error: Error,
/// Power off notification is not supported.
None = 0x00,
/// Host shall notify before powering off the device.
On = 0x01,
/// Host will power off the device within `GENERIC_CMD6_TIME`.
OffShort = 0x02,
/// Host will power off the device within `POWER_OFF_LONG_TIME`.
OffLong = 0x03,
/// Host will put the device into `Sleep Mode` within `SLEEP_NOTIFICATION_TIME`.
Sleep = 0x04,
}
}
impl ExtCsd {
/// Gets the `POWER_OFF_NOTIFICATION` field of the [ExtCsd] register.
pub const fn power_off_notification(&self) -> Result<PowerOffNotification> {
PowerOffNotification::from_raw(self.0[ExtCsdIndex::PowerOffNotification.into_inner()])
}
/// Sets the `POWER_OFF_NOTIFICATION` field of the [ExtCsd] register.
pub fn set_power_off_notification(&mut self, val: PowerOffNotification) {
self.0[ExtCsdIndex::PowerOffNotification.into_inner()] = val.into_raw();
}
}