bitbang

package
v3.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2018 License: Apache-2.0 Imports: 11 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(f physic.Frequency) 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 port implemented as bit-banging on 3 or 4 GPIO pins.

func NewSPI

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

NewSPI returns an spi.PortCloser 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.PortCloser.

func (*SPI) Connect

func (s *SPI) Connect(f physic.Frequency, mode spi.Mode, bits int) (spi.Conn, error)

Connect implements spi.PortCloser.

func (*SPI) LimitSpeed

func (s *SPI) LimitSpeed(f physic.Frequency) error

LimitSpeed implements spi.PortCloser.

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

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
  • Completely untested.

    cs can be nil.

  • Implement mode (HalfDuplex and LSBFirst remain to be done).

  • Implement bits.

  • Test if read works.

Jump to

Keyboard shortcuts

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