Device::BusPirate::Mode::BB - use Device::BusPirate in bit-banging mode
Device::BusPirate::Mode::BB
Device::BusPirate
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; }
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.
BB
The following methods documented with await expressions Future instances.
await
await $bb->configure( %args );
Change configuration options. The following options exist; all of which are simple true/false booleans.
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.
await $bb->write( %pins );
Sets the state of multiple output pins at the same time.
$pins = await $bbio->read( @pins );
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.
read_*
$in_pins = await $bbio->writeread( %out_pins );
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.
write
read
%out_pins
await $bb->power( $power );
Enable or disable the VREG 5V and 3.3V power outputs.
VREG
await $bb->pullup( $pullup );
Enable or disable the IO pin pullup resistors from Vpu. These are connected to the MISO, CLK, MOSI and CS pins.
Vpu
MISO
CLK
MOSI
CS
For each named pin, the following methods are defined. The pin names are
cs miso sck mosi aux
await $bbio->PIN( $state );
Sets the output state of the given pin.
$state = await $bbio->read_PIN;
Sets the pin to input direction and reads its current state.
Some method of setting multiple pins into read mode at once, so that a single read method hits them all.
Paul Evans <leonerd@leonerd.org.uk>
To install Device::BusPirate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Device::BusPirate
CPAN shell
perl -MCPAN -e shell install Device::BusPirate
For more information on module installation, please visit the detailed CPAN module installation guide.