esp_hal/soc/
psram_common.rs

1/// Size of PSRAM
2///
3/// [PsramSize::AutoDetect] will try to detect the size of PSRAM
4#[derive(Copy, Clone, Debug, Default, PartialEq)]
5#[cfg_attr(feature = "defmt", derive(defmt::Format))]
6pub enum PsramSize {
7    /// Detect PSRAM size
8    #[default]
9    AutoDetect,
10    /// A fixed PSRAM size
11    Size(usize),
12}
13
14impl PsramSize {
15    pub(crate) fn get(&self) -> usize {
16        match self {
17            PsramSize::AutoDetect => 0,
18            PsramSize::Size(size) => *size,
19        }
20    }
21
22    pub(crate) fn is_auto(&self) -> bool {
23        matches!(self, PsramSize::AutoDetect)
24    }
25}
26
27/// Returns the address and size of the available in external memory.
28#[cfg(feature = "psram")]
29pub fn psram_raw_parts(_psram: &crate::peripherals::PSRAM<'_>) -> (*mut u8, usize) {
30    let range = crate::soc::psram_range();
31    (range.start as *mut u8, range.end - range.start)
32}