aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-04-24 01:50:06 +0200
committerRon Evans <[email protected]>2021-04-24 18:41:40 +0200
commit4eac212695d22fc76899bcb4cd2cbd7e2872be15 (patch)
tree652fe758cb7fec0781baaaf0f356234e38261467
parentb6618823914f3008ae986141a847fec38076bfef (diff)
downloadtinygo-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.
-rw-r--r--src/runtime/runtime_nrf_softdevice.go4
-rwxr-xr-xtools/gen-device-svd/gen-device-svd.go48
2 files changed, 37 insertions, 15 deletions
diff --git a/src/runtime/runtime_nrf_softdevice.go b/src/runtime/runtime_nrf_softdevice.go
index 165712fa5..36269e11e 100644
--- a/src/runtime/runtime_nrf_softdevice.go
+++ b/src/runtime/runtime_nrf_softdevice.go
@@ -24,10 +24,10 @@ func waitForEvents() {
if enabled != 0 {
// Now pick the appropriate SVCall number. Hopefully they won't change
// in the future with a different SoftDevice version.
- if nrf.DEVICE == "nrf51" {
+ if nrf.Device == "nrf51" {
// sd_app_evt_wait: SOC_SVC_BASE_NOT_AVAILABLE + 29
arm.SVCall0(0x2B + 29)
- } else if nrf.DEVICE == "nrf52" || nrf.DEVICE == "nrf52840" || nrf.DEVICE == "nrf52833" {
+ } else if nrf.Device == "nrf52" || nrf.Device == "nrf52840" || nrf.Device == "nrf52833" {
// sd_app_evt_wait: SOC_SVC_BASE_NOT_AVAILABLE + 21
arm.SVCall0(0x2C + 21)
} else {
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.