Author image Dustin La Ferney

NAME

PINE64::GPIO - Perl interface to PineA64 and PineA64+ GPIO pins

SYNOPSIS

        use PINE64::GPIO;

        #instantiate PINE64::GPIO object
        my $p64 = PINE64::GPIO->new();
        
        #export pin 25 (physical pin 40) for output
        $p64->gpio_enable(25, 'out');

        #continuously blink LED
        for(;;){
                $p64->gpio_write(25, 1);
                sleep(1);
                $p64->gpio_write(25, 0);
                sleep(1);
        }#end for

DESCRIPTION

This module manipulates the GPIO file system interface of the PineA64 and PineA64+ single board computers so you can control the GPIO pins on the PineA64's PI-2 bus.

The PineA64's 40-pin PI-2 bus has the same pinout as the Raspberry Pi's 40-pin GPIO, however this module has it's own GPIO pin numbering convention for the 26 GPIO pins as follows:

 Module#                Physical#       A64 sys#
 ------------------------------------------
 0              3               227
 1              5               226
 2              7               362
 3              11              71
 4              13              233
 5              15              76
 6              19              64
 7              21              65
 8              23              66
 9              29              229
 10             31              230
 11             33              69
 12             35              73
 13             37              80
 14             8               32
 15             10              33
 16             12              72
 17             16              77
 18             18              78
 19             22              79
 20             24              67
 21             26              231
 22             32              68
 23             36              70
 24             38              74
 25             40              75
 

METHODS

new()

Returns a new PINE64::GPIO object.

gpio_enable($pin, 'out')

Takes the GPIO pin number and direction as arguments and exports it for use as either an input or output.

Valid pin number arguments are 0-25, and the direction is either 'in' or 'out'.

$p64->gpio_enable(25, 'out');

gpio_read($pin)

Takes pin number as an argument and returns the logic value on the pin.

gpio_write($pin, $value)

Takes pin number and value as an argument and writes the value to the GPIO pin. Valid values are 0 or 1.

gpio_disable($pin)

Takes pin number as an argument and unexports the pin in the file system interface.

AUTHOR

Dustin La Ferney