Skip to content

Commit 2f1f8fb

Browse files
aykevldeadprogram
authored andcommitted
machine: move PinMode to central location
It is always implemented exactly the same way (as an uint8) so there is no reason to implement it in each target separately. This also makes it easier to add some documentation to it.
1 parent 6f61b83 commit 2f1f8fb

14 files changed

+5
-25
lines changed

src/machine/machine.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ var (
1010
ErrNoPinChangeChannel = errors.New("machine: no channel available for pin interrupt")
1111
)
1212

13+
// PinMode sets the direction and pull mode of the pin. For example, PinOutput
14+
// sets the pin as an output and PinInputPullup sets the pin as an input with a
15+
// pull-up.
16+
type PinMode uint8
17+
1318
type PinConfig struct {
1419
Mode PinMode
1520
}

src/machine/machine_atsamd21.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import (
1616
"unsafe"
1717
)
1818

19-
type PinMode uint8
20-
2119
const (
2220
PinAnalog PinMode = 1
2321
PinSERCOM PinMode = 2

src/machine/machine_atsamd51.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ func CPUFrequency() uint32 {
2020
return 120000000
2121
}
2222

23-
type PinMode uint8
24-
2523
const (
2624
PinAnalog PinMode = 1
2725
PinSERCOM PinMode = 2

src/machine/machine_avr.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"unsafe"
99
)
1010

11-
type PinMode uint8
12-
1311
const (
1412
PinInput PinMode = iota
1513
PinInputPullup

src/machine/machine_esp32.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ var (
2121
ErrInvalidSPIBus = errors.New("machine: invalid SPI bus")
2222
)
2323

24-
type PinMode uint8
25-
2624
const (
2725
PinOutput PinMode = iota
2826
PinInput

src/machine/machine_esp8266.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ func CPUFrequency() uint32 {
1111
return 80000000 // 80MHz
1212
}
1313

14-
type PinMode uint8
15-
1614
const (
1715
PinOutput PinMode = iota
1816
PinInput

src/machine/machine_fe310.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ func CPUFrequency() uint32 {
1212
return 16000000
1313
}
1414

15-
type PinMode uint8
16-
1715
const (
1816
PinInput PinMode = iota
1917
PinOutput

src/machine/machine_gameboyadvance.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ const (
3030
// Make it easier to directly write to I/O RAM.
3131
var ioram = (*[0x400]volatile.Register8)(unsafe.Pointer(uintptr(0x04000000)))
3232

33-
type PinMode uint8
34-
3533
// Set has not been implemented.
3634
func (p Pin) Set(value bool) {
3735
// do nothing

src/machine/machine_generic.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ var (
1010
UART0 = UART{0}
1111
)
1212

13-
type PinMode uint8
14-
1513
const (
1614
PinInput PinMode = iota
1715
PinOutput

src/machine/machine_k210.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ func CPUFrequency() uint32 {
1414
return 390000000
1515
}
1616

17-
type PinMode uint8
1817
type fpioaPullMode uint8
1918
type PinChange uint8
2019

0 commit comments

Comments
 (0)