machine/stm32f103xx: add machine.Pin.Get method for reading GPIO values
Writing pin values was already possible but reading was missing.
Этот коммит содержится в:
родитель
500ee8067d
коммит
efd9cf72ba
1 изменённых файлов: 8 добавлений и 0 удалений
|
@ -99,6 +99,14 @@ func (p Pin) Set(high bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get returns the current value of a GPIO pin.
|
||||||
|
func (p Pin) Get() bool {
|
||||||
|
port := p.getPort()
|
||||||
|
pin := uint8(p) % 16
|
||||||
|
val := port.IDR.Get() & (1 << pin)
|
||||||
|
return (val > 0)
|
||||||
|
}
|
||||||
|
|
||||||
// UART
|
// UART
|
||||||
type UART struct {
|
type UART struct {
|
||||||
Buffer *RingBuffer
|
Buffer *RingBuffer
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче