line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VIC::PIC::P18F13K50; |
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
55
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.29'; |
5
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
6
|
1
|
|
|
1
|
|
3
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
extends 'VIC::PIC::Base'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# role CodeGen |
10
|
|
|
|
|
|
|
has type => (is => 'ro', default => 'p18f13k50'); |
11
|
|
|
|
|
|
|
has include => (is => 'ro', default => 'p18f13k50.inc'); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#role Chip |
14
|
|
|
|
|
|
|
has f_osc => (is => 'ro', default => 4e6); # 4MHz internal oscillator |
15
|
|
|
|
|
|
|
has pcl_size => (is => 'ro', default => 21); # program counter (PCL) size |
16
|
|
|
|
|
|
|
has stack_size => (is => 'ro', default => 31); # 31 levels of 21-bit entries |
17
|
|
|
|
|
|
|
has wreg_size => (is => 'ro', default => 8); # 8-bit register WREG |
18
|
|
|
|
|
|
|
# all memory is in bytes |
19
|
|
|
|
|
|
|
has memory => (is => 'ro', default => sub { |
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
flash => 4096, # words |
22
|
|
|
|
|
|
|
SRAM => 512, |
23
|
|
|
|
|
|
|
EEPROM => 256, |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
}); |
26
|
|
|
|
|
|
|
has address => (is => 'ro', default => sub { |
27
|
|
|
|
|
|
|
{ # high, low |
28
|
|
|
|
|
|
|
isr => [ 0x0008, 0x0018 ], |
29
|
|
|
|
|
|
|
reset => [ 0x0000 ], |
30
|
|
|
|
|
|
|
range => [ 0x0000, 0x1FFF ], |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
}); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has pin_counts => (is => 'ro', default => sub { { |
35
|
|
|
|
|
|
|
pdip => 20, ## PDIP or DIP ? |
36
|
|
|
|
|
|
|
soic => 20, |
37
|
|
|
|
|
|
|
ssop => 20, |
38
|
|
|
|
|
|
|
qfn => 20, |
39
|
|
|
|
|
|
|
total => 20, |
40
|
|
|
|
|
|
|
io => 15, |
41
|
|
|
|
|
|
|
}}); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has banks => (is => 'ro', default => sub { |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
count => 16, |
46
|
|
|
|
|
|
|
size => 0x100, |
47
|
|
|
|
|
|
|
gpr => { |
48
|
|
|
|
|
|
|
0 => [ 0x000, 0x0FF], |
49
|
|
|
|
|
|
|
2 => [ 0x200, 0x2FF], |
50
|
|
|
|
|
|
|
}, |
51
|
|
|
|
|
|
|
# remapping of these addresses automatically done by chip |
52
|
|
|
|
|
|
|
common => [ [0x000, 0x05F], [0xF60, 0xFFF] ], |
53
|
|
|
|
|
|
|
remap => [], |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
}); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has registers => (is => 'ro', default => sub { |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
TOSU => [0xFFF], |
60
|
|
|
|
|
|
|
TOSH => [0xFFE], |
61
|
|
|
|
|
|
|
TOSL => [0xFFD], |
62
|
|
|
|
|
|
|
STKPTR => [0xFFC], |
63
|
|
|
|
|
|
|
PCLATU => [0xFFB], |
64
|
|
|
|
|
|
|
PCLATH => [0xFFA], |
65
|
|
|
|
|
|
|
PCL => [0xFF9], |
66
|
|
|
|
|
|
|
TBLPTRU => [0xFF8], |
67
|
|
|
|
|
|
|
TBLPTRH => [0xFF7], |
68
|
|
|
|
|
|
|
TBLPTRL => [0xFF6], |
69
|
|
|
|
|
|
|
TABLAT => [0xFF5], |
70
|
|
|
|
|
|
|
PRODH => [0xFF4], |
71
|
|
|
|
|
|
|
PRODL => [0xFF3], |
72
|
|
|
|
|
|
|
INTCON => [0xFF2], |
73
|
|
|
|
|
|
|
INTCON2 => [0xFF1], |
74
|
|
|
|
|
|
|
INTCON3 => [0xFF0], |
75
|
|
|
|
|
|
|
INDF0 => [0xFEF], |
76
|
|
|
|
|
|
|
POSTINC0 => [0xFEE], |
77
|
|
|
|
|
|
|
POSTDEC0 => [0xFED], |
78
|
|
|
|
|
|
|
PREINC0 => [0xFEC], |
79
|
|
|
|
|
|
|
PLUSW0 => [0xFEB], |
80
|
|
|
|
|
|
|
FSR0H => [0xFEA], |
81
|
|
|
|
|
|
|
FSR0L => [0xFE9], |
82
|
|
|
|
|
|
|
WREG => [0xFE8], |
83
|
|
|
|
|
|
|
INDF1 => [0xFE7], |
84
|
|
|
|
|
|
|
POSTINC1 => [0xFE6], |
85
|
|
|
|
|
|
|
POSTDEC1 => [0xFE5], |
86
|
|
|
|
|
|
|
PREINC1 => [0xFE4], |
87
|
|
|
|
|
|
|
PLUSW1 => [0xFE3], |
88
|
|
|
|
|
|
|
FSR1H => [0xFE2], |
89
|
|
|
|
|
|
|
FSR1L => [0xFE1], |
90
|
|
|
|
|
|
|
BSR => [0xFE0], |
91
|
|
|
|
|
|
|
INDF2 => [0xFDF], |
92
|
|
|
|
|
|
|
POSTINC2 => [0xFDE], |
93
|
|
|
|
|
|
|
POSTDEC2 => [0xFDD], |
94
|
|
|
|
|
|
|
PREINC2 => [0xFDC], |
95
|
|
|
|
|
|
|
PLUSW2 => [0xFDB], |
96
|
|
|
|
|
|
|
FSR2H => [0xFDA], |
97
|
|
|
|
|
|
|
FSR2L => [0xFD9], |
98
|
|
|
|
|
|
|
STATUS => [0xFD8], |
99
|
|
|
|
|
|
|
TMR0H => [0xFD7], |
100
|
|
|
|
|
|
|
TMR0L => [0xFD6], |
101
|
|
|
|
|
|
|
T0CON => [0xFD5], |
102
|
|
|
|
|
|
|
OSCCON => [0xFD3], |
103
|
|
|
|
|
|
|
OSCCON2 => [0xFD2], |
104
|
|
|
|
|
|
|
WDTCON => [0xFD1], |
105
|
|
|
|
|
|
|
RCON => [0xFD0], |
106
|
|
|
|
|
|
|
TMR1H => [0xFCF], |
107
|
|
|
|
|
|
|
TMR1L => [0xFCE], |
108
|
|
|
|
|
|
|
T1CON => [0xFCD], |
109
|
|
|
|
|
|
|
TMR2 => [0xFCC], |
110
|
|
|
|
|
|
|
PR2 => [0xFCB], |
111
|
|
|
|
|
|
|
T2CON => [0xFCA], |
112
|
|
|
|
|
|
|
SSPBUF => [0xFC9], |
113
|
|
|
|
|
|
|
SSPADD => [0xFC8], |
114
|
|
|
|
|
|
|
SSPSTAT => [0xFC7], |
115
|
|
|
|
|
|
|
SSPCON1 => [0xFC6], |
116
|
|
|
|
|
|
|
SSPCON2 => [0xFC5], |
117
|
|
|
|
|
|
|
ADRESH => [0xFC4], |
118
|
|
|
|
|
|
|
ADRESL => [0xFC3], |
119
|
|
|
|
|
|
|
ADCON0 => [0xFC2], |
120
|
|
|
|
|
|
|
ADCON1 => [0xFC1], |
121
|
|
|
|
|
|
|
ADCON2 => [0xFC0], |
122
|
|
|
|
|
|
|
CCPR1H => [0xFBF], |
123
|
|
|
|
|
|
|
CCPR1L => [0xFBE], |
124
|
|
|
|
|
|
|
CCP1CON => [0xFBD], |
125
|
|
|
|
|
|
|
REFCON2 => [0xFBC], |
126
|
|
|
|
|
|
|
REFCON1 => [0xFBB], |
127
|
|
|
|
|
|
|
REFCON0 => [0xFBA], |
128
|
|
|
|
|
|
|
PSTRCON => [0xFB9], |
129
|
|
|
|
|
|
|
BAUDCON => [0xFB8], |
130
|
|
|
|
|
|
|
PWM1CON => [0xFB7], |
131
|
|
|
|
|
|
|
ECCP1AS => [0xFB6], |
132
|
|
|
|
|
|
|
TMR3H => [0xFB3], |
133
|
|
|
|
|
|
|
TMR3L => [0xFB2], |
134
|
|
|
|
|
|
|
T3CON => [0xFB1], |
135
|
|
|
|
|
|
|
SPBRGH => [0xFB0], |
136
|
|
|
|
|
|
|
SPBRG => [0xFAF], |
137
|
|
|
|
|
|
|
RCREG => [0xFAE], |
138
|
|
|
|
|
|
|
TXREG => [0xFAD], |
139
|
|
|
|
|
|
|
TXSTA => [0xFAC], |
140
|
|
|
|
|
|
|
RCSTA => [0xFAB], |
141
|
|
|
|
|
|
|
EEADR => [0xFA9], |
142
|
|
|
|
|
|
|
EEDATA => [0xFA8], |
143
|
|
|
|
|
|
|
EECON2 => [0xFA7], |
144
|
|
|
|
|
|
|
EECON1 => [0xFA6], |
145
|
|
|
|
|
|
|
IPR2 => [0xFA2], |
146
|
|
|
|
|
|
|
PIR2 => [0xFA1], |
147
|
|
|
|
|
|
|
PIE2 => [0xFA0], |
148
|
|
|
|
|
|
|
IPR1 => [0xF9F], |
149
|
|
|
|
|
|
|
PIR1 => [0xF9E], |
150
|
|
|
|
|
|
|
PIE1 => [0xF9D], |
151
|
|
|
|
|
|
|
OSCTUNE => [0xF9B], |
152
|
|
|
|
|
|
|
TRISC => [0xF94], |
153
|
|
|
|
|
|
|
TRISB => [0xF93], |
154
|
|
|
|
|
|
|
TRISA => [0xF92], |
155
|
|
|
|
|
|
|
LATC => [0xF8B], |
156
|
|
|
|
|
|
|
LATB => [0xF8A], |
157
|
|
|
|
|
|
|
LATA => [0xF89], |
158
|
|
|
|
|
|
|
PORTC => [0xF82], |
159
|
|
|
|
|
|
|
PORTB => [0xF81], |
160
|
|
|
|
|
|
|
PORTA => [0xF80], |
161
|
|
|
|
|
|
|
ANSELH => [0xF7F], |
162
|
|
|
|
|
|
|
ANSEL => [0xF7E], |
163
|
|
|
|
|
|
|
IOCB => [0xF7A], |
164
|
|
|
|
|
|
|
IOCA => [0xF79], |
165
|
|
|
|
|
|
|
WPUB => [0xF78], |
166
|
|
|
|
|
|
|
WPUA => [0xF77], |
167
|
|
|
|
|
|
|
SLRCON => [0xF76], |
168
|
|
|
|
|
|
|
SSPMASK => [0xF6F], |
169
|
|
|
|
|
|
|
CM1CON0 => [0xF6D], |
170
|
|
|
|
|
|
|
CM2CON1 => [0xF6C], |
171
|
|
|
|
|
|
|
CM2CON0 => [0xF6B], |
172
|
|
|
|
|
|
|
SRCON1 => [0xF69], |
173
|
|
|
|
|
|
|
SRCON0 => [0xF68], |
174
|
|
|
|
|
|
|
UCON => [0xF64], |
175
|
|
|
|
|
|
|
USTAT => [0xF63], |
176
|
|
|
|
|
|
|
UIR => [0xF63], |
177
|
|
|
|
|
|
|
UCFG => [0xF61], |
178
|
|
|
|
|
|
|
UIE => [0xF60], |
179
|
|
|
|
|
|
|
UEIR => [0xF5F], |
180
|
|
|
|
|
|
|
UFRMH => [0xF5E], |
181
|
|
|
|
|
|
|
UFRML => [0xF5D], |
182
|
|
|
|
|
|
|
UADDR => [0xF5C], |
183
|
|
|
|
|
|
|
UEIE => [0xF5B], |
184
|
|
|
|
|
|
|
UEP7 => [0xF5A], |
185
|
|
|
|
|
|
|
UEP6 => [0xF59], |
186
|
|
|
|
|
|
|
UEP5 => [0xF58], |
187
|
|
|
|
|
|
|
UEP4 => [0xF57], |
188
|
|
|
|
|
|
|
UEP3 => [0xF56], |
189
|
|
|
|
|
|
|
UEP2 => [0xF55], |
190
|
|
|
|
|
|
|
UEP1 => [0xF54], |
191
|
|
|
|
|
|
|
UEP0 => [0xF53], |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
}); |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
has pins => (is => 'ro', default => sub { |
196
|
|
|
|
|
|
|
my $h = { |
197
|
|
|
|
|
|
|
# number to pin name and pin name to number |
198
|
|
|
|
|
|
|
1 => [qw(Vdd)], |
199
|
|
|
|
|
|
|
2 => [qw(RA5 IOCA5 OSC1 CLKIN)], |
200
|
|
|
|
|
|
|
3 => [qw(RA4 AN3 IOCA3 OSC2 CLKOUT)], |
201
|
|
|
|
|
|
|
4 => [qw(RA3 IOCA3 MCLR Vpp)], |
202
|
|
|
|
|
|
|
5 => [qw(RC5 CCP1 P1A T0CKI)], |
203
|
|
|
|
|
|
|
6 => [qw(RC4 P1B C12OUT SRQ)], |
204
|
|
|
|
|
|
|
7 => [qw(RC3 AN7 P1C C12IN3- PGM)], |
205
|
|
|
|
|
|
|
8 => [qw(RC6 AN8 SS T13CKI T1OSCI)], |
206
|
|
|
|
|
|
|
9 => [qw(RC7 AN9 SDO T1OSCO)], |
207
|
|
|
|
|
|
|
10 => [qw(RB7 IOCB7 TX CK)], |
208
|
|
|
|
|
|
|
11 => [qw(RB6 IOCB6 SCK SCL)], |
209
|
|
|
|
|
|
|
12 => [qw(RB5 AN11 IOCB5 RX DT)], |
210
|
|
|
|
|
|
|
13 => [qw(RB4 AN10 IOCB4 SDI SDA)], |
211
|
|
|
|
|
|
|
14 => [qw(RC2 AN6 P1D C12IN2- CVref INT2)], |
212
|
|
|
|
|
|
|
15 => [qw(RC1 AN5 C12IN1- INT1 Vref-)], |
213
|
|
|
|
|
|
|
16 => [qw(RC0 AN4 C12IN+ INT0 Vref+)], |
214
|
|
|
|
|
|
|
17 => [qw(VUSB)], |
215
|
|
|
|
|
|
|
18 => [qw(RA1 IOCA1 D- PGC)], |
216
|
|
|
|
|
|
|
19 => [qw(RA0 IOCA0 D+ PGD)], |
217
|
|
|
|
|
|
|
20 => [qw(Vss)], |
218
|
|
|
|
|
|
|
}; |
219
|
|
|
|
|
|
|
foreach my $k (keys %$h) { |
220
|
|
|
|
|
|
|
my $v = $h->{$k}; |
221
|
|
|
|
|
|
|
foreach (@$v) { |
222
|
|
|
|
|
|
|
$h->{$_} = $k; |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
return $h; |
226
|
|
|
|
|
|
|
}); |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
has clock_pins => (is => 'ro', default => sub { |
229
|
|
|
|
|
|
|
{ |
230
|
|
|
|
|
|
|
out => 'CLKOUT', |
231
|
|
|
|
|
|
|
in => 'CLKIN', |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
}); |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
has oscillator_pins => (is => 'ro', default => sub { |
236
|
|
|
|
|
|
|
{ |
237
|
|
|
|
|
|
|
in => 'OSC1', |
238
|
|
|
|
|
|
|
out => 'OSC2', |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
}); |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
has program_pins => (is => 'ro', default => sub { |
243
|
|
|
|
|
|
|
{ |
244
|
|
|
|
|
|
|
clock => 'PGC', |
245
|
|
|
|
|
|
|
data => 'PGD', |
246
|
|
|
|
|
|
|
enable => 'PGM', |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
}); |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
has io_ports => (is => 'ro', default => sub { |
251
|
|
|
|
|
|
|
{ |
252
|
|
|
|
|
|
|
#port => tristate, |
253
|
|
|
|
|
|
|
PORTA => 'TRISA', |
254
|
|
|
|
|
|
|
PORTB => 'TRISB', |
255
|
|
|
|
|
|
|
PORTC => 'TRISC', |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
}); |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
has input_pins => (is => 'ro', default => sub { |
260
|
|
|
|
|
|
|
{ |
261
|
|
|
|
|
|
|
#I/O => [port, tristate, bit] |
262
|
|
|
|
|
|
|
RA0 => ['PORTA', 'TRISA', 0], # input only |
263
|
|
|
|
|
|
|
RA1 => ['PORTA', 'TRISA', 1], # input only |
264
|
|
|
|
|
|
|
RA3 => ['PORTA', 'TRISA', 3], # input only |
265
|
|
|
|
|
|
|
RA4 => ['PORTA', 'TRISA', 4], |
266
|
|
|
|
|
|
|
RA5 => ['PORTA', 'TRISA', 5], |
267
|
|
|
|
|
|
|
RB4 => ['PORTB', 'TRISB', 4], |
268
|
|
|
|
|
|
|
RB5 => ['PORTB', 'TRISB', 5], |
269
|
|
|
|
|
|
|
RB6 => ['PORTB', 'TRISB', 6], |
270
|
|
|
|
|
|
|
RB7 => ['PORTB', 'TRISB', 7], |
271
|
|
|
|
|
|
|
RC0 => ['PORTC', 'TRISC', 0], |
272
|
|
|
|
|
|
|
RC1 => ['PORTC', 'TRISC', 1], |
273
|
|
|
|
|
|
|
RC2 => ['PORTC', 'TRISC', 2], |
274
|
|
|
|
|
|
|
RC3 => ['PORTC', 'TRISC', 3], |
275
|
|
|
|
|
|
|
RC4 => ['PORTC', 'TRISC', 4], |
276
|
|
|
|
|
|
|
RC5 => ['PORTC', 'TRISC', 5], |
277
|
|
|
|
|
|
|
RC6 => ['PORTC', 'TRISC', 6], |
278
|
|
|
|
|
|
|
RC7 => ['PORTC', 'TRISC', 7], |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
}); |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
has output_pins => (is => 'ro', default => sub { |
283
|
|
|
|
|
|
|
{ |
284
|
|
|
|
|
|
|
#I/O => [port, tristate, bit] |
285
|
|
|
|
|
|
|
RA4 => ['PORTA', 'TRISA', 4], |
286
|
|
|
|
|
|
|
RA5 => ['PORTA', 'TRISA', 5], |
287
|
|
|
|
|
|
|
RB4 => ['PORTB', 'TRISB', 4], |
288
|
|
|
|
|
|
|
RB5 => ['PORTB', 'TRISB', 5], |
289
|
|
|
|
|
|
|
RB6 => ['PORTB', 'TRISB', 6], |
290
|
|
|
|
|
|
|
RB7 => ['PORTB', 'TRISB', 7], |
291
|
|
|
|
|
|
|
RC0 => ['PORTC', 'TRISC', 0], |
292
|
|
|
|
|
|
|
RC1 => ['PORTC', 'TRISC', 1], |
293
|
|
|
|
|
|
|
RC2 => ['PORTC', 'TRISC', 2], |
294
|
|
|
|
|
|
|
RC3 => ['PORTC', 'TRISC', 3], |
295
|
|
|
|
|
|
|
RC4 => ['PORTC', 'TRISC', 4], |
296
|
|
|
|
|
|
|
RC5 => ['PORTC', 'TRISC', 5], |
297
|
|
|
|
|
|
|
RC6 => ['PORTC', 'TRISC', 6], |
298
|
|
|
|
|
|
|
RC7 => ['PORTC', 'TRISC', 7], |
299
|
|
|
|
|
|
|
} |
300
|
|
|
|
|
|
|
}); |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
has analog_pins => (is => 'ro', default => sub { |
303
|
|
|
|
|
|
|
{ |
304
|
|
|
|
|
|
|
# use ANSEL for pins AN0-AN7 and ANSELH for AN8-AN11 |
305
|
|
|
|
|
|
|
#pin => number, bit |
306
|
|
|
|
|
|
|
AN3 => [3, 3], |
307
|
|
|
|
|
|
|
AN4 => [16, 4], |
308
|
|
|
|
|
|
|
AN5 => [15, 5], |
309
|
|
|
|
|
|
|
AN6 => [14, 6], |
310
|
|
|
|
|
|
|
AN7 => [ 7, 7], |
311
|
|
|
|
|
|
|
AN8 => [ 8, 8], |
312
|
|
|
|
|
|
|
AN9 => [ 9, 9], |
313
|
|
|
|
|
|
|
AN10 => [13, 10], |
314
|
|
|
|
|
|
|
AN11 => [12, 12], |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
}); |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
has adc_channels => (is => 'ro', default => 9); |
319
|
|
|
|
|
|
|
has adcs_bits => (is => 'ro', default => sub { |
320
|
|
|
|
|
|
|
{ |
321
|
|
|
|
|
|
|
2 => '000', |
322
|
|
|
|
|
|
|
4 => '100', |
323
|
|
|
|
|
|
|
8 => '001', |
324
|
|
|
|
|
|
|
16 => '101', |
325
|
|
|
|
|
|
|
32 => '010', |
326
|
|
|
|
|
|
|
64 => '110', |
327
|
|
|
|
|
|
|
internal => '111', |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
}); |
330
|
|
|
|
|
|
|
has adc_chs_bits => (is => 'ro', default => sub { |
331
|
|
|
|
|
|
|
{ |
332
|
|
|
|
|
|
|
#pin => chsbits |
333
|
|
|
|
|
|
|
AN3 => '0011', |
334
|
|
|
|
|
|
|
AN4 => '0100', |
335
|
|
|
|
|
|
|
AN5 => '0101', |
336
|
|
|
|
|
|
|
AN6 => '0110', |
337
|
|
|
|
|
|
|
AN7 => '0111', |
338
|
|
|
|
|
|
|
AN8 => '1000', |
339
|
|
|
|
|
|
|
AN9 => '1001', |
340
|
|
|
|
|
|
|
AN10 => '1010', |
341
|
|
|
|
|
|
|
AN11 => '1011', |
342
|
|
|
|
|
|
|
DAC => '1110', |
343
|
|
|
|
|
|
|
FVR => '1111', |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
}); |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
has timer_prescaler => (is => 'ro', default => sub { |
348
|
|
|
|
|
|
|
{ |
349
|
|
|
|
|
|
|
2 => '000', |
350
|
|
|
|
|
|
|
4 => '001', |
351
|
|
|
|
|
|
|
8 => '010', |
352
|
|
|
|
|
|
|
16 => '011', |
353
|
|
|
|
|
|
|
32 => '100', |
354
|
|
|
|
|
|
|
64 => '101', |
355
|
|
|
|
|
|
|
128 => '110', |
356
|
|
|
|
|
|
|
256 => '111', |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
}); |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
has wdt_prescaler => (is => 'ro', default => sub { |
361
|
|
|
|
|
|
|
{ |
362
|
|
|
|
|
|
|
1 => '000', |
363
|
|
|
|
|
|
|
2 => '001', |
364
|
|
|
|
|
|
|
4 => '010', |
365
|
|
|
|
|
|
|
8 => '011', |
366
|
|
|
|
|
|
|
16 => '100', |
367
|
|
|
|
|
|
|
32 => '101', |
368
|
|
|
|
|
|
|
64 => '110', |
369
|
|
|
|
|
|
|
128 => '111', |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
}); |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
has timer_pins => (is => 'ro', default => sub { |
374
|
|
|
|
|
|
|
{ |
375
|
|
|
|
|
|
|
TMR0 => { reg => ['TMR0H', 'TMR0L'], flag => 'TMR0IF', |
376
|
|
|
|
|
|
|
enable => 'TMR0IE', freg => 'INTCON', ereg => 'INTCON' }, |
377
|
|
|
|
|
|
|
TMR1 => { reg => ['TMR1H', 'TMR1L'], flag => 'TMR1IF', |
378
|
|
|
|
|
|
|
enable => 'TMR1IE', freg => 'PIR1', ereg => 'PIE1' }, |
379
|
|
|
|
|
|
|
TMR2 => { reg => 'TMR2', flag => 'TMR2IF', |
380
|
|
|
|
|
|
|
enable => 'TMR2IE', freg => 'PIR1', ereg => 'PIE1' }, |
381
|
|
|
|
|
|
|
TMR3 => { reg => ['TMR3H', 'TMR3L'], flag => 'TMR3IF', |
382
|
|
|
|
|
|
|
enable => 'TMR3IE', freg => 'PIR2', ereg => 'PIE2' }, |
383
|
|
|
|
|
|
|
T0CKI => 5, |
384
|
|
|
|
|
|
|
T13CKI => 8, |
385
|
|
|
|
|
|
|
T1OSCI => 8, |
386
|
|
|
|
|
|
|
T1OSCO => 9, |
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
}); |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
has eccp_pins => (is => 'ro', default => sub { |
391
|
|
|
|
|
|
|
{ # pin => pin_no, tris, bit |
392
|
|
|
|
|
|
|
P1D => [14, 'TRISC', 2], |
393
|
|
|
|
|
|
|
P1C => [7, 'TRISC', 3], |
394
|
|
|
|
|
|
|
P1B => [6, 'TRISC', 4], |
395
|
|
|
|
|
|
|
P1A => [5, 'TRISC', 5], |
396
|
|
|
|
|
|
|
CCP1 => [5, 'TRISC', 5], |
397
|
|
|
|
|
|
|
} |
398
|
|
|
|
|
|
|
}); |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
#external interrupt |
401
|
|
|
|
|
|
|
has eint_pins => (is => 'ro', default => sub { |
402
|
|
|
|
|
|
|
{ |
403
|
|
|
|
|
|
|
INT0 => 16, |
404
|
|
|
|
|
|
|
INT1 => 15, |
405
|
|
|
|
|
|
|
INT2 => 14, |
406
|
|
|
|
|
|
|
} |
407
|
|
|
|
|
|
|
}); |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
has ioc_pins => (is => 'ro', default => sub { |
410
|
|
|
|
|
|
|
{ |
411
|
|
|
|
|
|
|
RA0 => [19, 'IOCA0', 'IOCA'], |
412
|
|
|
|
|
|
|
RA1 => [18, 'IOCA1', 'IOCA'], |
413
|
|
|
|
|
|
|
RA3 => [4, 'IOCA3', 'IOCA'], |
414
|
|
|
|
|
|
|
RA4 => [3, 'IOCA4', 'IOCA'], |
415
|
|
|
|
|
|
|
RA5 => [2, 'IOCA5', 'IOCA'], |
416
|
|
|
|
|
|
|
RB4 => [13, 'IOCB4', 'IOCB'], |
417
|
|
|
|
|
|
|
RB5 => [12, 'IOCB5', 'IOCB'], |
418
|
|
|
|
|
|
|
RB6 => [11, 'IOCB6', 'IOCB'], |
419
|
|
|
|
|
|
|
RB7 => [10, 'IOCB7', 'IOCB'], |
420
|
|
|
|
|
|
|
} |
421
|
|
|
|
|
|
|
}); |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
has ioc_ports => (is => 'ro', default => sub { |
424
|
|
|
|
|
|
|
{ |
425
|
|
|
|
|
|
|
PORTA => 'IOCA', |
426
|
|
|
|
|
|
|
PORTB => 'IOCB', |
427
|
|
|
|
|
|
|
FLAG => 'RABIF', |
428
|
|
|
|
|
|
|
ENABLE => 'RABIE', |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
}); |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
has usart_pins => (is => 'ro', default => sub { |
433
|
|
|
|
|
|
|
{ |
434
|
|
|
|
|
|
|
async_in => 'RX', |
435
|
|
|
|
|
|
|
async_out => 'TX', |
436
|
|
|
|
|
|
|
sync_clock => 'CK', |
437
|
|
|
|
|
|
|
sync_data => 'DT', |
438
|
|
|
|
|
|
|
#TODO |
439
|
|
|
|
|
|
|
rx_int => {}, |
440
|
|
|
|
|
|
|
tx_int => {}, |
441
|
|
|
|
|
|
|
# this defines the port names that the user can use |
442
|
|
|
|
|
|
|
# validly. The port names define whether the user wants to use them in |
443
|
|
|
|
|
|
|
# synchronous or asynchronous mode |
444
|
|
|
|
|
|
|
UART => 'async', |
445
|
|
|
|
|
|
|
USART => 'sync', |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
}); |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
0
|
0
|
|
sub usart_baudrates {} |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
has selector_pins => (is => 'ro', default => sub { |
452
|
|
|
|
|
|
|
{ |
453
|
|
|
|
|
|
|
'spi_or_i2c' => 'SS', |
454
|
|
|
|
|
|
|
} |
455
|
|
|
|
|
|
|
}); |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
has spi_pins => (is => 'ro', default => sub { |
458
|
|
|
|
|
|
|
{ |
459
|
|
|
|
|
|
|
data_out => 'SDO', |
460
|
|
|
|
|
|
|
data_in => 'SDI', |
461
|
|
|
|
|
|
|
clock => 'SCK', |
462
|
|
|
|
|
|
|
} |
463
|
|
|
|
|
|
|
}); |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
has i2c_pins => (is => 'ro', default => sub { |
466
|
|
|
|
|
|
|
{ |
467
|
|
|
|
|
|
|
data => 'SDA', |
468
|
|
|
|
|
|
|
clock => 'SCL', |
469
|
|
|
|
|
|
|
} |
470
|
|
|
|
|
|
|
}); |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
has cmp_input_pins => (is => 'ro', default => sub { |
473
|
|
|
|
|
|
|
{ |
474
|
|
|
|
|
|
|
'C12IN+' => 'C12IN+', |
475
|
|
|
|
|
|
|
'C12IN1-' => 'C12IN1-', |
476
|
|
|
|
|
|
|
'C12IN2-' => 'C12IN2-', |
477
|
|
|
|
|
|
|
'C12IN3-' => 'C12IN3-', |
478
|
|
|
|
|
|
|
} |
479
|
|
|
|
|
|
|
}); |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
has cmp_output_pins => (is => 'ro', default => sub { |
482
|
|
|
|
|
|
|
{ |
483
|
|
|
|
|
|
|
C12OUT => 'C12OUT', |
484
|
|
|
|
|
|
|
CVref => 'CVref', |
485
|
|
|
|
|
|
|
} |
486
|
|
|
|
|
|
|
}); |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
has usb_pins => (is => 'ro', default => sub { |
489
|
|
|
|
|
|
|
{ |
490
|
|
|
|
|
|
|
'D+' => 'D+', |
491
|
|
|
|
|
|
|
'D-' => 'D-', |
492
|
|
|
|
|
|
|
'VUSB' => 'VUSB', |
493
|
|
|
|
|
|
|
} |
494
|
|
|
|
|
|
|
}); |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
has srlatch => (is => 'ro', default => sub { |
497
|
|
|
|
|
|
|
{ |
498
|
|
|
|
|
|
|
'SRQ' => 'SRQ', |
499
|
|
|
|
|
|
|
} |
500
|
|
|
|
|
|
|
}); |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
my @rolenames = qw(CodeGen Operators Chip GPIO ADC ISR Timer Operations ECCP |
503
|
|
|
|
|
|
|
USART SPI I2C Comparator USB SRLatch); |
504
|
|
|
|
|
|
|
my @roles = map (("VIC::PIC::Roles::$_", "VIC::PIC::Functions::$_"), @rolenames); |
505
|
|
|
|
|
|
|
with @roles; |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
sub list_roles { |
508
|
4
|
|
|
4
|
0
|
3781
|
my @arr = grep {!/CodeGen|Oper|Chip|ISR/} @rolenames; |
|
60
|
|
|
|
|
159
|
|
509
|
4
|
50
|
|
|
|
23
|
return wantarray ? @arr : [@arr]; |
510
|
|
|
|
|
|
|
} |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
1; |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
__END__ |