aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorDmitriy <[email protected]>2021-11-29 16:25:16 -0500
committerRon Evans <[email protected]>2021-12-23 15:14:06 +0100
commitd2963b153ee5036c2f689cb4053b858c3b7c7dbc (patch)
tree1be4679a90df1f88cadbf3d2fff286a323c729de /tools
parentf9293645af69ed4099d69e6fbedbf1c933cb7a9f (diff)
downloadtinygo-d2963b153ee5036c2f689cb4053b858c3b7c7dbc.tar.gz
tinygo-d2963b153ee5036c2f689cb4053b858c3b7c7dbc.zip
Add *_Msk for each bit field and avoid duplicate fields in the output file
Diffstat (limited to 'tools')
-rwxr-xr-xtools/gen-device-avr/gen-device-avr.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/gen-device-avr/gen-device-avr.go b/tools/gen-device-avr/gen-device-avr.go
index c553ec30d..2fd040b9a 100755
--- a/tools/gen-device-avr/gen-device-avr.go
+++ b/tools/gen-device-avr/gen-device-avr.go
@@ -358,6 +358,7 @@ var ({{range .peripherals}}
}
fmt.Fprintf(w, "\n")
}
+ allBits := map[string]interface{}{}
for _, bitfield := range register.Bitfields {
if bits.OnesCount(bitfield.Mask) == 1 {
fmt.Fprintf(w, "\t%s = 0x%x", bitfield.Name, bitfield.Mask)
@@ -365,19 +366,34 @@ var ({{range .peripherals}}
fmt.Fprintf(w, " // %s", bitfield.Caption)
}
fmt.Fprintf(w, "\n")
+ fmt.Fprintf(w, "\t%s_Msk = 0x%x", bitfield.Name, bitfield.Mask)
+ if len(bitfield.Caption) != 0 {
+ fmt.Fprintf(w, " // %s", bitfield.Caption)
+ }
+ fmt.Fprintf(w, "\n")
+ allBits[bitfield.Name] = nil
} else {
n := 0
for i := uint(0); i < 8; i++ {
if (bitfield.Mask>>i)&1 == 0 {
continue
}
- fmt.Fprintf(w, "\t%s%d = 0x%x", bitfield.Name, n, 1<<i)
+ name := fmt.Sprintf("%s%d", bitfield.Name, n)
+ if _, ok := allBits[name]; !ok {
+ fmt.Fprintf(w, "\t%s = 0x%x", name, 1<<i)
if len(bitfield.Caption) != 0 {
fmt.Fprintf(w, " // %s", bitfield.Caption)
}
- n++
fmt.Fprintf(w, "\n")
+ allBits[name] = nil
+ }
+ n++
}
+ fmt.Fprintf(w, "\t%s_Msk = 0x%x", bitfield.Name, bitfield.Mask)
+ if len(bitfield.Caption) != 0 {
+ fmt.Fprintf(w, " // %s", bitfield.Caption)
+ }
+ fmt.Fprintf(w, "\n")
}
}
}