aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHybridChild <[email protected]>2025-11-12 21:02:10 +0100
committerHybridChild <[email protected]>2025-11-12 21:02:10 +0100
commit973fdb6b222a24e881c722b33767aab76ab92896 (patch)
tree42f282f957ebcf6b5cc37b9d37084b484ea965a7
parent1c94d27a147035dfe40d33bae85be0308394dc53 (diff)
stm32: Add i2c v2 transaction test
-rw-r--r--examples/stm32f0/Cargo.toml1
-rw-r--r--tests/stm32/Cargo.toml7
-rw-r--r--tests/stm32/src/bin/i2c_v2.rs (renamed from examples/stm32f0/src/bin/i2c_transaction_test.rs)153
-rw-r--r--tests/stm32/src/common.rs25
4 files changed, 109 insertions, 77 deletions
diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml
index 177dd0ac2..a78873d21 100644
--- a/examples/stm32f0/Cargo.toml
+++ b/examples/stm32f0/Cargo.toml
@@ -16,7 +16,6 @@ panic-probe = { version = "1.0.0", features = ["print-defmt"] }
16embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } 16embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] }
17embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 17embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
18embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 18embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
19embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
20static_cell = "2" 19static_cell = "2"
21portable-atomic = { version = "1.5", features = ["unsafe-assume-single-core"] } 20portable-atomic = { version = "1.5", features = ["unsafe-assume-single-core"] }
22 21
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml
index b92b47be2..fa757e276 100644
--- a/tests/stm32/Cargo.toml
+++ b/tests/stm32/Cargo.toml
@@ -35,6 +35,7 @@ stm32wb55rg = ["embassy-stm32/stm32wb55rg", "chrono", "not-gpdma", "ble", "mac"
35stm32wba52cg = ["embassy-stm32/stm32wba52cg", "spi-v345", "chrono", "rng", "hash"] 35stm32wba52cg = ["embassy-stm32/stm32wba52cg", "spi-v345", "chrono", "rng", "hash"]
36stm32wl55jc = ["embassy-stm32/stm32wl55jc-cm4", "not-gpdma", "rng", "chrono"] 36stm32wl55jc = ["embassy-stm32/stm32wl55jc-cm4", "not-gpdma", "rng", "chrono"]
37stm32f091rc = ["embassy-stm32/stm32f091rc", "cm0", "not-gpdma", "chrono"] 37stm32f091rc = ["embassy-stm32/stm32f091rc", "cm0", "not-gpdma", "chrono"]
38stm32f072rb = ["embassy-stm32/stm32f072rb", "cm0", "not-gpdma", "chrono"]
38stm32h503rb = ["embassy-stm32/stm32h503rb", "spi-v345", "rng", "stop"] 39stm32h503rb = ["embassy-stm32/stm32h503rb", "spi-v345", "rng", "stop"]
39stm32h7s3l8 = ["embassy-stm32/stm32h7s3l8", "spi-v345", "rng", "cordic", "hash-v34"] # TODO: fdcan crashes, cryp dma hangs. 40stm32h7s3l8 = ["embassy-stm32/stm32h7s3l8", "spi-v345", "rng", "cordic", "hash-v34"] # TODO: fdcan crashes, cryp dma hangs.
40stm32u083rc = ["embassy-stm32/stm32u083rc", "cm0", "rng", "chrono"] 41stm32u083rc = ["embassy-stm32/stm32u083rc", "cm0", "rng", "chrono"]
@@ -160,6 +161,11 @@ path = "src/bin/hash.rs"
160required-features = [ "hash",] 161required-features = [ "hash",]
161 162
162[[bin]] 163[[bin]]
164name = "i2c_v2"
165path = "src/bin/i2c_v2.rs"
166required-features = [ "stm32f072rb",]
167
168[[bin]]
163name = "rng" 169name = "rng"
164path = "src/bin/rng.rs" 170path = "src/bin/rng.rs"
165required-features = [ "rng",] 171required-features = [ "rng",]
@@ -285,6 +291,7 @@ build = [
285 { target = "thumbv7em-none-eabi", features = ["stm32wl55jc"], artifact-dir = "out/tests/stm32wl55jc" }, 291 { target = "thumbv7em-none-eabi", features = ["stm32wl55jc"], artifact-dir = "out/tests/stm32wl55jc" },
286 { target = "thumbv7em-none-eabi", features = ["stm32h7s3l8"], artifact-dir = "out/tests/stm32h7s3l8" }, 292 { target = "thumbv7em-none-eabi", features = ["stm32h7s3l8"], artifact-dir = "out/tests/stm32h7s3l8" },
287 { target = "thumbv6m-none-eabi", features = ["stm32f091rc"], artifact-dir = "out/tests/stm32f091rc" }, 293 { target = "thumbv6m-none-eabi", features = ["stm32f091rc"], artifact-dir = "out/tests/stm32f091rc" },
294 { target = "thumbv6m-none-eabi", features = ["stm32f072rb"], artifact-dir = "out/tests/stm32f072rb" },
288 { target = "thumbv8m.main-none-eabihf", features = ["stm32h503rb"], artifact-dir = "out/tests/stm32h503rb" }, 295 { target = "thumbv8m.main-none-eabihf", features = ["stm32h503rb"], artifact-dir = "out/tests/stm32h503rb" },
289 { target = "thumbv6m-none-eabi", features = ["stm32u083rc"], artifact-dir = "out/tests/stm32u083rc" } 296 { target = "thumbv6m-none-eabi", features = ["stm32u083rc"], artifact-dir = "out/tests/stm32u083rc" }
290] 297]
diff --git a/examples/stm32f0/src/bin/i2c_transaction_test.rs b/tests/stm32/src/bin/i2c_v2.rs
index 0ecc3e8b1..9a23e28e1 100644
--- a/examples/stm32f0/src/bin/i2c_transaction_test.rs
+++ b/tests/stm32/src/bin/i2c_v2.rs
@@ -1,75 +1,81 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3// required-features: stm32f072rb
4use defmt::*; 4//
5// Hardware Setup for NUCLEO-F072RB:
6// - I2C1 pins: PB8 (SCL), PB9 (SDA) on CN5 connector
7// - Connect to I2C slave device (e.g., Digilent Analog Discovery I2C slave, or EEPROM)
8// - Default slave address: 0x50
9// - Pull-up resistors: 4.7kΩ on both SCL and SDA
10// - CN5 Pin 5 (PB8/SCL) and CN5 Pin 9 (PB9/SDA)
11//
12// Analog Discovery Setup:
13// - Configure as I2C Slave at address 0x50
14// - DIO 0: SCL
15// - DIO 1: SDA
16// - Enable pull-ups or use external 4.7kΩ pull-up resistors
17
18#[path = "../common.rs"]
19mod common;
20
21use common::*;
5use embassy_executor::Spawner; 22use embassy_executor::Spawner;
6use embassy_stm32::i2c::{Config, I2c, Master}; 23use embassy_stm32::i2c::{Config, I2c, Master};
7use embassy_stm32::mode::Blocking; 24use embassy_stm32::mode::Blocking;
8use embassy_stm32::time::Hertz; 25use embassy_stm32::time::Hertz;
9use embassy_stm32::{bind_interrupts, i2c, peripherals}; 26use embassy_time::block_for;
10use embassy_time::Timer;
11use embedded_hal_1::i2c::Operation; 27use embedded_hal_1::i2c::Operation;
12use {defmt_rtt as _, panic_probe as _};
13
14bind_interrupts!(struct Irqs {
15 I2C1 => i2c::EventInterruptHandler<peripherals::I2C1>, i2c::ErrorInterruptHandler<peripherals::I2C1>;
16});
17 28
18#[embassy_executor::main] 29#[embassy_executor::main]
19async fn main(_spawner: Spawner) { 30async fn main(_spawner: Spawner) {
20 // For STM32F072RB on NUCLEO board 31 let p = init();
21 let p = embassy_stm32::init(Default::default()); 32 info!("I2C v2 Transaction Test Starting...");
22 33
23 info!("I2C Transaction Test Starting..."); 34 let mut i2c_peri = peri!(p, I2C);
35 let mut scl = peri!(p, I2C_SCL);
36 let mut sda = peri!(p, I2C_SDA);
24 37
25 // Initialize I2C1: PB6=SCL, PB7=SDA
26 let mut config = Config::default(); 38 let mut config = Config::default();
27 config.frequency = Hertz(100_000); 39 config.frequency = Hertz(100_000);
40
28 let mut i2c = I2c::new_blocking( 41 let mut i2c = I2c::new_blocking(
29 p.I2C1, 42 i2c_peri.reborrow(),
30 p.PB8, // SCL 43 scl.reborrow(),
31 p.PB9, // SDA 44 sda.reborrow(),
32 config, 45 config,
33 ); 46 );
34 47
48 // I2C slave address for Analog Discovery or test EEPROM
35 let slave_addr = 0x50u8; 49 let slave_addr = 0x50u8;
36 50
37 // Wait for devices to initialize 51 // Wait for slave device to be ready
38 Timer::after_millis(100).await; 52 block_for(embassy_time::Duration::from_millis(100));
39 53
40 info!("=== Test 1: Consecutive Writes (Should Merge) ==="); 54 info!("=== Test 1: Consecutive Writes (Should Merge) ===");
41 test_consecutive_writes(&mut i2c, slave_addr); 55 test_consecutive_writes(&mut i2c, slave_addr);
42 Timer::after_millis(500).await;
43 56
44 info!("=== Test 2: Consecutive Reads (Should Merge) ==="); 57 info!("=== Test 2: Consecutive Reads (Should Merge) ===");
45 test_consecutive_reads(&mut i2c, slave_addr); 58 test_consecutive_reads(&mut i2c, slave_addr);
46 Timer::after_millis(500).await;
47 59
48 info!("=== Test 3: Write then Read (RESTART) ==="); 60 info!("=== Test 3: Write then Read (RESTART) ===");
49 test_write_then_read(&mut i2c, slave_addr); 61 test_write_then_read(&mut i2c, slave_addr);
50 Timer::after_millis(500).await;
51 62
52 info!("=== Test 4: Read then Write (RESTART) ==="); 63 info!("=== Test 4: Read then Write (RESTART) ===");
53 test_read_then_write(&mut i2c, slave_addr); 64 test_read_then_write(&mut i2c, slave_addr);
54 Timer::after_millis(500).await;
55 65
56 info!("=== Test 5: Complex Mixed Sequence ==="); 66 info!("=== Test 5: Complex Mixed Sequence ===");
57 test_mixed_sequence(&mut i2c, slave_addr); 67 test_mixed_sequence(&mut i2c, slave_addr);
58 Timer::after_millis(500).await;
59 68
60 info!("=== Test 6: Single Operations ==="); 69 info!("=== Test 6: Single Operations ===");
61 test_single_operations(&mut i2c, slave_addr); 70 test_single_operations(&mut i2c, slave_addr);
62 71
63 info!("All tests complete!"); 72 info!("Test OK");
64 73 cortex_m::asm::bkpt();
65 loop {
66 Timer::after_secs(1).await;
67 }
68} 74}
69 75
70fn test_consecutive_writes(i2c: &mut I2c<'static, Blocking, Master>, addr: u8) { 76fn test_consecutive_writes(i2c: &mut I2c<'_, Blocking, Master>, addr: u8) {
71 // Expected on bus: START, ADDR+W, data1, data2, data3, STOP 77 // Expected on bus: START, ADDR+W, data1, data2, data3, STOP
72 // NO intermediate RESTART/STOP between writes 78 // NO intermediate RESTART/STOP between writes - they should be merged
73 let data1 = [0x10, 0x11, 0x12]; 79 let data1 = [0x10, 0x11, 0x12];
74 let data2 = [0x20, 0x21]; 80 let data2 = [0x20, 0x21];
75 let data3 = [0x30, 0x31, 0x32, 0x33]; 81 let data3 = [0x30, 0x31, 0x32, 0x33];
@@ -81,17 +87,17 @@ fn test_consecutive_writes(i2c: &mut I2c<'static, Blocking, Master>, addr: u8) {
81 ]; 87 ];
82 88
83 match i2c.blocking_transaction(addr, &mut ops) { 89 match i2c.blocking_transaction(addr, &mut ops) {
84 Ok(_) => info!("✓ Consecutive writes succeeded"), 90 Ok(_) => info!("✓ Consecutive writes succeeded (merged 9 bytes)"),
85 Err(e) => warn!("✗ Consecutive writes failed: {:?}", e), 91 Err(e) => {
92 error!("✗ Consecutive writes failed: {:?}", e);
93 defmt::panic!("Test failed: consecutive writes");
94 }
86 } 95 }
87
88 info!("Expected: START, ADDR+W, [9 bytes], STOP");
89 info!("Check Analog Discovery: No RESTART between writes");
90} 96}
91 97
92fn test_consecutive_reads(i2c: &mut I2c<'static, Blocking, Master>, addr: u8) { 98fn test_consecutive_reads(i2c: &mut I2c<'_, Blocking, Master>, addr: u8) {
93 // Expected on bus: START, ADDR+R, data1, data2, data3, NACK, STOP 99 // Expected on bus: START, ADDR+R, data1, data2, data3, NACK, STOP
94 // NO intermediate RESTART/STOP between reads 100 // NO intermediate RESTART/STOP between reads - they should be merged
95 let mut buf1 = [0u8; 4]; 101 let mut buf1 = [0u8; 4];
96 let mut buf2 = [0u8; 3]; 102 let mut buf2 = [0u8; 3];
97 let mut buf3 = [0u8; 2]; 103 let mut buf3 = [0u8; 2];
@@ -104,65 +110,59 @@ fn test_consecutive_reads(i2c: &mut I2c<'static, Blocking, Master>, addr: u8) {
104 110
105 match i2c.blocking_transaction(addr, &mut ops) { 111 match i2c.blocking_transaction(addr, &mut ops) {
106 Ok(_) => { 112 Ok(_) => {
107 info!("✓ Consecutive reads succeeded"); 113 info!("✓ Consecutive reads succeeded (merged 9 bytes)");
108 info!(" buf1: {:02x}", buf1); 114 info!(" buf1: {:02x}", buf1);
109 info!(" buf2: {:02x}", buf2); 115 info!(" buf2: {:02x}", buf2);
110 info!(" buf3: {:02x}", buf3); 116 info!(" buf3: {:02x}", buf3);
111 } 117 }
112 Err(e) => warn!("✗ Consecutive reads failed: {:?}", e), 118 Err(e) => {
119 error!("✗ Consecutive reads failed: {:?}", e);
120 defmt::panic!("Test failed: consecutive reads");
121 }
113 } 122 }
114
115 info!("Expected: START, ADDR+R, [9 bytes], NACK on last, STOP");
116 info!("Check Analog Discovery: No RESTART between reads");
117} 123}
118 124
119fn test_write_then_read(i2c: &mut I2c<'static, Blocking, Master>, addr: u8) { 125fn test_write_then_read(i2c: &mut I2c<'_, Blocking, Master>, addr: u8) {
120 // Expected: START, ADDR+W, data, RESTART, ADDR+R, data, NACK, STOP 126 // Expected: START, ADDR+W, data, RESTART, ADDR+R, data, NACK, STOP
121 let write_data = [0xAA, 0xBB]; 127 let write_data = [0xAA, 0xBB];
122 let mut read_buf = [0u8; 4]; 128 let mut read_buf = [0u8; 4];
123 129
124 let mut ops = [ 130 let mut ops = [Operation::Write(&write_data), Operation::Read(&mut read_buf)];
125 Operation::Write(&write_data),
126 Operation::Read(&mut read_buf),
127 ];
128 131
129 match i2c.blocking_transaction(addr, &mut ops) { 132 match i2c.blocking_transaction(addr, &mut ops) {
130 Ok(_) => { 133 Ok(_) => {
131 info!("✓ Write-then-read succeeded"); 134 info!("✓ Write-then-read succeeded with RESTART");
132 info!(" Written: {:02x}", write_data); 135 info!(" Written: {:02x}", write_data);
133 info!(" Read: {:02x}", read_buf); 136 info!(" Read: {:02x}", read_buf);
134 } 137 }
135 Err(e) => warn!("✗ Write-then-read failed: {:?}", e), 138 Err(e) => {
139 error!("✗ Write-then-read failed: {:?}", e);
140 defmt::panic!("Test failed: write-then-read");
141 }
136 } 142 }
137
138 info!("Expected: START, ADDR+W, [2 bytes], RESTART, ADDR+R, [4 bytes], NACK, STOP");
139 info!("Check Analog Discovery: RESTART between write and read");
140} 143}
141 144
142fn test_read_then_write(i2c: &mut I2c<'static, Blocking, Master>, addr: u8) { 145fn test_read_then_write(i2c: &mut I2c<'_, Blocking, Master>, addr: u8) {
143 // Expected: START, ADDR+R, data, NACK, RESTART, ADDR+W, data, STOP 146 // Expected: START, ADDR+R, data, NACK, RESTART, ADDR+W, data, STOP
144 let mut read_buf = [0u8; 3]; 147 let mut read_buf = [0u8; 3];
145 let write_data = [0xCC, 0xDD, 0xEE]; 148 let write_data = [0xCC, 0xDD, 0xEE];
146 149
147 let mut ops = [ 150 let mut ops = [Operation::Read(&mut read_buf), Operation::Write(&write_data)];
148 Operation::Read(&mut read_buf),
149 Operation::Write(&write_data),
150 ];
151 151
152 match i2c.blocking_transaction(addr, &mut ops) { 152 match i2c.blocking_transaction(addr, &mut ops) {
153 Ok(_) => { 153 Ok(_) => {
154 info!("✓ Read-then-write succeeded"); 154 info!("✓ Read-then-write succeeded with RESTART");
155 info!(" Read: {:02x}", read_buf); 155 info!(" Read: {:02x}", read_buf);
156 info!(" Written: {:02x}", write_data); 156 info!(" Written: {:02x}", write_data);
157 } 157 }
158 Err(e) => warn!("✗ Read-then-write failed: {:?}", e), 158 Err(e) => {
159 error!("✗ Read-then-write failed: {:?}", e);
160 defmt::panic!("Test failed: read-then-write");
161 }
159 } 162 }
160
161 info!("Expected: START, ADDR+R, [3 bytes], NACK, RESTART, ADDR+W, [3 bytes], STOP");
162 info!("Check Analog Discovery: RESTART between read and write");
163} 163}
164 164
165fn test_mixed_sequence(i2c: &mut I2c<'static, Blocking, Master>, addr: u8) { 165fn test_mixed_sequence(i2c: &mut I2c<'_, Blocking, Master>, addr: u8) {
166 // Complex: W, W, R, R, W, R 166 // Complex: W, W, R, R, W, R
167 // Groups: [W,W] RESTART [R,R] RESTART [W] RESTART [R] 167 // Groups: [W,W] RESTART [R,R] RESTART [W] RESTART [R]
168 let w1 = [0x01, 0x02]; 168 let w1 = [0x01, 0x02];
@@ -184,28 +184,26 @@ fn test_mixed_sequence(i2c: &mut I2c<'static, Blocking, Master>, addr: u8) {
184 match i2c.blocking_transaction(addr, &mut ops) { 184 match i2c.blocking_transaction(addr, &mut ops) {
185 Ok(_) => { 185 Ok(_) => {
186 info!("✓ Mixed sequence succeeded"); 186 info!("✓ Mixed sequence succeeded");
187 info!(" r1: {:02x}", r1); 187 info!(" Groups: [W4] RESTART [R4] RESTART [W1] RESTART [R1]");
188 info!(" r2: {:02x}", r2); 188 }
189 info!(" r3: {:02x}", r3); 189 Err(e) => {
190 error!("✗ Mixed sequence failed: {:?}", e);
191 defmt::panic!("Test failed: mixed sequence");
190 } 192 }
191 Err(e) => warn!("✗ Mixed sequence failed: {:?}", e),
192 } 193 }
193
194 info!("Expected sequence:");
195 info!(" START, ADDR+W, [4 bytes merged], RESTART,");
196 info!(" ADDR+R, [4 bytes merged], NACK, RESTART,");
197 info!(" ADDR+W, [1 byte], RESTART,");
198 info!(" ADDR+R, [1 byte], NACK, STOP");
199} 194}
200 195
201fn test_single_operations(i2c: &mut I2c<'static, Blocking, Master>, addr: u8) { 196fn test_single_operations(i2c: &mut I2c<'_, Blocking, Master>, addr: u8) {
202 // Test single write 197 // Test single write
203 let write_data = [0xFF]; 198 let write_data = [0xFF];
204 let mut ops = [Operation::Write(&write_data)]; 199 let mut ops = [Operation::Write(&write_data)];
205 200
206 match i2c.blocking_transaction(addr, &mut ops) { 201 match i2c.blocking_transaction(addr, &mut ops) {
207 Ok(_) => info!("✓ Single write succeeded"), 202 Ok(_) => info!("✓ Single write succeeded"),
208 Err(e) => warn!("✗ Single write failed: {:?}", e), 203 Err(e) => {
204 error!("✗ Single write failed: {:?}", e);
205 defmt::panic!("Test failed: single write");
206 }
209 } 207 }
210 208
211 // Test single read 209 // Test single read
@@ -214,6 +212,9 @@ fn test_single_operations(i2c: &mut I2c<'static, Blocking, Master>, addr: u8) {
214 212
215 match i2c.blocking_transaction(addr, &mut ops) { 213 match i2c.blocking_transaction(addr, &mut ops) {
216 Ok(_) => info!("✓ Single read succeeded, data: 0x{:02x}", read_buf[0]), 214 Ok(_) => info!("✓ Single read succeeded, data: 0x{:02x}", read_buf[0]),
217 Err(e) => warn!("✗ Single read failed: {:?}", e), 215 Err(e) => {
216 error!("✗ Single read failed: {:?}", e);
217 defmt::panic!("Test failed: single read");
218 }
218 } 219 }
219} 220}
diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs
index 096cce947..07b667ade 100644
--- a/tests/stm32/src/common.rs
+++ b/tests/stm32/src/common.rs
@@ -60,6 +60,8 @@ teleprobe_meta::target!(b"nucleo-stm32wl55jc");
60teleprobe_meta::target!(b"nucleo-stm32wba52cg"); 60teleprobe_meta::target!(b"nucleo-stm32wba52cg");
61#[cfg(feature = "stm32f091rc")] 61#[cfg(feature = "stm32f091rc")]
62teleprobe_meta::target!(b"nucleo-stm32f091rc"); 62teleprobe_meta::target!(b"nucleo-stm32f091rc");
63#[cfg(feature = "stm32f072rb")]
64teleprobe_meta::target!(b"nucleo-stm32f072rb");
63#[cfg(feature = "stm32h503rb")] 65#[cfg(feature = "stm32h503rb")]
64teleprobe_meta::target!(b"nucleo-stm32h503rb"); 66teleprobe_meta::target!(b"nucleo-stm32h503rb");
65#[cfg(feature = "stm32h7s3l8")] 67#[cfg(feature = "stm32h7s3l8")]
@@ -103,6 +105,14 @@ define_peris!(
103 SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH3, SPI_RX_DMA = DMA1_CH2, 105 SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH3, SPI_RX_DMA = DMA1_CH2,
104 @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler<embassy_stm32::peripherals::USART1>;}, 106 @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler<embassy_stm32::peripherals::USART1>;},
105); 107);
108#[cfg(feature = "stm32f072rb")]
109define_peris!(
110 UART = USART1, UART_TX = PA9, UART_RX = PA10, UART_TX_DMA = DMA1_CH4, UART_RX_DMA = DMA1_CH5,
111 SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH3, SPI_RX_DMA = DMA1_CH2,
112 I2C = I2C1, I2C_SCL = PB8, I2C_SDA = PB9,
113 @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler<embassy_stm32::peripherals::USART1>;},
114 @irq I2C = {I2C1 => embassy_stm32::i2c::EventInterruptHandler<embassy_stm32::peripherals::I2C1>, embassy_stm32::i2c::ErrorInterruptHandler<embassy_stm32::peripherals::I2C1>;},
115);
106#[cfg(any(feature = "stm32f100rd", feature = "stm32f103c8", feature = "stm32f107vc"))] 116#[cfg(any(feature = "stm32f100rd", feature = "stm32f103c8", feature = "stm32f107vc"))]
107define_peris!( 117define_peris!(
108 UART = USART1, UART_TX = PA9, UART_RX = PA10, UART_TX_DMA = DMA1_CH4, UART_RX_DMA = DMA1_CH5, 118 UART = USART1, UART_TX = PA9, UART_RX = PA10, UART_TX_DMA = DMA1_CH4, UART_RX_DMA = DMA1_CH5,
@@ -325,6 +335,21 @@ pub fn config() -> Config {
325 config.rcc.ahb_pre = AHBPrescaler::DIV1; 335 config.rcc.ahb_pre = AHBPrescaler::DIV1;
326 config.rcc.apb1_pre = APBPrescaler::DIV1; 336 config.rcc.apb1_pre = APBPrescaler::DIV1;
327 } 337 }
338 #[cfg(feature = "stm32f072rb")]
339 {
340 config.rcc.hse = Some(Hse {
341 freq: Hertz(8_000_000),
342 mode: HseMode::Bypass,
343 });
344 config.rcc.pll = Some(Pll {
345 src: PllSource::HSE,
346 prediv: PllPreDiv::DIV1,
347 mul: PllMul::MUL6,
348 });
349 config.rcc.sys = Sysclk::PLL1_P;
350 config.rcc.ahb_pre = AHBPrescaler::DIV1;
351 config.rcc.apb1_pre = APBPrescaler::DIV1;
352 }
328 #[cfg(feature = "stm32f103c8")] 353 #[cfg(feature = "stm32f103c8")]
329 { 354 {
330 config.rcc.hse = Some(Hse { 355 config.rcc.hse = Some(Hse {