Skip to content

attiny-hal: get rid of feature gates by moving mcu specific code into own modules #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ckoehne
Copy link

@ckoehne ckoehne commented Apr 23, 2025

It's hard to add new devices to the attiny hal crate because it's heavily feature gated and those gates are spread across the whole code base. So, new devices have to modify a bunch of files and repeatedly add #[cfg(feature = "<device>"] making the code even less readable. There's already an open issue to make it easier to add new devices [1]. It also links to an attempt splitting the code base into mcu specific modules and making it easier to add new mcus. However, I'm proposing this new PR because it tries to take smaller steps to get into that direction. This PR is only focusing on splitting the crate into mcu specific modules by moving code around. It's intended to keep the API untouched. This should create less friction because we don't have to bump the semver of the crate and don't have to discuss API changes. This makes it hopefully easier to merge.

PS: If this approach looks good, I'm going to do the same for the atmega hal crate.

[1] #623
[2] #643

ckoehne added 7 commits April 23, 2025 19:36
It's quite hard to add new ATtiny devices to this crate. There are a
bunch of feature gates spread across the whole code base. In order to
get rid of them, move all mcu specific code into a single file. To keep
our current interface and avoid breaking existing user, the mcu specific
file defines a module for each periphal which gets reimported by our
periphal specific files.

No functional change intended.

Signed-off-by: Corvin Köhne <[email protected]>
It's quite hard to add new ATtiny devices to this crate. There are a
bunch of feature gates spread across the whole code base. In order to
get rid of them, move all mcu specific code into a single file. To keep
our current interface and avoid breaking existing user, the mcu specific
file defines a module for each periphal which gets reimported by our
periphal specific files.

No functional change intended.

Signed-off-by: Corvin Köhne <[email protected]>
It's quite hard to add new ATtiny devices to this crate. There are a
bunch of feature gates spread across the whole code base. In order to
get rid of them, move all mcu specific code into a single file. To keep
our current interface and avoid breaking existing user, the mcu specific
file defines a module for each periphal which gets reimported by our
periphal specific files.

No functional change intended.

Signed-off-by: Corvin Köhne <[email protected]>
It's quite hard to add new ATtiny devices to this crate. There are a
bunch of feature gates spread across the whole code base. In order to
get rid of them, move all mcu specific code into a single file. To keep
our current interface and avoid breaking existing user, the mcu specific
file defines a module for each periphal which gets reimported by our
periphal specific files.

No functional change intended.

Signed-off-by: Corvin Köhne <[email protected]>
It's quite hard to add new ATtiny devices to this crate. There are a
bunch of feature gates spread across the whole code base. In order to
get rid of them, move all mcu specific code into a single file. To keep
our current interface and avoid breaking existing user, the mcu specific
file defines a module for each periphal which gets reimported by our
periphal specific files.

No functional change intended.

Signed-off-by: Corvin Köhne <[email protected]>
It's quite hard to add new ATtiny devices to this crate. There are a
bunch of feature gates spread across the whole code base. In order to
get rid of them, move all mcu specific code into a single file. To keep
our current interface and avoid breaking existing user, the mcu specific
file defines a module for each periphal which gets reimported by our
periphal specific files.

No functional change intended.

Signed-off-by: Corvin Köhne <[email protected]>
It's quite hard to add new ATtiny devices to this crate. There are a
bunch of feature gates spread across the whole code base. In order to
get rid of them, move all mcu specific code into a single file. Macros
are exported by the crates root, so we can avoid the feature gates of
the pins macro by moving it into our mcu specific files.

No functional change intended.

Signed-off-by: Corvin Köhne <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant