Skip to content

Commit

Permalink
Add constants for Winbond flash memory
Browse files Browse the repository at this point in the history
  • Loading branch information
mciantyre committed Feb 17, 2020
1 parent 9e160c8 commit 5ca4d1a
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions tests/teensy4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,25 @@
use imxrt_boot_gen::serial_flash::opcodes::sdr::*;
use imxrt_boot_gen::serial_flash::*;

/// Instructions for the Winbond W25Q16JV
/// SPI flash memory controller
mod winbond {
pub const FAST_READ_QUAD_IO: u8 = 0xEB;
pub const READ_STATUS_REGISTER_1: u8 = 0x05;
pub const WRITE_ENABLE: u8 = 0x06;
pub const SECTOR_ERASE: u8 = 0x20;
pub const PAGE_PROGRAM: u8 = 0x02;
pub const CHIP_ERASE: u8 = 0x60;
}

use winbond::*;

//
// Sequences for lookup table
//

const SEQ_READ: Sequence = Sequence([
Instr::new(CMD, Pads::One, 0xEB),
Instr::new(CMD, Pads::One, FAST_READ_QUAD_IO),
Instr::new(RADDR, Pads::Four, 0x18),
Instr::new(DUMMY, Pads::Four, 0x06),
Instr::new(READ, Pads::Four, 0x04),
Expand All @@ -19,7 +32,7 @@ const SEQ_READ: Sequence = Sequence([
]);

const SEQ_READ_STATUS: Sequence = Sequence([
Instr::new(CMD, Pads::One, 0x05),
Instr::new(CMD, Pads::One, READ_STATUS_REGISTER_1),
Instr::new(READ, Pads::One, 0x04),
STOP,
STOP,
Expand All @@ -30,7 +43,7 @@ const SEQ_READ_STATUS: Sequence = Sequence([
]);

const SEQ_WRITE_ENABLE: Sequence = Sequence([
Instr::new(CMD, Pads::One, 0x06),
Instr::new(CMD, Pads::One, WRITE_ENABLE),
STOP,
STOP,
STOP,
Expand All @@ -41,7 +54,7 @@ const SEQ_WRITE_ENABLE: Sequence = Sequence([
]);

const SEQ_ERASE_SECTOR: Sequence = Sequence([
Instr::new(CMD, Pads::One, 0x20),
Instr::new(CMD, Pads::One, SECTOR_ERASE),
Instr::new(RADDR, Pads::One, 0x18),
STOP,
STOP,
Expand All @@ -52,7 +65,7 @@ const SEQ_ERASE_SECTOR: Sequence = Sequence([
]);

const SEQ_PAGE_PROGRAM: Sequence = Sequence([
Instr::new(CMD, Pads::One, 0x02),
Instr::new(CMD, Pads::One, PAGE_PROGRAM),
Instr::new(RADDR, Pads::One, 0x18),
Instr::new(WRITE, Pads::One, 0x04),
STOP,
Expand All @@ -63,7 +76,7 @@ const SEQ_PAGE_PROGRAM: Sequence = Sequence([
]);

const SEQ_CHIP_ERASE: Sequence = Sequence([
Instr::new(CMD, Pads::One, 0x60),
Instr::new(CMD, Pads::One, CHIP_ERASE),
STOP,
STOP,
STOP,
Expand Down

0 comments on commit 5ca4d1a

Please sign in to comment.