tools/gen-device-svd: small changes needed for Renesas MCUs
Signed-off-by: deadprogram <ron@hybridgroup.com>
Этот коммит содержится в:
родитель
04601a29e8
коммит
7755f2385c
1 изменённых файлов: 15 добавлений и 2 удалений
|
@ -18,7 +18,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var validName = regexp.MustCompile("^[a-zA-Z0-9_]+$")
|
var validName = regexp.MustCompile("^[a-zA-Z0-9_]+$")
|
||||||
var enumBitSpecifier = regexp.MustCompile("^#[x01]+$")
|
var enumBitSpecifier = regexp.MustCompile("^#x*[01]+[01x]*$")
|
||||||
|
|
||||||
type SVDFile struct {
|
type SVDFile struct {
|
||||||
XMLName xml.Name `xml:"device"`
|
XMLName xml.Name `xml:"device"`
|
||||||
|
@ -628,6 +628,11 @@ func parseBitfields(groupName, regName string, fieldEls []*SVDField, bitfieldPre
|
||||||
}
|
}
|
||||||
for _, enumEl := range enumeratedValues.EnumeratedValue {
|
for _, enumEl := range enumeratedValues.EnumeratedValue {
|
||||||
enumName := enumEl.Name
|
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) {
|
if strings.EqualFold(enumName, "reserved") || !validName.MatchString(enumName) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -645,7 +650,7 @@ func parseBitfields(groupName, regName string, fieldEls []*SVDField, bitfieldPre
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if enumBitSpecifier.MatchString(enumEl.Value) {
|
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)
|
enumValue, err = strconv.ParseUint(strings.ReplaceAll(enumEl.Value[1:], "x", "0"), 2, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -760,6 +765,14 @@ func (r *Register) dimIndex() []string {
|
||||||
|
|
||||||
t := strings.Split(*r.element.DimIndex, "-")
|
t := strings.Split(*r.element.DimIndex, "-")
|
||||||
if len(t) == 2 {
|
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)
|
x, err := strconv.ParseInt(t[0], 0, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче