We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c7c874a commit c830f87Copy full SHA for c830f87
src/machine/machine_stm32.go
@@ -58,3 +58,19 @@ func (p Pin) Get() bool {
58
val := port.IDR.Get() & (1 << pin)
59
return (val > 0)
60
}
61
+
62
+// PortMaskSet returns the register and mask to enable a given GPIO pin. This
63
+// can be used to implement bit-banged drivers.
64
+func (p Pin) PortMaskSet() (*uint32, uint32) {
65
+ port := p.getPort()
66
+ pin := uint8(p) % 16
67
+ return &port.BSRR.Reg, 1 << pin
68
+}
69
70
+// PortMaskClear returns the register and mask to disable a given port. This can
71
+// be used to implement bit-banged drivers.
72
+func (p Pin) PortMaskClear() (*uint32, uint32) {
73
74
75
+ return &port.BSRR.Reg, 1 << (pin + 16)
76
0 commit comments