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.
This commit is contained in:
Ayke van Laethem
2021-05-06 12:51:06 +02:00
committed by Ron Evans
parent 6f61b83ad5
commit 2f1f8fb075
14 changed files with 5 additions and 25 deletions
+5
View File
@@ -10,6 +10,11 @@ var (
ErrNoPinChangeChannel = errors.New("machine: no channel available for pin interrupt") ErrNoPinChangeChannel = errors.New("machine: no channel available for pin interrupt")
) )
// PinMode sets the direction and pull mode of the pin. For example, PinOutput
// sets the pin as an output and PinInputPullup sets the pin as an input with a
// pull-up.
type PinMode uint8
type PinConfig struct { type PinConfig struct {
Mode PinMode Mode PinMode
} }
-2
View File
@@ -16,8 +16,6 @@ import (
"unsafe" "unsafe"
) )
type PinMode uint8
const ( const (
PinAnalog PinMode = 1 PinAnalog PinMode = 1
PinSERCOM PinMode = 2 PinSERCOM PinMode = 2
-2
View File
@@ -20,8 +20,6 @@ func CPUFrequency() uint32 {
return 120000000 return 120000000
} }
type PinMode uint8
const ( const (
PinAnalog PinMode = 1 PinAnalog PinMode = 1
PinSERCOM PinMode = 2 PinSERCOM PinMode = 2
-2
View File
@@ -8,8 +8,6 @@ import (
"unsafe" "unsafe"
) )
type PinMode uint8
const ( const (
PinInput PinMode = iota PinInput PinMode = iota
PinInputPullup PinInputPullup
-2
View File
@@ -21,8 +21,6 @@ var (
ErrInvalidSPIBus = errors.New("machine: invalid SPI bus") ErrInvalidSPIBus = errors.New("machine: invalid SPI bus")
) )
type PinMode uint8
const ( const (
PinOutput PinMode = iota PinOutput PinMode = iota
PinInput PinInput
-2
View File
@@ -11,8 +11,6 @@ func CPUFrequency() uint32 {
return 80000000 // 80MHz return 80000000 // 80MHz
} }
type PinMode uint8
const ( const (
PinOutput PinMode = iota PinOutput PinMode = iota
PinInput PinInput
-2
View File
@@ -12,8 +12,6 @@ func CPUFrequency() uint32 {
return 16000000 return 16000000
} }
type PinMode uint8
const ( const (
PinInput PinMode = iota PinInput PinMode = iota
PinOutput PinOutput
-2
View File
@@ -30,8 +30,6 @@ const (
// Make it easier to directly write to I/O RAM. // Make it easier to directly write to I/O RAM.
var ioram = (*[0x400]volatile.Register8)(unsafe.Pointer(uintptr(0x04000000))) var ioram = (*[0x400]volatile.Register8)(unsafe.Pointer(uintptr(0x04000000)))
type PinMode uint8
// Set has not been implemented. // Set has not been implemented.
func (p Pin) Set(value bool) { func (p Pin) Set(value bool) {
// do nothing // do nothing
-2
View File
@@ -10,8 +10,6 @@ var (
UART0 = UART{0} UART0 = UART{0}
) )
type PinMode uint8
const ( const (
PinInput PinMode = iota PinInput PinMode = iota
PinOutput PinOutput
-1
View File
@@ -14,7 +14,6 @@ func CPUFrequency() uint32 {
return 390000000 return 390000000
} }
type PinMode uint8
type fpioaPullMode uint8 type fpioaPullMode uint8
type PinChange uint8 type PinChange uint8
-2
View File
@@ -15,8 +15,6 @@ func CPUFrequency() uint32 {
return 600000000 return 600000000
} }
type PinMode uint8
const ( const (
// GPIO // GPIO
PinInput PinMode = iota PinInput PinMode = iota
-2
View File
@@ -13,8 +13,6 @@ var (
ErrTxInvalidSliceSize = errors.New("SPI write and read slices must be same size") ErrTxInvalidSliceSize = errors.New("SPI write and read slices must be same size")
) )
type PinMode uint8
const ( const (
PinInput PinMode = (nrf.GPIO_PIN_CNF_DIR_Input << nrf.GPIO_PIN_CNF_DIR_Pos) | (nrf.GPIO_PIN_CNF_INPUT_Connect << nrf.GPIO_PIN_CNF_INPUT_Pos) PinInput PinMode = (nrf.GPIO_PIN_CNF_DIR_Input << nrf.GPIO_PIN_CNF_DIR_Pos) | (nrf.GPIO_PIN_CNF_INPUT_Connect << nrf.GPIO_PIN_CNF_INPUT_Pos)
PinInputPullup PinMode = PinInput | (nrf.GPIO_PIN_CNF_PULL_Pullup << nrf.GPIO_PIN_CNF_PULL_Pos) PinInputPullup PinMode = PinInput | (nrf.GPIO_PIN_CNF_PULL_Pullup << nrf.GPIO_PIN_CNF_PULL_Pos)
-2
View File
@@ -37,8 +37,6 @@ import (
"unsafe" "unsafe"
) )
type PinMode uint8
const ( const (
PinInput PinMode = iota PinInput PinMode = iota
PinInputPullUp PinInputPullUp
-2
View File
@@ -17,8 +17,6 @@ const (
portJ portJ
) )
type PinMode uint8
// Peripheral operations sequence: // Peripheral operations sequence:
// 1. Enable the clock to the alternate function. // 1. Enable the clock to the alternate function.
// 2. Enable clock to corresponding GPIO // 2. Enable clock to corresponding GPIO