Skip to content
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

Share identical field definitions between separate clusters #273

Closed
astapleton opened this issue Jan 30, 2025 · 2 comments
Closed

Share identical field definitions between separate clusters #273

astapleton opened this issue Jan 30, 2025 · 2 comments

Comments

@astapleton
Copy link

If a a peripheral is partitioned into multiple clusters because registers differ on a subset of the clustered registers between partitions, it would be nice to be able to share the enum definitions from registers that are identical. Even better would be to also share the enum definitions in identical fields in registers that have extra fields.

As an example, the STM32H5xx series GPDMA peripheral has a bank of 8 channels. Channels 0-5 are identical, but channels 6 & 7 have extra functionality, which manifests in extra fields in a few of those registers. Unfortunately this means that the bank is partitioned into channels 0-5 and channels 6-7 and all the identical field definitions are duplicated across the separate partitions, which also means that a single common enum cannot be used for addressing identical registers across all 8 channels.

@burrbull
Copy link
Member

burrbull commented Jan 31, 2025

It is already possible with fully-qualified paths but should be easier with #274

_cluster:
  CH%s:
    description: Channel cluster
    "C[0-5]LBAR":
      name: LBAR
    "C[0-5]FCR":
      name: FCR
    "C[0-5]SR":
      name: SR
    "C[0-5]CR":
      name: CR
    "C[0-5]TR1":
      name: TR1
    "C[0-5]TR2":
      name: TR2
    "C[0-5]BR1":
      name: BR1
    "C[0-5]SAR":
      name: SAR
    "C[0-5]DAR":
      name: DAR
    "C[0-5]LLR":
      name: LLR

  CH2D%s:
    description: 2D-addressing channel cluster
    "C[6-7]LBAR":
      name: LBAR
    "C[6-7]FCR":
      name: FCR
    "C[6-7]SR":
      name: SR
    "C[6-7]CR":
      name: CR
    "C[6-7]TR1":
      name: TR1
    "C[6-7]TR2":
      name: TR2
    "C[6-7]BR1":
      name: BR1
      _derive:
        BNDT: CH%s.BR1.BNDT
    "C[6-7]SAR":
      name: SAR
    "C[6-7]DAR":
      name: DAR
    "C[6-7]TR3":
      name: TR3
    "C[6-7]BR2":
      name: BR2
    "C[6-7]LLR":
      name: LLR
      _derive:
        LA: CH%s.LLR.LA
        ULL: CH%s.LLR.ULL
        UDA: CH%s.LLR.UDA
        USA: CH%s.LLR.USA
        UB1: CH%s.LLR.UB1
        UT2: CH%s.LLR.UT2
        UT1: CH%s.LLR.UT1

    _derive:
      LBAR: CH%s.LBAR
      FCR: CH%s.FCR
      SR: CH%s.SR
      CR: CH%s.CR
      TR1: CH%s.TR1
      TR2: CH%s.TR2
      SAR: CH%s.SAR
      DAR: CH%s.DAR

The more valuable issue is svd2rust rust-embedded/svd2rust#903
UPD. rust-embedded/svd2rust#904 should fix the issue

@astapleton
Copy link
Author

Ah, great. I was trying something with register patches before the cluster step. I didn't know you could put _derives inside the _cluster definitions. I'll try this when #904 lands.

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

No branches or pull requests

2 participants