Skip to content

Commit

Permalink
feat: add an SPI main abstraction (ariel-os#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 authored Oct 24, 2024
2 parents fc65556 + 9a21f58 commit d049aff
Show file tree
Hide file tree
Showing 46 changed files with 1,599 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

- name: Build rustdoc docs
run: |
cargo doc -p riot-rs --features bench,csprng,executor-thread,external-interrupts,hwrng,i2c,no-boards,random,threading,usb
cargo doc -p riot-rs --features bench,csprng,executor-thread,external-interrupts,hwrng,i2c,no-boards,random,spi,threading,usb
echo "<meta http-equiv=\"refresh\" content=\"0; url=riot_rs\">" > target/doc/index.html
mkdir -p ./_site/dev/docs/api && mv target/doc/* ./_site/dev/docs/api
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ jobs:
# TODO: we'll eventually want to enable relevant features
- name: Run crate tests
run: |
cargo test --no-default-features --features external-interrupts,i2c,no-boards -p riot-rs -p riot-rs-embassy -p riot-rs-embassy-common -p riot-rs-runqueue -p riot-rs-threads -p riot-rs-macros
cargo test --no-default-features --features external-interrupts,i2c,no-boards,spi -p riot-rs -p riot-rs-embassy -p riot-rs-embassy-common -p riot-rs-runqueue -p riot-rs-threads -p riot-rs-macros
cargo test -p rbi -p ringbuffer -p coapcore
# We need to set `RUSTDOCFLAGS` as well in the following jobs, because it
# is used for doc tests.
- name: cargo test for RP
run: RUSTDOCFLAGS='--cfg context="rp2040"' RUSTFLAGS='--cfg context="rp2040"' cargo test --features external-interrupts,i2c,embassy-rp/rp2040 -p riot-rs-rp
run: RUSTDOCFLAGS='--cfg context="rp2040"' RUSTFLAGS='--cfg context="rp2040"' cargo test --features external-interrupts,i2c,spi,embassy-rp/rp2040 -p riot-rs-rp

- name: cargo test for nRF
run: RUSTDOCFLAGS='--cfg context="nrf52840"' RUSTFLAGS='--cfg context="nrf52840"' cargo test --features external-interrupts,i2c,'embassy-nrf/nrf52840' -p riot-rs-nrf
run: RUSTDOCFLAGS='--cfg context="nrf52840"' RUSTFLAGS='--cfg context="nrf52840"' cargo test --features external-interrupts,i2c,spi,'embassy-nrf/nrf52840' -p riot-rs-nrf

- name: cargo test for STM32
run: RUSTDOCFLAGS='--cfg context="stm32wb55rgvx"' RUSTFLAGS='--cfg context="stm32wb55rgvx"' cargo test --features external-interrupts,i2c,'embassy-stm32/stm32wb55rg' -p riot-rs-stm32
run: RUSTDOCFLAGS='--cfg context="stm32wb55rgvx"' RUSTFLAGS='--cfg context="stm32wb55rgvx"' cargo test --features external-interrupts,i2c,spi,'embassy-stm32/stm32wb55rg' -p riot-rs-stm32

lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -176,49 +176,49 @@ jobs:
- name: clippy
uses: clechasseur/rs-clippy-check@v3
with:
args: --verbose --locked --features no-boards,external-interrupts -p riot-rs -p riot-rs-boards -p riot-rs-chips -p riot-rs-debug -p riot-rs-embassy -p riot-rs-embassy-common -p riot-rs-macros -p riot-rs-random -p riot-rs-rt -p riot-rs-threads -p riot-rs-utils -- --deny warnings
args: --verbose --locked --features no-boards,external-interrupts,spi -p riot-rs -p riot-rs-boards -p riot-rs-chips -p riot-rs-debug -p riot-rs-embassy -p riot-rs-embassy-common -p riot-rs-macros -p riot-rs-random -p riot-rs-rt -p riot-rs-threads -p riot-rs-utils -- --deny warnings

- run: echo 'RUSTFLAGS=--cfg context="esp32c6"' >> $GITHUB_ENV
- name: clippy for ESP32
uses: clechasseur/rs-clippy-check@v3
with:
args: --verbose --locked --target=riscv32imac-unknown-none-elf --features external-interrupts,i2c,esp-hal/esp32c6,esp-hal-embassy/esp32c6 -p riot-rs-esp -- --deny warnings
args: --verbose --locked --target=riscv32imac-unknown-none-elf --features external-interrupts,i2c,spi,esp-hal/esp32c6,esp-hal-embassy/esp32c6 -p riot-rs-esp -- --deny warnings

- run: echo 'RUSTFLAGS=--cfg context="rp2040"' >> $GITHUB_ENV
- name: clippy for RP
uses: clechasseur/rs-clippy-check@v3
with:
args: --verbose --locked --features external-interrupts,i2c,embassy-rp/rp2040 -p riot-rs-rp -- --deny warnings
args: --verbose --locked --features external-interrupts,i2c,spi,embassy-rp/rp2040 -p riot-rs-rp -- --deny warnings

- run: echo 'RUSTFLAGS=--cfg context="nrf52840"' >> $GITHUB_ENV
- name: clippy for nRF
uses: clechasseur/rs-clippy-check@v3
with:
args: --verbose --locked --features external-interrupts,i2c,embassy-nrf/nrf52840 -p riot-rs-nrf -- --deny warnings
args: --verbose --locked --features external-interrupts,i2c,spi,embassy-nrf/nrf52840 -p riot-rs-nrf -- --deny warnings

- run: echo 'RUSTFLAGS=--cfg context="stm32wb55rgvx"' >> $GITHUB_ENV
- name: clippy for STM32
uses: clechasseur/rs-clippy-check@v3
with:
args: --verbose --locked --features external-interrupts,i2c,embassy-stm32/stm32wb55rg -p riot-rs-stm32 -- --deny warnings
args: --verbose --locked --features external-interrupts,i2c,spi,embassy-stm32/stm32wb55rg -p riot-rs-stm32 -- --deny warnings

# Reset `RUSTFLAGS`
- run: echo 'RUSTFLAGS=' >> $GITHUB_ENV

- name: rustdoc
run: RUSTDOCFLAGS='-D warnings' cargo doc -p riot-rs --features bench,csprng,executor-thread,external-interrupts,hwrng,i2c,no-boards,random,threading,usb
run: RUSTDOCFLAGS='-D warnings' cargo doc -p riot-rs --features bench,csprng,executor-thread,external-interrupts,hwrng,i2c,no-boards,random,spi,threading,usb

- name: rustdoc for ESP32
run: RUSTDOCFLAGS='-D warnings --cfg context="esp32c6"' cargo doc --target=riscv32imac-unknown-none-elf --features external-interrupts,i2c,esp-hal/esp32c6,esp-hal-embassy/esp32c6 -p riot-rs-esp
run: RUSTDOCFLAGS='-D warnings --cfg context="esp32c6"' cargo doc --target=riscv32imac-unknown-none-elf --features external-interrupts,i2c,spi,esp-hal/esp32c6,esp-hal-embassy/esp32c6 -p riot-rs-esp

- name: rustdoc for RP
run: RUSTDOCFLAGS='-D warnings --cfg context="rp2040"' cargo doc --features external-interrupts,i2c,embassy-rp/rp2040 -p riot-rs-rp
run: RUSTDOCFLAGS='-D warnings --cfg context="rp2040"' cargo doc --features external-interrupts,i2c,spi,embassy-rp/rp2040 -p riot-rs-rp

- name: rustdoc for nRF
run: RUSTDOCFLAGS='-D warnings --cfg context="nrf52840"' cargo doc --features external-interrupts,i2c,embassy-nrf/nrf52840 -p riot-rs-nrf
run: RUSTDOCFLAGS='-D warnings --cfg context="nrf52840"' cargo doc --features external-interrupts,i2c,spi,embassy-nrf/nrf52840 -p riot-rs-nrf

- name: rustdoc for STM32
run: RUSTDOCFLAGS='-D warnings --cfg context="stm32wb55rgvx"' cargo doc --features external-interrupts,i2c,embassy-stm32/stm32wb55rg -p riot-rs-stm32
run: RUSTDOCFLAGS='-D warnings --cfg context="stm32wb55rgvx"' cargo doc --features external-interrupts,i2c,spi,embassy-stm32/stm32wb55rg -p riot-rs-stm32

- name: rustfmt
run: cargo fmt --check --all
Expand Down
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ members = [
"tests/gpio-interrupt-nrf",
"tests/gpio-interrupt-stm32",
"tests/i2c-controller",
"tests/spi-loopback",
"tests/spi-main",
"tests/threading-dynamic-prios",
"tests/threading-lock",
]
Expand Down
11 changes: 10 additions & 1 deletion book/src/support_matrix.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
<tr>
<th>Chip</th>
<th>Testing Board</th>
<th colspan="8">Functionality</th>
<th colspan="9">Functionality</th>
</tr>
<tr>
<th></th>
<th></th>
<th>GPIO</th>
<th>Debug Output</th>
<th>I2C Controller Mode</th>
<th>SPI Main Mode</th>
<th>Logging</th>
<th>User USB</th>
<th>Wi-Fi</th>
Expand All @@ -27,6 +28,7 @@
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="available in hardware, but not currently supported by RIOT-rs"></td>
<td class="support-cell" title="supported with some caveats">☑️</td>
<td class="support-cell" title="available in hardware, but not currently supported by RIOT-rs"></td>
Expand All @@ -40,6 +42,7 @@
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="not available on this piece of hardware"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
Expand All @@ -52,6 +55,7 @@
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="not available on this piece of hardware"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
Expand All @@ -64,6 +68,7 @@
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="not available on this piece of hardware"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
Expand All @@ -79,13 +84,15 @@
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
</tr>
<tr>
<td>STM32F401RETX</td>
<td>ST NUCLEO-F401RE</td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="available in hardware, but not currently supported by RIOT-rs"></td>
<td class="support-cell" title="available in hardware, but not currently supported by RIOT-rs"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="not available on this piece of hardware"></td>
<td class="support-cell" title="not available on this piece of hardware"></td>
Expand All @@ -100,6 +107,7 @@
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="not available on this piece of hardware"></td>
<td class="support-cell" title="available in hardware, but not currently supported by RIOT-rs"></td>
<td class="support-cell" title="supported"></td>
Expand All @@ -112,6 +120,7 @@
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="not available on this piece of hardware"></td>
<td class="support-cell" title="supported"></td>
<td class="support-cell" title="supported"></td>
Expand Down
2 changes: 2 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Require SAFETY docs, as well as a few other lints, for private items
check-private-items = true

doc-valid-idents = ["MHz", "GHz", "THz", ".."]
10 changes: 10 additions & 0 deletions doc/support_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ functionalities:
- name: i2c_controller
title: I2C Controller Mode
description: I2C in controller mode
- name: spi_main
title: SPI Main Mode
description: SPI in main mode
- name: logging
title: Logging
description:
Expand All @@ -51,6 +54,7 @@ chips:
debug_output: supported
hwrng: supported
i2c_controller: supported
spi_main: supported
logging: supported
wifi: not_available

Expand All @@ -61,6 +65,7 @@ chips:
debug_output: supported
hwrng: supported
i2c_controller: supported
spi_main: supported
logging: supported
wifi: not_available

Expand All @@ -71,6 +76,7 @@ chips:
debug_output: supported
hwrng: supported
i2c_controller: supported
spi_main: supported
logging: supported
wifi: not_available

Expand All @@ -81,6 +87,7 @@ chips:
debug_output: supported
hwrng: not_currently_supported
i2c_controller: supported
spi_main: supported
logging: supported
wifi: not_available

Expand All @@ -91,6 +98,7 @@ chips:
debug_output: supported
hwrng: not_available
i2c_controller: not_currently_supported
spi_main: not_currently_supported
logging: supported
wifi: not_available

Expand All @@ -101,6 +109,7 @@ chips:
debug_output: supported
hwrng: supported
i2c_controller: supported
spi_main: supported
logging: supported
wifi: not_available

Expand All @@ -111,6 +120,7 @@ chips:
debug_output: supported
hwrng: supported
i2c_controller: supported
spi_main: supported
logging: supported
wifi: not_available

Expand Down
3 changes: 3 additions & 0 deletions src/riot-rs-embassy-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ external-interrupts = []
## Enables I2C support.
i2c = ["dep:fugit"]

## Enables SPI support.
spi = ["dep:fugit"]

defmt = ["dep:defmt", "fugit?/defmt"]
3 changes: 3 additions & 0 deletions src/riot-rs-embassy-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ pub mod executor_swi;
#[cfg(feature = "i2c")]
pub mod i2c;

#[cfg(feature = "spi")]
pub mod spi;

pub mod reexports {
//! Crate re-exports.
Expand Down
Loading

0 comments on commit d049aff

Please sign in to comment.