HiPi
view release on metacpan or search on metacpan
lib/HiPi/RaspberryPi.pm view on Meta::CPAN
$binfo->{board_type} = $_revinfostash{board_type}->{$s_raspberry_type} || 3;
$binfo->{processor} = $_revinfostash{processor}->{$s_processor} || 'BCM2835';
$binfo->{revision} = $rev;
$binfo->{revisionnumber} = $s_revision;
$binfo->{processor_info} = $_revinfostash{processor_info}->{$binfo->{processor}};
my $unknown_raspberry_type =
( $s_raspberry_type == 5 ||
$s_raspberry_type == 7 ||
$s_raspberry_type == 11 ||
$s_raspberry_type == 15 ||
$s_raspberry_type == 22 ) ? 1 : 0;
$israspberry1 = ( $s_raspberry_type == 0 ||
$s_raspberry_type == 1 ||
$s_raspberry_type == 2 ||
$s_raspberry_type == 3 ||
$s_raspberry_type == 6 ||
$s_raspberry_type == 9 ||
$s_raspberry_type == 12 ) ? 1 : 0;
$israspberry2 = ( $s_raspberry_type == 4 ) ? 1 : 0;
$israspberry3 = ( $s_raspberry_type == 8 ||
$s_raspberry_type == 10 ||
$s_raspberry_type == 13 ||
$s_raspberry_type == 14 ||
$s_raspberry_type == 16 ||
$s_raspberry_type == 18 ) ? 1 : 0;
$israspberry4 = ( $s_raspberry_type == 17 ||
$s_raspberry_type == 19 ||
$s_raspberry_type == 20 ||
$s_raspberry_type == 21 ) ? 1 : 0;
$israspberry5 = ( $s_raspberry_type == 23 ) ? 1 : 0;
$israspberry = (
$israspberry1 || $israspberry2 || $israspberry3 || $israspberry4 || $israspberry5
) ? 1 : 0;
$_config = { %$binfo };
} else {
my $infokey = exists($_revstash{$rev}) ? $rev : $defaultkey;
$_config = { %{ $_revstash{$infokey} } };
$_config->{processor} = 'BCM2835';
$_config->{revisionnumber} = 0;
$_config->{processor_info} = $_revinfostash{processor_info}->{'BCM2835'};
$israspberry1 = $israspberry = exists($_revstash{$rev}) ? 1 : 0;
}
}
# Home Dir
if( os_is_windows ) {
require Win32;
$homedir = Win32::GetFolderPath( 0x001C, 1);
$homedir = Win32::GetShortPathName( $homedir );
$homedir =~ s/\\/\//g;
} else {
$homedir = (getpwuid($<))[7];
}
$_config->{serial} = $serial;
$_config->{short_serial} = $short_serial;
if($_config->{processor} eq 'BCM2712' ) {
$_alt_function_names = \@_alt_func_names_2712;
$_alt_function_names_version = 3;
} elsif($_config->{processor} eq 'BCM2711' ) {
$_alt_function_names = \@_alt_func_names_2711;
$_alt_function_names_version = 2;
} else {
$_alt_function_names = \@_alt_func_names_2708;
$_alt_function_names_version = 1;
}
return;
}
sub new {
my $class = shift;
my $self = bless {}, $class;
return $self;
}
sub validpins {
my $type = board_type();
if ( $type == 1 ) {
return ( 0, 1, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 21, 22, 23, 24, 25 );
} elsif ( $type == 2 ) {
return ( 2, 3, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 22, 23, 24, 25, 27, 28, 29, 30, 31 );
} else {
# return current latest known pinset
return ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 );
}
}
sub dump_board_info {
my $processor = $_config->{processor};
my $dump = qq(--------------------------------------------------\n);
$dump .= qq(Raspberry Pi Board Info\n);
$dump .= qq(--------------------------------------------------\n);
$dump .= qq(Model Name : $_config->{model_name}\n);
$dump .= qq(Released : $_config->{release}\n);
$dump .= qq(Manufacturer : $_config->{manufacturer}\n);
$dump .= qq(Memory : $_config->{memory}\n);
$dump .= qq(Processor : $processor\n);
$dump .= qq(Hardware : ) . hardware() . qq(\n);
my $description = board_description();
$dump .= qq(Description : $description\n);
$dump .= qq(Revision : $_config->{revision}\n);
$dump .= qq(Serial Number : $_config->{serial}\n);
$dump .= qq(Short Serial No : $_config->{short_serial}\n);
$dump .= qq(GPIO Header Type : $_config->{board_type}\n);
$dump .= qq(Revision Number : $_config->{revisionnumber}\n);
my $devtree = ( has_device_tree() ) ? 'Yes' : 'No';
$dump .= qq(Device Tree : $devtree\n);
$dump .= q(Is Raspberry : ) . (($israspberry) ? 'Yes' : 'No' ) . qq(\n);
$dump .= q(Is Raspberry 1 : ) . (($israspberry1) ? 'Yes' : 'No' ) . qq(\n);
( run in 2.477 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )