Skip to content

SVD for s32k344 leads to uncompilable output due to many duplicated methods #263

@photex

Description

@photex

Hi!

I'm new to embedded rust, and I probably just don't understand the cli options to svd2rust and how to get working output.

An example from the SVD I'm using that leads to many duplicated functions:

<field>
<name>RR_INITMOD</name>
<description>Initialization Delay Modulus</description>
<bitOffset>16</bitOffset>
<bitWidth>6</bitWidth>
<access>read-write</access>
<enumeratedValues>
  <enumeratedValue>
    <name>MOD_63</name>
    <description>63 cycles (same as 111111b)</description>
    <value>0</value>
  </enumeratedValue>
  <enumeratedValue>
    <name>MOD_1_63</name>
    <description>1 to 63 cycles</description>
    <value>0x1</value>
  </enumeratedValue>
  <enumeratedValue>
    <name>MOD_1_63</name>
    <description>1 to 63 cycles</description>
    <value>0x2</value>
  </enumeratedValue>
  <enumeratedValue>
    <name>MOD_1_63</name>
    <description>1 to 63 cycles</description>
    <value>0x3</value>
  </enumeratedValue>
  <enumeratedValue>
    <name>MOD_1_63</name>
    <description>1 to 63 cycles</description>
    <value>0x4</value>
  </enumeratedValue>
  <enumeratedValue>
    <name>MOD_1_63</name>
    <description>1 to 63 cycles</description>
    <value>0x5</value>
  </enumeratedValue>
  <enumeratedValue>
    <name>MOD_1_63</name>
    <description>1 to 63 cycles</description>
    <value>0x6</value>
  </enumeratedValue>
  <enumeratedValue>
    <name>MOD_1_63</name>
    <description>1 to 63 cycles</description>
    <value>0x7</value>
  </enumeratedValue>
  <enumeratedValue>
    <name>MOD_1_63</name>
    <description>1 to 63 cycles</description>
    <value>0x8</value>
  </enumeratedValue>
  <enumeratedValue>
    <name>MOD_1_63</name>
    <description>1 to 63 cycles</description>
    <value>0x9</value>
  </enumeratedValue>
</enumeratedValues>

Leads to code like:

#[doc = "Initialization Delay Modulus\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum RrInitmod {
    #[doc = "0: 63 cycles (same as 111111b)"]
    Mod63 = 0,
    #[doc = "1: 1 to 63 cycles"]
    Mod1_63 = 1,
    #[doc = "2: 1 to 63 cycles"]
    Mod1_63 = 2,
    #[doc = "3: 1 to 63 cycles"]
    Mod1_63 = 3,
    #[doc = "4: 1 to 63 cycles"]
    Mod1_63 = 4,
    #[doc = "5: 1 to 63 cycles"]
    Mod1_63 = 5,
    #[doc = "6: 1 to 63 cycles"]
    Mod1_63 = 6,
    #[doc = "7: 1 to 63 cycles"]
    Mod1_63 = 7,
    #[doc = "8: 1 to 63 cycles"]
    Mod1_63 = 8,
    #[doc = "9: 1 to 63 cycles"]
    Mod1_63 = 9,
}

#[doc = "Field `RR_INITMOD` writer - Initialization Delay Modulus"]
pub type RrInitmodW<'a, REG> = crate::FieldWriter<'a, REG, 6, RrInitmod>;
impl<'a, REG> RrInitmodW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    #[doc = "63 cycles (same as 111111b)"]
    #[inline(always)]
    pub fn mod_63(self) -> &'a mut crate::W<REG> {
        self.variant(RrInitmod::Mod63)
    }
    #[doc = "1 to 63 cycles"]
    #[inline(always)]
    pub fn mod_1_63(self) -> &'a mut crate::W<REG> {
        self.variant(RrInitmod::Mod1_63)
    }
    #[doc = "1 to 63 cycles"]
    #[inline(always)]
    pub fn mod_1_63(self) -> &'a mut crate::W<REG> {
        self.variant(RrInitmod::Mod1_63)
    }
    #[doc = "1 to 63 cycles"]
    #[inline(always)]
    pub fn mod_1_63(self) -> &'a mut crate::W<REG> {
        self.variant(RrInitmod::Mod1_63)
    }
    #[doc = "1 to 63 cycles"]
    #[inline(always)]
    pub fn mod_1_63(self) -> &'a mut crate::W<REG> {
        self.variant(RrInitmod::Mod1_63)
    }
    #[doc = "1 to 63 cycles"]
    #[inline(always)]
    pub fn mod_1_63(self) -> &'a mut crate::W<REG> {
        self.variant(RrInitmod::Mod1_63)
    }
    #[doc = "1 to 63 cycles"]
    #[inline(always)]
    pub fn mod_1_63(self) -> &'a mut crate::W<REG> {
        self.variant(RrInitmod::Mod1_63)
    }
    #[doc = "1 to 63 cycles"]
    #[inline(always)]
    pub fn mod_1_63(self) -> &'a mut crate::W<REG> {
        self.variant(RrInitmod::Mod1_63)
    }
    #[doc = "1 to 63 cycles"]
    #[inline(always)]
    pub fn mod_1_63(self) -> &'a mut crate::W<REG> {
        self.variant(RrInitmod::Mod1_63)
    }
    #[doc = "1 to 63 cycles"]
    #[inline(always)]
    pub fn mod_1_63(self) -> &'a mut crate::W<REG> {
        self.variant(RrInitmod::Mod1_63)
    }
}

This is one example of many in the generated output. Am I holding this wrong? There isn't any output from svd2rust to indicate that I might be doing something wrong.

Here is the command I'm running:
svd2rust -i S32K344_M7.svd -o src --target cortex-m -s --atomics --keep-list

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions