aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authordeadprogram <[email protected]>2023-05-14 18:48:23 +0200
committerRon Evans <[email protected]>2023-07-05 13:30:21 +0200
commit7755f2385cefea465b01dc1dfabc3f539f0135d4 (patch)
tree957c58c676f7c8fc541274956106f74e194630d9
parent04601a29e8ed5070d25f7d9d1c1df98e8d1c1b03 (diff)
downloadtinygo-7755f2385cefea465b01dc1dfabc3f539f0135d4.tar.gz
tinygo-7755f2385cefea465b01dc1dfabc3f539f0135d4.zip
tools/gen-device-svd: small changes needed for Renesas MCUs
Signed-off-by: deadprogram <[email protected]>
-rwxr-xr-xtools/gen-device-svd/gen-device-svd.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/gen-device-svd/gen-device-svd.go b/tools/gen-device-svd/gen-device-svd.go
index 8eb308c7f..0c49986ab 100755
--- a/tools/gen-device-svd/gen-device-svd.go
+++ b/tools/gen-device-svd/gen-device-svd.go
@@ -18,7 +18,7 @@ import (
)
var validName = regexp.MustCompile("^[a-zA-Z0-9_]+$")
-var enumBitSpecifier = regexp.MustCompile("^#[x01]+$")
+var enumBitSpecifier = regexp.MustCompile("^#x*[01]+[01x]*$")
type SVDFile struct {
XMLName xml.Name `xml:"device"`
@@ -628,6 +628,11 @@ func parseBitfields(groupName, regName string, fieldEls []*SVDField, bitfieldPre
}
for _, enumEl := range enumeratedValues.EnumeratedValue {
enumName := enumEl.Name
+ // Renesas has enum without actual values that we have to skip
+ if enumEl.Value == "" {
+ continue
+ }
+
if strings.EqualFold(enumName, "reserved") || !validName.MatchString(enumName) {
continue
}
@@ -645,7 +650,7 @@ func parseBitfields(groupName, regName string, fieldEls []*SVDField, bitfieldPre
}
if err != nil {
if enumBitSpecifier.MatchString(enumEl.Value) {
- // NXP SVDs use the form #xx1x, #x0xx, etc for values
+ // NXP and Renesas SVDs use the form #xx1x, #x0xx, etc for values
enumValue, err = strconv.ParseUint(strings.ReplaceAll(enumEl.Value[1:], "x", "0"), 2, 64)
if err != nil {
panic(err)
@@ -760,6 +765,14 @@ func (r *Register) dimIndex() []string {
t := strings.Split(*r.element.DimIndex, "-")
if len(t) == 2 {
+ // renesas uses hex letters e.g. A-B
+ if strings.Contains("ABCDEFabcdef", t[0]) {
+ t[0] = "0x" + t[0]
+ }
+ if strings.Contains("ABCDEFabcdef", t[1]) {
+ t[1] = "0x" + t[1]
+ }
+
x, err := strconv.ParseInt(t[0], 0, 32)
if err != nil {
panic(err)