rust-embedded / svd2rust

Generate Rust register maps (`struct`s) from SVD files
Apache License 2.0
675 stars 147 forks source link

Replace cluster suffixes with _ #712

Closed n8tlarsen closed 1 year ago

n8tlarsen commented 1 year ago

In some devices, a cluster array has registers named the same as the cluster. So when making a Rust array out of the cluster, the PAC failed to compile due to a recursive definition. For example, see ATSAME51G18A.svd, CHANNEL[%s] cluster definition on line 11593.

burrbull commented 1 year ago

It is awfullest idea I've seen.

n8tlarsen commented 1 year ago
  1. Please explain your reasoning.
  2. Propose a better solution.
burrbull commented 1 year ago
  1. Please explain your reasoning.

Due to several bad designed SVDs you suggest to add breaking change which even looks non unaesthetic.

2. Propose a better solution.
  1. Fix or preprocess SVDs (easiest)
  2. Move this change under option
  3. Add options for custom prefixes and suffixes for names of enums, clusters, etc. (flexible)
n8tlarsen commented 1 year ago

I think in this particular case, only one register is affected, so a patch was applied to remedy the SVD name collision. Thanks for your time.