From d2963b153ee5036c2f689cb4053b858c3b7c7dbc Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Mon, 29 Nov 2021 16:25:16 -0500 Subject: [PATCH] Add *_Msk for each bit field and avoid duplicate fields in the output file --- tools/gen-device-avr/gen-device-avr.go | 20 ++++++++++++++++++-- 1 file 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 c553ec30..2fd040b9 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<