tools: generate volatile HasBits() method in device wrappers to simplify bit comparison code

Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
Ron Evans
2019-05-27 15:35:46 +02:00
committed by Ayke
parent 2f95a5d452
commit 90cd3f8ea5
2 changed files with 40 additions and 0 deletions
+10
View File
@@ -200,6 +200,16 @@ func (r *Register8) ClearBits(value uint8) {{
volatile.StoreUint8(&r.Reg, volatile.LoadUint8(&r.Reg) &^ value)
}}
// HasBits reads the register and then checks to see if the passed bits are set. It
// is the volatile equivalent of:
//
// (*r.Reg & value) > 0
//
//go:inline
func (r *Register8) HasBits(value uint8) bool {{
return (r.Get() & value) > 0
}}
// Some information about this device.
const (
DEVICE = "{name}"