diff options
| author | Magnus Nordlander <[email protected]> | 2025-08-05 09:53:16 +0200 |
|---|---|---|
| committer | Magnus Nordlander <[email protected]> | 2025-08-05 09:56:09 +0200 |
| commit | 8965a13da4149a6f1a56c5abcf879ff8ad822844 (patch) | |
| tree | 02840fff99801f534c7acdab907903d9dab9cb36 /examples | |
| parent | 6d38e8b3060e4408ce493aee259048e5cf55dbb0 (diff) | |
Interface changes and added example
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rp235x/src/bin/psram.rs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/examples/rp235x/src/bin/psram.rs b/examples/rp235x/src/bin/psram.rs new file mode 100644 index 000000000..c0e41dd9e --- /dev/null +++ b/examples/rp235x/src/bin/psram.rs | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | //! This example tests an APS6404L PSRAM chip connected to the RP235x | ||
| 2 | //! It fills the PSRAM with alternating patterns and reads back a value | ||
| 3 | //! | ||
| 4 | //! In this example, the PSRAM CS is connected to Pin 0. | ||
| 5 | |||
| 6 | #![no_std] | ||
| 7 | #![no_main] | ||
| 8 | |||
| 9 | use defmt::*; | ||
| 10 | use embassy_executor::Spawner; | ||
| 11 | use embassy_time::Timer; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | ||
| 13 | use core::slice; | ||
| 14 | |||
| 15 | #[embassy_executor::main] | ||
| 16 | async fn main(_spawner: Spawner) { | ||
| 17 | let config = embassy_rp::config::Config::default(); | ||
| 18 | let p = embassy_rp::init(config); | ||
| 19 | let psram_config = embassy_rp::psram::Config::aps6404l(); | ||
| 20 | let psram = embassy_rp::psram::Psram::new(embassy_rp::qmi_cs1::QmiCs1::new(p.QMI_CS1, p.PIN_0), psram_config); | ||
| 21 | |||
| 22 | let Ok(psram) = psram else { | ||
| 23 | error!("PSRAM not found"); | ||
| 24 | loop { | ||
| 25 | Timer::after_secs(1).await; | ||
| 26 | }; | ||
| 27 | }; | ||
| 28 | |||
| 29 | let psram_slice = unsafe { | ||
| 30 | let psram_ptr = psram.base_address(); | ||
| 31 | let slice: &'static mut [u8] = | ||
| 32 | slice::from_raw_parts_mut(psram_ptr, psram.size() as usize); | ||
| 33 | slice | ||
| 34 | }; | ||
| 35 | |||
| 36 | loop { | ||
| 37 | psram_slice.fill(0x55); | ||
| 38 | info!("PSRAM filled with 0x55"); | ||
| 39 | let at_addr = psram_slice[0x100]; | ||
| 40 | info!("Read from PSRAM at address 0x100: 0x{:02x}", at_addr); | ||
| 41 | Timer::after_secs(1).await; | ||
| 42 | |||
| 43 | psram_slice.fill(0xAA); | ||
| 44 | info!("PSRAM filled with 0xAA"); | ||
| 45 | let at_addr = psram_slice[0x100]; | ||
| 46 | info!("Read from PSRAM at address 0x100: 0x{:02x}", at_addr); | ||
| 47 | Timer::after_secs(1).await; | ||
| 48 | } | ||
| 49 | } | ||
