buspirate

package module
v0.0.0-...-dad67b3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2016 License: BSD-2-Clause Imports: 3 Imported by: 1

Documentation

Overview

Package buspirate interfaces with the binary mode of the BusPirate. http://dangerousprototypes.com/docs/Bus_Pirate

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BusPirate

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

BusPirate represents a connection to a remote BusPirate device.

func Open

func Open(dev string) (*BusPirate, error)

Open opens a connection to a BusPirate module and places it into binary mode.

func (*BusPirate) PowerOff

func (bp *BusPirate) PowerOff()

PowerOff turns off the 5v and 3v3 regulators.

func (*BusPirate) PowerOn

func (bp *BusPirate) PowerOn()

PowerOn turns on the 5v and 3v3 regulators.

func (*BusPirate) SetPWM

func (bp *BusPirate) SetPWM(duty float64)

SetPWM enables PWM output on the AUX pin with the specified duty cycle. duty is clamped between [0, 1].

Example

Pulse a LED connected to the AUX pin.

bp, err := buspirate.Open("/dev/ttyACM0")
if err != nil {
	panic(err)
}
duty := 0.1
delta := 0.1
for {
	bp.SetPWM(duty)
	time.Sleep(50 * time.Millisecond)
	duty += delta
	if duty > 1.0 {
		duty = 1.0
		delta = -delta
	}
	if duty < 0 {
		duty = 0.0
		delta = -delta
	}
}
Output:

func (*BusPirate) SpiConfigure

func (bp *BusPirate) SpiConfigure(power, pullups, aux, cs bool) error

0100wxyz – Configure peripherals, w=power, x=pullups, y=AUX, z=CS

func (*BusPirate) SpiConfigure2

func (bp *BusPirate) SpiConfigure2(output33v, idle, edge, sample bool) error

1000wxyz – SPI config, w=output type, x=idle, y=clock edge, z=sample

func (*BusPirate) SpiCs

func (bp *BusPirate) SpiCs(high bool) error

00000010 – CS low (0) 00000011 – CS high (1)

func (*BusPirate) SpiEnter

func (bp *BusPirate) SpiEnter() error

func (*BusPirate) SpiLeave

func (bp *BusPirate) SpiLeave() error

func (*BusPirate) SpiSpeed

func (bp *BusPirate) SpiSpeed(speed SpiSpeed) error

01100xxx – Set SPI speed, 30, 125, 250khz; 1, 2, 2.6, 4, 8MHz 000=30kHz, 001=125kHz, 010=250kHz, 011=1MHz, 100=2MHz, 101=2.6MHz, 110=4MHz, 111=8MHz

func (*BusPirate) SpiTransfer

func (bp *BusPirate) SpiTransfer(send []byte) (*[]byte, error)

0001xxxx – Bulk SPI transfer, send 1-16 bytes (0=1byte!)

type SpiSpeed

type SpiSpeed uint8
const (
	SpiSpeed30khz SpiSpeed = iota
	SpiSpeed125khz
	SpiSpeed250khz
	SpiSpeed1mhz
	SpiSpeed2mhz
	SpiSpeed2600khz
	SpiSpeed4mhz
	SpiSpeed8mhz
)

Jump to

Keyboard shortcuts

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