aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/gen-device-svd/gen-device-svd.go
diff options
context:
space:
mode:
authorDmitriy Zakharkin <[email protected]>2021-10-27 08:52:27 -0400
committerGitHub <[email protected]>2021-10-27 14:52:27 +0200
commite848f47ad4667bafaca545dde5028a7be4748595 (patch)
tree739c9edefb52ce0711ae57022c17085b987518c3 /tools/gen-device-svd/gen-device-svd.go
parent3fe7ab19f68161207626df6e67e1ff2877608973 (diff)
downloadtinygo-e848f47ad4667bafaca545dde5028a7be4748595.tar.gz
tinygo-e848f47ad4667bafaca545dde5028a7be4748595.zip
Fix gen-device-svd to handle 64-bit
Diffstat (limited to 'tools/gen-device-svd/gen-device-svd.go')
-rwxr-xr-xtools/gen-device-svd/gen-device-svd.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/gen-device-svd/gen-device-svd.go b/tools/gen-device-svd/gen-device-svd.go
index 4bb9e291b..752286f41 100755
--- a/tools/gen-device-svd/gen-device-svd.go
+++ b/tools/gen-device-svd/gen-device-svd.go
@@ -140,7 +140,7 @@ type PeripheralField struct {
type Bitfield struct {
Name string
Description string
- Value uint32
+ Value uint64
}
func formatText(text string) string {
@@ -208,7 +208,7 @@ func readSVD(path, sourceURL string) (*Device, error) {
for _, periphEl := range orderedPeripherals {
description := formatText(periphEl.Description)
- baseAddress, err := strconv.ParseUint(periphEl.BaseAddress, 0, 32)
+ baseAddress, err := strconv.ParseUint(periphEl.BaseAddress, 0, 64)
if err != nil {
return nil, fmt.Errorf("invalid base address: %w", err)
}
@@ -581,12 +581,12 @@ func parseBitfields(groupName, regName string, fieldEls []*SVDField, bitfieldPre
fields = append(fields, Bitfield{
Name: fmt.Sprintf("%s_%s%s_%s_Pos", groupName, bitfieldPrefix, regName, fieldName),
Description: fmt.Sprintf("Position of %s field.", fieldName),
- Value: lsb,
+ Value: uint64(lsb),
})
fields = append(fields, Bitfield{
Name: fmt.Sprintf("%s_%s%s_%s_Msk", groupName, bitfieldPrefix, regName, fieldName),
Description: fmt.Sprintf("Bit mask of %s field.", fieldName),
- Value: (0xffffffff >> (31 - (msb - lsb))) << lsb,
+ Value: (0xffffffffffffffff >> (63 - (msb - lsb))) << lsb,
})
if lsb == msb { // single bit
fields = append(fields, Bitfield{
@@ -608,14 +608,14 @@ func parseBitfields(groupName, regName string, fieldEls []*SVDField, bitfieldPre
var err error
if strings.HasPrefix(enumEl.Value, "0b") {
val := strings.TrimPrefix(enumEl.Value, "0b")
- enumValue, err = strconv.ParseUint(val, 2, 32)
+ enumValue, err = strconv.ParseUint(val, 2, 64)
} else {
- enumValue, err = strconv.ParseUint(enumEl.Value, 0, 32)
+ enumValue, err = strconv.ParseUint(enumEl.Value, 0, 64)
}
if err != nil {
if enumBitSpecifier.MatchString(enumEl.Value) {
// NXP SVDs use the form #xx1x, #x0xx, etc for values
- enumValue, err = strconv.ParseUint(strings.ReplaceAll(enumEl.Value[1:], "x", "0"), 2, 32)
+ enumValue, err = strconv.ParseUint(strings.ReplaceAll(enumEl.Value[1:], "x", "0"), 2, 64)
if err != nil {
panic(err)
}
@@ -656,7 +656,7 @@ func parseBitfields(groupName, regName string, fieldEls []*SVDField, bitfieldPre
fields = append(fields, Bitfield{
Name: enumName,
Description: enumDescription,
- Value: uint32(enumValue),
+ Value: enumValue,
})
}
}