mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-27 12:20:56 +00:00
Use the ram macro instead of assuming the .rwtext section (#4005)
This commit is contained in:
parent
1ecb6f5f76
commit
63d48b3c04
@ -19,6 +19,7 @@ bench = false
|
||||
|
||||
[dependencies]
|
||||
embedded-storage = "0.3.1"
|
||||
procmacros = { version = "0.19.0", package = "esp-hal-procmacros", path = "../esp-hal-procmacros" }
|
||||
|
||||
# Optional dependencies
|
||||
critical-section = { version = "1.2.0", optional = true }
|
||||
|
@ -1,28 +1,25 @@
|
||||
use esp_rom_sys as _;
|
||||
use esp_rom_sys::rom::spiflash::*;
|
||||
use procmacros::ram;
|
||||
|
||||
use crate::maybe_with_critical_section;
|
||||
|
||||
#[inline(never)]
|
||||
#[unsafe(link_section = ".rwtext")]
|
||||
#[ram]
|
||||
pub(crate) fn spiflash_read(src_addr: u32, data: *const u32, len: u32) -> i32 {
|
||||
maybe_with_critical_section(|| unsafe { esp_rom_spiflash_read(src_addr, data, len) })
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
#[unsafe(link_section = ".rwtext")]
|
||||
#[ram]
|
||||
pub(crate) fn spiflash_unlock() -> i32 {
|
||||
maybe_with_critical_section(|| unsafe { esp_rom_spiflash_unlock() })
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
#[unsafe(link_section = ".rwtext")]
|
||||
#[ram]
|
||||
pub(crate) fn spiflash_erase_sector(sector_number: u32) -> i32 {
|
||||
maybe_with_critical_section(|| unsafe { esp_rom_spiflash_erase_sector(sector_number) })
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
#[unsafe(link_section = ".rwtext")]
|
||||
#[ram]
|
||||
pub(crate) fn spiflash_write(dest_addr: u32, data: *const u32, len: u32) -> i32 {
|
||||
maybe_with_critical_section(|| unsafe { esp_rom_spiflash_write(dest_addr, data, len) })
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ mod storage;
|
||||
|
||||
#[cfg(not(feature = "emulation"))]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(not(target_os = "macos"), unsafe(link_section = ".rwtext"))]
|
||||
fn maybe_with_critical_section<R>(f: impl FnOnce() -> R) -> R {
|
||||
#[cfg(feature = "critical-section")]
|
||||
return critical_section::with(|_| f());
|
||||
|
Loading…
x
Reference in New Issue
Block a user