spi: Add first version of TxPackets + NoCS, HalfDuplex, LSBFirst.

- This enables more complex use case like write-then-read, 3-wire SPI and when
  the number of bits per word changes accross packets.
- Remove the transparent Tx() buffer cutting, the Raspberry Pi 3 spi_bcm2835
  driver asserts the CS line even if csChange = 0 on the last packet. This broke
  some use case (like FLIR Lepton).

spi-io: improve with more use cases. Used for adhoc testing of the SPI bus and
looking at the results over an oscilloscope.
pull/1/head
Marc-Antoine Ruel 9 years ago
parent aff3ae8a77
commit b61c90429c

@ -73,7 +73,7 @@ func (s *SPI) DevParams(maxHz int64, mode spi.Mode, bits int) error {
return errors.New("bitbang-spi: invalid maxHz") return errors.New("bitbang-spi: invalid maxHz")
} }
if mode != spi.Mode3 { if mode != spi.Mode3 {
return errors.New("bitbang-spi: not implemented") return fmt.Errorf("bitbang-spi: mode %v is not implemented", mode)
} }
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
@ -119,7 +119,12 @@ func (s *SPI) Tx(w, r []byte) error {
return nil return nil
} }
// Write implements spi.Conn. // TxPackets implements spi.Conn.
func (s *SPI) TxPackets(p []spi.Packet) error {
return errors.New("bitbang-spi: not implemented")
}
// Write implements io.Writer.
func (s *SPI) Write(d []byte) (int, error) { func (s *SPI) Write(d []byte) (int, error) {
if err := s.Tx(d, nil); err != nil { if err := s.Tx(d, nil); err != nil {
return 0, err return 0, err

Loading…
Cancel
Save