@@ -18,7 +18,7 @@ import (
1818)
1919
2020var validName = regexp .MustCompile ("^[a-zA-Z0-9_]+$" )
21- var enumBitSpecifier = regexp .MustCompile ("^#[x01]+ $" )
21+ var enumBitSpecifier = regexp .MustCompile ("^#x*[01]+[01x]* $" )
2222
2323type SVDFile struct {
2424 XMLName xml.Name `xml:"device"`
@@ -628,6 +628,11 @@ func parseBitfields(groupName, regName string, fieldEls []*SVDField, bitfieldPre
628628 }
629629 for _ , enumEl := range enumeratedValues .EnumeratedValue {
630630 enumName := enumEl .Name
631+ // Renesas has enum without actual values that we have to skip
632+ if enumEl .Value == "" {
633+ continue
634+ }
635+
631636 if strings .EqualFold (enumName , "reserved" ) || ! validName .MatchString (enumName ) {
632637 continue
633638 }
@@ -645,7 +650,7 @@ func parseBitfields(groupName, regName string, fieldEls []*SVDField, bitfieldPre
645650 }
646651 if err != nil {
647652 if enumBitSpecifier .MatchString (enumEl .Value ) {
648- // NXP SVDs use the form #xx1x, #x0xx, etc for values
653+ // NXP and Renesas SVDs use the form #xx1x, #x0xx, etc for values
649654 enumValue , err = strconv .ParseUint (strings .ReplaceAll (enumEl .Value [1 :], "x" , "0" ), 2 , 64 )
650655 if err != nil {
651656 panic (err )
@@ -760,6 +765,14 @@ func (r *Register) dimIndex() []string {
760765
761766 t := strings .Split (* r .element .DimIndex , "-" )
762767 if len (t ) == 2 {
768+ // renesas uses hex letters e.g. A-B
769+ if strings .Contains ("ABCDEFabcdef" , t [0 ]) {
770+ t [0 ] = "0x" + t [0 ]
771+ }
772+ if strings .Contains ("ABCDEFabcdef" , t [1 ]) {
773+ t [1 ] = "0x" + t [1 ]
774+ }
775+
763776 x , err := strconv .ParseInt (t [0 ], 0 , 32 )
764777 if err != nil {
765778 panic (err )
0 commit comments