Add conn.Conn.Duplex() (#118)

Now each connection can report if the underlying communication channel is
half-duplex or full-duplex.

This information is leveraged by some clients, like memory mapped registers
helper struct, to change their behavior or deny use on certain kind of
communication channel.
pull/1/head
M-A 9 years ago committed by GitHub
parent 56aad834ae
commit c15fd0bfa5

@ -17,6 +17,7 @@ import (
"sync" "sync"
"time" "time"
"periph.io/x/periph/conn"
"periph.io/x/periph/conn/gpio" "periph.io/x/periph/conn/gpio"
"periph.io/x/periph/conn/spi" "periph.io/x/periph/conn/spi"
"periph.io/x/periph/host/cpu" "periph.io/x/periph/host/cpu"
@ -44,6 +45,12 @@ func (s *SPI) Close() error {
return nil return nil
} }
// Duplex implements spi.Conn.
func (s *SPI) Duplex() conn.Duplex {
// Maybe implement bitbanging SPI only in half mode?
return conn.Full
}
// Speed implements spi.Conn. // Speed implements spi.Conn.
func (s *SPI) Speed(hz int64) error { func (s *SPI) Speed(hz int64) error {
s.mu.Lock() s.mu.Lock()

Loading…
Cancel
Save