@@ -19,10 +19,15 @@ var validName = regexp.MustCompile("^[a-zA-Z0-9_]+$")
19
19
var enumBitSpecifier = regexp .MustCompile ("^#[x01]+$" )
20
20
21
21
type SVDFile struct {
22
- XMLName xml.Name `xml:"device"`
23
- Name string `xml:"name"`
24
- Description string `xml:"description"`
25
- LicenseText string `xml:"licenseText"`
22
+ XMLName xml.Name `xml:"device"`
23
+ Name string `xml:"name"`
24
+ Description string `xml:"description"`
25
+ LicenseText string `xml:"licenseText"`
26
+ CPU * struct {
27
+ Name string `xml:"name"`
28
+ FPUPresent bool `xml:"fpuPresent"`
29
+ NVICPrioBits int `xml:"nvicPrioBits"`
30
+ } `xml:"cpu"`
26
31
Peripherals []SVDPeripheral `xml:"peripherals>peripheral"`
27
32
}
28
33
@@ -95,6 +100,11 @@ type Metadata struct {
95
100
NameLower string
96
101
Description string
97
102
LicenseBlock string
103
+
104
+ HasCPUInfo bool // set if the following fields are populated
105
+ CPUName string
106
+ FPUPresent bool
107
+ NVICPrioBits int
98
108
}
99
109
100
110
type Interrupt struct {
@@ -418,15 +428,22 @@ func readSVD(path, sourceURL string) (*Device, error) {
418
428
licenseBlock = regexp .MustCompile (`\s+\n` ).ReplaceAllString (licenseBlock , "\n " )
419
429
}
420
430
431
+ metadata := & Metadata {
432
+ File : filepath .Base (path ),
433
+ DescriptorSource : sourceURL ,
434
+ Name : device .Name ,
435
+ NameLower : strings .ToLower (device .Name ),
436
+ Description : strings .TrimSpace (device .Description ),
437
+ LicenseBlock : licenseBlock ,
438
+ }
439
+ if device .CPU != nil {
440
+ metadata .HasCPUInfo = true
441
+ metadata .CPUName = device .CPU .Name
442
+ metadata .FPUPresent = device .CPU .FPUPresent
443
+ metadata .NVICPrioBits = device .CPU .NVICPrioBits
444
+ }
421
445
return & Device {
422
- Metadata : & Metadata {
423
- File : filepath .Base (path ),
424
- DescriptorSource : sourceURL ,
425
- Name : device .Name ,
426
- NameLower : strings .ToLower (device .Name ),
427
- Description : strings .TrimSpace (device .Description ),
428
- LicenseBlock : licenseBlock ,
429
- },
446
+ Metadata : metadata ,
430
447
Interrupts : interruptList ,
431
448
Peripherals : peripheralsList ,
432
449
}, nil
@@ -833,7 +850,12 @@ import (
833
850
834
851
// Some information about this device.
835
852
const (
836
- DEVICE = "{{.device.Metadata.Name}}"
853
+ Device = "{{.device.Metadata.Name}}"
854
+ {{- if .device.Metadata.HasCPUInfo }}
855
+ CPU = "{{.device.Metadata.CPUName}}"
856
+ FPUPresent = {{.device.Metadata.FPUPresent}}
857
+ NVICPrioBits = {{.device.Metadata.NVICPrioBits}}
858
+ {{- end }}
837
859
)
838
860
839
861
// Interrupt numbers.
0 commit comments