aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkalkyl <[email protected]>2024-07-08 22:53:50 +0200
committerkalkyl <[email protected]>2024-07-08 22:53:50 +0200
commitaf9c7379f99b309a99b0b573ebfb8ea1bebecaf9 (patch)
tree7160def9d4b71c014f0279917bbdab0e035f5e22
parent03f3a3389d0691492e5d60cd243f3287a4ab42b8 (diff)
Add link to example in book
-rw-r--r--docs/pages/sharing_peripherals.adoc6
-rw-r--r--examples/rp/src/bin/shared_bus.rs4
2 files changed, 7 insertions, 3 deletions
diff --git a/docs/pages/sharing_peripherals.adoc b/docs/pages/sharing_peripherals.adoc
index ebd899c4e..6ba13f93b 100644
--- a/docs/pages/sharing_peripherals.adoc
+++ b/docs/pages/sharing_peripherals.adoc
@@ -127,4 +127,8 @@ async fn toggle_led(control: Sender<'static, ThreadModeRawMutex, LedState, 64>,
127This example replaces the Mutex with a Channel, and uses another task (the main loop) to drive the LED. The advantage of this approach is that only a single task references the peripheral, separating concerns. However, using a Mutex has a lower overhead and might be necessary if you need to ensure 127This example replaces the Mutex with a Channel, and uses another task (the main loop) to drive the LED. The advantage of this approach is that only a single task references the peripheral, separating concerns. However, using a Mutex has a lower overhead and might be necessary if you need to ensure
128that the operation is completed before continuing to do other work in your task. 128that the operation is completed before continuing to do other work in your task.
129 129
130An example showcasing more methods for sharing link:https://github.com/embassy-rs/embassy/blob/main/examples/rp/src/bin/sharing.rs[can be found here]. \ No newline at end of file 130An example showcasing more methods for sharing link:https://github.com/embassy-rs/embassy/blob/main/examples/rp/src/bin/sharing.rs[can be found here].
131
132== Sharing an I2C or SPI bus between multiple devices
133
134An example of how to deal with multiple devices sharing a common I2C or SPI bus link:https://github.com/embassy-rs/embassy/blob/main/examples/rp/src/bin/shared_bus.rs[can be found here].
diff --git a/examples/rp/src/bin/shared_bus.rs b/examples/rp/src/bin/shared_bus.rs
index dad8b812f..c6cb5d64c 100644
--- a/examples/rp/src/bin/shared_bus.rs
+++ b/examples/rp/src/bin/shared_bus.rs
@@ -92,7 +92,7 @@ async fn spi_task_b(spi_bus: &'static Spi1Bus, cs: Output<'static>) {
92 } 92 }
93} 93}
94 94
95// Dummy I2C device driver, implementing `embedded-hal-async` 95// Dummy I2C device driver, using `embedded-hal-async`
96struct DummyI2cDeviceDriver<I2C: embedded_hal_async::i2c::I2c> { 96struct DummyI2cDeviceDriver<I2C: embedded_hal_async::i2c::I2c> {
97 _i2c: I2C, 97 _i2c: I2C,
98} 98}
@@ -103,7 +103,7 @@ impl<I2C: embedded_hal_async::i2c::I2c> DummyI2cDeviceDriver<I2C> {
103 } 103 }
104} 104}
105 105
106// Dummy SPI device driver, implementing `embedded-hal-async` 106// Dummy SPI device driver, using `embedded-hal-async`
107struct DummySpiDeviceDriver<SPI: embedded_hal_async::spi::SpiDevice> { 107struct DummySpiDeviceDriver<SPI: embedded_hal_async::spi::SpiDevice> {
108 _spi: SPI, 108 _spi: SPI,
109} 109}