@@ -22,9 +22,9 @@ use panic_semihosting as _; // logs messages to the host stderr; requires a debu
22
22
use stm32f4xx_hal as hal;
23
23
24
24
use crate :: hal:: {
25
- dma:: { Stream0 , Stream1 , StreamsTuple } ,
25
+ dma:: { Stream1 , StreamsTuple } ,
26
26
gpio:: * ,
27
- i2c:: dma:: { I2CMasterDma , I2CMasterWriteDMA } ,
27
+ i2c:: dma:: { I2CMasterDma , I2CMasterHandleIT , I2CMasterWriteDMA , NoDMA , TxDMA } ,
28
28
i2c:: I2c ,
29
29
interrupt, pac,
30
30
pac:: { DMA1 , I2C1 } ,
@@ -52,11 +52,9 @@ use heapless::String;
52
52
use ssd1306:: { prelude:: * , Ssd1306 } ;
53
53
54
54
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
60
58
> ;
61
59
62
60
// Set up global state. It's all mutexed up for concurrency safety.
@@ -177,7 +175,7 @@ fn main() -> ! {
177
175
178
176
// Then convert it to DMA
179
177
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 ) ;
181
179
free ( |cs| {
182
180
I2C1 . borrow ( cs) . replace ( Some ( i2c_dma) ) ;
183
181
} ) ;
0 commit comments