line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
######################################################################################### |
2
|
|
|
|
|
|
|
# Package HiPi::GPIO::Pin |
3
|
|
|
|
|
|
|
# Description: Pin |
4
|
|
|
|
|
|
|
# Copyright : Copyright (c) 2017 Mark Dootson |
5
|
|
|
|
|
|
|
# License : This is free software; you can redistribute it and/or modify it under |
6
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
7
|
|
|
|
|
|
|
######################################################################################### |
8
|
|
|
|
|
|
|
package HiPi::GPIO::Pin; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
######################################################################################### |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
1699
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
13
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
14
|
1
|
|
|
1
|
|
6
|
use parent qw( HiPi::Pin ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
15
|
1
|
|
|
1
|
|
67
|
use Carp; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
71
|
|
16
|
1
|
|
|
1
|
|
6
|
use HiPi qw( :rpi ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
874
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION ='0.81'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
__PACKAGE__->create_accessors( ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _open { |
23
|
0
|
|
|
0
|
|
|
my ($class, %params) = @_; |
24
|
0
|
0
|
|
|
|
|
defined($params{pinid}) or croak q(pinid not defined in parameters); |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $self = $class->SUPER::_open(%params); |
27
|
0
|
|
|
|
|
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _do_getvalue { |
31
|
0
|
|
|
0
|
|
|
my($self) = @_; |
32
|
0
|
|
|
|
|
|
return HiPi::GPIO->pin_read( $self->pinid ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _do_setvalue { |
36
|
0
|
|
|
0
|
|
|
my( $self, $newval) = @_; |
37
|
0
|
|
|
|
|
|
return HiPi::GPIO->pin_write( $self->pinid, $newval ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _do_getmode { |
41
|
0
|
|
|
0
|
|
|
my $self = shift; |
42
|
0
|
|
|
|
|
|
return HiPi::GPIO->get_pin_mode( $self->pinid ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _do_setmode { |
46
|
0
|
|
|
0
|
|
|
my ($self, $newmode) = @_; |
47
|
0
|
|
|
|
|
|
return HiPi::GPIO->set_pin_mode( $self->pinid, $newmode ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _do_get_function_name { |
51
|
0
|
|
|
0
|
|
|
my($self) = @_; |
52
|
0
|
|
|
|
|
|
return HiPi::GPIO->get_pin_function( $self->pinid ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _do_getinterrupt { |
56
|
0
|
|
|
0
|
|
|
my ( $self ) = @_; |
57
|
0
|
|
|
|
|
|
return HiPi::GPIO->get_pin_interrupt($self->pinid); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _do_setinterrupt { |
61
|
0
|
|
|
0
|
|
|
my ($self, $newedge) = @_; |
62
|
0
|
|
|
|
|
|
return HiPi::GPIO->set_pin_interrupt($self->pinid, $newedge); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _do_setpud { |
66
|
0
|
|
|
0
|
|
|
my($self, $pudval) = @_; |
67
|
0
|
|
|
|
|
|
return HiPi::GPIO->set_pin_pud($self->pinid, $pudval); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _do_getpud { |
71
|
0
|
|
|
0
|
|
|
my($self ) = @_; |
72
|
0
|
|
|
|
|
|
return HiPi::GPIO->get_pin_pud($self->pinid); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _do_get_interrupt_filepath { |
76
|
0
|
|
|
0
|
|
|
my($self) = @_; |
77
|
0
|
|
|
|
|
|
return HiPi::GPIO->get_pin_interrupt_filepath( $self->pinid ); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _do_activelow { |
81
|
0
|
|
|
0
|
|
|
my($self, $newval) = @_; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $result = undef; |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
if( defined( $newval ) ) { |
86
|
0
|
|
|
|
|
|
$result = HiPi::GPIO->set_pin_activelow($self->pinid, $newval); |
87
|
|
|
|
|
|
|
} else { |
88
|
0
|
|
|
|
|
|
$result = HiPi::GPIO->get_pin_activelow($self->pinid); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
return $result; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |