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.
Этот коммит содержится в:
Ayke van Laethem 2021-05-06 12:51:06 +02:00 коммит произвёл Ron Evans
родитель 6f61b83ad5
коммит 2f1f8fb075
14 изменённых файлов: 5 добавлений и 25 удалений

Просмотреть файл

@ -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
} }

Просмотреть файл

@ -16,8 +16,6 @@ import (
"unsafe" "unsafe"
) )
type PinMode uint8
const ( const (
PinAnalog PinMode = 1 PinAnalog PinMode = 1
PinSERCOM PinMode = 2 PinSERCOM PinMode = 2

Просмотреть файл

@ -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

Просмотреть файл

@ -8,8 +8,6 @@ import (
"unsafe" "unsafe"
) )
type PinMode uint8
const ( const (
PinInput PinMode = iota PinInput PinMode = iota
PinInputPullup PinInputPullup

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -12,8 +12,6 @@ func CPUFrequency() uint32 {
return 16000000 return 16000000
} }
type PinMode uint8
const ( const (
PinInput PinMode = iota PinInput PinMode = iota
PinOutput PinOutput

Просмотреть файл

@ -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

Просмотреть файл

@ -10,8 +10,6 @@ var (
UART0 = UART{0} UART0 = UART{0}
) )
type PinMode uint8
const ( const (
PinInput PinMode = iota PinInput PinMode = iota
PinOutput PinOutput

Просмотреть файл

@ -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

Просмотреть файл

@ -15,8 +15,6 @@ func CPUFrequency() uint32 {
return 600000000 return 600000000
} }
type PinMode uint8
const ( const (
// GPIO // GPIO
PinInput PinMode = iota PinInput PinMode = iota

Просмотреть файл

@ -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)

Просмотреть файл

@ -37,8 +37,6 @@ import (
"unsafe" "unsafe"
) )
type PinMode uint8
const ( const (
PinInput PinMode = iota PinInput PinMode = iota
PinInputPullUp PinInputPullUp

Просмотреть файл

@ -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