Skip to content

Commit 711fac8

Browse files
committed
Update guide for using updated pinmux driver interface
Sonata's Pinmux driver has been updated to give it more granaular capabilites, such that capabilities to individual pin sinks and block sinks can be created and distributed, for better compartmentalisation and isolation of software that uses pinmux. This commit updates `sonata-software` to use the updated driver. Currently, the only thing using Pinmux in the software repo is the IO guide, and so this is updated to reflect the new software interface for this driver.
1 parent ede51ec commit 711fac8

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

doc/guide/sonata-io.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,25 @@ For example say you wished to connect the PMOD0 SPI to SPI block 1; there are 4
3535
- PMOD 0 CS (pin 1), COPI (pin 2) and SCK (pin 4) output selectors
3636
- SPI Block 1 CIPO input selector
3737

38-
The code below shows how to use the pinmux driver to do this:
38+
The code below shows how you could use the pinmux driver to do this:
3939

4040
```c++
4141
#include <platform-pinmux.hh>
4242

4343
...
4444

45-
auto pinmux = SonataPinmux();
46-
pinmux.output_pin_select(SonataPinmux::OutputPin::pmod0_1, 2);
47-
pinmux.block_input_select(SonataPinmux::BlockInput::spi_1_cipo, 3);
48-
pinmux.output_pin_select(SonataPinmux::OutputPin::pmod0_2, 2);
49-
pinmux.output_pin_select(SonataPinmux::OutputPin::pmod0_4, 2);
45+
auto pinmuxPinSinks = MMIO_CAPABILITY(SonataPinmux::PinSinks, pinmux_pins_sinks);
46+
auto pinmuxBlockSinks = MMIO_CAPABILITY(SonataPinmux::BlockSinks, pinmux_block_sinks);
47+
48+
auto pmod0_1 = pinmuxPinSinks->get(SonataPinmux::PinSink::pmod0_1);
49+
auto spi_1_cipo = pinmuxBlockSinks->get(SonataPinmux::BlockSink::spi_1_cipo);
50+
auto pmod0_2 = pinmuxPinSinks->get(SonataPinmux::PinSink::pmod0_2);
51+
auto pmod0_4 = pinmuxPinSinks->get(SonataPinmux::PinSink::pmod0_4);
52+
53+
pmod0_1.select(2);
54+
spi_1_cipo.select(3);
55+
pmod0_2.select(2);
56+
pmod0_4.select(2);
5057
```
5158
5259
Following this you can then use the `spi1` SPI instance to communicate with whatever SPI device is plugged into PMOD0.

0 commit comments

Comments
 (0)