cisen / blog

Time waits for no one.
135 stars 20 forks source link

NAND FLASH 读写相关 #908

Open cisen opened 4 years ago

cisen commented 4 years ago

总结

指令相关

capsules\src\nonvolatile_to_pages.rs

// 有NAND FLASH Datasheet的介绍
#[derive(Clone, Copy, PartialEq)]
#[allow(dead_code)]
enum FlashCMD {
    NOP,
    // WP=write protect ,用与NAND的写保护,这些在NAND的Datasheet中都会有
    WP,
    EP,
    CPB,
    LP,
    UP,
    EA,
    WGPB,
    EGPB,
    SSB,
    PGPFB,
    EAGPF,
    QPR,
    WUP,
    EUP,
    QPRUP,
    HSEN,
    HSDIS,
}

/// FlashState is used to track the current state and command of the flash.
#[derive(Clone, Copy, PartialEq)]
enum FlashState {
    Unconfigured,                 // Flash is unconfigured, call configure().
    Ready,                        // Flash is ready to complete a command.
    Read,                         // Performing a read operation.
    WriteUnlocking { page: i32 }, // Started a write operation. 开始写操作。
    WriteErasing { page: i32 },   // Waiting on the page to erase. 等待页面擦除。
    WriteWriting, // Waiting on the page to actually be written. 等待页面上实际被写入。
    EraseUnlocking { page: i32 }, // Started an erase operation.
    EraseErasing, // Waiting on the erase to finish.
}