Skip to content

Conversation

@Rahix
Copy link
Owner

@Rahix Rahix commented May 4, 2025

The next version of avr-device will bring quite a few breaking changes, mainly due to the upgrade to a newer version of svd2rust. This PR includes all the necessary changes across avr-hal to upgrade to the new API. Please check individual commit messages for details.

This PR will be unblocked when a new release of avr-device is ready.

@Rahix Rahix added waiting-for-avr-device Waiting for a new release of `avr-device` dependencies Pull requests that update a dependency file labels May 4, 2025
@Rahix Rahix force-pushed the avr-device-next branch 3 times, most recently from 0981791 to 3e05785 Compare May 5, 2025 15:59
@Rahix Rahix force-pushed the avr-device-next branch 2 times, most recently from 6c76a7f to 355aa79 Compare November 30, 2025 16:40
This commit only moves the dependency version forward but does not make
any of the necessary changes for compatibility with the new version yet.
This will be done in the upcoming commits.
As avr-device is upgrading to use svd2rust version 0.33.1, there are
some significant changes in the generated API.  We have to adapt the HAL
code to use the new API whereever relevant.

This commit was mostly generated using the following command, which adds
the parentheses behind each register access to change it from
struct-field access to method call.

	cargo build --message-format json 2>/dev/null \
	  | jq '.message.children[].spans[] | {file: .file_name, line: .line_start, col: (.text[0].highlight_start - 1), insert: .suggested_replacement}' 2>/dev/null \
	  | jq -r '"sed -ri '"'"'" + (.line | tostring) + "s/^(.{" + (.col | tostring) + "})/\\1" + .insert + "/'"'"' $(cd ../..; realpath " + .file + ")"' \
	  | sort | uniq | bash

Shell magic for the win :)

Beyond this, .bits() had to be converted to .set() where safe accesses
are performed.
avr-device no longer has a `critical-section-impl` feature.  Instead it
now has a `critical-section` feature that is enabled by default [1].  As
such, we can drop the re-exposed feature here.

[1]: Rahix/avr-device#195
In svd2rust 0.34.0, the `.write()` and `.modify()` register access
functions were changed to return the written register value.  As
avr-device is upgrading to a more recent svd2rust version, we need to
adjust accordingly.

Fixup the few places where the return value of `.write()` or `.modify()`
mattered due to expression form calls.
Previous versions of `avr-device` allowed accidentally mis-specifying
the MCU in the interrupt definition.  Now that this is caught, fix one
such mistake here.
@Rahix Rahix changed the title Upgrade to the upcoming version of avr-device Upgrade to avr-device version 0.8 Nov 30, 2025
@Rahix Rahix removed the waiting-for-avr-device Waiting for a new release of `avr-device` label Nov 30, 2025
@Rahix Rahix merged commit 0f7fa4d into main Nov 30, 2025
27 checks passed
@Rahix Rahix deleted the avr-device-next branch November 30, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants