use bitflags::bitflags;
#[allow(clippy::enum_variant_names)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SdTimingMode {
SDR12DefaultMode = 0,
SDR25HighSpeedMode = 1,
SDR50Mode = 2,
SDR104Mode = 3,
DDR50Mode = 4,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SdDriverStrength {
TypeB = 0,
TypeA = 1,
TypeC = 2,
TypeD = 3,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SdMaxCurrent {
Limit200mA = 0,
Limit400mA = 1,
Limit600mA = 2,
Limit800mA = 3,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SdIoVoltageCtrlType {
NotSupport = 0,
ByHost = 1,
ByGpio = 2,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SdCmd {
SendRelativeAddress = 3,
Switch = 6,
SendInterfaceCondition = 8,
VoltageSwitch = 11,
SpeedClassControl = 20,
SendTuningBlock = 19,
EraseWriteBlockStart = 32,
EraseWriteBlockEnd = 33,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SdAppCmd {
SetBusWdith = 6,
Status = 13,
SendNumberWriteBlocks = 22,
SetWriteBlockEraseCount = 23,
SendOperationCondition = 41,
SetClearCardDetect = 42,
SendScr = 51,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SdSwitchMode {
Check = 0,
Set = 1,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SdGroupNum {
TimingMode = 0,
CommandSystem = 1,
DriverStrength = 2,
CurrentLimit = 3,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SdTimingFuncNum {
SDR12Default = 0,
SDR25HighSpeed = 1,
SDR50 = 2,
SDR104 = 3,
DDR50 = 4,
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SdCardFlag: u32 {
const SupportHighCapacity = 1 << 1;
const Support4BitWidth = 1 << 2;
const SupportSdhc = 1 << 3;
const SupportSdxc = 1 << 4;
const SupportVoltage180v = 1 << 5;
const SupportSetBlockCountCmd = 1 << 6;
const SupportSpeedClassControlCmd = 1 << 7;
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SdSpecificationVersion {
Version1_0 = 1 << 0,
Version1_1 = 1 << 1,
Version2_0 = 1 << 2,
Version3_0 = 1 << 3,
}
pub(crate) const SD_POWER_ON_DELAY_MS: u32 = 400;
pub(crate) const SD_POWER_OFF_DELAY_MS: u32 = 100;
pub(crate) const SD_CLOCK_25MHZ: u32 = 25_000_000;
pub(crate) const SD_CLOCK_50MHZ: u32 = 50_000_000;
pub(crate) const SD_CLOCK_100MHZ: u32 = 100_000_000;
pub(crate) const SD_CLOCK_208MHZ: u32 = 208_000_000;
pub(crate) const SD_CMD13_RETRY_TIMES: u32 = 10;
pub(crate) const SD_PRODUCT_NAME_BYTES: usize = 5;
pub(crate) const SD_MAX_RW_BLK: usize = 1024;
pub(crate) const SD_BLOCK_SIZE: usize = 512;
pub(crate) const SD_CARD_ACCESS_WAIT_IDLE_TIMEOUT: u32 = 600;