bitbang

package
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package bitbang implements conn by banging on the bits (GPIO pins).

This is not efficient but works around broken or missing drivers.

Index

Constants

View Source
const SkipAddr uint16 = 0xFFFF

SkipAddr can be used to skip the address from being sent.

Variables

This section is empty.

Functions

This section is empty.

Types

type I2C

type I2C struct {
	// contains filtered or unexported fields
}

I2C represents an I²C master implemented as bit-banging on 2 GPIO pins.

func New

func New(clk gpio.PinIO, data gpio.PinIO, speedHz int) (*I2C, error)

New returns an object that communicates I²C over two pins.

BUG(maruel): It is close to working but not yet, the signal is incorrect during ACK.

It has two special features:

  • Special address SkipAddr can be used to skip the address from being communicated
  • An arbitrary speed can be used

func (*I2C) Close

func (i *I2C) Close() error

Close implements i2c.BusCloser.

func (*I2C) SCL

func (i *I2C) SCL() gpio.PinIO

SCL implements i2c.Pins.

func (*I2C) SDA

func (i *I2C) SDA() gpio.PinIO

SDA implements i2c.Pins.

func (*I2C) SetSpeed

func (i *I2C) SetSpeed(hz int64) error

SetSpeed implements i2c.Bus.

func (*I2C) String

func (i *I2C) String() string

func (*I2C) Tx

func (i *I2C) Tx(addr uint16, w, r []byte) error

Tx implements i2c.Bus.

type SPI

type SPI struct {
	// contains filtered or unexported fields
}

SPI represents a SPI master implemented as bit-banging on 3 or 4 GPIO pins.

func NewSPI

func NewSPI(clk, mosi gpio.PinOut, miso gpio.PinIn, cs gpio.PinOut, speedHz int64) (*SPI, error)

NewSPI returns an object that communicates SPI over 3 or 4 pins.

BUG(maruel): Completely untested.

cs can be nil.

func (*SPI) CLK

func (s *SPI) CLK() gpio.PinOut

CLK implements spi.Pins.

func (*SPI) CS

func (s *SPI) CS() gpio.PinOut

CS implements spi.Pins.

func (*SPI) Close

func (s *SPI) Close() error

Close implements spi.ConnCloser.

func (*SPI) Connect

func (s *SPI) Connect(maxHz int64, mode spi.Mode, bits int) error

Connect implements spi.Conn.

func (*SPI) Duplex

func (s *SPI) Duplex() conn.Duplex

Duplex implements spi.Conn.

func (*SPI) LimitSpeed

func (s *SPI) LimitSpeed(maxHz int64) error

LimitSpeed implements spi.ConnCloser.

func (*SPI) MISO

func (s *SPI) MISO() gpio.PinIn

MISO implements spi.Pins.

func (*SPI) MOSI

func (s *SPI) MOSI() gpio.PinOut

MOSI implements spi.Pins.

func (*SPI) String

func (s *SPI) String() string

func (*SPI) Tx

func (s *SPI) Tx(w, r []byte) error

Tx implements spi.Conn.

BUG(maruel): Implement mode. BUG(maruel): Implement bits. BUG(maruel): Test if read works.

func (*SPI) TxPackets

func (s *SPI) TxPackets(p []spi.Packet) error

TxPackets implements spi.Conn.

func (*SPI) Write

func (s *SPI) Write(d []byte) (int, error)

Write implements io.Writer.

Notes

Bugs

  • It is close to working but not yet, the signal is incorrect during ACK.

    It has two special features:

    • Special address SkipAddr can be used to skip the address from being communicated
    • An arbitrary speed can be used
  • Implement mode.

  • Implement bits.

  • Test if read works.

  • Completely untested.

    cs can be nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL