diff options
author | Ayke van Laethem <[email protected]> | 2021-04-24 01:50:06 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-04-24 18:41:40 +0200 |
commit | 4eac212695d22fc76899bcb4cd2cbd7e2872be15 (patch) | |
tree | 652fe758cb7fec0781baaaf0f356234e38261467 /tools | |
parent | b6618823914f3008ae986141a847fec38076bfef (diff) | |
download | tinygo-4eac212695d22fc76899bcb4cd2cbd7e2872be15.tar.gz tinygo-4eac212695d22fc76899bcb4cd2cbd7e2872be15.zip |
gen-device: add extra constants and rename them to be Go style
- Add some extra fields: FPUPresent, CPU and NVICPrioBits which may
come in handy at a later time (and are easy to add).
- Rename DEVICE to Device, to match Go style.
This is in preparation to the next commit, which requires the FPUPresent
flag.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/gen-device-svd/gen-device-svd.go | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/tools/gen-device-svd/gen-device-svd.go b/tools/gen-device-svd/gen-device-svd.go index 67d1b1300..e527be0e4 100755 --- a/tools/gen-device-svd/gen-device-svd.go +++ b/tools/gen-device-svd/gen-device-svd.go @@ -19,10 +19,15 @@ var validName = regexp.MustCompile("^[a-zA-Z0-9_]+$") var enumBitSpecifier = regexp.MustCompile("^#[x01]+$") type SVDFile struct { - XMLName xml.Name `xml:"device"` - Name string `xml:"name"` - Description string `xml:"description"` - LicenseText string `xml:"licenseText"` + XMLName xml.Name `xml:"device"` + Name string `xml:"name"` + Description string `xml:"description"` + LicenseText string `xml:"licenseText"` + CPU *struct { + Name string `xml:"name"` + FPUPresent bool `xml:"fpuPresent"` + NVICPrioBits int `xml:"nvicPrioBits"` + } `xml:"cpu"` Peripherals []SVDPeripheral `xml:"peripherals>peripheral"` } @@ -95,6 +100,11 @@ type Metadata struct { NameLower string Description string LicenseBlock string + + HasCPUInfo bool // set if the following fields are populated + CPUName string + FPUPresent bool + NVICPrioBits int } type Interrupt struct { @@ -418,15 +428,22 @@ func readSVD(path, sourceURL string) (*Device, error) { licenseBlock = regexp.MustCompile(`\s+\n`).ReplaceAllString(licenseBlock, "\n") } + metadata := &Metadata{ + File: filepath.Base(path), + DescriptorSource: sourceURL, + Name: device.Name, + NameLower: strings.ToLower(device.Name), + Description: strings.TrimSpace(device.Description), + LicenseBlock: licenseBlock, + } + if device.CPU != nil { + metadata.HasCPUInfo = true + metadata.CPUName = device.CPU.Name + metadata.FPUPresent = device.CPU.FPUPresent + metadata.NVICPrioBits = device.CPU.NVICPrioBits + } return &Device{ - Metadata: &Metadata{ - File: filepath.Base(path), - DescriptorSource: sourceURL, - Name: device.Name, - NameLower: strings.ToLower(device.Name), - Description: strings.TrimSpace(device.Description), - LicenseBlock: licenseBlock, - }, + Metadata: metadata, Interrupts: interruptList, Peripherals: peripheralsList, }, nil @@ -833,7 +850,12 @@ import ( // Some information about this device. const ( - DEVICE = "{{.device.Metadata.Name}}" + Device = "{{.device.Metadata.Name}}" +{{- if .device.Metadata.HasCPUInfo }} + CPU = "{{.device.Metadata.CPUName}}" + FPUPresent = {{.device.Metadata.FPUPresent}} + NVICPrioBits = {{.device.Metadata.NVICPrioBits}} +{{- end }} ) // Interrupt numbers. |