Skip to content

Commit

Permalink
Check interrupt existence in the caller's scope
Browse files Browse the repository at this point in the history
This updates our `interrupt` macro, adapting it from a newer iteration
of `cortex-m-rt`'s. In particular, this makes generation of the sibling
`vector` module unneeded, since the check of whether the named interrupt
exists is done via checking a newly exported `Interrupt` enum in the
PAC (we use the path `::avr_device::Interrupt`, which does not require
avr_device to be imported in the caller's scope). There is one downside,
though: we can't enable more than one MCU feature, because that causes
duplicate items. As such, docs.rs now only builds for the `atmega328p`.
  • Loading branch information
LuigiPiucco committed Jun 9, 2024
1 parent f4934c6 commit 9a99870
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 170 deletions.
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ rt = ["avr-device-macros"]

critical-section-impl = ["critical-section/restore-state-u8"]

# Unfortunately, we can only build documentation for a subset of the supported
# MCUs on docs.rs. If you think a very popular chip is missing from the list,
# feel free to add it here.
docsrs = ["rt", "ufmt", "atmega328p", "atmega32u4", "atmega2560", "attiny85", "atmega4809"]
# Unfortunately, we can only build documentation for a single MCU.
docsrs = ["rt", "ufmt", "atmega328p"]

[dependencies]
bare-metal = "1.0.0"
Expand Down
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ RUSTUP_TOOLCHAIN ?= nightly
PATCHES := $(foreach chip, $(CHIPS), $(wildcard patch/$(chip).yaml))
DEPS := $(foreach patch, $(PATCHES), $(patsubst patch/%.yaml, .deps/%.d, $(patch)))

.PHONY: chips deps $(CHIPS) vector all clean
.PHONY: chips deps $(CHIPS) all clean
chips: $(CHIPS)
deps: $(DEPS)
vector: macros/src/vector.rs

$(foreach chip, $(CHIPS), $(eval $(chip): src/devices/$(chip)/mod.rs))

Expand Down Expand Up @@ -53,12 +52,6 @@ src/devices/%/mod.rs: src/devices/%/mod.full.rs
@# Fixup the take() implementation
@sed -i'' -e '/#\[cfg(feature = "critical-section")]/d' $@
@sed -i'' -e 's/critical_section::with/crate::interrupt::free/' $@
@echo -e "\tGEN-VECTOR\t>macros/src/vector.rs"
@./gen-intr-lut.sh svd/*.patched >macros/src/vector.rs

macros/src/vector.rs: svd/*.patched
@echo -e "\tGEN-VECTOR\t>macros/src/vector.rs"
@./gen-intr-lut.sh $^ >$@

clean:
@echo -e "\tCLEAN\t\t./svd/"
Expand All @@ -69,8 +62,6 @@ clean:
@rm -f src/generic.rs
@echo -e "\tCLEAN\t\t./.deps/"
@rm -rf .deps/
@echo -e "\tCLEAN\t\t./macros/src/vector.rs"
@rm -rf macros/src/vector.rs

# Patch dependencies
patch/%.yaml: .deps/%.d
Expand Down
2 changes: 1 addition & 1 deletion examples/atmega328p/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn panic(_info: &core::panic::PanicInfo) -> ! {
}
}

#[avr_device::interrupt(atmega328p)]
#[avr_device::interrupt]
fn TIMER0_OVF() {
// This interrupt should raise every (1024*255)/16MHz s ≈ 0.01s
// We then count 61 times to approximate 1s.
Expand Down
20 changes: 0 additions & 20 deletions gen-intr-lut.sh

This file was deleted.

1 change: 0 additions & 1 deletion macros/src/.gitignore

This file was deleted.

Loading

0 comments on commit 9a99870

Please sign in to comment.