aboutsummaryrefslogtreecommitdiff
path: root/src/flash/winbond.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/flash/winbond.rs')
-rw-r--r--src/flash/winbond.rs92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/flash/winbond.rs b/src/flash/winbond.rs
new file mode 100644
index 0000000..afac605
--- /dev/null
+++ b/src/flash/winbond.rs
@@ -0,0 +1,92 @@
+//! Winbond Serial NOR Flash.
+
+use super::*;
+use crate::{ImxrtFlashAlgorithm, sequences::common as sequences};
+
+pub type W25q64 = Winbond<{ 64 / 8 * 1024 * 1024 }>;
+
+/// A Winbond serial NOR flash driver.
+pub struct Winbond<const FLASH_CAPACITY_BYTES: usize>;
+
+impl<const FLASH_CAPACITY_BYTES: usize> ImxrtFlashAlgorithm for Winbond<FLASH_CAPACITY_BYTES> {
+ const FLASH_CAPACITY_BYTES: usize = FLASH_CAPACITY_BYTES;
+ const FLASH_PAGE_SIZE_BYTES: usize = 256;
+ const FLASH_SECTOR_SIZE_BYTES: usize = 4096;
+
+ fn initialize(flexspi: imxrt_drivers_flexspi::Instance) {
+ defmt::assert_eq!(
+ READ,
+ defmt::unwrap!(crate::install_ip_cmd(
+ flexspi,
+ READ.seq_id,
+ &[sequences::seq_fast_read_quad_io(6)],
+ ))
+ );
+
+ defmt::assert_eq!(
+ SET_READ_PARAMS,
+ defmt::unwrap!(crate::install_ip_cmd(
+ flexspi,
+ SET_READ_PARAMS.seq_id,
+ &[sequences::SEQ_SET_READ_PARAMS_VOL]
+ ))
+ );
+
+ defmt::assert_eq!(
+ WRITE_ENABLE,
+ defmt::unwrap!(crate::install_ip_cmd(
+ flexspi,
+ WRITE_ENABLE.seq_id,
+ &[sequences::SEQ_WRITE_ENABLE]
+ ))
+ );
+
+ defmt::assert_eq!(
+ ERASE_SECTOR,
+ defmt::unwrap!(crate::install_ip_cmd(
+ flexspi,
+ ERASE_SECTOR.seq_id,
+ &[sequences::SEQ_WRITE_ENABLE, sequences::SEQ_ERASE_SECTOR]
+ ))
+ );
+
+ defmt::assert_eq!(
+ READ_STATUS,
+ defmt::unwrap!(crate::install_ip_cmd(
+ flexspi,
+ READ_STATUS.seq_id,
+ &[sequences::SEQ_READ_STATUS]
+ ))
+ );
+
+ defmt::assert_eq!(
+ PAGE_PROGRAM,
+ defmt::unwrap!(crate::install_ip_cmd(
+ flexspi,
+ PAGE_PROGRAM.seq_id,
+ &[
+ sequences::SEQ_WRITE_ENABLE,
+ sequences::SEQ_PAGE_PROGRAM_QUAD_INPUT
+ ]
+ ))
+ );
+
+ defmt::assert_eq!(
+ CHIP_ERASE,
+ defmt::unwrap!(crate::install_ip_cmd(
+ flexspi,
+ CHIP_ERASE.seq_id,
+ &[sequences::SEQ_WRITE_ENABLE, sequences::SEQ_ERASE_CHIP]
+ ))
+ );
+
+ defmt::assert_eq!(
+ RESET,
+ defmt::unwrap!(crate::install_ip_cmd(
+ flexspi,
+ RESET.seq_id,
+ &[sequences::SEQ_RSTEN, sequences::SEQ_RST]
+ ))
+ );
+ }
+}