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

support clusters #107

Closed
japaric opened this issue Jun 5, 2017 · 4 comments · Fixed by #182
Closed

support clusters #107

japaric opened this issue Jun 5, 2017 · 4 comments · Fixed by #182
Milestone

Comments

@japaric
Copy link
Member

japaric commented Jun 5, 2017

Example:

File: ATSAMD21E15A.svd

Contents:

    <peripheral>
      <name>SERCOM0</name>
      <version>2.0.0</version>
      <description>Serial Communication Interface 0</description>
      <groupName>SERCOM</groupName>
      <prependToName>SERCOM_</prependToName>
      <baseAddress>0x42000800</baseAddress>
      <addressBlock>
        <offset>0</offset>
        <size>0x40</size>
        <usage>registers</usage>
      </addressBlock>
      <interrupt>
        <name>SERCOM0</name>
        <value>9</value>
      </interrupt>
      <registers>
       <cluster>
        <name>I2CM</name>
        <description>I2C Master Mode</description>
        <headerStructName>SercomI2cm</headerStructName>
        <addressOffset>0x0</addressOffset>
        <register>
          <name>ADDR</name>
          <!-- .. -->
       </cluster> <!-- SercomI2cm -->
       <cluster>
        <name>I2CS</name>
        <description>I2C Slave Mode</description>
        <alternateCluster>I2CM</alternateCluster>
        <headerStructName>SercomI2cs</headerStructName>
        <addressOffset>0x0</addressOffset>
        <register>
          <name>ADDR</name>
          <!-- .. -->

These clusters seem to be non-functional. They only add more structure (namespaces) to a register block. The above is supposed to generate something like this:

pub struct RegisterBlock {
    pub i2cm: I2CM,
    pub i2cs: I2CS,
    ..
}

pub struct I2CM {
    pub addr: ADDR,
    ..
}

pub struct I2CS {
    pub addr: ADDR,
    ..
}

The "flat" version would have resulted in a name collision between I2CM.ADDR and I2CS.ADDR.

We currently don't generate anything at all for clusters. For instance the above SERCOM0 peripheral is totally omitted in the output because it appears to have 0 registers as clusters are ignored.

@japaric japaric added this to the cmsis-svd milestone Jun 5, 2017
japaric added a commit that referenced this issue Jun 6, 2017
@japaric
Copy link
Member Author

japaric commented Jun 6, 2017

Blocker: svd doesn't parse <cluster> elements. See rust-embedded/svd#33

@therealprof
Copy link
Contributor

Is anyone working on this at the moment?

Emilgardis added a commit to Emilgardis/stm32f103xx that referenced this issue Jan 29, 2018
I would preferably use a cluster here, but svd2rust doesn't yet have
that feature. See rust-embedded/svd2rust#149 and rust-embedded/svd2rust#107
closes japaric#16
@jamesmunns
Copy link
Member

This also affects https://github.com/jamesmunns/nrf52. I may look into implementing clusters.

@jamesmunns
Copy link
Member

@japaric - how should svd2rust handle clusters that contain registers with repeated names in the same scope? Particularly ones like:

       <cluster>
        <name>USART</name>
        <description>USART Mode</description>
        <alternateCluster>I2CM</alternateCluster>
        <headerStructName>SercomUsart</headerStructName>
        <addressOffset>0x0</addressOffset>
        <register>
          <name>BAUD</name>
          <description>USART Baud Rate</description>
          <alternateGroup>DEFAULT_MODE</alternateGroup>
          <addressOffset>0x0C</addressOffset>
          <size>16</size>
          <fields>
            <field>
              <name>BAUD</name>
              <description>Baud Rate Value</description>
              <bitOffset>0</bitOffset>
              <bitWidth>16</bitWidth>
            </field>
          </fields>
        </register>
        <register>
          <name>BAUD</name>
          <description>USART Baud Rate</description>
          <alternateGroup>FRAC_MODE</alternateGroup>
          <addressOffset>0x0C</addressOffset>
          <size>16</size>
          <fields>
            <field>
              <name>BAUD</name>
              <description>Baud Rate Value</description>
              <bitOffset>0</bitOffset>
              <bitWidth>13</bitWidth>
            </field>
            <field>
              <name>FP</name>
              <description>Fractional Part</description>
              <bitOffset>13</bitOffset>
              <bitWidth>3</bitWidth>
            </field>
          </fields>
        </register>
        <register>

Is there a tracking issue for union'd registers (inside or not inside clusters) in svd2rust? is this the same as #16 ?

bors bot added a commit that referenced this issue Mar 4, 2018
182: Add initial Cluster support r=jamesmunns a=jamesmunns

Add cluster support to svd2rust. I am calling it initial, because I have only tested it against the `nRF52` [svd file](https://github.com/jamesmunns/nrf52/blob/master/nrf52.svd).

Note, this is based on #180, so I would prefer that PR be merged first. If that PR is rejected, I can instead rebase these changes on `japaric/master` (just let me know).

Edit: All changes relevant to clusters are squashed into the last commit of this PR, so if you want to see the relevant changes, check out 6de6de7.

This is based on the work of @brandonedens earlier #149, and I believe would close #107 and related issues.

CC @japaric @Emilgardis @therealprof

Edit 2: Here are some handy references:
* [SVD snippet with clusters](https://gist.github.com/jamesmunns/c4e53fe5bd74dca81fdbff6bb1798ddd)
* [code generated before](https://gist.github.com/jamesmunns/d854a6c2665cca59edb88143d82a19c6)
* [code generated after](https://gist.github.com/jamesmunns/7558667e34c33124c60b3aaaf679a196)
* [diff of code generated](https://gist.github.com/jamesmunns/03fd0d7d3595cd0816dbfa8daca0a553)
bors bot added a commit that referenced this issue Mar 8, 2018
182: Add initial Cluster support r=jamesmunns a=jamesmunns

Add cluster support to svd2rust. I am calling it initial, because I have only tested it against the `nRF52` [svd file](https://github.com/jamesmunns/nrf52/blob/master/nrf52.svd).

Note, this is based on #180, so I would prefer that PR be merged first. If that PR is rejected, I can instead rebase these changes on `japaric/master` (just let me know).

Edit: All changes relevant to clusters are squashed into the last commit of this PR, so if you want to see the relevant changes, check out 6de6de7.

This is based on the work of @brandonedens earlier #149, and I believe would close #107 and related issues.

CC @japaric @Emilgardis @therealprof

Edit 2: Here are some handy references:
* [SVD snippet with clusters](https://gist.github.com/jamesmunns/c4e53fe5bd74dca81fdbff6bb1798ddd)
* [code generated before](https://gist.github.com/jamesmunns/d854a6c2665cca59edb88143d82a19c6)
* [code generated after](https://gist.github.com/jamesmunns/7558667e34c33124c60b3aaaf679a196)
* [diff of code generated](https://gist.github.com/jamesmunns/03fd0d7d3595cd0816dbfa8daca0a553)
bors bot added a commit to japaric/stm32f103xx that referenced this issue Mar 10, 2018
19: Make EPnR into an array. r=japaric a=Emilgardis

I would preferably use a cluster here, but svd2rust doesn't yet have
that feature. See rust-embedded/svd2rust#149 and rust-embedded/svd2rust#107
closes #16
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 a pull request may close this issue.

3 participants