mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 02:33:28 +00:00
machine: add helpers for bit-banged driver support
The returned pointer and value can be used to set or clear a specific pin.
This commit is contained in:
@@ -34,6 +34,20 @@ func (p GPIO) Set(high bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the register and mask to enable a given GPIO pin. This can be used to
|
||||||
|
// implement bit-banged drivers.
|
||||||
|
func (p GPIO) PortMaskSet() (*uint32, uint32) {
|
||||||
|
port, pin := p.getPortPin()
|
||||||
|
return (*uint32)(&port.OUTSET), 1 << pin
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the register and mask to disable a given port. This can be used to
|
||||||
|
// implement bit-banged drivers.
|
||||||
|
func (p GPIO) PortMaskClear() (*uint32, uint32) {
|
||||||
|
port, pin := p.getPortPin()
|
||||||
|
return (*uint32)(&port.OUTCLR), 1 << pin
|
||||||
|
}
|
||||||
|
|
||||||
// Get returns the current value of a GPIO pin.
|
// Get returns the current value of a GPIO pin.
|
||||||
func (p GPIO) Get() bool {
|
func (p GPIO) Get() bool {
|
||||||
port, pin := p.getPortPin()
|
port, pin := p.getPortPin()
|
||||||
|
|||||||
Reference in New Issue
Block a user