svd2rust icon indicating copy to clipboard operation
svd2rust copied to clipboard

Do not transform peripheral names

Open docbrown opened this issue 7 years ago • 6 comments

Currently, svd2rust always transforms peripheral names to uppercase. For peripherals that are not acronyms, like SysTick, the resulting type name looks a little odd. This patch simply sanitizes peripheral names, but leaves them in their original case. For vendor SVDs with weirdly-formatted names, an XML transform or .patch could be used to fix them, much like device-specific crates already do to add enumeratedValues and such.

This is a breaking change that could lead to API breakage in existing crates that assume the uppercase transformation is always done.

docbrown avatar Feb 25 '18 20:02 docbrown

I can undo the change to the Peripherals fields since that is guaranteed to break existing crates, but Peripherals::take().sys_tick looks more Rustic than Peripherals::take().SYSTICK or Peripherals::take().SysTick to me.

docbrown avatar Feb 25 '18 20:02 docbrown

This does in a way make it look more rusty, but I'm not sure if this is what we want as the change would be "purely" cosmetic. Uppercase also reminds me of static values, which matches the idea of having singleton peripherals.

Emilgardis avatar Mar 01 '18 22:03 Emilgardis

Ping from triage: @rust-embedded/tools can someone tell if that can be accepted ?

mathk avatar Feb 20 '19 19:02 mathk

Ping from triage: @docbrown need a merge/rebase.

mathk avatar Feb 21 '19 09:02 mathk

This is a breaking change since it may change the name of peripheral types so first it needs to be approved by the team and then it must wait until we are ready for the next minor release before it can land in tree.

This sounds good to me; iirc, we already leave register and bitfield names as they are so this would make things more consistent. AFAIS, most vendors use uppercase for peripheral names so most people won't see any change though.

I will leave the rest of the team comment. (Changing label to S-waiting-on-team)

japaric avatar Mar 04 '19 04:03 japaric

If we're going to break things, I'd like someone to suggest how we can distinguish modules, PAC objects and HAL implementations other than only by using different capitalisations of the same letters (see uarte, Uarte and UARTE).

thejpster avatar Mar 19 '19 19:03 thejpster