Skip to content

Commit 594166f

Browse files
Merge #534
534: Non-Blocking I2C based on DMA r=burrbull a=SpeedCrash100 Adds method `use_dma` on I2c structure for creating a new structure `I2CMasterDma`. The new structure allows to use unsafe methods ended with `_dma` to send/receive data in non blocking mode and call specified `callback` at the end of transfer. The `I2CMasterDma` also have methods for blocking transfers but they returns `nb::Result` and `WouldBlock` if there are operation in progress. Clients must call `handle_dma_interrupt` in DMAx_STREAMy interrupt and `handle_error_interrupt` in I2Cx_ER interrupt for correct working of this structure. At the current stage Start generation and Address sending is blocking anyway, so current implementation have benefits only with high amount of data to transfer. For example, sending image to display. I've also prepared example of usage with SSD1306 display and LM75B temperature sensor in [separate repository](https://github.com/SpeedCrash100/stm32f4xx-dma-i2c-example) Co-authored-by: SpeedCrash100 <[email protected]>
2 parents 3949ad6 + 2ae78c2 commit 594166f

File tree

6 files changed

+1089
-22
lines changed

6 files changed

+1089
-22
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4040
- `SysMonoTimerExt` helper trait, `Pwm::(get/set)_duty_time` [#497]
4141
- example of using i2s in out with rtic and interrupt.
4242
- example of using USB CDC with interrupts.
43+
- Added non-blocking I2C based on DMA [#534]
4344

4445
[#481]: https://github.com/stm32-rs/stm32f4xx-hal/pull/481
4546
[#489]: https://github.com/stm32-rs/stm32f4xx-hal/pull/489
@@ -55,6 +56,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
5556
[#519]: https://github.com/stm32-rs/stm32f4xx-hal/pull/519
5657
[#529]: https://github.com/stm32-rs/stm32f4xx-hal/pull/529
5758
[#536]: https://github.com/stm32-rs/stm32f4xx-hal/pull/536
59+
[#534]: https://github.com/stm32-rs/stm32f4xx-hal/pull/529
5860

5961
## [v0.13.2] - 2022-05-16
6062

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ ist7920 = "0.1.1"
8181
smart-leds = "0.3.0"
8282
ws2812-spi = { version = "0.4.0", features = [] }
8383
hd44780-driver = "0.4.0"
84+
display-interface = "0.4"
8485

8586
[dev-dependencies.time]
8687
version = "0.3"
@@ -403,6 +404,10 @@ required-features = ["device-selected"] # stm32f411
403404
name = "stopwatch-with-ssd1306-and-interrupts"
404405
required-features = ["tim2"] # stm32f411
405406

407+
[[example]]
408+
name = "stopwatch-with-ssd1306-and-interrupts-and-dma-i2c"
409+
required-features = ["tim2", "stm32f411"] # stm32f411
410+
406411
[[example]]
407412
name = "analog-stopwatch-with-spi-ssd1306"
408413
required-features = ["spi4", "tim2", "gpioe", "gpiog"] # stm32f429

0 commit comments

Comments
 (0)