| 1 |
divert(-1) |
| 2 |
|
| 3 |
`Macros defining some integrated circuits and connectors for LaTeX' |
| 4 |
|
| 5 |
`A sequence of pins along the east or west side of a chip: |
| 6 |
lg_pinseq(initial pin no, final pin no, |
| 7 |
e|w, initial offset, pinnum_root, Labelroot, [N])' |
| 8 |
`e.g., lg_pinseq(1,8,w)' |
| 9 |
define(`lg_pinseq',`for_($1,$2,1, |
| 10 |
`lg_pin( Chip.s`$3'+(0,($4+m4x)*lg_pinsep), |
| 11 |
$6`'m4x,Pin`'eval($5`'m4x),`$3'`$7',eval($5`'m4x))') ') |
| 12 |
|
| 13 |
define(`ic_tiny',`iflatex(`\hbox{\tiny `$1'}',ifsvg(`svg_small(`$1')',`$1'))') |
| 14 |
define(`ic_tilde',`iflatex(`{\raisebox{-0.5ex}{\char126}}',~)') |
| 15 |
|
| 16 |
define(`m4_1',`regexp(`$1',^\([^:]*\):.*,\1)') |
| 17 |
define(`m4_2',`regexp(`$1',^[^:]*:\([^:]*\):?.*,\1)') |
| 18 |
define(`m4_3',`regexp(`$1',^[^:]*:[^:]*:\([^:]*\):?.*,\1)') |
| 19 |
define(`m4_4',`regexp(`$1',^[^:]*:[^:]*:[^:]*:\([^:]*\):?.*,\1)') |
| 20 |
|
| 21 |
`ic4017( keys ) |
| 22 |
keys: pinsep=expr; (lg_pinsep) |
| 23 |
pincount=expr; (12 per side) |
| 24 |
hght=expr; ((pincount+1)*pinsep) |
| 25 |
wdth=expr; (0.6*hght) |
| 26 |
box=attributes; (shaded light blue)' |
| 27 |
define(`ic4017',`[ pushkeys_(`$1',`pinsep:lg_pinsep; pincount:12; |
| 28 |
hght:(m4`'pincount+1)*m4`'pinsep; wdth:0.6*m4`'hght; |
| 29 |
box:shaded LTtmpcolr:N')dnl |
| 30 |
Chip: box wid m4wdth ht m4hght m4box "`4017'" |
| 31 |
foreach_(`t',`ifelse(t,nul,,`lg_pin( |
| 32 |
Chip.nw-(0,m4_1(t)*lg_pinsep),m4_2(t),Pin`'m4_3(t), w`'m4_4(t), m4_3(t))')', |
| 33 |
1:CLK:14:E:, 2:CKEN:13:N:, 4:Reset:15) |
| 34 |
foreach_(`t',`ifelse(t,nul,,`lg_pin( |
| 35 |
Chip.ne-(0,m4_1(t)*lg_pinsep),m4_2(t),Pin`'m4_3(t), e`'m4_4(t), m4_3(t))')', |
| 36 |
1:Q0:3:E, 2:Q1:2:N, 3:Q2:4, 4:Q3:7, 5:Q4:10, 6:Q5:1, 7:Q6:5, 8:Q7:6, 9:Q8:9, |
| 37 |
10:Q9:11,12:C`'svg_sub(out):12) |
| 38 |
lg_pin(Chip.n,VDD,Pin16,n,16) |
| 39 |
lg_pin(Chip.s,VSS,Pin18,s,8) |
| 40 |
`$2' popdef(`m4pinsep',`m4pincount',`m4hght',`m4wdth',`m4box') ]') |
| 41 |
|
| 42 |
define(`ic6116',`[ Chip: box wid_ lg_chipwd ht_ 15*lg_pinsep |
| 43 |
lg_pin(Chip.sw_+(0,lg_pinsep),GND,Pin12,w,12) |
| 44 |
lg_pin(Chip.sw_+(0,2*lg_pinsep),lg_bartxt(CS),Pin18,wN,18) |
| 45 |
lg_pinseq(0,2,w,4,9+,D) |
| 46 |
lg_pinseq(3,7,w,4,10+,D) |
| 47 |
lg_pin(Chip.sw_+(0,13*lg_pinsep),R/lg_bartxt(W),Pin21,w,21) |
| 48 |
lg_pin(Chip.sw_+(0,14*lg_pinsep),V`'ic_tiny(CC),Pin24,w,24) |
| 49 |
lg_pin(Chip.se_+(0,lg_pinsep),lg_bartxt(OE),Pin20,eN,20) |
| 50 |
lg_pinseq(0,7,e,3,8-,A) |
| 51 |
lg_pinseq(8,9,e,3,31-,A) |
| 52 |
lg_pin(Chip.se_+(0,13*lg_pinsep),A10,Pin19,e,19) |
| 53 |
`$1']') |
| 54 |
|
| 55 |
define(`ic6502',`[ Chip: box wid_ lg_chipwd ht_ 24*lg_pinsep |
| 56 |
lg_pin(Chip.sw_+(0,lg_pinsep),V`'ic_tiny(SS),Pin21,w,21) |
| 57 |
lg_pin(Chip.sw_+(0,2*lg_pinsep),V`'ic_tiny(SS),Pin1,w,1) |
| 58 |
lg_pin(Chip.sw_+(0,4*lg_pinsep),R/lg_bartxt(W),Pin34,w,34) |
| 59 |
lg_pinseq(0,7,w,6,33-,D) |
| 60 |
lg_pin(Chip.sw_+(0,15*lg_pinsep),lg_bartxt(RESET),Pin40,wN,40) |
| 61 |
lg_pin(Chip.sw_+(0,17*lg_pinsep),SYNC,Pin7,w,7) |
| 62 |
lg_pin(Chip.sw_+(0,19*lg_pinsep),lg_bartxt(NMI),Pin6,wN,6) |
| 63 |
lg_pin(Chip.sw_+(0,21*lg_pinsep),RDY,Pin2,w,2) |
| 64 |
lg_pin(Chip.sw_+(0,22*lg_pinsep),SO,Pin38,w,38) |
| 65 |
lg_pin(Chip.sw_+(0,23*lg_pinsep),V`'ic_tiny(CC),Pin8,w,8) |
| 66 |
lg_pin(Chip.se_+(0,lg_pinsep),CK`'ic_tiny(1)(in),Pin39,e,39) |
| 67 |
lg_pin(Chip.se_+(0,4*lg_pinsep), |
| 68 |
CK`'ic_tiny(2)(out),Pin37,e,37) |
| 69 |
lg_pinseq(0,11,e,6,9+,A) |
| 70 |
lg_pinseq(12,15,e,6,10+,A) |
| 71 |
lg_pin(Chip.se+(0,23*lg_pinsep),lg_bartxt(IRQ),Pin4,eN,4) |
| 72 |
`$1']') |
| 73 |
|
| 74 |
define(`ic6522',`[ Chip: box wid_ lg_chipwd ht_ 24*lg_pinsep |
| 75 |
lg_pin(Chip.sw_+(0,lg_pinsep),V`'ic_tiny(SS),Pin1,w,1) |
| 76 |
lg_pin(Chip.sw_+(0,3*lg_pinsep),CS1,Pin24,w,24) |
| 77 |
lg_pin(Chip.sw_+(0,4*lg_pinsep),CK,Pin25,w,25) |
| 78 |
lg_pin(Chip.sw_+(0,5*lg_pinsep),lg_bartxt(CS2),Pin23,wN,23) |
| 79 |
lg_pin(Chip.sw_+(0,7*lg_pinsep),RS0(A0),Pin38,w,38) |
| 80 |
lg_pin(Chip.sw_+(0,8*lg_pinsep),RS1(A1),Pin37,w,37) |
| 81 |
lg_pin(Chip.sw_+(0,9*lg_pinsep),RS2(A2),Pin36,w,36) |
| 82 |
lg_pin(Chip.sw_+(0,10*lg_pinsep),RS3(A3),Pin35,w,35) |
| 83 |
lg_pinseq(0,7,w,12,33-,D) |
| 84 |
lg_pin(Chip.sw_+(0,21*lg_pinsep),R/lg_bartxt(W),Pin22,w,22) |
| 85 |
lg_pin(Chip.sw_+(0,22*lg_pinsep),lg_bartxt(IRQ),Pin21,wN,21) |
| 86 |
lg_pin(Chip.sw_+(0,23*lg_pinsep),V`'ic_tiny(CC),Pin20,w,20) |
| 87 |
lg_pinseq(0,7,e,1,10+,PB) |
| 88 |
lg_pinseq(1,2,e,8,17+,CB) |
| 89 |
lg_pinseq(0,7,e,12,2+,PA) |
| 90 |
lg_pinseq(1,2,e,19,41-,CA) |
| 91 |
lg_pin(Chip.se_+(0,23*lg_pinsep),lg_bartxt(RESET),Pin34,eN,34) |
| 92 |
`$1']') |
| 93 |
|
| 94 |
define(`ic74LS138',`[ Chip: box wid_ lg_chipwd ht_ 11*lg_pinsep |
| 95 |
lg_pin(Chip.sw_+(0,lg_pinsep),GND,Pin8,w,8) |
| 96 |
lg_pin(Chip.sw_+(0,2*lg_pinsep),lg_bartxt(G2a),Pin4,wN,4) |
| 97 |
lg_pin(Chip.sw_+(0,3*lg_pinsep),lg_bartxt(G2b),Pin5,wN,5) |
| 98 |
lg_pin(Chip.sw_+(0,5*lg_pinsep),A,Pin1,w,1) |
| 99 |
lg_pin(Chip.sw_+(0,6*lg_pinsep),B,Pin2,w,2) |
| 100 |
lg_pin(Chip.sw_+(0,7*lg_pinsep),C,Pin3,w,3) |
| 101 |
lg_pin(Chip.sw_+(0,9*lg_pinsep),G1,Pin6,w,6) |
| 102 |
lg_pin(Chip.sw_+(0,10*lg_pinsep),V`'ic_tiny(CC),Pin16,w,16) |
| 103 |
lg_pinseq(0,6,e,2,15-,Y,n) |
| 104 |
lg_pin(Chip.se_+(0,9*lg_pinsep),Y7,Pin7,eN,7) |
| 105 |
`$1']') |
| 106 |
|
| 107 |
define(`ic555DIP',`[ Chip: DIP_chip_outline(8) |
| 108 |
foreach_(`x', |
| 109 |
`lg_pin(Chip.nw-(0,lg_pinsep*m4Lx),x,Pin`'m4Lx,w,m4Lx)', |
| 110 |
GND, TR, OUT, RESET) |
| 111 |
foreach_(`x', |
| 112 |
`lg_pin(Chip.se+(0,lg_pinsep*m4Lx),x,Pin`'eval(m4Lx+4),e,eval(m4Lx+4))', |
| 113 |
CTRL, THR, DIS, Vcc) |
| 114 |
`$1']') |
| 115 |
|
| 116 |
define(`ic4017DIP',`[ Chip: DIP_chip_outline(16) |
| 117 |
foreach_(`x', |
| 118 |
`lg_pin(Chip.nw-(0,lg_pinsep*m4Lx),x,Pin`'m4Lx,w,m4Lx)', |
| 119 |
PL, Q3, I3, I0, CLE, Q0, TC, GND) |
| 120 |
foreach_(`x', |
| 121 |
`lg_pin(Chip.se+(0,lg_pinsep*m4Lx),x,Pin`'eval(m4Lx+8),e,eval(m4Lx+8))', |
| 122 |
MR, U/D, Q1, I1, I2, Q2, CLK, Vcc) |
| 123 |
`$1']') |
| 124 |
|
| 125 |
define(`ic4510DIP',`[ Chip: DIP_chip_outline(16) |
| 126 |
foreach_(`x', |
| 127 |
`lg_pin(Chip.nw-(0,lg_pinsep*m4Lx),x,Pin`'m4Lx,w,m4Lx)', |
| 128 |
PL, Q3, I3, I0, CLE, Q0, TC, GND) |
| 129 |
foreach_(`x', |
| 130 |
`lg_pin(Chip.se+(0,lg_pinsep*m4Lx),x,Pin`'eval(m4Lx+8),e,eval(m4Lx+8))', |
| 131 |
MR, U/D, Q1, I1, I2, Q2, CLK, Vcc) |
| 132 |
`$1']') |
| 133 |
|
| 134 |
define(`icVS1053DIP',`[ Chip: DIP_chip_outline(32) |
| 135 |
foreach_(`x', |
| 136 |
`lg_pin(Chip.nw-(0,lg_pinsep*m4Lx),x,Pin`'m4Lx,w,m4Lx)', |
| 137 |
LOUT,ROUT,GBUF,AGND,AGND,DREG,Vcc,3V3,GND,MISO,MOSI,sclk,RST,CS,DCS,DCS) |
| 138 |
foreach_(`x', |
| 139 |
`lg_pin(Chip.se+(0,lg_pinsep*m4Lx),x,Pin`'eval(m4Lx+16),e,eval(m4Lx+16))', |
| 140 |
SDCD,RX,TX,7,6,5,4,3,2,1,0,GND,3V3,AGND,MIC-,MIC+) |
| 141 |
`$1']') |
| 142 |
|
| 143 |
`DIP_chip_outline( pin count, wid )' |
| 144 |
define(`DIP_chip_outline', |
| 145 |
`[ pushdef(`m4pinct',`ifelse(`$1',,16,`$1')')dnl |
| 146 |
pushdef(`m4chgw',`ifelse(`$2',,(18*L_unit),`$2')')dnl |
| 147 |
Chip: box invis wid m4chgw ht lg_pinsep*eval((m4pinct)/2+1) |
| 148 |
arcd(Chip.n, lg_pinsep/2, 180, 360) |
| 149 |
{ line to Chip.ne chop -linewid bp__/2 } |
| 150 |
{ line from last arc.start to Chip.nw chop -linewid bp__/2 } |
| 151 |
line from Chip.nw to Chip.sw then to Chip.se then to Chip.ne |
| 152 |
`$3'] popdef(`m4pinct',`m4chgw') ') |
| 153 |
|
| 154 |
`DIP( pin count, attributes) |
| 155 |
Dual in-line package |
| 156 |
attributes=semicolon-separated list of optional terms: |
| 157 |
bodywid=expr; (default 0.25 = 5*L_unit ) |
| 158 |
bodylen=expr; (default pin count/2 x pinpitch) |
| 159 |
pinpitch=expr; (default 0.1) |
| 160 |
pinwid=expr; (default 0.06) |
| 161 |
pinlen=expr; (default 0.05) |
| 162 |
direct=U|D|L|R;(default U for up) |
| 163 |
type=I|Q; (default I for uniform-length pins; |
| 164 |
Q: staggered) ' |
| 165 |
define(`DIP',`[ pinct= ifelse(`$1',,8,`$1') |
| 166 |
setkeys_(`$2', |
| 167 |
bodywid: 5*L_unit; |
| 168 |
bodylen: m4pinpitch*int(pinct/2+0.5); |
| 169 |
pinpitch:2*L_unit; |
| 170 |
pinwid: 1.2*L_unit; |
| 171 |
pinlen: L_unit; |
| 172 |
direct:U:N; |
| 173 |
type:I:N) |
| 174 |
setdir_(m4direct,U) |
| 175 |
Body: box ht_ m4bodywid wid_ m4bodylen |
| 176 |
arcs = ifelse(m4_dir_,right,90,m4_dir_,up,180,m4_dir_,left,270,0) |
| 177 |
arcd(Body.e_, 0.1/2, arcs,arcs+180) |
| 178 |
np2 = int(pinct/2+0.5) |
| 179 |
define(`m4bxht',`m4pinlen ifelse(m4type,Q,`*(1+(i%%2))')')dnl |
| 180 |
for i=0 to np2-1 do { |
| 181 |
exec sprintf("Pin%g: box ht_ m4bxht wid_ m4pinwid \ |
| 182 |
with .s_ at (i+0.5)/np2 between Body.ne_ and Body.nw_",i+1) } |
| 183 |
for i=np2+1 to pinct do { |
| 184 |
exec sprintf("Pin%g: box ht_ m4bxht wid_ m4pinwid \ |
| 185 |
with .n_ at (i-np2-0.5)/(pinct-np2) between Body.sw_ and Body.se_",i) } |
| 186 |
`$3'; resetdir_ |
| 187 |
popdef(`m4bodywid',`m4bodylen',`m4pinpitch',`m4pinwid',`m4pinlen',`m4direct', |
| 188 |
`m4type') ]')) |
| 189 |
`There is more than one way to draw an IC and |
| 190 |
label its pins; here is one:' |
| 191 |
`LT3724( keys ) IC in a [] block |
| 192 |
keys: pinsep=expr; (0.25) |
| 193 |
pincount=expr; (8 per side) |
| 194 |
hght=expr; ((pincount+1)*pinsep) |
| 195 |
wdth=expr; (0.6*hght) |
| 196 |
box=attributes; (shaded light blue) |
| 197 |
8 pins per side; pin labels |
| 198 |
VIN, SHDN, CSS, BURST_EN, VFB, VC, SYNC, FSET, |
| 199 |
SGND, SENSEM, SENSEP, PGND, VCC, SW, TG, BOOST' |
| 200 |
define(`LT3724',`[ pushkeys_(`$1',`pinsep:svg_baselineskip*2.5; pincount:8; |
| 201 |
hght:(m4`'m4pincount+1)*m4`'pinsep; wdth:0.6*m4`'hght; |
| 202 |
box:shaded LTtmpcolr:N')dnl |
| 203 |
define LTtmpcolr {rgbstring(0.9,0.96,1)} # Note: dpic macro |
| 204 |
Chip: box wid m4wdth ht m4hght m4box "`LT3724'" ; undefine LTtmpcolr |
| 205 |
foreach_(`m4hx',`ifelse(m4hx,nil,, |
| 206 |
`patsubst(m4hx,^[^:]*:): Chip.nw-(0,m4Lx*m4hght/(m4pincount+1)) |
| 207 |
"patsubst(m4hx,:.*)" ljust at Chip.nw-(0,m4Lx*m4hght/(m4pincount+1))')', |
| 208 |
V`'svg_sub(IN):VIN, SHDN, C`'svg_sub(SS):CSS, BURST_EN, |
| 209 |
V`'svg_sub(FB):VFB, V`'svg_sub(C):VC, SYNC, f`'svg_sub(SET):FSET) |
| 210 |
line right_ textht*4 from SHDN+(textoffset,textht/2+2bp__) |
| 211 |
foreach_(`m4hx',`ifelse(m4hx,nil,, |
| 212 |
`patsubst(m4hx,^[^:]*:): Chip.se+(0,m4Lx*m4hght/(m4pincount+1)) |
| 213 |
"patsubst(m4hx,:.*)" rjust at Chip.se+(0,m4Lx*m4hght/(m4pincount+1))')', |
| 214 |
SGND, SENSE`'svg_sup(-):SENSEM, SENSE`'svg_sup(+):SENSEP, PGND, |
| 215 |
V`'svg_sub(CC):VCC, SW, TG, BOOST) |
| 216 |
`$2' popdef(`m4pinsep',`m4pincount',`m4hght',`m4wdth',`m4box') ]') |
| 217 |
|
| 218 |
`Here is another way to draw an IC and |
| 219 |
label its pins:' |
| 220 |
`LT3757( keys ) IC in a [] block |
| 221 |
keys: pinsep=expr; (0.25) |
| 222 |
pincount=expr; (8 per side) |
| 223 |
hght=expr; ((pincount+1)*pinsep) |
| 224 |
wdth=expr; (0.6*hght)' |
| 225 |
`8 pins per side; pin labels |
| 226 |
top: VIN; left: SHU, SYNC, RT, SS; |
| 227 |
right: GATE, SENSE, FBX; |
| 228 |
bottom: VC, GND, INTVCC' |
| 229 |
define(`LT3757',`[ pushkeys_(`$1', |
| 230 |
`pinsep:svg_baselineskip*2.5; |
| 231 |
pincount:8; |
| 232 |
hght:(m4`'pincount+1)*m4`'pinsep; |
| 233 |
wdth:0.6*m4`'hght';)dnl |
| 234 |
Chip: box wid m4wdth ht m4hght shaded rgbstring(0.9,0.96,1) \ |
| 235 |
"`LT3757'" above |
| 236 |
VIN: Chip.n; "V`'svg_sub(IN)" at VIN below |
| 237 |
foreach_(`LL',`m43757label(nw,sw,ljust,patsubst(LL,:,`,'))', |
| 238 |
SHU:2:"SHDN/UVLO", SYNC:5, RT:7, SS:8) |
| 239 |
line from SHU+(2bp__,5bp__) right_ 24bp__ |
| 240 |
foreach_(`LL',`m43757label(se,ne,rjust,patsubst(LL,:,`,'))', |
| 241 |
FBX:1, SENSE:3, GATE:5) |
| 242 |
foreach_(`LL',`m43757label(sw,se,+(0,textht/3) above,patsubst(LL,:,`,'))', |
| 243 |
VC:2:"V`'svg_sub(C)", GND:5, INTVCC:8:"INTV`'svg_sub(CC)") |
| 244 |
`$2' popdef(`m4pinsep',`m4pincount',`m4hght',`m4wdth') ]') |
| 245 |
define(`m43757label',``$4': `$5'/(m4pincount+1) between Chip.`$1' and Chip.`$2' |
| 246 |
ifelse(`$6',,"`$4'",`$6') at `$4' `$3'') |
| 247 |
|
| 248 |
`ArduinoUno( wid,ht,pinlen )' |
| 249 |
define(`ArduinoUno',`[ |
| 250 |
pushdef(`m4bwid',`ifelse(`$1',,`24*L_unit',`$1')')dnl |
| 251 |
pushdef(`m4bht',`ifelse(`$2',,`20*lg_pinsep',`$2')')dnl |
| 252 |
# |
| 253 |
Connector: box wid m4bwid ht m4bht |
| 254 |
# |
| 255 |
m4pl = ifelse(`$3',,`2*L_unit',`$3') |
| 256 |
# |
| 257 |
foreach_(`x',`ifelse(x,nul,, |
| 258 |
`Pin`'eval(5+m4Lx): line left_ m4pl from Connector.nw-(0,(5+m4Lx)*lg_pinsep) |
| 259 |
{ "x" ljust at last line.start }')', |
| 260 |
IOREF, RESET,+3V3,+5V, GND, GND, VIN, nul, A0, A1, A2, A3, A4, A5) |
| 261 |
# |
| 262 |
foreach_(`x',`ifelse(x,nul,, |
| 263 |
`Pin`'eval(22-m4Lx): line right_ m4pl from Connector.ne-(0,m4Lx*lg_pinsep) |
| 264 |
{ "x" rjust at last line.start }')', |
| 265 |
SCL, SDA, AREF, GND, D13, D12, ic_tilde`'D11, ic_tilde`'D10, ic_tilde`'D9, D8, |
| 266 |
nul, D7, ic_tilde`'D6, ic_tilde`'D5, D4, ic_tilde`'D3, D2, TX D1, RX D0) |
| 267 |
# |
| 268 |
`$4'] popdef(`m4bwid',`m4bht') ') |
| 269 |
|
| 270 |
`ArduinoLeonardo( wid,ht,pinlen )' |
| 271 |
define(`ArduinoLeonardo',`[ |
| 272 |
pushdef(`m4bwid',`ifelse(`$1',,`24*L_unit',`$1')')dnl |
| 273 |
pushdef(`m4bht',`ifelse(`$2',,`20*lg_pinsep',`$2')')dnl |
| 274 |
# |
| 275 |
Connector: box wid m4bwid ht m4bht |
| 276 |
# |
| 277 |
m4pl = ifelse(`$3',,`2*L_unit',`$3') |
| 278 |
# |
| 279 |
foreach_(`x',`ifelse(x,nul,, |
| 280 |
`Pin`'eval(5+m4Lx): line left_ m4pl from Connector.nw-(0,(5+m4Lx)*lg_pinsep) |
| 281 |
{ "x" ljust at last line.start }')', |
| 282 |
IOREF, RESET,+3V3,+5V, GND, GND, VIN, nul, A0, A1, A2, A3, A4, A5) |
| 283 |
# |
| 284 |
foreach_(`x',`ifelse(x,nul,, |
| 285 |
`Pin`'eval(22-m4Lx): line right_ m4pl from Connector.ne-(0,m4Lx*lg_pinsep) |
| 286 |
{ "x" rjust at last line.start }')', |
| 287 |
SCL, SDA, AREF, GND, |
| 288 |
ic_tilde`'D13, D12, ic_tilde`'D11, ic_tilde`'D10, ic_tilde`'D9, D8, |
| 289 |
nul, D7, ic_tilde`'D6, ic_tilde`'D5, D4, ic_tilde`'D3, D2, TX D1, RX D0) |
| 290 |
# |
| 291 |
`$4'] popdef(`m4bwid',`m4bht') ') # `ArduinoLeonardo' |
| 292 |
|
| 293 |
`RPi( wid,ht,pinlen )' # Raspberry Pi connector |
| 294 |
define(`RPi',`[ |
| 295 |
pushdef(`m4bwid',`ifelse(`$1',,`34*L_unit',`$1')')dnl |
| 296 |
pushdef(`m4bht',`ifelse(`$2',,`21*lg_pinsep',`$2')')dnl |
| 297 |
# |
| 298 |
GPIO: box wid m4bwid ht m4bht |
| 299 |
m4pl = ifelse(`$3',,`6*L_unit',`$3') |
| 300 |
# |
| 301 |
define A_LeftGPIO { dnl pin downcount, internal label , pin no above line |
| 302 |
exec sprintf("Pin%g: line left_ m4pl from GPIO.nw-(0,%g)",\ |
| 303 |
2*(`$'1)-1,(`$'1)*lg_pinsep) |
| 304 |
{ "`$'3" ljust at last line.start } |
| 305 |
"`$'2" at last line.c above } |
| 306 |
# |
| 307 |
foreach_(`x',`ifelse(x,nul,,`A_LeftGPIO(m4Lx,patsubst(x,;,`,'))')', |
| 308 |
;3V3, |
| 309 |
2;SDA1, 3;SCL1, 4;GPIO_GCLK, |
| 310 |
;GND, |
| 311 |
17;GPIO_GEN0, 27;GPIO_GEN2, 22;GPIO_GEN3, |
| 312 |
;3V3, |
| 313 |
10;SPI_MOSI, 9;SPI_MISO, 11;SPI_SCLK, |
| 314 |
;GND, |
| 315 |
;ID_SD, |
| 316 |
5;, 6;, 13;, 19;, 26;, |
| 317 |
;GND ) |
| 318 |
# |
| 319 |
define A_RightGPIO { dnl pin downcount, internal label , pin no above line |
| 320 |
exec sprintf("Pin%g: line right_ m4pl from GPIO.ne-(0,%g)",\ |
| 321 |
2*(`$'1),(`$'1)*lg_pinsep) |
| 322 |
{ "`$'3" rjust at last line.start } |
| 323 |
"`$'2" at last line.c above } |
| 324 |
# |
| 325 |
foreach_(`x',`ifelse(x,nul,,`A_RightGPIO(m4Lx,patsubst(x,;,`,'))')', |
| 326 |
;5V, |
| 327 |
;5V, |
| 328 |
;GND, |
| 329 |
14;TXD0, 15;RXD0, 18;GPIO_GEN1, |
| 330 |
;GND, |
| 331 |
23;GPIO_GEN4, 24;GPIO_GEN5, |
| 332 |
;GND, |
| 333 |
25;GPIO_GEN6, 8;SPI_CEO_N, 7;SPI_CE1_N, |
| 334 |
;ID_SC, |
| 335 |
;GND, |
| 336 |
12;, |
| 337 |
;GND, |
| 338 |
16;, 20;, 21; ) |
| 339 |
# |
| 340 |
`$4'] popdef(`m4bwid',`m4bht') ') # `RPi' |
| 341 |
|
| 342 |
`USB_C_Socket( wid, ht, pinlen )' |
| 343 |
define(`USB_C_Socket',`[ |
| 344 |
pushdef(`m4bwid',`ifelse(`$1',,`18*L_unit',`$1')')dnl |
| 345 |
pushdef(`m4bht',`ifelse(`$2',,`14*lg_pinsep',`$2')')dnl |
| 346 |
# |
| 347 |
Base: box wid m4bwid ht m4bht rad 5/3*lg_pinsep |
| 348 |
m4pl = ifelse(`$3',,`6*L_unit',`$3') |
| 349 |
# |
| 350 |
foreach_(`x', |
| 351 |
`B`'eval(13-m4Lx): dnl |
| 352 |
line left_ m4pl from Base.n-(m4bwid/2,(m4Lx+0.5)*lg_pinsep) |
| 353 |
{"x" ljust at last line.start}', |
| 354 |
GND, RX1+, RX1-, VBUS, SBU2, D-, D+, CC2, VBUS, TX2-, |
| 355 |
TX2+, GND) |
| 356 |
# |
| 357 |
foreach_(`x', |
| 358 |
`A`'m4Lx: line right_ m4pl from Base.n+(m4bwid/2,-(m4Lx+0.5)*lg_pinsep) |
| 359 |
{"x" rjust at last line.start}', |
| 360 |
GND, TX1+, TX1-, VBUS, CC1, D+, D-, SBU1, VBUS, RX2-, |
| 361 |
RX2+, GND) |
| 362 |
# |
| 363 |
`$4'] popdef(`m4bwid',`m4bht') ') |
| 364 |
|
| 365 |
`connDX( n,R|L|U|D|degrees,keys )' |
| 366 |
`keys: |
| 367 |
type=M|F; |
| 368 |
lgth=expr; |
| 369 |
wdth=expr; lgth*0.33 |
| 370 |
pindiam=expr; wdth/9 |
| 371 |
pin=attributes; ' |
| 372 |
define(`connDX',`pushdef(`m4n',`ifelse(`$1',,15,`$1')')dnl |
| 373 |
pushkeys_(`$3',`type:M:N; lgth:(m4`'n+3)*dimen_/8; |
| 374 |
wdth:m4`'lgth*0.33; pindiam:max(linewid*5bp__,m4`'wdth/9); pin::N;')dnl |
| 375 |
[ setdir_(`$2')dnl |
| 376 |
NW: vec_(0,m4lgth/2); SW: vec_(0,-m4lgth/2) |
| 377 |
NE: vec_(m4wdth,m4lgth/2-m4wdth*sind(10)) |
| 378 |
SE: vec_(m4wdth,-m4lgth/2+m4wdth*sind(10)) |
| 379 |
W: 1/2 between SW and NW; move to W |
| 380 |
arcto(NW,NE,m4wdth/5); arcto(NE,SE,m4wdth/5) |
| 381 |
arcto(SE,SW,m4wdth/5); arcto(SW,W,m4wdth/5); line to W |
| 382 |
np2 = int(m4n+1)/2 |
| 383 |
dv = m4lgth/(np2+1) |
| 384 |
for i=1 to np2 do { M4X: SW+vec_(m4wdth/3,dv*i) |
| 385 |
exec sprintf("T%g: dot(at M4X,circle=diam m4pindiam ifelse(m4type,M, |
| 386 |
fill_(0)) m4pin,ifelse(m4type,M,0,1))",ifelse(m4type,M,i,np2+1-i)) } |
| 387 |
for i=1 to np2-1 do { M4X: SW+vec_(m4wdth*2/3,dv*(i+1/2)) |
| 388 |
exec sprintf("T%g: dot(at M4X,circle=diam m4pindiam ifelse(m4type,M, |
| 389 |
fill_(0)) m4pin,ifelse(m4type,M,0,1))",ifelse(m4type,M,np2+i,m4n+1-i)) } |
| 390 |
resetdir_ ; `$4'] dnl |
| 391 |
popdef(`m4n',`m4type',`m4lgth',`m4wdth', `m4pindiam', `m4pin' ) ') |
| 392 |
|
| 393 |
`HDMI_micro( wid, ht, pinlen )' |
| 394 |
define(`HDMI_micro',`[ |
| 395 |
pushdef(`m4bwid',`ifelse(`$1',,`16*L_unit',`$1')')dnl |
| 396 |
pushdef(`m4bht',`ifelse(`$2',,`20*lg_pinsep+m4bwid*2/3',`$2')')dnl |
| 397 |
# |
| 398 |
Base:[line up m4bht/2 then right m4bwid*2/3 \ |
| 399 |
then right m4bwid/3 down m4bwid/3 \ |
| 400 |
then down m4bht-2*m4bwid/3 then down m4bwid/3 left m4bwid/3 \ |
| 401 |
then left m4bwid*2/3 then to Here] |
| 402 |
m4pl = ifelse(`$3',,`6*L_unit',`$3') |
| 403 |
# |
| 404 |
foreach_(`x', |
| 405 |
`Pin`'m4Lx: line left_ m4pl from Base.nw-(0,m4bwid/3+m4Lx*lg_pinsep) |
| 406 |
{"x" ljust at last line.start} |
| 407 |
"m4Lx" at last line.c above', |
| 408 |
HPD, UTILITY, D2+, D2_SH, D2-, D1+, D1_SH, D1-, D0+, D0_SH, D0-, CLK+, |
| 409 |
CLK_SH, CLK-, CEC, GND, SCL, SDA,+5V) |
| 410 |
line from Base.nw+(m4bwid*2/3-lg_pinsep,0) up m4pl |
| 411 |
r_text(,21,at last line.c+(-5bp__,0)) |
| 412 |
r_text(,SH2,at last line.start + (0,-10bp__)) |
| 413 |
line from Base.nw+(m4bwid*2/3-2*lg_pinsep,0) up m4pl |
| 414 |
r_text(,20,at last line.c+(-5bp__,0)) |
| 415 |
r_text(,SH1,at last line.start + (0,-10bp__)) |
| 416 |
line from Base.sw+(m4bwid*2/3-lg_pinsep,0) down m4pl |
| 417 |
r_text(,23,at last line.c+(-5bp__,0)) |
| 418 |
r_text(,SH4,at last line.start + (0, 10bp__)) |
| 419 |
line from Base.sw+(m4bwid*2/3-2*lg_pinsep,0) down m4pl |
| 420 |
r_text(,22,at last line.c+(-5bp__,0)) |
| 421 |
r_text(,SH3,at last line.start + (0, 10bp__)) |
| 422 |
# |
| 423 |
`$4'] popdef(`m4bwid',`m4bht') ') |
| 424 |
|
| 425 |
divert(0)dnl |
| 426 |
#efine LTtmpcolr {rgbstring(0.9,0.96,1)} |
| 427 |
define LTtmpcolr {rgbstring(0.99,0.99,0.8)} |