line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VIC::PIC::Any; |
2
|
34
|
|
|
34
|
|
779
|
use strict; |
|
34
|
|
|
|
|
47
|
|
|
34
|
|
|
|
|
912
|
|
3
|
34
|
|
|
34
|
|
123
|
use warnings; |
|
34
|
|
|
|
|
47
|
|
|
34
|
|
|
|
|
655
|
|
4
|
34
|
|
|
34
|
|
115
|
use Carp; |
|
34
|
|
|
|
|
40
|
|
|
34
|
|
|
|
|
2623
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.29'; |
7
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
8
|
|
|
|
|
|
|
|
9
|
34
|
|
|
34
|
|
12399
|
use VIC::PIC::Gpsim; |
|
34
|
|
|
|
|
1461
|
|
|
34
|
|
|
|
|
1882
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# use this to map various PICs to their classes |
12
|
|
|
|
|
|
|
# allows for the same class to be used for different pics |
13
|
34
|
|
|
|
|
2600
|
use constant PICS => { |
14
|
|
|
|
|
|
|
# PIC12 |
15
|
|
|
|
|
|
|
P12F683 => 'P12F683', |
16
|
|
|
|
|
|
|
# PIC16 |
17
|
|
|
|
|
|
|
P16F690 => 'P16F690', |
18
|
|
|
|
|
|
|
P16F631 => 'P16F631', |
19
|
|
|
|
|
|
|
P16F677 => 'P16F677', |
20
|
|
|
|
|
|
|
P16F685 => 'P16F685', |
21
|
|
|
|
|
|
|
P16F687 => 'P16F687', |
22
|
|
|
|
|
|
|
P16F689 => 'P16F689', |
23
|
|
|
|
|
|
|
P16F627A => 'P16F627A', |
24
|
|
|
|
|
|
|
P16F628A => 'P16F628A', |
25
|
|
|
|
|
|
|
P16F648A => 'P16F648A', |
26
|
|
|
|
|
|
|
# PIC18 |
27
|
|
|
|
|
|
|
P18F242 => 'P18F242', |
28
|
|
|
|
|
|
|
P18F252 => 'P18F252', |
29
|
|
|
|
|
|
|
P18F442 => 'P18F442', |
30
|
|
|
|
|
|
|
P18F452 => 'P18F452', |
31
|
|
|
|
|
|
|
P18F13K50 => 'P18F13K50', |
32
|
|
|
|
|
|
|
P18F14K50 => 'P18F14K50', |
33
|
|
|
|
|
|
|
P18LF13K50 => 'P18LF13K50', |
34
|
|
|
|
|
|
|
P18LF14K50 => 'P18LF14K50', |
35
|
34
|
|
|
34
|
|
216
|
}; |
|
34
|
|
|
|
|
42
|
|
36
|
|
|
|
|
|
|
|
37
|
34
|
|
|
|
|
1336
|
use constant PICREGEX => { |
38
|
|
|
|
|
|
|
# PIC18 |
39
|
34
|
|
|
34
|
|
126
|
}; |
|
34
|
|
|
|
|
43
|
|
40
|
|
|
|
|
|
|
|
41
|
34
|
|
|
|
|
19631
|
use constant SIMS => { |
42
|
|
|
|
|
|
|
gpsim => 'Gpsim', |
43
|
34
|
|
|
34
|
|
118
|
}; |
|
34
|
|
|
|
|
42
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _get_pic_type { |
46
|
70
|
|
|
70
|
|
129
|
my $type = shift; |
47
|
70
|
|
|
|
|
223
|
$type =~ s/^PIC/P/gi; |
48
|
70
|
|
|
|
|
227
|
my $ctype = PICS->{uc $type}; |
49
|
70
|
100
|
|
|
|
207
|
unless (defined $ctype) { |
50
|
1
|
|
|
|
|
2
|
foreach my $regex (keys %{+PICREGEX}) { |
|
1
|
|
|
|
|
7
|
|
51
|
0
|
0
|
|
|
|
0
|
if ($type =~ $regex) { |
52
|
0
|
|
|
|
|
0
|
$ctype = PICREGEX->{$regex}; |
53
|
0
|
|
|
|
|
0
|
last; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
70
|
|
|
|
|
170
|
return $ctype; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub new { |
61
|
51
|
|
|
51
|
1
|
35554
|
my ($class, $type) = @_; |
62
|
51
|
50
|
|
|
|
255
|
if (uc $type eq 'ANY') { |
63
|
0
|
|
|
|
|
0
|
die "You need to specify the type of the chip on the commandline to use 'Any'\n"; |
64
|
0
|
|
|
|
|
0
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
51
|
|
|
|
|
200
|
my $ctype = &_get_pic_type($type); |
67
|
51
|
50
|
|
|
|
150
|
return unless defined $ctype; |
68
|
51
|
|
|
|
|
388
|
$class =~ s/::Any/::$ctype/g; |
69
|
51
|
50
|
|
|
|
4864
|
eval "require $class;" or croak "Unable to load $class: $@"; |
70
|
51
|
|
|
|
|
649
|
return $class->new(type => lc $ctype); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub new_simulator { |
74
|
36
|
|
|
36
|
0
|
1312
|
my ($class, %hh) = @_; |
75
|
36
|
|
|
|
|
70
|
my $stype = 'Gpsim'; |
76
|
36
|
100
|
|
|
|
124
|
if (exists $hh{type}) { |
77
|
3
|
|
|
|
|
11
|
$stype = SIMS->{lc $hh{type}}; |
78
|
3
|
50
|
|
|
|
9
|
unless (defined $stype) { |
79
|
0
|
|
|
|
|
0
|
carp "No simulator of type $hh{type}"; |
80
|
0
|
|
|
|
|
0
|
return; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
36
|
|
|
|
|
229
|
$class =~ s/::Any/::$stype/g; |
84
|
36
|
|
|
|
|
99
|
$hh{type} = lc $stype; |
85
|
36
|
|
|
|
|
275
|
return $class->new(%hh); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub supported_chips { |
89
|
3
|
|
|
3
|
0
|
1944
|
my @chips = sort(keys %{+PICS}); |
|
3
|
|
|
|
|
50
|
|
90
|
3
|
|
|
|
|
8
|
push @chips, sort(values %{+PICREGEX}); |
|
3
|
|
|
|
|
9
|
|
91
|
3
|
50
|
|
|
|
16
|
return wantarray ? @chips : \@chips; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub supported_simulators { |
95
|
2
|
|
|
2
|
0
|
2446
|
my @sims = sort(keys %{+SIMS}); |
|
2
|
|
|
|
|
16
|
|
96
|
2
|
50
|
|
|
|
11
|
return wantarray ? @sims : \@sims; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub is_simulator_supported { |
100
|
0
|
|
|
0
|
0
|
0
|
my $ss = shift; |
101
|
0
|
|
|
|
|
0
|
my @sims = &supported_simulators(); |
102
|
0
|
0
|
|
|
|
0
|
return (grep {/$ss/} @sims) ? 1 : 0; |
|
0
|
|
|
|
|
0
|
|
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub is_chip_supported { |
106
|
19
|
|
|
19
|
0
|
18
|
my $chip = shift; |
107
|
19
|
|
|
|
|
93
|
my $ret = &_get_pic_type(uc $chip); |
108
|
19
|
100
|
|
|
|
88
|
return (defined $ret) ? 1 : 0; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub list_chip_features { |
112
|
0
|
|
|
0
|
0
|
|
my $chip = shift; |
113
|
0
|
|
|
|
|
|
my $ctype = &_get_pic_type($chip); |
114
|
0
|
0
|
|
|
|
|
unless (defined $ctype) { |
115
|
0
|
|
|
|
|
|
carp "Chip $chip is not supported\n"; |
116
|
0
|
|
|
|
|
|
return; |
117
|
|
|
|
|
|
|
} |
118
|
0
|
|
|
|
|
|
my $obj = __PACKAGE__->new($chip); |
119
|
0
|
|
|
|
|
|
my $roles = $obj->list_roles(); |
120
|
|
|
|
|
|
|
return { |
121
|
0
|
|
|
|
|
|
roles => $roles, |
122
|
|
|
|
|
|
|
memory => $obj->memory, |
123
|
|
|
|
|
|
|
}; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub print_pinout { |
127
|
0
|
|
|
0
|
0
|
|
my $chip = shift; |
128
|
0
|
|
|
|
|
|
my $ctype = &_get_pic_type($chip); |
129
|
0
|
0
|
|
|
|
|
unless (defined $ctype) { |
130
|
0
|
|
|
|
|
|
carp "Chip $chip is not supported\n"; |
131
|
0
|
|
|
|
|
|
return; |
132
|
|
|
|
|
|
|
} |
133
|
0
|
|
|
|
|
|
my $obj = __PACKAGE__->new($chip); |
134
|
0
|
|
|
|
|
|
return $obj->print_pinout; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=encoding utf8 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 NAME |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
VIC::PIC::Any |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 SYNOPSIS |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
A wrapper class that returns the appropriate object for the given PIC |
148
|
|
|
|
|
|
|
microcontroller name. This is used internally by VIC. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 DESCRIPTION |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=over |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item B |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Returns an object for the given microcontroller name such as 'P16F690'. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 AUTHOR |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Vikas N Kumar |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 COPYRIGHT |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Copyright (c) 2014. Vikas N Kumar |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
169
|
|
|
|
|
|
|
under the same terms as Perl itself. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
See http://www.perl.com/perl/misc/Artistic.html |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |