mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 07:23:39 +00:00
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:
@@ -200,6 +200,16 @@ func (r *Register8) ClearBits(value uint8) {{
|
|||||||
volatile.StoreUint8(&r.Reg, volatile.LoadUint8(&r.Reg) &^ value)
|
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.
|
// Some information about this device.
|
||||||
const (
|
const (
|
||||||
DEVICE = "{name}"
|
DEVICE = "{name}"
|
||||||
|
|||||||
@@ -349,6 +349,16 @@ func (r *Register8) ClearBits(value uint8) {{
|
|||||||
volatile.StoreUint8(&r.Reg, volatile.LoadUint8(&r.Reg) &^ value)
|
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
|
||||||
|
}}
|
||||||
|
|
||||||
type Register16 struct {{
|
type Register16 struct {{
|
||||||
Reg uint16
|
Reg uint16
|
||||||
}}
|
}}
|
||||||
@@ -391,6 +401,16 @@ func (r *Register16) ClearBits(value uint16) {{
|
|||||||
volatile.StoreUint16(&r.Reg, volatile.LoadUint16(&r.Reg) &^ value)
|
volatile.StoreUint16(&r.Reg, volatile.LoadUint16(&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 *Register16) HasBits(value uint16) bool {{
|
||||||
|
return (r.Get() & value) > 0
|
||||||
|
}}
|
||||||
|
|
||||||
type Register32 struct {{
|
type Register32 struct {{
|
||||||
Reg uint32
|
Reg uint32
|
||||||
}}
|
}}
|
||||||
@@ -433,6 +453,16 @@ func (r *Register32) ClearBits(value uint32) {{
|
|||||||
volatile.StoreUint32(&r.Reg, volatile.LoadUint32(&r.Reg) &^ value)
|
volatile.StoreUint32(&r.Reg, volatile.LoadUint32(&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 *Register32) HasBits(value uint32) bool {{
|
||||||
|
return (r.Get() & value) > 0
|
||||||
|
}}
|
||||||
|
|
||||||
// Some information about this device.
|
// Some information about this device.
|
||||||
const (
|
const (
|
||||||
DEVICE = "{name}"
|
DEVICE = "{name}"
|
||||||
|
|||||||
Reference in New Issue
Block a user