Help us shape the future of Go! Take the 2026 Go Developer Survey

bp

package module
v0.0.0-...-8fa9ec1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2013 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package bp enables access to a bus pirate. Currently only I2C mode is implemented.

Index

Constants

View Source
const (
	MODE_CLOSED = iota
	MODE_UNKNOWN
	MODE_BITBANG
	MODE_SPI
	MODE_I2C
	MODE_UART
	MODE_1WIRE
	MODE_RAW
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BusPirate

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

BusPirate offers the functionality of a bus pirate. It works with the device in binary mode. Before using a BusPirate object, the user has to put the bus pirate into a known state via a call to BusPirate.Open().

func NewBusPirate

func NewBusPirate(c Conn) *BusPirate

NewBusPirate generates a new BusPirate objected that uses c as its communication channel. Note that you need to correctly configure the connection with respect to baud rate, parity and flow control. An 8 bit connection is assumed. The BusPirate object pointed to by the return value is not ready to use, you need to call the Open() method to put the device into a known state.

func (*BusPirate) Close

func (bp *BusPirate) Close() error

Close leaves binary mode. If the bus pirate is currently not in binary bit bang mode, it first enters binary bit bang mode. If the user does not call Close, the device might be unresponsive in text mode.

func (*BusPirate) EnterBitbangMode

func (bp *BusPirate) EnterBitbangMode() error

func (*BusPirate) EnterI2CMode

func (bp *BusPirate) EnterI2CMode() (BusPirateI2C, error)

EnterI2CMode makes the bus pirate enter I2C mode and returns a BusPirateI2C object offering the I2C functionality of the device. The I2CMode can only be entered from bitbang mode. This might change.

func (*BusPirate) EnterNonStrictI2CMode

func (bp *BusPirate) EnterNonStrictI2CMode() (NonStrictI2C, error)

func (*BusPirate) GetMode

func (bp *BusPirate) GetMode() (int, int)

GetMode returns the active mode and the mode's version.

func (*BusPirate) Open

func (bp *BusPirate) Open() error

Open puts the bus pirate into binary bit bang mode. The user needs to call this method as the bus pirate cannot be assumed to be in any specific mode when the connection to it is opened.

type BusPirateI2C

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

BusPirateI2C represents a bus pirate in I2C mode. It offers an interface consistent with i2cm.I2CMaster. Obtain a BusPirateI2C by switching the bus pirate into I2C mode with *BusPirate.EnterI2CMode(). When the user makes the bus pirate switch into a different mode, the BusPirateI2C object becomes invalid and must no be used any longer.

func (BusPirateI2C) ReadByte

func (inf BusPirateI2C) ReadByte(ack bool) (byte, error)

func (BusPirateI2C) Start

func (inf BusPirateI2C) Start() error

func (BusPirateI2C) Stop

func (inf BusPirateI2C) Stop() error

func (BusPirateI2C) WriteByte

func (inf BusPirateI2C) WriteByte(b byte) error

type Conn

type Conn interface {
	io.ReadWriteCloser
	SetReadParams(int, float64) error
}

Conn represents a serial connection to a bus pirate. The connection needs to be open and configured with the correct baud rate prior to use.

The signature is satisfied by sers.SerialPort. Find it at github.com/distributed/sers.

type ModeError

type ModeError string

ModeError is returned when the device is not in a suitable mode for the desired operation.

func (ModeError) Error

func (me ModeError) Error() string

type NonStrictI2C

type NonStrictI2C struct {
	BusPirateI2C
}

NonStrictI2C offers the same functionality as BusPirateI2C, but also adds a fast if not completely faithful Transact8x8 implementation. The Transact8x8 implementation is not faithful in that one transaction results in *two* transactions on the bus. Before using NonStrictI2C make sure that no other master is interfering with you and that your device's behavior doesn't change when a write-then-read transaction is split into a write and a read. Expect substantial speed gains from using this implementation.

Obtain a NonStrictI2C by switching the bus pirate into non-strict I2C mode with *BusPirate.EnterNonStrictI2CMode().

func (NonStrictI2C) Transact8x8

func (nsi NonStrictI2C) Transact8x8(addr i2cm.Addr, regaddr uint8, w []byte, r []byte) (nw, nr int, err error)

only supports 7 bit addressing

Jump to

Keyboard shortcuts

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