Esempio n. 1
0
def test_register_element():
    reg = cmsis.SvdRegister(et.fromstring(
        """
        <register>
            <name>TimerCtrl0</name>
            <description>Timer Control Register</description>
            <addressOffset>0x0</addressOffset>
            <access>read-write</access>
            <resetValue>0x00008001</resetValue>
            <resetMask>0x0000ffff</resetMask>
            <size>32</size>
            <writeConstraint>
                <writeAsRead>true</writeAsRead>
                <useEnumeratedValues>true</useEnumeratedValues>
                <range>
                    <minimum>0</minimum>
                    <maximum>5</maximum>
                </range>
            </writeConstraint>
        </register>
        """
    ))
    assert reg.name == "TimerCtrl0"
    assert reg.description == "Timer Control Register"
    assert reg.addressOffset == 0
    assert reg.access == "read-write"
    assert reg.resetValue == 0x8001
    assert reg.resetMask == 0xffff
    assert reg.size == 32
    assert reg.writeConstraint.writeAsRead == True
    assert reg.writeConstraint.useEnumeratedValues == True
    assert reg.writeConstraint.range == (0,5)
Esempio n. 2
0
def test_register_is_dimensionless_after_fold_up():
    r = cmsis.SvdRegister(et.fromstring(
        """
        <register>
            <dim>4</dim>
            <dimIncrement>4</dimIncrement>
            <dimIndex>3-6</dimIndex>
            <name>IRQ%s</name>
            <addressOffset>4</addressOffset>
        </register>
        """
    ))
    for r in r.fold():
        assert r.dim == None
        assert r.dimIndex == None
        assert r.dimIncrement == None
Esempio n. 3
0
def test_register_folding_commaseparated_index():
    r = cmsis.SvdRegister(et.fromstring(
        """
        <register>
            <dim>3</dim>
            <dimIncrement>4</dimIncrement>
            <dimIndex>A,B,C</dimIndex>
            <name>GPIO_%s</name>
            <addressOffset>4</addressOffset>
        </register>
        """
    ))
    a = r.fold()

    assert len(a) == 3
    assert a[0].name == "GPIO_A"
    assert a[1].name == "GPIO_B"
    assert a[2].name == "GPIO_C"
Esempio n. 4
0
def test_register_folding_integerrange_index():
    r = cmsis.SvdRegister(et.fromstring(
        """
        <register>
            <dim>4</dim>
            <dimIncrement>4</dimIncrement>
            <dimIndex>3-6</dimIndex>
            <name>IRQ%s</name>
            <addressOffset>4</addressOffset>
        </register>
        """
    ))
    a = r.fold()

    assert len(a) == 4
    assert a[0].name == "IRQ3"
    assert a[1].name == "IRQ4"
    assert a[2].name == "IRQ5"
    assert a[3].name == "IRQ6"

    for i in range(4):
        assert a[i].addressOffset == 4 + (i * 4)