From b87c0fe495d011d5e1140d993f67b53b0cd99420 Mon Sep 17 00:00:00 2001 From: Evan La Fontaine Date: Tue, 3 Mar 2026 12:51:27 +1100 Subject: [PATCH] =?UTF-8?q?Corrected=20FlashWriter::write=20to=20follow=20?= =?UTF-8?q?datasheet=20=F0=9F=92=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/flash.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/flash.rs b/src/flash.rs index 7f68cb18..2810e2a3 100644 --- a/src/flash.rs +++ b/src/flash.rs @@ -298,11 +298,10 @@ impl FlashWriter<'_, SECTOR_SZ_KB> { | ((data[idx + 7] as u32) << 24); } + while self.flash.sr.sr().read().bsy().bit_is_set() {} // Set Page Programming to 1 self.flash.cr.cr().modify(|_, w| w.pg().set_bit()); - while self.flash.sr.sr().read().bsy().bit_is_set() {} - // NOTE(unsafe) Write to FLASH area with no side effects unsafe { core::ptr::write_volatile(write_address1, word1) }; unsafe { core::ptr::write_volatile(write_address2, word2) }; @@ -310,6 +309,7 @@ impl FlashWriter<'_, SECTOR_SZ_KB> { // Wait for write while self.flash.sr.sr().read().bsy().bit_is_set() {} + self.flash.sr.sr().modify(|_, w| w.eop().clear_bit()); // Set Page Programming to 0 self.flash.cr.cr().modify(|_, w| w.pg().clear_bit());