Skip to content

Commit 24852c3

Browse files
committed
I2C DMA: adapt i2c dma example to use only Tx DMA
1 parent 31dd747 commit 24852c3

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

examples/stopwatch-with-ssd1306-and-interrupts-and-dma-i2c.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ use panic_semihosting as _; // logs messages to the host stderr; requires a debu
2222
use stm32f4xx_hal as hal;
2323

2424
use crate::hal::{
25-
dma::{Stream0, Stream1, StreamsTuple},
25+
dma::{Stream1, StreamsTuple},
2626
gpio::*,
27-
i2c::dma::{I2CMasterDma, I2CMasterWriteDMA},
27+
i2c::dma::{I2CMasterDma, I2CMasterHandleIT, I2CMasterWriteDMA, NoDMA, TxDMA},
2828
i2c::I2c,
2929
interrupt, pac,
3030
pac::{DMA1, I2C1},
@@ -52,11 +52,9 @@ use heapless::String;
5252
use ssd1306::{prelude::*, Ssd1306};
5353

5454
pub type I2c1Handle = I2CMasterDma<
55-
I2C1, // Instance of I2C
56-
Stream1<DMA1>, // Stream used for Tx
57-
0, // Channel for Tx
58-
Stream0<DMA1>, // Stream used for Rx (Not used in example)
59-
1, // Channel for Rx (Not used in example)
55+
I2C1, // Instance of I2C
56+
TxDMA<I2C1, Stream1<DMA1>, 0>, // Stream and channel used for Tx. First parameter must be same Instance as first generic parameter of I2CMasterDma
57+
NoDMA, // This example don't need Rx
6058
>;
6159

6260
// Set up global state. It's all mutexed up for concurrency safety.
@@ -177,7 +175,7 @@ fn main() -> ! {
177175

178176
// Then convert it to DMA
179177
let streams = StreamsTuple::new(dp.DMA1);
180-
let i2c_dma: I2c1Handle = i2c.use_dma(streams.1, streams.0);
178+
let i2c_dma: I2c1Handle = i2c.use_dma_tx(streams.1);
181179
free(|cs| {
182180
I2C1.borrow(cs).replace(Some(i2c_dma));
183181
});

0 commit comments

Comments
 (0)