NAME
Device::BusPirate::Mode::BB
- use Device::BusPirate
in bit-banging mode
SYNOPSIS
use Device::BusPirate;
my $pirate = Device::BusPirate->new;
my $bb = $pirate->enter_mode( "BB" )->get;
my $count = 0;
while(1) {
$bb->write(
miso => $count == 0,
cs => $count == 1,
mosi => $count == 2,
clk => $count == 3,
aux => $count == 4,
)->then( sub { $pirate->sleep( 0.5 ) })
->get;
$count++;
$count = 0 if $count >= 5;
}
DESCRIPTION
This object is returned by a Device::BusPirate instance when switching it into BB
mode. It provides methods to configure the hardware, and interact with the five basic IO lines in bit-banging mode.
METHODS
configure
$bb->configure( %args )->get
Change configuration options. The following options exist; all of which are simple true/false booleans.
- open_drain
-
If enabled, a "high" output pin will be set as an input; i.e. hi-Z. When disabled (default), a "high" output pin will be driven by 3.3V. A "low" output will be driven to GND in either case.
write
$bb->write( %pins )->get
Sets the state of multiple output pins at the same time.
read
$pins = $bbio->read( @pins )->get
Sets given list of pins (which may be empty) to be inputs, and returns a HASH containing the current state of all the pins currently configured as inputs. More efficient than calling multiple read_*
methods when more than one pin is being read at the same time.
writeread
$in_pins = $bbio->writeread( %out_pins )->get
Combines the effects of write
and read
in a single operation; sets the output state of any pins in %out_pins
then returns the input state of the pins currently set as inputs.
power
$bb->power( $power )->get
Enable or disable the VREG
5V and 3.3V power outputs.
pullup
$bb->pullup( $pullup )->get
Enable or disable the IO pin pullup resistors from Vpu
. These are connected to the MISO
, CLK
, MOSI
and CS
pins.
PER-PIN METHODS
For each named pin, the following methods are defined. The pin names are
cs miso sck mosi aux
PIN
$bbio->PIN( $state )->get
Sets the output state of the given pin.
read_PIN
$state = $bbio->read_PIN->get
Sets the pin to input direction and reads its current state.
TODO
Some method of setting multiple pins into read mode at once, so that a single
read
method hits them all.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>