From c15fd0bfa55ddede10cd2ef7a3cff1ec7146e45f Mon Sep 17 00:00:00 2001 From: M-A Date: Sat, 25 Mar 2017 15:36:57 -0400 Subject: [PATCH] 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. --- experimental/devices/bitbang/spi.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/experimental/devices/bitbang/spi.go b/experimental/devices/bitbang/spi.go index 0c8cce4..f448b5d 100644 --- a/experimental/devices/bitbang/spi.go +++ b/experimental/devices/bitbang/spi.go @@ -17,6 +17,7 @@ import ( "sync" "time" + "periph.io/x/periph/conn" "periph.io/x/periph/conn/gpio" "periph.io/x/periph/conn/spi" "periph.io/x/periph/host/cpu" @@ -44,6 +45,12 @@ func (s *SPI) Close() error { 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. func (s *SPI) Speed(hz int64) error { s.mu.Lock()