tools/gen: ignore cluster registers with no actual clusters in them, and handle parsing binary integer fields in versions of Go before 1.13

Signed-off-by: deadprogram <ron@hybridgroup.com>
Этот коммит содержится в:
deadprogram 2021-01-03 17:45:29 +01:00 коммит произвёл Ron Evans
родитель cf930f652e
коммит 086645153e

Просмотреть файл

@ -350,7 +350,7 @@ func readSVD(path, sourceURL string) (*Device, error) {
sort.SliceStable(clusterRegisters, func(i, j int) bool {
return clusterRegisters[i].address < clusterRegisters[j].address
})
if dimIncrement == -1 {
if dimIncrement == -1 && len(clusterRegisters) > 0 {
lastReg := clusterRegisters[len(clusterRegisters)-1]
lastAddress := lastReg.address
if lastReg.array != -1 {
@ -537,7 +537,14 @@ func parseBitfields(groupName, regName string, fieldEls []*SVDField, bitfieldPre
enumName = strings.ToUpper(enumName)
}
enumDescription := strings.Replace(enumEl.Description, "\n", " ", -1)
enumValue, err := strconv.ParseUint(enumEl.Value, 0, 32)
var enumValue uint64
var err error
if strings.HasPrefix(enumEl.Value, "0b") {
val := strings.TrimPrefix(enumEl.Value, "0b")
enumValue, err = strconv.ParseUint(val, 2, 32)
} else {
enumValue, err = strconv.ParseUint(enumEl.Value, 0, 32)
}
if err != nil {
if enumBitSpecifier.MatchString(enumEl.Value) {
// NXP SVDs use the form #xx1x, #x0xx, etc for values