| 1 |
divert(-1) |
| 2 |
|
| 3 |
`Header([A][1|2], rows, wid, ht, |
| 4 |
boxspec, pinlen;pinsize) |
| 5 |
arg1: A= type A; number of columns |
| 6 |
arg2: pins per column |
| 7 |
arg3,4: custom wid, ht |
| 8 |
arg5: eg fill_(0.9)' |
| 9 |
define(`Header', |
| 10 |
`[ define(`m4tp',ifinstr(`$1',A,A))define(`m4Hq',patsubst(`$1',A))dnl |
| 11 |
define(`m4Hn',`ifelse(m4Hq,,1,m4Hq)')dnl |
| 12 |
define(`m4Hm',`ifelse(`$2',,2,`$2')')dnl |
| 13 |
define(`m4Hw',`ifelse(`$3',,`m4Hn*L_unit*3',`($3)')')dnl |
| 14 |
define(`m4Hh',`ifelse(`$4',,`m4Hm*L_unit*3',`($4)')')dnl |
| 15 |
ifinstr(`$6',;, |
| 16 |
`stacksplit_(`m4Jdr',`$6',;)dnl |
| 17 |
define(`m4Jps',ifelse(m4Jdr,,`L_unit',m4Jdr))popdef(`m4Jdr')dnl |
| 18 |
define(`m4Jpl',ifelse(m4Jdr,,`lg_plen*L_unit',m4Jdr))popdef(`m4Jdr') ', |
| 19 |
`define(`m4Jps',L_unit)dnl |
| 20 |
define(`m4Jpl',`ifelse(`$6',,lg_plen*L_unit,`$6')')')dnl |
| 21 |
Block: rotbox(m4Hw,m4Hh,`$5') |
| 22 |
ifelse(`m4tp',A,`pushdef(`L_unit',(linewid/6))') |
| 23 |
define(`m4Hct',1)dnl |
| 24 |
for_(1,m4Hm,1, |
| 25 |
`HeaderPin(Block.NW+vec_(m4Jps*3/2,-(m4x-1/2)*m4Hh/m4Hm), |
| 26 |
ifinstr(m4tp,A,1,eval(m4Hct-1)), |
| 27 |
P`'m4Hct, w, (m4Jpl+m4Jps);m4Jps) define(`m4Hct',incr(m4Hct)) |
| 28 |
ifelse(m4Hn, 2, `HeaderPin(Block.NE+vec_(-m4Jps*3/2,-(m4x-1/2)*m4Hh/m4Hm), |
| 29 |
1, P`'m4Hct, e, (m4Jpl+m4Jps);m4Hps) define(`m4Hct',incr(m4Hct))') ') |
| 30 |
ifelse(`m4Hq',A,`popdef(`L_unit')') |
| 31 |
`$7' ]') |
| 32 |
`HeaderPin(location, type, Picname, n|e|s|w, |
| 33 |
[length][;pinsize]) |
| 34 |
arg2: 0= square' |
| 35 |
define(`HeaderPin',` |
| 36 |
ifinstr(`$5',;, |
| 37 |
`stacksplit_(`m4Hdr',`$5',;)dnl |
| 38 |
define(`m4Hps',ifelse(m4Hdr,,`L_unit',m4Hdr))popdef(`m4Hdr')dnl |
| 39 |
define(`m4Hpl',ifelse(m4Hdr,,`lg_plen*L_unit',m4Hdr))popdef(`m4Hdr') ', |
| 40 |
`define(`m4Hps',L_unit)dnl |
| 41 |
define(`m4Hpl',`ifelse(`$5',,lg_plen*L_unit,`$5')')')dnl |
| 42 |
ifelse(`$1',,,`move to `$1';') |
| 43 |
ifelse(`$3',,,`$3':) line to ifelse( |
| 44 |
`$4',n,`rvec_(0,m4Hpl)', `$4',e,`rvec_(m4Hpl,0)', |
| 45 |
`$4',s,`rvec_(0,-m4Hpl)', `rvec_(-m4Hpl,0)') |
| 46 |
ifelse(`$3',,,Pin`$3':) ifelse(ifelse(`$2',,0,`$2'),0, |
| 47 |
`rotbox(m4Hps,m4Hps,fill_(1))', |
| 48 |
`circle diam m4Hps fill_(1)') at last line.start ') |
| 49 |
|
| 50 |
define(`ATMEGA16U2',`[ |
| 51 |
Chip: box wid 10*lg_pinsep ht 25*lg_pinsep |
| 52 |
foreach_(`x', |
| 53 |
`Arightpin(patsubst(x,;,`,'))', |
| 54 |
6;PD0, 7;PD1, 8;PD2, 9;PD3, 10;PD4, 11;PD5, 12;PD6, 13;PD7, |
| 55 |
131;nul, |
| 56 |
5;PC2, 26;PC4, 25;PC5, 23;PC6, 22;PC7, |
| 57 |
132;nul, |
| 58 |
133;nul, |
| 59 |
14;PB0, 15;PB1, 16;PB2, 17;PB3, 18;PB4, 19;PB5, 20;PB6, 21;PB7) |
| 60 |
foreach_(`x', |
| 61 |
`Aleftpin(patsubst(x,;,`,'))', |
| 62 |
33;PAD, |
| 63 |
100;nul, |
| 64 |
28;UGND, 29;D$+$, 30;D$-$, 31;UVCC, 27;UCAP, |
| 65 |
101;nul, 102;nul, |
| 66 |
3;GND, 4;VCC, 103;nul, |
| 67 |
104;nul, |
| 68 |
32;AVCC, |
| 69 |
105;nul, 106;nul, |
| 70 |
1;XTAL1, |
| 71 |
107;nul, |
| 72 |
2;XTAL2(PC0), |
| 73 |
108;nul, 109;nul) |
| 74 |
lg_pin(Pin109+(0,lg_pinsep),ifpostscript(,\tiny\sf) RESET,Pin24,wN,24,pinlen) |
| 75 |
]') |
| 76 |
define(`Aleftpin',`move to Chip.sw+(0,m4Lx*lg_pinsep) |
| 77 |
Pin`$1': ifelse(`$2',nul,Here,dnl |
| 78 |
`line left pinlen "`$1'" above |
| 79 |
"`$2'" ljust at last line.start')') |
| 80 |
define(`Arightpin',`move to Chip.se+(0,m4Lx*lg_pinsep) |
| 81 |
Pin`$1': ifelse(`$2',nul,Here,dnl |
| 82 |
`line right pinlen "`$1'" above |
| 83 |
"`$2'" rjust at last line.start')') |
| 84 |
|
| 85 |
define(`ATMEGA328P',`[ |
| 86 |
Chip: box wid 10*lg_pinsep ht 23*lg_pinsep |
| 87 |
foreach_(`x', |
| 88 |
`Arightpin(patsubst(x,;,`,'))', |
| 89 |
2;PD0, 3;PD1, 4;PD2, 5;PD3, 6;PD4, 11;PD5, 12;PD6, 13;PD7, |
| 90 |
100;nul, |
| 91 |
23;PC0, 24;PC1, 25;PC2, 26;PC3, 27;PC4, 28;PC5, |
| 92 |
101;nul, |
| 93 |
14;PB0, 15;PB1, 16;PB2, 17;PB3, 18;PB4, 19;PB5) |
| 94 |
foreach_(`x', |
| 95 |
`Aleftpin(patsubst(x,;,`,'))', |
| 96 |
201;nul, 202;nul, 203;nul, 204;nul, 205;nul, 206;nul, 207;nul, 208;nul, |
| 97 |
209;nul, |
| 98 |
8;GND, 7;VCC, |
| 99 |
301;nul, |
| 100 |
22;AGND, 20;AVCC, 21;AREF, |
| 101 |
302;nul, |
| 102 |
9;XTAL1, |
| 103 |
303;nul, |
| 104 |
10;XTAL2, |
| 105 |
304;nul, 305;nul) |
| 106 |
lg_pin(Pin305+(0,lg_pinsep),ifpostscript(,\tiny\sf) RESET,Pin1,wN,1,pinlen) |
| 107 |
]') |
| 108 |
|
| 109 |
define(`rswitch',`dswitch(`$1',,WBoDCP) |
| 110 |
DS: last line.start; DC: last line.c; DE: last line.end |
| 111 |
DL: DC-vec_(dimen_/6,0); DR: DC+vec_(dimen_/6,0) |
| 112 |
{{"1" at DL above rjust}; {"3" at DR above ljust} |
| 113 |
{ line from DL to DL-vec_(0,dimen_/6) chop dotrad_ chop 0 |
| 114 |
{"2" below rjust} |
| 115 |
continue to DS-vec_(0,dimen_/6) then to DS; dot } |
| 116 |
{ line from DR to DR+vec_(0,-dimen_/6) chop dotrad_ chop 0 |
| 117 |
{"4" below ljust} |
| 118 |
continue to DE+vec_(0,-dimen_/6) then to DE; dot } |
| 119 |
line from DC+vec_(dimen_/10,-dimen_/6) to DC+vec_(-dimen_/10,-dimen_/6) |
| 120 |
move to last line.c; line to rvec_(0,-dimen_/3) \ |
| 121 |
then to rvec_(-dimen_/3,-dimen_/3) |
| 122 |
{"5" below}} ') |
| 123 |
|
| 124 |
divert(0)dnl |