aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJoel Schulz-Andres <[email protected]>2024-05-23 15:34:16 +0200
committerGitHub <[email protected]>2024-05-23 15:34:16 +0200
commit0a5820e3ed423af1788072a5416e04ab86c44c2d (patch)
tree5a2b8d3d7a88835aebec0914da234d547e3b3dbe /examples
parent27e8ef6e7e720a3c74f7c696ab105915695431c5 (diff)
parentded1f9d33520fc847dce8fe72f2fb80f6fa86350 (diff)
Merge branch 'embassy-rs:main' into add-miso-pullup
Diffstat (limited to 'examples')
-rw-r--r--examples/rp/Cargo.toml2
-rw-r--r--examples/rp/src/bin/interrupt.rs3
-rw-r--r--examples/rp/src/bin/uart_r503.rs158
-rw-r--r--examples/stm32f4/Cargo.toml2
-rw-r--r--examples/stm32f4/src/bin/input_capture.rs52
-rw-r--r--examples/stm32f469/.cargo/config.toml9
-rw-r--r--examples/stm32f469/Cargo.toml22
-rw-r--r--examples/stm32f469/build.rs5
-rw-r--r--examples/stm32f469/src/bin/dsi_bsp.rs694
-rw-r--r--examples/stm32f469/src/bin/ferris.bin70
-rw-r--r--examples/stm32f7/src/bin/qspi.rs13
-rw-r--r--examples/stm32g0/src/bin/i2c_async.rs48
-rw-r--r--examples/stm32h7/Cargo.toml1
-rw-r--r--examples/stm32h7/src/bin/adc.rs2
-rw-r--r--examples/stm32h7/src/bin/i2c_shared.rs111
-rw-r--r--examples/stm32h7/src/bin/spi.rs3
-rw-r--r--examples/stm32h7/src/bin/spi_bdma.rs4
-rw-r--r--examples/stm32h7/src/bin/spi_dma.rs4
-rw-r--r--examples/stm32h7rs/src/bin/spi.rs3
-rw-r--r--examples/stm32h7rs/src/bin/spi_dma.rs4
-rw-r--r--examples/stm32l4/src/bin/can.rs68
-rw-r--r--examples/stm32l4/src/bin/spe_adin1110_http_server.rs4
22 files changed, 1259 insertions, 23 deletions
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml
index 73d19c28b..5178a690f 100644
--- a/examples/rp/Cargo.toml
+++ b/examples/rp/Cargo.toml
@@ -15,7 +15,7 @@ embassy-usb = { version = "0.2.0", path = "../../embassy-usb", features = ["defm
15embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "raw", "dhcpv4", "medium-ethernet"] } 15embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "raw", "dhcpv4", "medium-ethernet"] }
16embassy-net-wiznet = { version = "0.1.0", path = "../../embassy-net-wiznet", features = ["defmt"] } 16embassy-net-wiznet = { version = "0.1.0", path = "../../embassy-net-wiznet", features = ["defmt"] }
17embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 17embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
18embassy-usb-logger = { version = "0.1.0", path = "../../embassy-usb-logger" } 18embassy-usb-logger = { version = "0.2.0", path = "../../embassy-usb-logger" }
19cyw43 = { version = "0.1.0", path = "../../cyw43", features = ["defmt", "firmware-logs"] } 19cyw43 = { version = "0.1.0", path = "../../cyw43", features = ["defmt", "firmware-logs"] }
20cyw43-pio = { version = "0.1.0", path = "../../cyw43-pio", features = ["defmt", "overclock"] } 20cyw43-pio = { version = "0.1.0", path = "../../cyw43-pio", features = ["defmt", "overclock"] }
21 21
diff --git a/examples/rp/src/bin/interrupt.rs b/examples/rp/src/bin/interrupt.rs
index d334d35d7..5b9d7027e 100644
--- a/examples/rp/src/bin/interrupt.rs
+++ b/examples/rp/src/bin/interrupt.rs
@@ -15,7 +15,6 @@ use embassy_executor::Spawner;
15use embassy_rp::adc::{self, Adc, Blocking}; 15use embassy_rp::adc::{self, Adc, Blocking};
16use embassy_rp::gpio::Pull; 16use embassy_rp::gpio::Pull;
17use embassy_rp::interrupt; 17use embassy_rp::interrupt;
18use embassy_rp::peripherals::PWM_SLICE4;
19use embassy_rp::pwm::{Config, Pwm}; 18use embassy_rp::pwm::{Config, Pwm};
20use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; 19use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
21use embassy_sync::blocking_mutex::Mutex; 20use embassy_sync::blocking_mutex::Mutex;
@@ -26,7 +25,7 @@ use static_cell::StaticCell;
26use {defmt_rtt as _, panic_probe as _}; 25use {defmt_rtt as _, panic_probe as _};
27 26
28static COUNTER: AtomicU32 = AtomicU32::new(0); 27static COUNTER: AtomicU32 = AtomicU32::new(0);
29static PWM: Mutex<CriticalSectionRawMutex, RefCell<Option<Pwm<PWM_SLICE4>>>> = Mutex::new(RefCell::new(None)); 28static PWM: Mutex<CriticalSectionRawMutex, RefCell<Option<Pwm>>> = Mutex::new(RefCell::new(None));
30static ADC: Mutex<CriticalSectionRawMutex, RefCell<Option<(Adc<Blocking>, adc::Channel)>>> = 29static ADC: Mutex<CriticalSectionRawMutex, RefCell<Option<(Adc<Blocking>, adc::Channel)>>> =
31 Mutex::new(RefCell::new(None)); 30 Mutex::new(RefCell::new(None));
32static ADC_VALUES: Channel<CriticalSectionRawMutex, u16, 2048> = Channel::new(); 31static ADC_VALUES: Channel<CriticalSectionRawMutex, u16, 2048> = Channel::new();
diff --git a/examples/rp/src/bin/uart_r503.rs b/examples/rp/src/bin/uart_r503.rs
new file mode 100644
index 000000000..085be280b
--- /dev/null
+++ b/examples/rp/src/bin/uart_r503.rs
@@ -0,0 +1,158 @@
1#![no_std]
2#![no_main]
3
4use defmt::{debug, error, info};
5use embassy_executor::Spawner;
6use embassy_rp::bind_interrupts;
7use embassy_rp::peripherals::UART0;
8use embassy_rp::uart::{Config, DataBits, InterruptHandler as UARTInterruptHandler, Parity, StopBits, Uart};
9use embassy_time::{with_timeout, Duration, Timer};
10use heapless::Vec;
11use {defmt_rtt as _, panic_probe as _};
12
13bind_interrupts!(pub struct Irqs {
14 UART0_IRQ => UARTInterruptHandler<UART0>;
15});
16
17const START: u16 = 0xEF01;
18const ADDRESS: u32 = 0xFFFFFFFF;
19
20// ================================================================================
21
22// Data package format
23// Name Length Description
24// ==========================================================================================================
25// Start 2 bytes Fixed value of 0xEF01; High byte transferred first.
26// Address 4 bytes Default value is 0xFFFFFFFF, which can be modified by command.
27// High byte transferred first and at wrong adder value, module
28// will reject to transfer.
29// PID 1 byte 01H Command packet;
30// 02H Data packet; Data packet shall not appear alone in executing
31// processs, must follow command packet or acknowledge packet.
32// 07H Acknowledge packet;
33// 08H End of Data packet.
34// LENGTH 2 bytes Refers to the length of package content (command packets and data packets)
35// plus the length of Checksum (2 bytes). Unit is byte. Max length is 256 bytes.
36// And high byte is transferred first.
37// DATA - It can be commands, data, command’s parameters, acknowledge result, etc.
38// (fingerprint character value, template are all deemed as data);
39// SUM 2 bytes The arithmetic sum of package identifier, package length and all package
40// contens. Overflowing bits are omitted. high byte is transferred first.
41
42// ================================================================================
43
44// Checksum is calculated on 'length (2 bytes) + data (??)'.
45fn compute_checksum(buf: Vec<u8, 32>) -> u16 {
46 let mut checksum = 0u16;
47
48 let check_end = buf.len();
49 let checked_bytes = &buf[6..check_end];
50 for byte in checked_bytes {
51 checksum += (*byte) as u16;
52 }
53 return checksum;
54}
55
56#[embassy_executor::main]
57async fn main(_spawner: Spawner) {
58 info!("Start");
59
60 let p = embassy_rp::init(Default::default());
61
62 // Initialize the fingerprint scanner.
63 let mut config = Config::default();
64 config.baudrate = 57600;
65 config.stop_bits = StopBits::STOP1;
66 config.data_bits = DataBits::DataBits8;
67 config.parity = Parity::ParityNone;
68
69 let (uart, tx_pin, tx_dma, rx_pin, rx_dma) = (p.UART0, p.PIN_16, p.DMA_CH0, p.PIN_17, p.DMA_CH1);
70 let uart = Uart::new(uart, tx_pin, rx_pin, Irqs, tx_dma, rx_dma, config);
71 let (mut tx, mut rx) = uart.split();
72
73 let mut vec_buf: Vec<u8, 32> = heapless::Vec::new();
74 let mut data: Vec<u8, 32> = heapless::Vec::new();
75
76 let mut speeds: Vec<u8, 3> = heapless::Vec::new();
77 let _ = speeds.push(0xC8); // Slow
78 let _ = speeds.push(0x20); // Medium
79 let _ = speeds.push(0x02); // Fast
80
81 // Cycle through the three colours Red, Blue and Purple forever.
82 loop {
83 for colour in 1..=3 {
84 for speed in &speeds {
85 // Set the data first, because the length is dependent on that.
86 // However, we write the length bits before we do the data.
87 data.clear();
88 let _ = data.push(0x01); // ctrl=Breathing light
89 let _ = data.push(*speed);
90 let _ = data.push(colour as u8); // colour=Red, Blue, Purple
91 let _ = data.push(0x00); // times=Infinite
92
93 // Clear buffers
94 vec_buf.clear();
95
96 // START
97 let _ = vec_buf.extend_from_slice(&START.to_be_bytes()[..]);
98
99 // ADDRESS
100 let _ = vec_buf.extend_from_slice(&ADDRESS.to_be_bytes()[..]);
101
102 // PID
103 let _ = vec_buf.extend_from_slice(&[0x01]);
104
105 // LENGTH
106 let len: u16 = (1 + data.len() + 2).try_into().unwrap();
107 let _ = vec_buf.extend_from_slice(&len.to_be_bytes()[..]);
108
109 // COMMAND
110 let _ = vec_buf.push(0x35); // Command: AuraLedConfig
111
112 // DATA
113 let _ = vec_buf.extend_from_slice(&data);
114
115 // SUM
116 let chk = compute_checksum(vec_buf.clone());
117 let _ = vec_buf.extend_from_slice(&chk.to_be_bytes()[..]);
118
119 // =====
120
121 // Send command buffer.
122 let data_write: [u8; 16] = vec_buf.clone().into_array().unwrap();
123 debug!(" write='{:?}'", data_write[..]);
124 match tx.write(&data_write).await {
125 Ok(..) => info!("Write successful."),
126 Err(e) => error!("Write error: {:?}", e),
127 }
128
129 // =====
130
131 // Read command buffer.
132 let mut read_buf: [u8; 1] = [0; 1]; // Can only read one byte at a time!
133 let mut data_read: Vec<u8, 32> = heapless::Vec::new(); // Save buffer.
134
135 info!("Attempting read.");
136 loop {
137 // Some commands, like `Img2Tz()` needs longer, but we hard-code this to 200ms
138 // for this command.
139 match with_timeout(Duration::from_millis(200), rx.read(&mut read_buf)).await {
140 Ok(..) => {
141 // Extract and save read byte.
142 debug!(" r='{=u8:#04x}H' ({:03}D)", read_buf[0], read_buf[0]);
143 let _ = data_read.push(read_buf[0]).unwrap();
144 }
145 Err(..) => break, // TimeoutError -> Ignore.
146 }
147 }
148 info!("Read successful");
149 debug!(" read='{:?}'", data_read[..]);
150
151 Timer::after_secs(3).await;
152 info!("Changing speed.");
153 }
154
155 info!("Changing colour.");
156 }
157 }
158}
diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml
index 64ac50818..1eb1ae6db 100644
--- a/examples/stm32f4/Cargo.toml
+++ b/examples/stm32f4/Cargo.toml
@@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0"
6 6
7[dependencies] 7[dependencies]
8# Change stm32f429zi to your chip name, if necessary. 8# Change stm32f429zi to your chip name, if necessary.
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "chrono"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "chrono"] }
10embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
diff --git a/examples/stm32f4/src/bin/input_capture.rs b/examples/stm32f4/src/bin/input_capture.rs
new file mode 100644
index 000000000..49de33d2b
--- /dev/null
+++ b/examples/stm32f4/src/bin/input_capture.rs
@@ -0,0 +1,52 @@
1#![no_std]
2#![no_main]
3
4use defmt::*;
5use embassy_executor::Spawner;
6use embassy_stm32::gpio::{Level, Output, Pull, Speed};
7use embassy_stm32::time::khz;
8use embassy_stm32::timer::input_capture::{CapturePin, InputCapture};
9use embassy_stm32::timer::{self, Channel};
10use embassy_stm32::{bind_interrupts, peripherals};
11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _};
13
14/// Connect PB2 and PB10 with a 1k Ohm resistor
15
16#[embassy_executor::task]
17async fn blinky(led: peripherals::PB2) {
18 let mut led = Output::new(led, Level::High, Speed::Low);
19
20 loop {
21 info!("high");
22 led.set_high();
23 Timer::after_millis(300).await;
24
25 info!("low");
26 led.set_low();
27 Timer::after_millis(300).await;
28 }
29}
30
31bind_interrupts!(struct Irqs {
32 TIM2 => timer::CaptureCompareInterruptHandler<peripherals::TIM2>;
33});
34
35#[embassy_executor::main]
36async fn main(spawner: Spawner) {
37 let p = embassy_stm32::init(Default::default());
38 info!("Hello World!");
39
40 unwrap!(spawner.spawn(blinky(p.PB2)));
41
42 let ch3 = CapturePin::new_ch3(p.PB10, Pull::None);
43 let mut ic = InputCapture::new(p.TIM2, None, None, Some(ch3), None, Irqs, khz(1000), Default::default());
44
45 loop {
46 info!("wait for risign edge");
47 ic.wait_for_rising_edge(Channel::Ch3).await;
48
49 let capture_value = ic.get_capture_value(Channel::Ch3);
50 info!("new capture! {}", capture_value);
51 }
52}
diff --git a/examples/stm32f469/.cargo/config.toml b/examples/stm32f469/.cargo/config.toml
new file mode 100644
index 000000000..05250954f
--- /dev/null
+++ b/examples/stm32f469/.cargo/config.toml
@@ -0,0 +1,9 @@
1[target.'cfg(all(target_arch = "arm", target_os = "none"))']
2# replace STM32F429ZITx with your chip as listed in `probe-rs chip list`
3runner = "probe-rs run --chip STM32F469NIHx"
4
5[build]
6target = "thumbv7em-none-eabi"
7
8[env]
9DEFMT_LOG = "trace"
diff --git a/examples/stm32f469/Cargo.toml b/examples/stm32f469/Cargo.toml
new file mode 100644
index 000000000..7718a46c1
--- /dev/null
+++ b/examples/stm32f469/Cargo.toml
@@ -0,0 +1,22 @@
1[package]
2edition = "2021"
3name = "embassy-stm32f469-examples"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6
7[dependencies]
8# Specific examples only for stm32f469
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f469ni", "unstable-pac", "memory-x", "time-driver-any", "exti", "chrono"] }
10embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
11embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
12
13defmt = "0.3"
14defmt-rtt = "0.4"
15
16cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
17cortex-m-rt = "0.7.0"
18embedded-hal = "1.0.0"
19panic-probe = { version = "0.3", features = ["print-defmt"] }
20
21[profile.release]
22debug = 2
diff --git a/examples/stm32f469/build.rs b/examples/stm32f469/build.rs
new file mode 100644
index 000000000..8cd32d7ed
--- /dev/null
+++ b/examples/stm32f469/build.rs
@@ -0,0 +1,5 @@
1fn main() {
2 println!("cargo:rustc-link-arg-bins=--nmagic");
3 println!("cargo:rustc-link-arg-bins=-Tlink.x");
4 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
5}
diff --git a/examples/stm32f469/src/bin/dsi_bsp.rs b/examples/stm32f469/src/bin/dsi_bsp.rs
new file mode 100644
index 000000000..e4e9e9c01
--- /dev/null
+++ b/examples/stm32f469/src/bin/dsi_bsp.rs
@@ -0,0 +1,694 @@
1#![no_std]
2#![no_main]
3
4use defmt::*;
5use embassy_executor::Spawner;
6use embassy_stm32::dsihost::{blocking_delay_ms, DsiHost, PacketType};
7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_stm32::ltdc::Ltdc;
9use embassy_stm32::pac::dsihost::regs::{Ier0, Ier1};
10use embassy_stm32::pac::ltdc::vals::{Bf1, Bf2, Depol, Hspol, Imr, Pcpol, Pf, Vspol};
11use embassy_stm32::pac::{DSIHOST, LTDC};
12use embassy_stm32::rcc::{
13 AHBPrescaler, APBPrescaler, Hse, HseMode, Pll, PllMul, PllPDiv, PllPreDiv, PllQDiv, PllRDiv, PllSource, Sysclk,
14};
15use embassy_stm32::time::mhz;
16use embassy_time::Timer;
17use {defmt_rtt as _, panic_probe as _};
18
19enum _Orientation {
20 Landscape,
21 Portrait,
22}
23
24const _LCD_ORIENTATION: _Orientation = _Orientation::Landscape;
25const LCD_X_SIZE: u16 = 800;
26const LCD_Y_SIZE: u16 = 480;
27
28static FERRIS_IMAGE: &[u8; 1536000] = include_bytes!("ferris.bin");
29
30// This example allows to display an image on the STM32F469NI-DISCO boards
31// with the Revision C, that is at least the boards marked DK32F469I$AU1.
32// These boards have the NT35510 display driver. This example does not work
33// for the older revisions with OTM8009A, though there are lots of C-examples
34// available online where the correct config for the OTM8009A could be gotten from.
35#[embassy_executor::main]
36async fn main(_spawner: Spawner) {
37 let mut config = embassy_stm32::Config::default();
38 config.rcc.sys = Sysclk::PLL1_P;
39 config.rcc.ahb_pre = AHBPrescaler::DIV1;
40 config.rcc.apb1_pre = APBPrescaler::DIV4;
41 config.rcc.apb2_pre = APBPrescaler::DIV2;
42
43 // HSE is on and ready
44 config.rcc.hse = Some(Hse {
45 freq: mhz(8),
46 mode: HseMode::Oscillator,
47 });
48 config.rcc.pll_src = PllSource::HSE;
49
50 config.rcc.pll = Some(Pll {
51 prediv: PllPreDiv::DIV8, // PLLM
52 mul: PllMul::MUL360, // PLLN
53 divp: Some(PllPDiv::DIV2),
54 divq: Some(PllQDiv::DIV7), // was DIV4, but STM BSP example uses 7
55 divr: Some(PllRDiv::DIV6),
56 });
57
58 // This seems to be working, the values in the RCC.PLLSAICFGR are correct according to the debugger. Also on and ready according to CR
59 config.rcc.pllsai = Some(Pll {
60 prediv: PllPreDiv::DIV8, // Actually ignored
61 mul: PllMul::MUL384, // PLLN
62 divp: None, // PLLP
63 divq: None, // PLLQ
64 divr: Some(PllRDiv::DIV7), // PLLR (Sai actually has special clockdiv register)
65 });
66
67 let p = embassy_stm32::init(config);
68 info!("Starting...");
69
70 let mut led = Output::new(p.PG6, Level::High, Speed::Low);
71
72 // According to UM for the discovery kit, PH7 is an active-low reset for the LCD and touchsensor
73 let mut reset = Output::new(p.PH7, Level::Low, Speed::High);
74
75 // CubeMX example waits 20 ms before de-asserting reset
76 embassy_time::block_for(embassy_time::Duration::from_millis(20));
77
78 // Disable the reset signal and wait 140ms as in the Linux driver (CubeMX waits only 20)
79 reset.set_high();
80 embassy_time::block_for(embassy_time::Duration::from_millis(140));
81
82 let mut ltdc = Ltdc::new(p.LTDC);
83 let mut dsi = DsiHost::new(p.DSIHOST, p.PJ2);
84 let version = dsi.get_version();
85 defmt::warn!("en: {:x}", version);
86
87 // Disable the DSI wrapper
88 dsi.disable_wrapper_dsi();
89
90 // Disable the DSI host
91 dsi.disable();
92
93 // D-PHY clock and digital disable
94 DSIHOST.pctlr().modify(|w| {
95 w.set_cke(false);
96 w.set_den(false)
97 });
98
99 // Turn off the DSI PLL
100 DSIHOST.wrpcr().modify(|w| w.set_pllen(false));
101
102 // Disable the regulator
103 DSIHOST.wrpcr().write(|w| w.set_regen(false));
104
105 // Enable regulator
106 info!("DSIHOST: enabling regulator");
107 DSIHOST.wrpcr().write(|w| w.set_regen(true));
108
109 for _ in 1..1000 {
110 // The regulator status (ready or not) can be monitored with the RRS flag in the DSI_WISR register.
111 // Once it is set, we stop waiting.
112 if DSIHOST.wisr().read().rrs() {
113 info!("DSIHOST Regulator ready");
114 break;
115 }
116 embassy_time::block_for(embassy_time::Duration::from_millis(1));
117 }
118
119 if !DSIHOST.wisr().read().rrs() {
120 defmt::panic!("DSIHOST: enabling regulator FAILED");
121 }
122
123 // Set up PLL and enable it
124 DSIHOST.wrpcr().modify(|w| {
125 w.set_pllen(true);
126 w.set_ndiv(125); // PLL loop division factor set to 125
127 w.set_idf(2); // PLL input divided by 2
128 w.set_odf(0); // PLL output divided by 1
129 });
130
131 /* 500 MHz / 8 = 62.5 MHz = 62500 kHz */
132 const LANE_BYTE_CLK_K_HZ: u16 = 62500; // https://github.com/STMicroelectronics/32f469idiscovery-bsp/blob/ec051de2bff3e1b73a9ccd49c9b85abf7320add9/stm32469i_discovery_lcd.c#L224C21-L224C26
133
134 const _LCD_CLOCK: u16 = 27429; // https://github.com/STMicroelectronics/32f469idiscovery-bsp/blob/ec051de2bff3e1b73a9ccd49c9b85abf7320add9/stm32469i_discovery_lcd.c#L183
135
136 /* TX_ESCAPE_CKDIV = f(LaneByteClk)/15.62 = 4 */
137 const TX_ESCAPE_CKDIV: u8 = (LANE_BYTE_CLK_K_HZ / 15620) as u8; // https://github.com/STMicroelectronics/32f469idiscovery-bsp/blob/ec051de2bff3e1b73a9ccd49c9b85abf7320add9/stm32469i_discovery_lcd.c#L230
138
139 for _ in 1..1000 {
140 embassy_time::block_for(embassy_time::Duration::from_millis(1));
141 // The PLL status (lock or unlock) can be monitored with the PLLLS flag in the DSI_WISR register.
142 // Once it is set, we stop waiting.
143 if DSIHOST.wisr().read().pllls() {
144 info!("DSIHOST PLL locked");
145 break;
146 }
147 }
148
149 if !DSIHOST.wisr().read().pllls() {
150 defmt::panic!("DSIHOST: enabling PLL FAILED");
151 }
152
153 // Set the PHY parameters
154
155 // D-PHY clock and digital enable
156 DSIHOST.pctlr().write(|w| {
157 w.set_cke(true);
158 w.set_den(true);
159 });
160
161 // Set Clock lane to high-speed mode and disable automatic clock lane control
162 DSIHOST.clcr().modify(|w| {
163 w.set_dpcc(true);
164 w.set_acr(false);
165 });
166
167 // Set number of active data lanes to two (lanes 0 and 1)
168 DSIHOST.pconfr().modify(|w| w.set_nl(1));
169
170 // Set the DSI clock parameters
171
172 // Set the TX escape clock division factor to 4
173 DSIHOST.ccr().modify(|w| w.set_txeckdiv(TX_ESCAPE_CKDIV));
174
175 // Calculate the bit period in high-speed mode in unit of 0.25 ns (UIX4)
176 // The equation is : UIX4 = IntegerPart( (1000/F_PHY_Mhz) * 4 )
177 // Where : F_PHY_Mhz = (NDIV * HSE_Mhz) / (IDF * ODF)
178 // Set the bit period in high-speed mode
179 DSIHOST.wpcr0().modify(|w| w.set_uix4(8)); // 8 is set in the BSP example (confirmed with Debugger)
180
181 // Disable all error interrupts and reset the Error Mask
182 DSIHOST.ier0().write_value(Ier0(0));
183 DSIHOST.ier1().write_value(Ier1(0));
184
185 // Enable this to fix read timeout
186 DSIHOST.pcr().modify(|w| w.set_btae(true));
187
188 const DSI_PIXEL_FORMAT_RGB888: u8 = 0x05;
189 const _DSI_PIXEL_FORMAT_ARGB888: u8 = 0x00;
190
191 const HACT: u16 = LCD_X_SIZE;
192 const VACT: u16 = LCD_Y_SIZE;
193
194 const VSA: u16 = 120;
195 const VBP: u16 = 150;
196 const VFP: u16 = 150;
197 const HSA: u16 = 2;
198 const HBP: u16 = 34;
199 const HFP: u16 = 34;
200
201 const VIRTUAL_CHANNEL_ID: u8 = 0;
202
203 const COLOR_CODING: u8 = DSI_PIXEL_FORMAT_RGB888;
204 const VS_POLARITY: bool = false; // DSI_VSYNC_ACTIVE_HIGH == 0
205 const HS_POLARITY: bool = false; // DSI_HSYNC_ACTIVE_HIGH == 0
206 const DE_POLARITY: bool = false; // DSI_DATA_ENABLE_ACTIVE_HIGH == 0
207 const MODE: u8 = 2; // DSI_VID_MODE_BURST; /* Mode Video burst ie : one LgP per line */
208 const NULL_PACKET_SIZE: u16 = 0xFFF;
209 const NUMBER_OF_CHUNKS: u16 = 0;
210 const PACKET_SIZE: u16 = HACT; /* Value depending on display orientation choice portrait/landscape */
211 const HORIZONTAL_SYNC_ACTIVE: u16 = 4; // ((HSA as u32 * LANE_BYTE_CLK_K_HZ as u32 ) / LCD_CLOCK as u32 ) as u16;
212 const HORIZONTAL_BACK_PORCH: u16 = 77; //((HBP as u32 * LANE_BYTE_CLK_K_HZ as u32 ) / LCD_CLOCK as u32) as u16;
213 const HORIZONTAL_LINE: u16 = 1982; //(((HACT + HSA + HBP + HFP) as u32 * LANE_BYTE_CLK_K_HZ as u32 ) / LCD_CLOCK as u32 ) as u16; /* Value depending on display orientation choice portrait/landscape */
214 // FIXME: Make depend on orientation
215 const VERTICAL_SYNC_ACTIVE: u16 = VSA;
216 const VERTICAL_BACK_PORCH: u16 = VBP;
217 const VERTICAL_FRONT_PORCH: u16 = VFP;
218 const VERTICAL_ACTIVE: u16 = VACT;
219 const LP_COMMAND_ENABLE: bool = true; /* Enable sending commands in mode LP (Low Power) */
220
221 /* Largest packet size possible to transmit in LP mode in VSA, VBP, VFP regions */
222 /* Only useful when sending LP packets is allowed while streaming is active in video mode */
223 const LP_LARGEST_PACKET_SIZE: u8 = 16;
224
225 /* Largest packet size possible to transmit in LP mode in HFP region during VACT period */
226 /* Only useful when sending LP packets is allowed while streaming is active in video mode */
227 const LPVACT_LARGEST_PACKET_SIZE: u8 = 0;
228
229 const LPHORIZONTAL_FRONT_PORCH_ENABLE: bool = true; /* Allow sending LP commands during HFP period */
230 const LPHORIZONTAL_BACK_PORCH_ENABLE: bool = true; /* Allow sending LP commands during HBP period */
231 const LPVERTICAL_ACTIVE_ENABLE: bool = true; /* Allow sending LP commands during VACT period */
232 const LPVERTICAL_FRONT_PORCH_ENABLE: bool = true; /* Allow sending LP commands during VFP period */
233 const LPVERTICAL_BACK_PORCH_ENABLE: bool = true; /* Allow sending LP commands during VBP period */
234 const LPVERTICAL_SYNC_ACTIVE_ENABLE: bool = true; /* Allow sending LP commands during VSync = VSA period */
235 const FRAME_BTAACKNOWLEDGE_ENABLE: bool = false; /* Frame bus-turn-around acknowledge enable => false according to debugger */
236
237 /* Select video mode by resetting CMDM and DSIM bits */
238 DSIHOST.mcr().modify(|w| w.set_cmdm(false));
239 DSIHOST.wcfgr().modify(|w| w.set_dsim(false));
240
241 /* Configure the video mode transmission type */
242 DSIHOST.vmcr().modify(|w| w.set_vmt(MODE));
243
244 /* Configure the video packet size */
245 DSIHOST.vpcr().modify(|w| w.set_vpsize(PACKET_SIZE));
246
247 /* Set the chunks number to be transmitted through the DSI link */
248 DSIHOST.vccr().modify(|w| w.set_numc(NUMBER_OF_CHUNKS));
249
250 /* Set the size of the null packet */
251 DSIHOST.vnpcr().modify(|w| w.set_npsize(NULL_PACKET_SIZE));
252
253 /* Select the virtual channel for the LTDC interface traffic */
254 DSIHOST.lvcidr().modify(|w| w.set_vcid(VIRTUAL_CHANNEL_ID));
255
256 /* Configure the polarity of control signals */
257 DSIHOST.lpcr().modify(|w| {
258 w.set_dep(DE_POLARITY);
259 w.set_hsp(HS_POLARITY);
260 w.set_vsp(VS_POLARITY);
261 });
262
263 /* Select the color coding for the host */
264 DSIHOST.lcolcr().modify(|w| w.set_colc(COLOR_CODING));
265
266 /* Select the color coding for the wrapper */
267 DSIHOST.wcfgr().modify(|w| w.set_colmux(COLOR_CODING));
268
269 /* Set the Horizontal Synchronization Active (HSA) in lane byte clock cycles */
270 DSIHOST.vhsacr().modify(|w| w.set_hsa(HORIZONTAL_SYNC_ACTIVE));
271
272 /* Set the Horizontal Back Porch (HBP) in lane byte clock cycles */
273 DSIHOST.vhbpcr().modify(|w| w.set_hbp(HORIZONTAL_BACK_PORCH));
274
275 /* Set the total line time (HLINE=HSA+HBP+HACT+HFP) in lane byte clock cycles */
276 DSIHOST.vlcr().modify(|w| w.set_hline(HORIZONTAL_LINE));
277
278 /* Set the Vertical Synchronization Active (VSA) */
279 DSIHOST.vvsacr().modify(|w| w.set_vsa(VERTICAL_SYNC_ACTIVE));
280
281 /* Set the Vertical Back Porch (VBP)*/
282 DSIHOST.vvbpcr().modify(|w| w.set_vbp(VERTICAL_BACK_PORCH));
283
284 /* Set the Vertical Front Porch (VFP)*/
285 DSIHOST.vvfpcr().modify(|w| w.set_vfp(VERTICAL_FRONT_PORCH));
286
287 /* Set the Vertical Active period*/
288 DSIHOST.vvacr().modify(|w| w.set_va(VERTICAL_ACTIVE));
289
290 /* Configure the command transmission mode */
291 DSIHOST.vmcr().modify(|w| w.set_lpce(LP_COMMAND_ENABLE));
292
293 /* Low power largest packet size */
294 DSIHOST.lpmcr().modify(|w| w.set_lpsize(LP_LARGEST_PACKET_SIZE));
295
296 /* Low power VACT largest packet size */
297 DSIHOST.lpmcr().modify(|w| w.set_lpsize(LP_LARGEST_PACKET_SIZE));
298 DSIHOST.lpmcr().modify(|w| w.set_vlpsize(LPVACT_LARGEST_PACKET_SIZE));
299
300 /* Enable LP transition in HFP period */
301 DSIHOST.vmcr().modify(|w| w.set_lphfpe(LPHORIZONTAL_FRONT_PORCH_ENABLE));
302
303 /* Enable LP transition in HBP period */
304 DSIHOST.vmcr().modify(|w| w.set_lphbpe(LPHORIZONTAL_BACK_PORCH_ENABLE));
305
306 /* Enable LP transition in VACT period */
307 DSIHOST.vmcr().modify(|w| w.set_lpvae(LPVERTICAL_ACTIVE_ENABLE));
308
309 /* Enable LP transition in VFP period */
310 DSIHOST.vmcr().modify(|w| w.set_lpvfpe(LPVERTICAL_FRONT_PORCH_ENABLE));
311
312 /* Enable LP transition in VBP period */
313 DSIHOST.vmcr().modify(|w| w.set_lpvbpe(LPVERTICAL_BACK_PORCH_ENABLE));
314
315 /* Enable LP transition in vertical sync period */
316 DSIHOST.vmcr().modify(|w| w.set_lpvsae(LPVERTICAL_SYNC_ACTIVE_ENABLE));
317
318 /* Enable the request for an acknowledge response at the end of a frame */
319 DSIHOST.vmcr().modify(|w| w.set_fbtaae(FRAME_BTAACKNOWLEDGE_ENABLE));
320
321 /* Configure DSI PHY HS2LP and LP2HS timings */
322 const CLOCK_LANE_HS2_LPTIME: u16 = 35;
323 const CLOCK_LANE_LP2_HSTIME: u16 = 35;
324 const DATA_LANE_HS2_LPTIME: u8 = 35;
325 const DATA_LANE_LP2_HSTIME: u8 = 35;
326 const DATA_LANE_MAX_READ_TIME: u16 = 0;
327 const STOP_WAIT_TIME: u8 = 10;
328
329 const MAX_TIME: u16 = if CLOCK_LANE_HS2_LPTIME > CLOCK_LANE_LP2_HSTIME {
330 CLOCK_LANE_HS2_LPTIME
331 } else {
332 CLOCK_LANE_LP2_HSTIME
333 };
334
335 /* Clock lane timer configuration */
336
337 /* In Automatic Clock Lane control mode, the DSI Host can turn off the clock lane between two
338 High-Speed transmission.
339 To do so, the DSI Host calculates the time required for the clock lane to change from HighSpeed
340 to Low-Power and from Low-Power to High-Speed.
341 This timings are configured by the HS2LP_TIME and LP2HS_TIME in the DSI Host Clock Lane Timer Configuration
342 Register (DSI_CLTCR).
343 But the DSI Host is not calculating LP2HS_TIME + HS2LP_TIME but 2 x HS2LP_TIME.
344
345 Workaround : Configure HS2LP_TIME and LP2HS_TIME with the same value being the max of HS2LP_TIME or LP2HS_TIME.
346 */
347
348 DSIHOST.cltcr().modify(|w| {
349 w.set_hs2lp_time(MAX_TIME);
350 w.set_lp2hs_time(MAX_TIME)
351 });
352
353 // Data lane timer configuration
354 DSIHOST.dltcr().modify(|w| {
355 w.set_hs2lp_time(DATA_LANE_HS2_LPTIME);
356 w.set_lp2hs_time(DATA_LANE_LP2_HSTIME);
357 w.set_mrd_time(DATA_LANE_MAX_READ_TIME);
358 });
359
360 // Configure the wait period to request HS transmission after a stop state
361 DSIHOST.pconfr().modify(|w| w.set_sw_time(STOP_WAIT_TIME));
362
363 const _PCPOLARITY: bool = false; // LTDC_PCPOLARITY_IPC == 0
364
365 const LTDC_DE_POLARITY: Depol = if !DE_POLARITY {
366 Depol::ACTIVELOW
367 } else {
368 Depol::ACTIVEHIGH
369 };
370 const LTDC_VS_POLARITY: Vspol = if !VS_POLARITY {
371 Vspol::ACTIVEHIGH
372 } else {
373 Vspol::ACTIVELOW
374 };
375
376 const LTDC_HS_POLARITY: Hspol = if !HS_POLARITY {
377 Hspol::ACTIVEHIGH
378 } else {
379 Hspol::ACTIVELOW
380 };
381
382 /* Timing Configuration */
383 const HORIZONTAL_SYNC: u16 = HSA - 1;
384 const VERTICAL_SYNC: u16 = VERTICAL_SYNC_ACTIVE - 1;
385 const ACCUMULATED_HBP: u16 = HSA + HBP - 1;
386 const ACCUMULATED_VBP: u16 = VERTICAL_SYNC_ACTIVE + VERTICAL_BACK_PORCH - 1;
387 const ACCUMULATED_ACTIVE_W: u16 = LCD_X_SIZE + HSA + HBP - 1;
388 const ACCUMULATED_ACTIVE_H: u16 = VERTICAL_SYNC_ACTIVE + VERTICAL_BACK_PORCH + VERTICAL_ACTIVE - 1;
389 const TOTAL_WIDTH: u16 = LCD_X_SIZE + HSA + HBP + HFP - 1;
390 const TOTAL_HEIGHT: u16 = VERTICAL_SYNC_ACTIVE + VERTICAL_BACK_PORCH + VERTICAL_ACTIVE + VERTICAL_FRONT_PORCH - 1;
391
392 // DISABLE LTDC before making changes
393 ltdc.disable();
394
395 // Configure the HS, VS, DE and PC polarity
396 LTDC.gcr().modify(|w| {
397 w.set_hspol(LTDC_HS_POLARITY);
398 w.set_vspol(LTDC_VS_POLARITY);
399 w.set_depol(LTDC_DE_POLARITY);
400 w.set_pcpol(Pcpol::RISINGEDGE);
401 });
402
403 // Set Synchronization size
404 LTDC.sscr().modify(|w| {
405 w.set_hsw(HORIZONTAL_SYNC);
406 w.set_vsh(VERTICAL_SYNC)
407 });
408
409 // Set Accumulated Back porch
410 LTDC.bpcr().modify(|w| {
411 w.set_ahbp(ACCUMULATED_HBP);
412 w.set_avbp(ACCUMULATED_VBP);
413 });
414
415 // Set Accumulated Active Width
416 LTDC.awcr().modify(|w| {
417 w.set_aah(ACCUMULATED_ACTIVE_H);
418 w.set_aaw(ACCUMULATED_ACTIVE_W);
419 });
420
421 // Set Total Width
422 LTDC.twcr().modify(|w| {
423 w.set_totalh(TOTAL_HEIGHT);
424 w.set_totalw(TOTAL_WIDTH);
425 });
426
427 // Set the background color value
428 LTDC.bccr().modify(|w| {
429 w.set_bcred(0);
430 w.set_bcgreen(0);
431 w.set_bcblue(0)
432 });
433
434 // Enable the Transfer Error and FIFO underrun interrupts
435 LTDC.ier().modify(|w| {
436 w.set_terrie(true);
437 w.set_fuie(true);
438 });
439
440 // ENABLE LTDC after making changes
441 ltdc.enable();
442
443 dsi.enable();
444 dsi.enable_wrapper_dsi();
445
446 // First, delay 120 ms (reason unknown, STM32 Cube Example does it)
447 blocking_delay_ms(120);
448
449 // 1 to 26
450 dsi.write_cmd(0, NT35510_WRITES_0[0], &NT35510_WRITES_0[1..]).unwrap();
451 dsi.write_cmd(0, NT35510_WRITES_1[0], &NT35510_WRITES_1[1..]).unwrap();
452 dsi.write_cmd(0, NT35510_WRITES_2[0], &NT35510_WRITES_2[1..]).unwrap();
453 dsi.write_cmd(0, NT35510_WRITES_3[0], &NT35510_WRITES_3[1..]).unwrap();
454 dsi.write_cmd(0, NT35510_WRITES_4[0], &NT35510_WRITES_4[1..]).unwrap();
455 dsi.write_cmd(0, NT35510_WRITES_5[0], &NT35510_WRITES_5[1..]).unwrap();
456 dsi.write_cmd(0, NT35510_WRITES_6[0], &NT35510_WRITES_6[1..]).unwrap();
457 dsi.write_cmd(0, NT35510_WRITES_7[0], &NT35510_WRITES_7[1..]).unwrap();
458 dsi.write_cmd(0, NT35510_WRITES_8[0], &NT35510_WRITES_8[1..]).unwrap();
459 dsi.write_cmd(0, NT35510_WRITES_9[0], &NT35510_WRITES_9[1..]).unwrap();
460 dsi.write_cmd(0, NT35510_WRITES_10[0], &NT35510_WRITES_10[1..]).unwrap();
461 // 11 missing
462 dsi.write_cmd(0, NT35510_WRITES_12[0], &NT35510_WRITES_12[1..]).unwrap();
463 dsi.write_cmd(0, NT35510_WRITES_13[0], &NT35510_WRITES_13[1..]).unwrap();
464 dsi.write_cmd(0, NT35510_WRITES_14[0], &NT35510_WRITES_14[1..]).unwrap();
465 dsi.write_cmd(0, NT35510_WRITES_15[0], &NT35510_WRITES_15[1..]).unwrap();
466 dsi.write_cmd(0, NT35510_WRITES_16[0], &NT35510_WRITES_16[1..]).unwrap();
467 dsi.write_cmd(0, NT35510_WRITES_17[0], &NT35510_WRITES_17[1..]).unwrap();
468 dsi.write_cmd(0, NT35510_WRITES_18[0], &NT35510_WRITES_18[1..]).unwrap();
469 dsi.write_cmd(0, NT35510_WRITES_19[0], &NT35510_WRITES_19[1..]).unwrap();
470 dsi.write_cmd(0, NT35510_WRITES_20[0], &NT35510_WRITES_20[1..]).unwrap();
471 dsi.write_cmd(0, NT35510_WRITES_21[0], &NT35510_WRITES_21[1..]).unwrap();
472 dsi.write_cmd(0, NT35510_WRITES_22[0], &NT35510_WRITES_22[1..]).unwrap();
473 dsi.write_cmd(0, NT35510_WRITES_23[0], &NT35510_WRITES_23[1..]).unwrap();
474 dsi.write_cmd(0, NT35510_WRITES_24[0], &NT35510_WRITES_24[1..]).unwrap();
475
476 // Tear on
477 dsi.write_cmd(0, NT35510_WRITES_26[0], &NT35510_WRITES_26[1..]).unwrap();
478
479 // Set Pixel color format to RGB888
480 dsi.write_cmd(0, NT35510_WRITES_37[0], &NT35510_WRITES_37[1..]).unwrap();
481
482 // Add a delay, otherwise MADCTL not taken
483 blocking_delay_ms(200);
484
485 // Configure orientation as landscape
486 dsi.write_cmd(0, NT35510_MADCTL_LANDSCAPE[0], &NT35510_MADCTL_LANDSCAPE[1..])
487 .unwrap();
488 dsi.write_cmd(0, NT35510_CASET_LANDSCAPE[0], &NT35510_CASET_LANDSCAPE[1..])
489 .unwrap();
490 dsi.write_cmd(0, NT35510_RASET_LANDSCAPE[0], &NT35510_RASET_LANDSCAPE[1..])
491 .unwrap();
492
493 // Sleep out
494 dsi.write_cmd(0, NT35510_WRITES_27[0], &NT35510_WRITES_27[1..]).unwrap();
495
496 // Wait for sleep out exit
497 blocking_delay_ms(120);
498
499 // Configure COLOR_CODING
500 dsi.write_cmd(0, NT35510_WRITES_37[0], &NT35510_WRITES_37[1..]).unwrap();
501
502 /* CABC : Content Adaptive Backlight Control section start >> */
503 /* Note : defaut is 0 (lowest Brightness), 0xFF is highest Brightness, try 0x7F : intermediate value */
504 dsi.write_cmd(0, NT35510_WRITES_31[0], &NT35510_WRITES_31[1..]).unwrap();
505 /* defaut is 0, try 0x2C - Brightness Control Block, Display Dimming & BackLight on */
506 dsi.write_cmd(0, NT35510_WRITES_32[0], &NT35510_WRITES_32[1..]).unwrap();
507 /* defaut is 0, try 0x02 - image Content based Adaptive Brightness [Still Picture] */
508 dsi.write_cmd(0, NT35510_WRITES_33[0], &NT35510_WRITES_33[1..]).unwrap();
509 /* defaut is 0 (lowest Brightness), 0xFF is highest Brightness */
510 dsi.write_cmd(0, NT35510_WRITES_34[0], &NT35510_WRITES_34[1..]).unwrap();
511 /* CABC : Content Adaptive Backlight Control section end << */
512 /* Display on */
513 dsi.write_cmd(0, NT35510_WRITES_30[0], &NT35510_WRITES_30[1..]).unwrap();
514
515 /* Send Command GRAM memory write (no parameters) : this initiates frame write via other DSI commands sent by */
516 /* DSI host from LTDC incoming pixels in video mode */
517 dsi.write_cmd(0, NT35510_WRITES_35[0], &NT35510_WRITES_35[1..]).unwrap();
518
519 /* Initialize the LCD pixel width and pixel height */
520 const WINDOW_X0: u16 = 0;
521 const WINDOW_X1: u16 = LCD_X_SIZE; // 480 for ferris
522 const WINDOW_Y0: u16 = 0;
523 const WINDOW_Y1: u16 = LCD_Y_SIZE; // 800 for ferris
524 const PIXEL_FORMAT: Pf = Pf::ARGB8888;
525 //const FBStartAdress: u16 = FB_Address;
526 const ALPHA: u8 = 255;
527 const ALPHA0: u8 = 0;
528 const BACKCOLOR_BLUE: u8 = 0;
529 const BACKCOLOR_GREEN: u8 = 0;
530 const BACKCOLOR_RED: u8 = 0;
531 const IMAGE_WIDTH: u16 = LCD_X_SIZE; // 480 for ferris
532 const IMAGE_HEIGHT: u16 = LCD_Y_SIZE; // 800 for ferris
533
534 const PIXEL_SIZE: u8 = match PIXEL_FORMAT {
535 Pf::ARGB8888 => 4,
536 Pf::RGB888 => 3,
537 Pf::ARGB4444 | Pf::RGB565 | Pf::ARGB1555 | Pf::AL88 => 2,
538 _ => 1,
539 };
540
541 // Configure the horizontal start and stop position
542 LTDC.layer(0).whpcr().write(|w| {
543 w.set_whstpos(LTDC.bpcr().read().ahbp() + 1 + WINDOW_X0);
544 w.set_whsppos(LTDC.bpcr().read().ahbp() + WINDOW_X1);
545 });
546
547 // Configures the vertical start and stop position
548 LTDC.layer(0).wvpcr().write(|w| {
549 w.set_wvstpos(LTDC.bpcr().read().avbp() + 1 + WINDOW_Y0);
550 w.set_wvsppos(LTDC.bpcr().read().avbp() + WINDOW_Y1);
551 });
552
553 // Specify the pixel format
554 LTDC.layer(0).pfcr().write(|w| w.set_pf(PIXEL_FORMAT));
555
556 // Configures the default color values as zero
557 LTDC.layer(0).dccr().modify(|w| {
558 w.set_dcblue(BACKCOLOR_BLUE);
559 w.set_dcgreen(BACKCOLOR_GREEN);
560 w.set_dcred(BACKCOLOR_RED);
561 w.set_dcalpha(ALPHA0);
562 });
563
564 // Specifies the constant ALPHA value
565 LTDC.layer(0).cacr().write(|w| w.set_consta(ALPHA));
566
567 // Specifies the blending factors
568 LTDC.layer(0).bfcr().write(|w| {
569 w.set_bf1(Bf1::CONSTANT);
570 w.set_bf2(Bf2::CONSTANT);
571 });
572
573 // Configure the color frame buffer start address
574 let fb_start_address: u32 = &FERRIS_IMAGE[0] as *const _ as u32;
575 info!("Setting Framebuffer Start Address: {:010x}", fb_start_address);
576 LTDC.layer(0).cfbar().write(|w| w.set_cfbadd(fb_start_address));
577
578 // Configures the color frame buffer pitch in byte
579 LTDC.layer(0).cfblr().write(|w| {
580 w.set_cfbp(IMAGE_WIDTH * PIXEL_SIZE as u16);
581 w.set_cfbll(((WINDOW_X1 - WINDOW_X0) * PIXEL_SIZE as u16) + 3);
582 });
583
584 // Configures the frame buffer line number
585 LTDC.layer(0).cfblnr().write(|w| w.set_cfblnbr(IMAGE_HEIGHT));
586
587 // Enable LTDC_Layer by setting LEN bit
588 LTDC.layer(0).cr().modify(|w| w.set_len(true));
589
590 //LTDC->SRCR = LTDC_SRCR_IMR;
591 LTDC.srcr().modify(|w| w.set_imr(Imr::RELOAD));
592
593 blocking_delay_ms(5000);
594
595 const READ_SIZE: u16 = 1;
596 let mut data = [1u8; READ_SIZE as usize];
597 dsi.read(0, PacketType::DcsShortPktRead(0xDA), READ_SIZE, &mut data)
598 .unwrap();
599 info!("Display ID1: {:#04x}", data);
600
601 dsi.read(0, PacketType::DcsShortPktRead(0xDB), READ_SIZE, &mut data)
602 .unwrap();
603 info!("Display ID2: {:#04x}", data);
604
605 dsi.read(0, PacketType::DcsShortPktRead(0xDC), READ_SIZE, &mut data)
606 .unwrap();
607 info!("Display ID3: {:#04x}", data);
608
609 blocking_delay_ms(500);
610
611 info!("Config done, start blinking LED");
612 loop {
613 led.set_high();
614 Timer::after_millis(1000).await;
615
616 // Increase screen brightness
617 dsi.write_cmd(0, NT35510_CMD_WRDISBV, &[0xFF]).unwrap();
618
619 led.set_low();
620 Timer::after_millis(1000).await;
621
622 // Reduce screen brightness
623 dsi.write_cmd(0, NT35510_CMD_WRDISBV, &[0x50]).unwrap();
624 }
625}
626
627const NT35510_WRITES_0: &[u8] = &[0xF0, 0x55, 0xAA, 0x52, 0x08, 0x01]; // LV2: Page 1 enable
628const NT35510_WRITES_1: &[u8] = &[0xB0, 0x03, 0x03, 0x03]; // AVDD: 5.2V
629const NT35510_WRITES_2: &[u8] = &[0xB6, 0x46, 0x46, 0x46]; // AVDD: Ratio
630const NT35510_WRITES_3: &[u8] = &[0xB1, 0x03, 0x03, 0x03]; // AVEE: -5.2V
631const NT35510_WRITES_4: &[u8] = &[0xB7, 0x36, 0x36, 0x36]; // AVEE: Ratio
632const NT35510_WRITES_5: &[u8] = &[0xB2, 0x00, 0x00, 0x02]; // VCL: -2.5V
633const NT35510_WRITES_6: &[u8] = &[0xB8, 0x26, 0x26, 0x26]; // VCL: Ratio
634const NT35510_WRITES_7: &[u8] = &[0xBF, 0x01]; // VGH: 15V (Free Pump)
635const NT35510_WRITES_8: &[u8] = &[0xB3, 0x09, 0x09, 0x09];
636const NT35510_WRITES_9: &[u8] = &[0xB9, 0x36, 0x36, 0x36]; // VGH: Ratio
637const NT35510_WRITES_10: &[u8] = &[0xB5, 0x08, 0x08, 0x08]; // VGL_REG: -10V
638const NT35510_WRITES_12: &[u8] = &[0xBA, 0x26, 0x26, 0x26]; // VGLX: Ratio
639const NT35510_WRITES_13: &[u8] = &[0xBC, 0x00, 0x80, 0x00]; // VGMP/VGSP: 4.5V/0V
640const NT35510_WRITES_14: &[u8] = &[0xBD, 0x00, 0x80, 0x00]; // VGMN/VGSN:-4.5V/0V
641const NT35510_WRITES_15: &[u8] = &[0xBE, 0x00, 0x50]; // VCOM: -1.325V
642const NT35510_WRITES_16: &[u8] = &[0xF0, 0x55, 0xAA, 0x52, 0x08, 0x00]; // LV2: Page 0 enable
643const NT35510_WRITES_17: &[u8] = &[0xB1, 0xFC, 0x00]; // Display control
644const NT35510_WRITES_18: &[u8] = &[0xB6, 0x03]; // Src hold time
645const NT35510_WRITES_19: &[u8] = &[0xB5, 0x51];
646const NT35510_WRITES_20: &[u8] = &[0x00, 0x00, 0xB7]; // Gate EQ control
647const NT35510_WRITES_21: &[u8] = &[0xB8, 0x01, 0x02, 0x02, 0x02]; // Src EQ control(Mode2)
648const NT35510_WRITES_22: &[u8] = &[0xBC, 0x00, 0x00, 0x00]; // Inv. mode(2-dot)
649const NT35510_WRITES_23: &[u8] = &[0xCC, 0x03, 0x00, 0x00];
650const NT35510_WRITES_24: &[u8] = &[0xBA, 0x01];
651
652const _NT35510_MADCTL_PORTRAIT: &[u8] = &[NT35510_CMD_MADCTL, 0x00];
653const _NT35510_CASET_PORTRAIT: &[u8] = &[NT35510_CMD_CASET, 0x00, 0x00, 0x01, 0xDF];
654const _NT35510_RASET_PORTRAIT: &[u8] = &[NT35510_CMD_RASET, 0x00, 0x00, 0x03, 0x1F];
655const NT35510_MADCTL_LANDSCAPE: &[u8] = &[NT35510_CMD_MADCTL, 0x60];
656const NT35510_CASET_LANDSCAPE: &[u8] = &[NT35510_CMD_CASET, 0x00, 0x00, 0x03, 0x1F];
657const NT35510_RASET_LANDSCAPE: &[u8] = &[NT35510_CMD_RASET, 0x00, 0x00, 0x01, 0xDF];
658
659const NT35510_WRITES_26: &[u8] = &[NT35510_CMD_TEEON, 0x00]; // Tear on
660const NT35510_WRITES_27: &[u8] = &[NT35510_CMD_SLPOUT, 0x00]; // Sleep out
661 // 28,29 missing
662const NT35510_WRITES_30: &[u8] = &[NT35510_CMD_DISPON, 0x00]; // Display on
663
664const NT35510_WRITES_31: &[u8] = &[NT35510_CMD_WRDISBV, 0x7F];
665const NT35510_WRITES_32: &[u8] = &[NT35510_CMD_WRCTRLD, 0x2C];
666const NT35510_WRITES_33: &[u8] = &[NT35510_CMD_WRCABC, 0x02];
667const NT35510_WRITES_34: &[u8] = &[NT35510_CMD_WRCABCMB, 0xFF];
668const NT35510_WRITES_35: &[u8] = &[NT35510_CMD_RAMWR, 0x00];
669
670//const NT35510_WRITES_36: &[u8] = &[NT35510_CMD_COLMOD, NT35510_COLMOD_RGB565]; // FIXME: Example sets it to 888 but rest of the code seems to configure DSI for 565
671const NT35510_WRITES_37: &[u8] = &[NT35510_CMD_COLMOD, NT35510_COLMOD_RGB888];
672
673// More of these: https://elixir.bootlin.com/linux/latest/source/include/video/mipi_display.h#L83
674const _NT35510_CMD_TEEON_GET_DISPLAY_ID: u8 = 0x04;
675
676const NT35510_CMD_TEEON: u8 = 0x35;
677const NT35510_CMD_MADCTL: u8 = 0x36;
678
679const NT35510_CMD_SLPOUT: u8 = 0x11;
680const NT35510_CMD_DISPON: u8 = 0x29;
681const NT35510_CMD_CASET: u8 = 0x2A;
682const NT35510_CMD_RASET: u8 = 0x2B;
683const NT35510_CMD_RAMWR: u8 = 0x2C; /* Memory write */
684const NT35510_CMD_COLMOD: u8 = 0x3A;
685
686const NT35510_CMD_WRDISBV: u8 = 0x51; /* Write display brightness */
687const _NT35510_CMD_RDDISBV: u8 = 0x52; /* Read display brightness */
688const NT35510_CMD_WRCTRLD: u8 = 0x53; /* Write CTRL display */
689const _NT35510_CMD_RDCTRLD: u8 = 0x54; /* Read CTRL display value */
690const NT35510_CMD_WRCABC: u8 = 0x55; /* Write content adaptative brightness control */
691const NT35510_CMD_WRCABCMB: u8 = 0x5E; /* Write CABC minimum brightness */
692
693const _NT35510_COLMOD_RGB565: u8 = 0x55;
694const NT35510_COLMOD_RGB888: u8 = 0x77;
diff --git a/examples/stm32f469/src/bin/ferris.bin b/examples/stm32f469/src/bin/ferris.bin
new file mode 100644
index 000000000..ae1c466be
--- /dev/null
+++ b/examples/stm32f469/src/bin/ferris.bin
@@ -0,0 +1,70 @@
1��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������f���2���
2���
3���
4�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������=���
5�������������������������������������������������������������������������������������������������������������������������������I���
6���
7�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������%���
8���
9���
10���
11���������������������������������������������������������������������������������������������������������������������������T���
12���������������������������������������������������������������������������������������������������2���
13���=���c�����������������������������������G���
14
15
16ďż˝
17e��
18
19
20�������������������������������������������������������������������������������������������������������������������������hhh�
21_��
22_��
23ďż˝
24(ďż˝
25ďż˝
26.ďż˝
271ďż˝
28-ďż˝
29ďż˝
30.��
31.��Yb��������������
32M��
33.��S]����������������������������������
34.��
35.��
36-ďż˝
37.��
38.��
39.��v{������������������������������_f��%9��,��
405ďż˝
41.��
42L����������������������������������������������������������������������������������������������
43.��|������������������������������������������������������������������
44-ďż˝
45.��
46ďż˝
47ďż˝
48M��
493ďż˝
50-ďż˝
510ďż˝
522ďż˝
53.ďż˝
54'ďż˝
55.����������������������������������������������������������������������������������������������%T��
56M������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������lx��
576ďż˝
58M��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������fu��
593ďż˝
60M��
61/ďż˝
622ďż˝
63J��
64.��
65.����������������������������������������������������������������������������������������������������������Sl��
66H��
67M��
68.��
69M������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������q|��O��
70M������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������(T��
diff --git a/examples/stm32f7/src/bin/qspi.rs b/examples/stm32f7/src/bin/qspi.rs
index 005694db3..90d319b7a 100644
--- a/examples/stm32f7/src/bin/qspi.rs
+++ b/examples/stm32f7/src/bin/qspi.rs
@@ -4,8 +4,9 @@
4 4
5use defmt::info; 5use defmt::info;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::mode::Async;
7use embassy_stm32::qspi::enums::{AddressSize, ChipSelectHighTime, FIFOThresholdLevel, MemorySize, *}; 8use embassy_stm32::qspi::enums::{AddressSize, ChipSelectHighTime, FIFOThresholdLevel, MemorySize, *};
8use embassy_stm32::qspi::{Config as QspiCfg, Instance, Qspi, QuadDma, TransferConfig}; 9use embassy_stm32::qspi::{Config as QspiCfg, Instance, Qspi, TransferConfig};
9use embassy_stm32::time::mhz; 10use embassy_stm32::time::mhz;
10use embassy_stm32::Config as StmCfg; 11use embassy_stm32::Config as StmCfg;
11use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
@@ -43,12 +44,12 @@ const MEMORY_ADDR: u32 = 0x00000000u32;
43/// Implementation of access to flash chip. 44/// Implementation of access to flash chip.
44/// Chip commands are hardcoded as it depends on used chip. 45/// Chip commands are hardcoded as it depends on used chip.
45/// This implementation is using chip GD25Q64C from Giga Device 46/// This implementation is using chip GD25Q64C from Giga Device
46pub struct FlashMemory<I: Instance, D: QuadDma<I>> { 47pub struct FlashMemory<I: Instance> {
47 qspi: Qspi<'static, I, D>, 48 qspi: Qspi<'static, I, Async>,
48} 49}
49 50
50impl<I: Instance, D: QuadDma<I>> FlashMemory<I, D> { 51impl<I: Instance> FlashMemory<I> {
51 pub fn new(qspi: Qspi<'static, I, D>) -> Self { 52 pub fn new(qspi: Qspi<'static, I, Async>) -> Self {
52 let mut memory = Self { qspi }; 53 let mut memory = Self { qspi };
53 54
54 memory.reset_memory(); 55 memory.reset_memory();
@@ -279,7 +280,7 @@ async fn main(_spawner: Spawner) -> ! {
279 cs_high_time: ChipSelectHighTime::_1Cycle, 280 cs_high_time: ChipSelectHighTime::_1Cycle,
280 fifo_threshold: FIFOThresholdLevel::_16Bytes, 281 fifo_threshold: FIFOThresholdLevel::_16Bytes,
281 }; 282 };
282 let driver = Qspi::new_bk1( 283 let driver = Qspi::new_bank1(
283 p.QUADSPI, p.PF8, p.PF9, p.PE2, p.PF6, p.PF10, p.PB10, p.DMA2_CH7, config, 284 p.QUADSPI, p.PF8, p.PF9, p.PE2, p.PF6, p.PF10, p.PB10, p.DMA2_CH7, config,
284 ); 285 );
285 let mut flash = FlashMemory::new(driver); 286 let mut flash = FlashMemory::new(driver);
diff --git a/examples/stm32g0/src/bin/i2c_async.rs b/examples/stm32g0/src/bin/i2c_async.rs
new file mode 100644
index 000000000..7e3189b05
--- /dev/null
+++ b/examples/stm32g0/src/bin/i2c_async.rs
@@ -0,0 +1,48 @@
1#![no_std]
2#![no_main]
3
4use defmt::*;
5use embassy_executor::Spawner;
6use embassy_stm32::i2c::{self, I2c};
7use embassy_stm32::time::Hertz;
8use embassy_stm32::{bind_interrupts, peripherals};
9use embassy_time::{Duration, Timer};
10use {defmt_rtt as _, panic_probe as _};
11
12bind_interrupts!(struct Irqs {
13 I2C1 => i2c::EventInterruptHandler<peripherals::I2C1>, i2c::ErrorInterruptHandler<peripherals::I2C1>;
14});
15
16const TMP117_ADDR: u8 = 0x48;
17const TMP117_TEMP_RESULT: u8 = 0x00;
18
19#[embassy_executor::main]
20async fn main(_spawner: Spawner) {
21 info!("Hello world");
22
23 let p = embassy_stm32::init(Default::default());
24
25 let mut data = [0u8; 2];
26 let mut i2c = I2c::new(
27 p.I2C1,
28 p.PB8,
29 p.PB9,
30 Irqs,
31 p.DMA1_CH1,
32 p.DMA1_CH2,
33 Hertz(100_000),
34 Default::default(),
35 );
36
37 loop {
38 match i2c.write_read(TMP117_ADDR, &[TMP117_TEMP_RESULT], &mut data).await {
39 Ok(()) => {
40 let temp = f32::from(i16::from_be_bytes(data)) * 7.8125 / 1000.0;
41 info!("Temperature {}", temp);
42 }
43 Err(_) => error!("I2C Error"),
44 }
45
46 Timer::after(Duration::from_millis(1000)).await;
47 }
48}
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml
index a09af4b97..c6c2d1354 100644
--- a/examples/stm32h7/Cargo.toml
+++ b/examples/stm32h7/Cargo.toml
@@ -8,6 +8,7 @@ license = "MIT OR Apache-2.0"
8# Change stm32h743bi to your chip name, if necessary. 8# Change stm32h743bi to your chip name, if necessary.
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h743bi", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h743bi", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] }
10embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" }
11embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } 12embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 13embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } 14embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] }
diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs
index 0009103d1..e9a857a74 100644
--- a/examples/stm32h7/src/bin/adc.rs
+++ b/examples/stm32h7/src/bin/adc.rs
@@ -51,7 +51,7 @@ async fn main(_spawner: Spawner) {
51 let mut vrefint_channel = adc.enable_vrefint(); 51 let mut vrefint_channel = adc.enable_vrefint();
52 52
53 loop { 53 loop {
54 let vrefint = adc.read_internal(&mut vrefint_channel); 54 let vrefint = adc.read(&mut vrefint_channel);
55 info!("vrefint: {}", vrefint); 55 info!("vrefint: {}", vrefint);
56 let measured = adc.read(&mut p.PC0); 56 let measured = adc.read(&mut p.PC0);
57 info!("measured: {}", measured); 57 info!("measured: {}", measured);
diff --git a/examples/stm32h7/src/bin/i2c_shared.rs b/examples/stm32h7/src/bin/i2c_shared.rs
new file mode 100644
index 000000000..6f4815582
--- /dev/null
+++ b/examples/stm32h7/src/bin/i2c_shared.rs
@@ -0,0 +1,111 @@
1#![no_std]
2#![no_main]
3
4use core::cell::RefCell;
5
6use defmt::*;
7use embassy_embedded_hal::shared_bus::blocking::i2c::I2cDevice;
8use embassy_executor::Spawner;
9use embassy_stm32::i2c::{self, I2c};
10use embassy_stm32::mode::Async;
11use embassy_stm32::time::Hertz;
12use embassy_stm32::{bind_interrupts, peripherals};
13use embassy_sync::blocking_mutex::NoopMutex;
14use embassy_time::{Duration, Timer};
15use static_cell::StaticCell;
16use {defmt_rtt as _, panic_probe as _};
17
18const TMP117_ADDR: u8 = 0x48;
19const TMP117_TEMP_RESULT: u8 = 0x00;
20
21const SHTC3_ADDR: u8 = 0x70;
22const SHTC3_WAKEUP: [u8; 2] = [0x35, 0x17];
23const SHTC3_MEASURE_RH_FIRST: [u8; 2] = [0x5c, 0x24];
24const SHTC3_SLEEP: [u8; 2] = [0xb0, 0x98];
25
26static I2C_BUS: StaticCell<NoopMutex<RefCell<I2c<'static, Async>>>> = StaticCell::new();
27
28bind_interrupts!(struct Irqs {
29 I2C1_EV => i2c::EventInterruptHandler<peripherals::I2C1>;
30 I2C1_ER => i2c::ErrorInterruptHandler<peripherals::I2C1>;
31});
32
33#[embassy_executor::task]
34async fn temperature(mut i2c: impl embedded_hal_1::i2c::I2c + 'static) {
35 let mut data = [0u8; 2];
36
37 loop {
38 match i2c.write_read(TMP117_ADDR, &[TMP117_TEMP_RESULT], &mut data) {
39 Ok(()) => {
40 let temp = f32::from(i16::from_be_bytes(data)) * 7.8125 / 1000.0;
41 info!("Temperature {}", temp);
42 }
43 Err(_) => error!("I2C Error"),
44 }
45
46 Timer::after(Duration::from_millis(1000)).await;
47 }
48}
49
50#[embassy_executor::task]
51async fn humidity(mut i2c: impl embedded_hal_1::i2c::I2c + 'static) {
52 let mut data = [0u8; 6];
53
54 loop {
55 // Wakeup
56 match i2c.write(SHTC3_ADDR, &SHTC3_WAKEUP) {
57 Ok(()) => Timer::after(Duration::from_millis(20)).await,
58 Err(_) => error!("I2C Error"),
59 }
60
61 // Measurement
62 match i2c.write(SHTC3_ADDR, &SHTC3_MEASURE_RH_FIRST) {
63 Ok(()) => Timer::after(Duration::from_millis(5)).await,
64 Err(_) => error!("I2C Error"),
65 }
66
67 // Result
68 match i2c.read(SHTC3_ADDR, &mut data) {
69 Ok(()) => Timer::after(Duration::from_millis(5)).await,
70 Err(_) => error!("I2C Error"),
71 }
72
73 // Sleep
74 match i2c.write(SHTC3_ADDR, &SHTC3_SLEEP) {
75 Ok(()) => {
76 let (bytes, _) = data.split_at(core::mem::size_of::<i16>());
77 let rh = f32::from(u16::from_be_bytes(bytes.try_into().unwrap())) * 100.0 / 65536.0;
78 info!("Humidity: {}", rh);
79 }
80 Err(_) => error!("I2C Error"),
81 }
82
83 Timer::after(Duration::from_millis(1000)).await;
84 }
85}
86
87#[embassy_executor::main]
88async fn main(spawner: Spawner) {
89 let p = embassy_stm32::init(Default::default());
90
91 let i2c = I2c::new(
92 p.I2C1,
93 p.PB8,
94 p.PB9,
95 Irqs,
96 p.DMA1_CH4,
97 p.DMA1_CH5,
98 Hertz(100_000),
99 Default::default(),
100 );
101 let i2c_bus = NoopMutex::new(RefCell::new(i2c));
102 let i2c_bus = I2C_BUS.init(i2c_bus);
103
104 // Device 1, using embedded-hal-async compatible driver for TMP117
105 let i2c_dev1 = I2cDevice::new(i2c_bus);
106 spawner.spawn(temperature(i2c_dev1)).unwrap();
107
108 // Device 2, using embedded-hal-async compatible driver for SHTC3
109 let i2c_dev2 = I2cDevice::new(i2c_bus);
110 spawner.spawn(humidity(i2c_dev2)).unwrap();
111}
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs
index aaebdc346..ad4a8aaf7 100644
--- a/examples/stm32h7/src/bin/spi.rs
+++ b/examples/stm32h7/src/bin/spi.rs
@@ -8,7 +8,6 @@ use cortex_m_rt::entry;
8use defmt::*; 8use defmt::*;
9use embassy_executor::Executor; 9use embassy_executor::Executor;
10use embassy_stm32::mode::Blocking; 10use embassy_stm32::mode::Blocking;
11use embassy_stm32::peripherals::SPI3;
12use embassy_stm32::time::mhz; 11use embassy_stm32::time::mhz;
13use embassy_stm32::{spi, Config}; 12use embassy_stm32::{spi, Config};
14use heapless::String; 13use heapless::String;
@@ -16,7 +15,7 @@ use static_cell::StaticCell;
16use {defmt_rtt as _, panic_probe as _}; 15use {defmt_rtt as _, panic_probe as _};
17 16
18#[embassy_executor::task] 17#[embassy_executor::task]
19async fn main_task(mut spi: spi::Spi<'static, SPI3, Blocking>) { 18async fn main_task(mut spi: spi::Spi<'static, Blocking>) {
20 for n in 0u32.. { 19 for n in 0u32.. {
21 let mut write: String<128> = String::new(); 20 let mut write: String<128> = String::new();
22 core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap(); 21 core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap();
diff --git a/examples/stm32h7/src/bin/spi_bdma.rs b/examples/stm32h7/src/bin/spi_bdma.rs
index f968df4a7..b2e941078 100644
--- a/examples/stm32h7/src/bin/spi_bdma.rs
+++ b/examples/stm32h7/src/bin/spi_bdma.rs
@@ -9,7 +9,7 @@ use defmt::*;
9use embassy_executor::Executor; 9use embassy_executor::Executor;
10use embassy_stm32::mode::Async; 10use embassy_stm32::mode::Async;
11use embassy_stm32::time::mhz; 11use embassy_stm32::time::mhz;
12use embassy_stm32::{peripherals, spi, Config}; 12use embassy_stm32::{spi, Config};
13use heapless::String; 13use heapless::String;
14use static_cell::StaticCell; 14use static_cell::StaticCell;
15use {defmt_rtt as _, panic_probe as _}; 15use {defmt_rtt as _, panic_probe as _};
@@ -19,7 +19,7 @@ use {defmt_rtt as _, panic_probe as _};
19static mut RAM_D3: [u8; 64 * 1024] = [0u8; 64 * 1024]; 19static mut RAM_D3: [u8; 64 * 1024] = [0u8; 64 * 1024];
20 20
21#[embassy_executor::task] 21#[embassy_executor::task]
22async fn main_task(mut spi: spi::Spi<'static, peripherals::SPI6, Async>) { 22async fn main_task(mut spi: spi::Spi<'static, Async>) {
23 let read_buffer = unsafe { &mut RAM_D3[0..128] }; 23 let read_buffer = unsafe { &mut RAM_D3[0..128] };
24 let write_buffer = unsafe { &mut RAM_D3[128..256] }; 24 let write_buffer = unsafe { &mut RAM_D3[128..256] };
25 25
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs
index 3d3c724eb..731c7fef5 100644
--- a/examples/stm32h7/src/bin/spi_dma.rs
+++ b/examples/stm32h7/src/bin/spi_dma.rs
@@ -9,13 +9,13 @@ use defmt::*;
9use embassy_executor::Executor; 9use embassy_executor::Executor;
10use embassy_stm32::mode::Async; 10use embassy_stm32::mode::Async;
11use embassy_stm32::time::mhz; 11use embassy_stm32::time::mhz;
12use embassy_stm32::{peripherals, spi, Config}; 12use embassy_stm32::{spi, Config};
13use heapless::String; 13use heapless::String;
14use static_cell::StaticCell; 14use static_cell::StaticCell;
15use {defmt_rtt as _, panic_probe as _}; 15use {defmt_rtt as _, panic_probe as _};
16 16
17#[embassy_executor::task] 17#[embassy_executor::task]
18async fn main_task(mut spi: spi::Spi<'static, peripherals::SPI3, Async>) { 18async fn main_task(mut spi: spi::Spi<'static, Async>) {
19 for n in 0u32.. { 19 for n in 0u32.. {
20 let mut write: String<128> = String::new(); 20 let mut write: String<128> = String::new();
21 let mut read = [0; 128]; 21 let mut read = [0; 128];
diff --git a/examples/stm32h7rs/src/bin/spi.rs b/examples/stm32h7rs/src/bin/spi.rs
index a7767876d..8d6ccc58b 100644
--- a/examples/stm32h7rs/src/bin/spi.rs
+++ b/examples/stm32h7rs/src/bin/spi.rs
@@ -8,7 +8,6 @@ use cortex_m_rt::entry;
8use defmt::*; 8use defmt::*;
9use embassy_executor::Executor; 9use embassy_executor::Executor;
10use embassy_stm32::mode::Blocking; 10use embassy_stm32::mode::Blocking;
11use embassy_stm32::peripherals::SPI3;
12use embassy_stm32::spi; 11use embassy_stm32::spi;
13use embassy_stm32::time::mhz; 12use embassy_stm32::time::mhz;
14use heapless::String; 13use heapless::String;
@@ -16,7 +15,7 @@ use static_cell::StaticCell;
16use {defmt_rtt as _, panic_probe as _}; 15use {defmt_rtt as _, panic_probe as _};
17 16
18#[embassy_executor::task] 17#[embassy_executor::task]
19async fn main_task(mut spi: spi::Spi<'static, SPI3, Blocking>) { 18async fn main_task(mut spi: spi::Spi<'static, Blocking>) {
20 for n in 0u32.. { 19 for n in 0u32.. {
21 let mut write: String<128> = String::new(); 20 let mut write: String<128> = String::new();
22 core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap(); 21 core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap();
diff --git a/examples/stm32h7rs/src/bin/spi_dma.rs b/examples/stm32h7rs/src/bin/spi_dma.rs
index 26b5d6751..cb305351b 100644
--- a/examples/stm32h7rs/src/bin/spi_dma.rs
+++ b/examples/stm32h7rs/src/bin/spi_dma.rs
@@ -8,14 +8,14 @@ use cortex_m_rt::entry;
8use defmt::*; 8use defmt::*;
9use embassy_executor::Executor; 9use embassy_executor::Executor;
10use embassy_stm32::mode::Async; 10use embassy_stm32::mode::Async;
11use embassy_stm32::spi;
11use embassy_stm32::time::mhz; 12use embassy_stm32::time::mhz;
12use embassy_stm32::{peripherals, spi};
13use heapless::String; 13use heapless::String;
14use static_cell::StaticCell; 14use static_cell::StaticCell;
15use {defmt_rtt as _, panic_probe as _}; 15use {defmt_rtt as _, panic_probe as _};
16 16
17#[embassy_executor::task] 17#[embassy_executor::task]
18async fn main_task(mut spi: spi::Spi<'static, peripherals::SPI3, Async>) { 18async fn main_task(mut spi: spi::Spi<'static, Async>) {
19 for n in 0u32.. { 19 for n in 0u32.. {
20 let mut write: String<128> = String::new(); 20 let mut write: String<128> = String::new();
21 let mut read = [0; 128]; 21 let mut read = [0; 128];
diff --git a/examples/stm32l4/src/bin/can.rs b/examples/stm32l4/src/bin/can.rs
new file mode 100644
index 000000000..3c4cdac24
--- /dev/null
+++ b/examples/stm32l4/src/bin/can.rs
@@ -0,0 +1,68 @@
1#![no_std]
2#![no_main]
3
4use defmt::*;
5use embassy_executor::Spawner;
6use embassy_stm32::can::filter::Mask32;
7use embassy_stm32::can::{
8 Can, Fifo, Frame, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, TxInterruptHandler,
9};
10use embassy_stm32::peripherals::CAN1;
11use embassy_stm32::{bind_interrupts, Config};
12use embassy_time::Timer;
13use {defmt_rtt as _, panic_probe as _};
14
15bind_interrupts!(struct Irqs {
16 CAN1_RX0 => Rx0InterruptHandler<CAN1>;
17 CAN1_RX1 => Rx1InterruptHandler<CAN1>;
18 CAN1_SCE => SceInterruptHandler<CAN1>;
19 CAN1_TX => TxInterruptHandler<CAN1>;
20});
21
22#[embassy_executor::main]
23async fn main(_spawner: Spawner) {
24 let p = embassy_stm32::init(Config::default());
25
26 let mut can = Can::new(p.CAN1, p.PA11, p.PA12, Irqs);
27
28 can.modify_filters().enable_bank(0, Fifo::Fifo0, Mask32::accept_all());
29
30 can.modify_config()
31 .set_loopback(true) // Receive own frames
32 .set_silent(true)
33 .set_bitrate(250_000);
34
35 can.enable().await;
36 println!("CAN enabled");
37
38 let mut i = 0;
39 let mut last_read_ts = embassy_time::Instant::now();
40 loop {
41 let frame = Frame::new_extended(0x123456F, &[i; 8]).unwrap();
42 info!("Writing frame");
43
44 _ = can.write(&frame).await;
45
46 match can.read().await {
47 Ok(envelope) => {
48 let (ts, rx_frame) = (envelope.ts, envelope.frame);
49 let delta = (ts - last_read_ts).as_millis();
50 last_read_ts = ts;
51 info!(
52 "Rx: {} {:02x} --- {}ms",
53 rx_frame.header().len(),
54 rx_frame.data()[0..rx_frame.header().len() as usize],
55 delta,
56 )
57 }
58 Err(err) => error!("Error in frame: {}", err),
59 }
60
61 Timer::after_millis(250).await;
62
63 i += 1;
64 if i > 2 {
65 break;
66 }
67 }
68}
diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs
index 694629ede..33149144c 100644
--- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs
+++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs
@@ -55,12 +55,12 @@ const IP_ADDRESS: Ipv4Cidr = Ipv4Cidr::new(Ipv4Address([192, 168, 1, 5]), 24);
55// Listen port for the webserver 55// Listen port for the webserver
56const HTTP_LISTEN_PORT: u16 = 80; 56const HTTP_LISTEN_PORT: u16 = 80;
57 57
58pub type SpeSpi = Spi<'static, peripherals::SPI2, Async>; 58pub type SpeSpi = Spi<'static, Async>;
59pub type SpeSpiCs = ExclusiveDevice<SpeSpi, Output<'static>, Delay>; 59pub type SpeSpiCs = ExclusiveDevice<SpeSpi, Output<'static>, Delay>;
60pub type SpeInt = exti::ExtiInput<'static>; 60pub type SpeInt = exti::ExtiInput<'static>;
61pub type SpeRst = Output<'static>; 61pub type SpeRst = Output<'static>;
62pub type Adin1110T = ADIN1110<SpeSpiCs>; 62pub type Adin1110T = ADIN1110<SpeSpiCs>;
63pub type TempSensI2c = I2c<'static, peripherals::I2C3, Async>; 63pub type TempSensI2c = I2c<'static, Async>;
64 64
65static TEMP: AtomicI32 = AtomicI32::new(0); 65static TEMP: AtomicI32 = AtomicI32::new(0);
66 66