Skip to content

Commit

Permalink
feat: add an I2C controller abstraction (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
ROMemories authored Sep 20, 2024
2 parents e563838 + db9ea57 commit 47b90cb
Show file tree
Hide file tree
Showing 40 changed files with 1,597 additions and 28 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,no-boards,random,threading,usb
cargo doc -p riot-rs --features bench,csprng,executor-thread,external-interrupts,hwrng,i2c,no-boards,random,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
41 changes: 28 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,20 @@ jobs:
# TODO: we'll eventually want to enable relevant features
- name: Run crate tests
run: |
cargo test --no-default-features --features no-boards -p riot-rs -p riot-rs-embassy -p riot-rs-runqueue -p riot-rs-threads -p riot-rs-macros
cargo test --features external-interrupts,embassy-rp/rp2040 -p riot-rs-rp
cargo test --features external-interrupts,'embassy-nrf/nrf52840' -p riot-rs-nrf
cargo test --features external-interrupts,'embassy-stm32/stm32wb55rg' -p riot-rs-stm32
cargo test --no-default-features --features i2c,no-boards -p riot-rs -p riot-rs-embassy -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

- 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

- 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

lint:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -164,40 +172,47 @@ jobs:
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-macros -p riot-rs-random -p riot-rs-rt -p riot-rs-threads -p riot-rs-utils

- 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,esp-hal/esp32c6,esp-hal-embassy/esp32c6 -p riot-rs-esp
args: --verbose --locked --target=riscv32imac-unknown-none-elf --features external-interrupts,i2c,esp-hal/esp32c6,esp-hal-embassy/esp32c6 -p riot-rs-esp

- 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,embassy-rp/rp2040 -p riot-rs-rp
args: --verbose --locked --features external-interrupts,i2c,embassy-rp/rp2040 -p riot-rs-rp

- 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,embassy-nrf/nrf52840 -p riot-rs-nrf
args: --verbose --locked --features external-interrupts,i2c,embassy-nrf/nrf52840 -p riot-rs-nrf

- 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,embassy-stm32/stm32wb55rg -p riot-rs-stm32
args: --verbose --locked --features external-interrupts,i2c,embassy-stm32/stm32wb55rg -p riot-rs-stm32

# 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,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,threading,usb

- name: rustdoc for ESP32
run: RUSTDOCFLAGS='-D warnings' cargo doc --target=riscv32imac-unknown-none-elf --features external-interrupts,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,esp-hal/esp32c6,esp-hal-embassy/esp32c6 -p riot-rs-esp

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

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

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

- name: rustfmt
run: cargo fmt --check --all
Expand Down
49 changes: 43 additions & 6 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ members = [
"tests/gpio",
"tests/gpio-interrupt-nrf",
"tests/gpio-interrupt-stm32",
"tests/i2c-controller",
"tests/threading-lock",
]

Expand Down Expand Up @@ -52,6 +53,7 @@ portable-atomic = { version = "1.7.0", default-features = false, features = [
"require-cas",
] }

embassy-embedded-hal = { version = "0.2.0", default-features = false }
embassy-executor = { version = "0.6", default-features = false }
embassy-futures = { version = "0.1.1", default-features = false }
embassy-hal-internal = { version = "0.2.0", default-features = false }
Expand Down Expand Up @@ -89,6 +91,7 @@ riot-rs-utils = { path = "src/riot-rs-utils", default-features = false }
const_panic = { version = "0.2.8", default-features = false }
defmt = { version = "0.3.7" }
document-features = "0.2.8"
fugit = { version = "0.3.7", default-features = false }
heapless = { version = "0.8.0", default-features = false }
konst = { version = "0.3.8", default-features = false }
ld-memory = { version = "0.2.9" }
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,13 +4,14 @@
<tr>
<th>Chip</th>
<th>Testing Board</th>
<th colspan="7">Functionality</th>
<th colspan="8">Functionality</th>
</tr>
<tr>
<th></th>
<th></th>
<th>GPIO</th>
<th>Debug Output</th>
<th>I2C Controller Mode</th>
<th>Logging</th>
<th>User USB</th>
<th>Wi-Fi</th>
Expand All @@ -25,6 +26,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 @@ -37,6 +39,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 @@ -48,6 +51,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 @@ -59,6 +63,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 @@ -73,12 +78,14 @@
<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="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 @@ -92,6 +99,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 @@ -103,6 +111,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
Loading

0 comments on commit 47b90cb

Please sign in to comment.