aboutsummaryrefslogtreecommitdiff
path: root/examples/rp235x
diff options
context:
space:
mode:
authorMagnus Nordlander <[email protected]>2025-08-05 09:53:16 +0200
committerMagnus Nordlander <[email protected]>2025-08-05 09:56:09 +0200
commit8965a13da4149a6f1a56c5abcf879ff8ad822844 (patch)
tree02840fff99801f534c7acdab907903d9dab9cb36 /examples/rp235x
parent6d38e8b3060e4408ce493aee259048e5cf55dbb0 (diff)
Interface changes and added example
Diffstat (limited to 'examples/rp235x')
-rw-r--r--examples/rp235x/src/bin/psram.rs49
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
9use defmt::*;
10use embassy_executor::Spawner;
11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _};
13use core::slice;
14
15#[embassy_executor::main]
16async 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}